Repository navigation
Conversation
tip_changed was only set through last_header_entry, which stays None unless the client subscribed to headers. A scripthash-only client never saw a new tip, so on a block-only tick the touched-scripthash fast path skipped its subscription and the notification was lost. Track the tip from each connection's last periodic tick and force the full scan when it changes. Add raw-TCP tests for a mempool tx, a block without a mempool tx, and a block with a headers subscription.
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to my comment on #237, as offered: the three tests and the fix, against this branch.
Bug:
tip_changedis only set throughlast_header_entry, which isNoneunless the client calledblockchain.headers.subscribe. A client that subscribes only to scripthashes never seestip_changed, so on a block-only tick (the spend was never in our mempool) the touched-scripthash fast path skips its subscription and the notification is lost.Fix: each connection remembers the chain tip from its last periodic tick (
last_tick_tip), whether or not it subscribed to headers. A new tip forces the full scan, as before.Tests (raw TCP in
tests/electrum.rs):test_electrum_subscription_notified_on_mempool_tx: passes before and after.test_electrum_subscription_notified_on_block_without_mempool_tx: passes on new-index, fails on this branch, passes with the fix.test_electrum_subscription_notified_on_block_with_headers_subscription: passes before and after.Happy to change the approach if you'd rather fold this into
tip_changeddifferently.