fix(node): fork-aware getWorldState that fails closed on sync errors#24563
Open
spalladino wants to merge 3 commits into
Open
Conversation
The txe bundle stubs @aztec/world-state; node_world_state_queries.ts now imports WorldStateSynchronizerError from it, which broke the esbuild bundling step.
…ed history getVerifiedSnapshot classified every unreadable archive leaf as a retryable WorldStateSynchronizerError, so queries against historically pruned blocks burned all sync retries and surfaced 'Unable to read block hash' instead of the established 'Unable to find leaf' error callers match on. Distinguish a block that predates oldestHistoricalBlock (permanent, terminal plain Error) from a transient fork flip (retryable).
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.
Context
getWorldStatebacks most node RPC tree/witness queries, and had three related problems:provenquery could be answered with a same-height block from a new fork that is not proven.Approach
getBlockData, and the sync is driven to that exact block and hash so the synchronizer barriers on it and detects fork mismatches.WorldStateSynchronizer.getVerifiedSnapshot(blockNumber, blockHash)verifies the snapshot's own archive view matches the requested fork before handing it out (block 0 is checked against the initial header hash, since its snapshot predates the genesis archive leaf), closing the remaining window between sync and snapshot read.WorldStateSynchronizerErrorand are retried a few times with the query re-resolved each time, so prunes and fork flips heal onto the current chain instead of failing or serving wrong-fork state. Hash and archive resolution misses stay terminal with a clear reorg error; tag and number misses are treated as transient.proposed/latestqueries keep their "latest on the current fork" semantics: plain sync plus the committed db, unverified.API changes
WorldStateSynchronizergainsgetVerifiedSnapshot(blockNumber, blockHash), implemented byServerWorldStateSynchronizer(fork-verified) andTXESynchronizer(passthrough, no reorgs). OthergetSnapshotcallers are unchanged.Fixes A-1339