Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi: bitcoind rpc polling option #6345

Merged
merged 8 commits into from May 11, 2022

Conversation

ellemouton
Copy link
Collaborator

@ellemouton ellemouton commented Mar 18, 2022

replaces #6117
Depends on btcsuite/btcwallet#795

Thanks to @orbitalturtle for the original lnd and btcwallet PRs 🚀

Note, this PR also adds a new itest backend.

@ellemouton ellemouton requested a review from guggero March 18, 2022 12:46
@Roasbeef Roasbeef added this to the v0.15.0 milestone Mar 18, 2022
@Roasbeef Roasbeef added this to In progress in v0.15.0-beta via automation Mar 18, 2022
@Roasbeef Roasbeef added the bitcoind Bitcoin Core backend label Mar 18, 2022
@Roasbeef Roasbeef requested review from arshbot and carlaKC and removed request for arshbot March 18, 2022 21:13
Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool to see all unit and integration tests being green with this new "backend" type 🎉

LGTM pending a few nits and the merge of the dependent PR.

routing/chainview/interface_test.go Outdated Show resolved Hide resolved
chainreg/chainregistry.go Outdated Show resolved Hide resolved
chainntnfs/bitcoindnotify/bitcoind.go Outdated Show resolved Hide resolved
@ellemouton ellemouton force-pushed the bitcoind-rpc-polling branch 3 times, most recently from f52a0a3 to 3e0d297 Compare March 30, 2022 14:30
@ellemouton
Copy link
Collaborator Author

updated both PRs 👍

@ellemouton ellemouton requested a review from guggero March 31, 2022 07:53
Copy link
Collaborator

@guggero guggero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice 🎉

@lightninglabs-deploy
Copy link

@carlaKC: review reminder

@ellemouton ellemouton removed the request for review from carlaKC April 7, 2022 12:15
@Roasbeef Roasbeef self-requested a review April 13, 2022 17:15
@Roasbeef Roasbeef moved this from In progress to Review in progress in v0.15.0-beta Apr 13, 2022
}

// Wait for the bitcoind instance to start up.
time.Sleep(time.Second)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we tighten this check up here with something like a wait.Predicate? Otherwise I fear this'll end up flaking a lot on CI.

Copy link
Collaborator Author

@ellemouton ellemouton May 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i havent yet been able to figure out how to completely get rid of the time.Sleep even when adding the wait.NoError. Seems like needs to happen between starting bitcoind and calling calling Start on the chainView. This seems to be the case for the ZMQ connection too (in multiple places in the code base) so is not specific to this PR so wondering if i can add a todo for now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about instead doing a mini poll here until we get a valid response from the bitcoind connection?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i did try this before but it consistently flakes on my machine.
I pushed up the patch to demonstrate the flake now but I see it does not happen on github. So it might be a MacOS thing or something specific to my machine or my bitcoind installation...

@Roasbeef , could you try run this test on your machine to see if it flakes?

lnwallet/test/test_interface.go Outdated Show resolved Hide resolved
chainreg/chainregistry.go Outdated Show resolved Hide resolved
@ellemouton ellemouton force-pushed the bitcoind-rpc-polling branch 7 times, most recently from 791907e to 3ab29c3 Compare April 19, 2022 18:26
@ellemouton
Copy link
Collaborator Author

erg, must have broken something today while updating. Will find and fix tomorrow

@ellemouton ellemouton force-pushed the bitcoind-rpc-polling branch 2 times, most recently from 5d626ef to a820c9a Compare April 20, 2022 13:27
@Roasbeef
Copy link
Member

Roasbeef commented May 3, 2022

I'm assuming this isn't ready for a re-review?

@ellemouton ellemouton force-pushed the bitcoind-rpc-polling branch 6 times, most recently from eca4dad to bf356ac Compare May 4, 2022 12:20
@ellemouton
Copy link
Collaborator Author

I'm assuming this isn't ready for a re-review?

it is but there are 2 comments from the review that i have not been able to address. Have left comments on those 2 points.

@ellemouton ellemouton force-pushed the bitcoind-rpc-polling branch 2 times, most recently from 1bdab1a to 771d5c4 Compare May 6, 2022 10:33
@ellemouton ellemouton requested a review from Roasbeef May 6, 2022 11:23
@Roasbeef
Copy link
Member

Needs a rebase!

@Roasbeef
Copy link
Member

I get this segfault when I try to run the tests on my machine:

    interface_test.go:1132: Testing 'bitcoind_zmq' implementation of FilteredChainView
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x40 pc=0x100d58710]

goroutine 166 [running]:
github.com/btcsuite/btcd/rpcclient.(*Client).handleSendPostMessage(0x140001f2000, 0x140000f8280)
	/Users/roasbeef/gocode/pkg/mod/github.com/btcsuite/btcd@v0.22.0-beta.0.20220413172512-bf64c8bdbbbf/rpcclient/infrastructure.go:814 +0x480
github.com/btcsuite/btcd/rpcclient.(*Client).sendPostHandler(0x140001f2000)
	/Users/roasbeef/gocode/pkg/mod/github.com/btcsuite/btcd@v0.22.0-beta.0.20220413172512-bf64c8bdbbbf/rpcclient/infrastructure.go:861 +0x30
created by github.com/btcsuite/btcd/rpcclient.(*Client).start
	/Users/roasbeef/gocode/pkg/mod/github.com/btcsuite/btcd@v0.22.0-beta.0.20220413172512-bf64c8bdbbbf/rpcclient/infrastructure.go:1134 +0x11c
exit status 2

@Roasbeef
Copy link
Member

Roasbeef commented May 11, 2022

AFAICT, this happens because the response is nil at that point, and I think the backoff has fully expired. This happens for all the bitcoind tests (not just this new one).

Tried to see if btcsuite/btcd#1856 helped, but didn't see to do anything. Perhaps

@Roasbeef
Copy link
Member

AFAICT, when I ran it locally, bitcoind actually didn't fully stand up for some reason. There does appears to be an issue in the rpcclient library though, the loop exists but the response is nil, which causes that panic cc @bhandras.

@Roasbeef
Copy link
Member

So turns out my bitcoind install locally was borked (some dynlib thing w/ openssl, had to reinstall). After fixing that, everything works fine!

I realized that though we check that error output, the process can still fail to start. So we can do another check to make sure cmd.Process is set after Start there. If it isn't, then something messed up. I was able to debug this by threading the cmd.Stdout/Stderr into os.Stdout/Stderr.

Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💰

routing/chainview/interface_test.go Show resolved Hide resolved
ellemouton and others added 8 commits May 11, 2022 08:45
Update go.mod to point to latest btcwallet version.
Make the Bitcoind ZMQReadDeadline option configurable.
Add a new chainview interface test that runds the chainview tests
against a bitcoind node that we are getting block and tx notifications
from using the rpc interface.
@guggero guggero merged commit 0051e39 into lightningnetwork:master May 11, 2022
v0.15.0-beta automation moved this from Reviewer approved + active testing to Done May 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bitcoind Bitcoin Core backend
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants