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

lightning-block-sync: Fix synchronize_listeners always calling default implementation #3354

Merged

Conversation

tnull
Copy link
Contributor

@tnull tnull commented Oct 10, 2024

Previously, the ChainListenerSet Listen implementation wouldn't forward to the listeners block_connected implementation outside of tests. This would result in the default implementation of Listen::block_connected being used and the listeners implementation never being called.

Previously, the `ChainListenerSet` `Listen` implementation wouldn't
forward to the listeners `block_connected` implementation outside of
tests. This would result in the default implementation of
`Listen::block_connected` being used and the listeners implementation
never being called.
@tnull tnull requested a review from jkczyz October 10, 2024 15:19
Copy link

codecov bot commented Oct 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.61%. Comparing base (a952d2d) to head (f4fe450).
Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3354      +/-   ##
==========================================
- Coverage   89.61%   89.61%   -0.01%     
==========================================
  Files         127      127              
  Lines      103531   103531              
  Branches   103531   103531              
==========================================
- Hits        92782    92779       -3     
+ Misses       8052     8048       -4     
- Partials     2697     2704       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines -242 to -243
// Needed to differentiate test expectations.
#[cfg(test)]
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like it was calling each listener's filtered_block_connected method, though, instead of block_connected. Is that a problem? Not clear from the commit message why.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As also discussed offline, the issue here is that the overridden Listen::block_connected implementation would never be called for the listeners. I.e., if they implement some behavior diverging from the default implementation, it would never be used which is clearly a bug.

If we don't expect users to override block_connected, it shouldn't be a trait method in the first place, IMO. Although I really think we should allow it (as we'll now also require it for LDK Node onchain wallet's listener).

tnull added a commit to tnull/ldk-node that referenced this pull request Oct 14, 2024
We previously discovered a minor bug that resulted in
`synchronize_listeners` not calling the actual implementation of
`Listen::block_connected`. While we will fix this upstream
(lightningdevkit/rust-lightning#3354), we now
copy over the fixed code in question to not be blocked on the next LDK
release. We also slightly adjusted it to account for types/APIs that are
only visible inside of `lightning-block-sync`.

We intend to drop the newly added module as soon as we can upgrade to
the next LDK release shipping the fixed version.
Copy link
Contributor

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

LGMT

@TheBlueMatt TheBlueMatt merged commit 46d8a0d into lightningdevkit:main Oct 14, 2024
19 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants