fix: stabilize flaky CI (stage-exec-test (from-0, paral) - #21888
Closed
erigon-copilot[bot] wants to merge 2 commits into
Closed
erigon-copilot[bot] wants to merge 2 commits into
erigon-copilot[bot] wants to merge 2 commits into
Conversation
…e root PR #21380 (State Cache Consolidation) introduced an aggregator-scoped BranchCache that caches commitment-trie branch data across transactions. SharedDomains.Commit() correctly updates the cache, but Flush() did not - it wrote new commitment branches to the transaction without invalidating or updating the cache. The integration stage_exec command (non-chaintip mode) uses a Flush+ClearRam+Commit loop. On the next batch iteration, GetLatest for CommitmentDomain keys hit the BranchCache and returned stale branch data from the previous iteration's read-through population. The trie walker then computed an incorrect state root from these stale branches, causing wrong trie root errors at blocks 263641 and 513814. Fix: clear the BranchCache after a successful Flush in SharedDomains.Flush(). This forces the next read to go to the backing transaction/files which contain the correct post-flush data. The cache re-warms naturally via read-through. Fixes: wrong trie root at block 263641 and 513814 on stage-exec-test (from-0, parallel) Co-authored-by: Giulio Rebuffo <giulio.rebuffo@gmail.com>
Actions fixed: stage-exec-test (from-0, parallel) Co-authored-by: Giulio Rebuffo <giulio.rebuffo@gmail.com>
erigon-copilot
Bot
requested review from
AskAlexSharov,
sudeepdino008 and
yperbasis
as code owners
June 18, 2026 13:26
Collaborator
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.
db/state: clear BranchCache on Flush to prevent stale trie data
What was failing
The
stage-exec-test (from-0, parallel)CI job failed with:All four
from-0andresume-nonchaintipmatrix jobs failed with wrong trie roots at different blocks (263641, 513814, 25314648). Thechaintip, serialandresume-nonchaintip, paralleljobs passed.Root cause
PR #21380 (State Cache Consolidation, commit
193d04a) introduced an aggregator-scopedBranchCachethat caches commitment-trie branch data across transactions. TheSharedDomains.Commit()method correctly updates the cache after flushing, butSharedDomains.Flush()did not — it wrote new commitment branches to the transaction without invalidating or updating the cache.The integration tool's
stage_execcommand (non-chaintip mode) uses a Flush+ClearRam+Commit loop:On the next batch iteration,
GetLatestforCommitmentDomainkeys hit the BranchCache (line 837 ofdomain_shared.go) and returned stale branch data from the read-through population in the previous iteration. The trie walker then computed an incorrect state root from these stale branches.Fix
Clear the
BranchCacheafter a successfulFlushinSharedDomains.Flush()(db/state/execctx/domain_shared.go:657). This forces the next read to go to the backing transaction/files, which contain the correct post-flush data. The cache re-warms naturally via read-through during the next execution batch.Commit()is unaffected — it already maintains cache consistency via itsCommitmentFlushCallback.Verification
TestFromZero_GenesisAllocPreservedAfterResetReExec(serial + parallel): PASS ×10TestBranchCacheCommitRefreshesAfterReadThrough: PASS ×10db/state/execctxtests: PASSexecution/commitmenttests (including BranchCache, DecodeBranch, HPH): PASSmake erigon+make integration: build cleanmake lint: 0 issues (2 consecutive runs)The actual CI failure cannot be reproduced locally (requires a mainnet reference datadir), but the fix is deterministic: the stale-cache read path is eliminated by clearing on Flush.