mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-08 16:01:36 +00:00
core: fix AdvancePartialHead to initialize partial state root
After the second snap sync completes, AdvancePartialHead moves the head markers forward but never initialized partialState.Root(). This caused ProcessBlockWithBAL to fall back to the parent's header root, which doesn't match the computed trie root from BAL processing — resulting in a state root mismatch on the first block after sync. Fix: call SetRoot(root) and SetLastProcessedBlock() in AdvancePartialHead so subsequent BAL processing chains from the correct state root. Also add diagnostic logging to ProcessBlockWithBAL for easier debugging. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
962e2de6e1
commit
a0c3999bb9
2 changed files with 12 additions and 0 deletions
|
|
@ -1418,6 +1418,13 @@ func (bc *BlockChain) AdvancePartialHead(hash common.Hash) error {
|
|||
bc.currentBlock.Store(block.Header())
|
||||
headBlockGauge.Update(int64(block.NumberU64()))
|
||||
|
||||
// Set the partial state root so ProcessBlockWithBAL chains from the correct root.
|
||||
// After the second snap sync, the trie root matches the block's header root.
|
||||
if bc.partialState != nil {
|
||||
bc.partialState.SetRoot(root)
|
||||
bc.partialState.SetLastProcessedBlock(block.NumberU64())
|
||||
}
|
||||
|
||||
log.Info("Advanced partial state head", "number", block.Number(), "hash", hash)
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,6 +94,11 @@ func (bc *BlockChain) ProcessBlockWithBAL(
|
|||
parentRoot = parent.Root()
|
||||
}
|
||||
|
||||
log.Debug("ProcessBlockWithBAL: parent root details",
|
||||
"block", block.NumberU64(), "parentRoot", parentRoot,
|
||||
"hasState", bc.HasState(parentRoot), "headerRoot", block.Root(),
|
||||
"trackedRoot", bc.partialState.Root())
|
||||
|
||||
// 4. Apply BAL diffs and compute new state root.
|
||||
// Pass block.Root() as expectedRoot so the resolver can query peers for this
|
||||
// state's untracked contracts.
|
||||
|
|
|
|||
Loading…
Reference in a new issue