-
Notifications
You must be signed in to change notification settings - Fork 84
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
Add bitcoind RPC support #370
Add bitcoind RPC support #370
Conversation
a2b10ef
to
d9cc69a
Compare
Now rebased on #365 after we bumped to 0.0.125, i.e., also dropped the commit copy/pasting |
d9cc69a
to
6e6e9b7
Compare
Alright, rebased on main after #365 landed. Also addressed (or postponed) the remaining TODOs, should be ready for review. |
f68adfc
to
7c1ad82
Compare
tests/integration_tests_rust.rs
Outdated
#[test] | ||
fn channel_full_cycle_bitcoind() { | ||
let (bitcoind, electrsd) = setup_bitcoind_and_electrsd(); | ||
premine_dummy_blocks(&bitcoind.client, &electrsd.client); | ||
let chain_source = TestChainSource::BitcoinRpc(&bitcoind); | ||
let (node_a, node_b) = setup_two_nodes(&chain_source, false, true, false); | ||
do_channel_full_cycle(node_a, node_b, &bitcoind.client, &electrsd.client, false, true, false); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not expand the other tests for BitcoinRpc
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally sounds good, I mostly started off with this as I didn't simply want to double our test surface. Do you have any specific test cases in mind that would lend themselves to also be run on a BitcoindRpc
backend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... probably only tests where non-setup code depends on block (dis)connection notification (e.g., onchain_spend_receive
). Though, I also wonder if we should use BitcoinRpc
normally just to remove one moving part from the tests assuming that would lead to less flakiness.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though, I also wonder if we should use BitcoinRpc normally just to remove one moving part from the tests assuming that would lead to less flakiness.
I generally agree this would be preferable but thought we might be limited by the additional overhead of the premining required to populate estimatesmartfee
. As we now added fallbacks for regtest anyways we can however drop that premining again.
I now added a fixup switching it around: we now default to bitcoind RPC and only have a single Esplora-specific full-cycle test. It seemed a bit flaky when run concurrently locally, but let's see how it works out in CI. If it turns out to be flaky we can take additional mitigation steps in a follow up (e.g., reduce the number of threads used in tests, etc).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, if the extra part is actually removing the underlying flakiness, maybe we should keep it. 😛 Though perhaps we need to make sure the (non-test) code is robust enough to retry appropriately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh, there we have the first CI failure due to flakiness. Mind if I revert and do the CI switch as a follow-up (possibly post-release)? I'd like to get main into a release-ready state ASAP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now reverted, but still dropped the unnecessary premining.
83b0a4f
to
c20359a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo test changes
tests/integration_tests_rust.rs
Outdated
#[test] | ||
fn channel_full_cycle_bitcoind() { | ||
let (bitcoind, electrsd) = setup_bitcoind_and_electrsd(); | ||
premine_dummy_blocks(&bitcoind.client, &electrsd.client); | ||
let chain_source = TestChainSource::BitcoinRpc(&bitcoind); | ||
let (node_a, node_b) = setup_two_nodes(&chain_source, false, true, false); | ||
do_channel_full_cycle(node_a, node_b, &bitcoind.client, &electrsd.client, false, true, false); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... probably only tests where non-setup code depends on block (dis)connection notification (e.g., onchain_spend_receive
). Though, I also wonder if we should use BitcoinRpc
normally just to remove one moving part from the tests assuming that would lead to less flakiness.
.. which we'll use to feed blocks to it in following commits.
c20359a
to
a45c7a7
Compare
Cool, let me know if I can squash. |
4839e10
to
f4538a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, please squash
We first initialize by synchronizing all `Listen` implementations, and then head into a loop continuously polling our RPC `BlockSource`. We also implement a `BoundedHeaderCache` to limit in-memory footprint.
.. to allow the on-chain wallet to detect what's inflight.
This behavior mirrors what we do in the Esplora case: we only enforce successful fee rate updates on mainnet. On regtest/signet/testnet we will just skip (i.e. return `Ok(())`) if we fail to retrieve the updates (e.g., when bitcoind's `estimatesmartfee` isn't sufficiently populated) and will either keep previously-retrieved values or worst case fallback to the fallback defaults.
.. as it regularly makes CI fail and doesn't provide us anything really.
.. to account for slight differences in fee rate estmations between chain sources.
f4538a3
to
7c629f2
Compare
Squashed fixups without further changes. |
(sweeper_best_block_hash, &*output_sweeper as &(dyn Listen + Send + Sync)), | ||
]; | ||
|
||
// TODO: Eventually we might want to see if we can synchronize `ChannelMonitor`s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for the question post-merge but what would be the benefit of syncing the ChannelMonitor
s before passing them to the ChainMonitor
? There would still be a need to sync them via the monitor even if it was possible to sync before, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
post-merge questions are great!
ChannelMonitor
s can by sync'd by just syncing the ChainMonitor
and it'll multiplex the events across all the ChannelMonitor
s for us (cleaning up the logic here quite a bit). Sadly, doing so requires that the ChannelMonitor
s be in sync with each other before we pass them to ChainMonitor
on load (or we'll end up connecting blocks on different ChannelMonitor
s even though they have different ideas of the current chain tip).
Based on #365.
We add support for sourcing chain data from the
bitcoind
RPC interface. Ready for review.TODO:
estimatesmartfee
in tests. Probably just do a simliar carve-out for non-mainnet as for Esplora, i.e., default to 253?sync_wallet
calls. No-op? Or still block until the next polling is finished?lightning-block-sync
: Fixsynchronize_listeners
always calling default implementation rust-lightning#3354, so we might temporarily need to copy/pastsynchronize_listeners
over here.- [ ] Implement UtxoSource / GossipVerifier (via(Bashing my head against the typechecker for a few hours is having me believe this is currently ~impossible with the upstream types, so moved to #377 / blocked on lightningdevkit/rust-lightning#3369)tokio
feature oflightning-block-sync
)