Repository navigation
fix(dash-spv): follow the network onto a branch that replaces stored blocks - #320
Closed
xdustinface wants to merge 1 commit into
Closed
xdustinface wants to merge 1 commit into
xdustinface wants to merge 1 commit into
Conversation
…blocks When the network reorganized onto a branch that replaces blocks the client already stored, the client stayed on the old branch for good. The headers of the new branch do not connect to any segment of the header pipeline, so they were dropped with a "no segment matched" warning, every time. The block headers manager now looks up where such headers branch off: past the headers it already stores, if the parent of the first unknown one is stored below the tip, it emits `SyncEvent::ForkDetected` with that height. The sync loop then hands it to `handle_fork()`, which, under the lifecycle lock, stops the client, truncates the stored headers, filter headers, filters and blocks above the fork, and runs the client again, so it syncs onto the branch the network follows. To run again without releasing the lock, `run()` now delegates to `run_locked()`. The wallet is not rewound: its synced height only moves forward, so the blocks of the new branch below its old height are not rescanned, and transactions of the dropped blocks stay as they were. `test_sync_follows_reorg` makes dashd replace its last 3 blocks with a branch of 5 and requires the client to end on the new tip. Without this change it times out with the client still on the old branch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Manki reviews one pull request per commit. #312 has the same head commit |
Owner
Author
|
Not dispatched while run 1 on the same commit was open. Replaced. |
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.
Replay of upstream PR 1102 at its initial state, for testing Manki reviews.
When the network reorganized onto a branch that replaces blocks the client already stored, the client stayed on the old branch for good. The headers of the new branch do not connect to any segment of the header pipeline, so they were dropped with a "no segment matched" warning, every time.
The block headers manager now looks up where such headers branch off: past the headers it already stores, if the parent of the first unknown one is stored below the tip, it emits
SyncEvent::ForkDetectedwith that height. The sync loop then hands it tohandle_fork(), which, under the lifecycle lock, stops the client, truncates the stored headers, filter headers, filters and blocks above the fork, and runs the client again, so it syncs onto the branch the network follows. To run again without releasing the lock,run()now delegates torun_locked().The wallet is not rewound: its synced height only moves forward, so the blocks of the new branch below its old height are not rescanned, and transactions of the dropped blocks stay as they were.
test_sync_follows_reorgmakes dashd replace its last 3 blocks with a branch of 5 and requires the client to end on the new tip. Without this change it times out with the client still on the old branch.