Repository navigation
Conversation
The head was read once at the start of verify() and the batch length was compared against it after verification, so a concurrent update advancing storage in between made the result stale. Re-read the head after verifying and compare against that. Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
Simulates a storage advance during proof verification by doctoring the first head read, then asserts newer is computed against the fresh head. Co-authored-by: generaltony007 <144252170+GeneralTony007@users.noreply.github.com>
[Low impact] The PR appears safe to merge; no actionable issues were found. SummaryRe-reads the stored head after proof checks so
|
Author
|
Closing as duplicate of #791, which already addresses the stale head read. My apologies - I mistook that open PR for an issue when scanning the tracker. |
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.
Fixes #791
The race
verify()inlib/fully-remote-proof.jsreads the head once at the start, then upgrades the core and requests the proof batch. If storage advances in between (a concurrent update appending a block), the proof is verified against the new state butneweris still computed by comparingbatch.lengthagainst the stale head read from before verification, soinfocan report a stalenewervalue.The fix
Re-read the head after
verifyFullyRemotesucceeds and computeneweragainst the freshest head:Test
Adds
fully remote proof - newer uses freshest head, which deterministically simulates the race by wrapping the storage so the first head read (the one taken at the start ofverify()) returns a stale length while the post-verification read sees the advanced core. Without the fix the test reportsnewer: true(stale); with the fix it reportsnewer: falseas expected. Note: the race is simulated via the storage wrapper rather than a real concurrent append, to keep the test deterministic.Verification
newerreported stale) and passes post-fixtest/fully-remote-proof.jspass (3/3, 12 assertions)prettier --checkandlunteclean on both changed filestest/replicate.jssuite exceeds this machine's memory at the pre-existing "one missing block, big core (slow)" test, so verification was scoped to the affected file