fix: keep the old sink open when a proof replacement is rejected - #2301
Open
0xrlawrence wants to merge 1 commit into
Open
fix: keep the old sink open when a proof replacement is rejected#23010xrlawrence wants to merge 1 commit into
0xrlawrence wants to merge 1 commit into
Conversation
handle_replacement_message closed the previous connection's sink before calling replacement_entry_is_valid. The replacement entry is cloned from the original, so the two share the same Arc sink. When validation failed the function returned with the original entry still queued, but its sink had already been closed and the client had already been told ProofReplaced, so that proof could never report its inclusion. Take the old sink aside, run the validity check, and only close it once the replacement is actually going into the queue. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Description
handle_replacement_messageclosed the previous connection's sink before callingreplacement_entry_is_valid.replacement_entryis cloned from the queued entry, so both hold the sameArc<RwLock<...>>sink. When validation fails the function returns with the original entry still in the batch queue — but the client has already been sentProofReplacedand the shared sink has already been closed. That proof stays queued and paid for, and can no longer report its inclusion to the user.The fix takes the old sink aside with
Option::take, runs the validity check, and only spawns the notify-and-close task once the replacement is actually going into the queue.replacement_entry_is_validonly inspectssender,nonceandmax_fee, so moving it ahead of the sink handling does not change what it decides.Type of change
Checklist
testnet, everything else tostagingVerified with
cargo check -p aligned-batcher,cargo clippy -p aligned-batcherandcargo fmt --checkonstaging. Clippy reports the same warnings before and after (both atlib.rs:365/:391, unrelated to this change).