diff --git a/core/blockchain.go b/core/blockchain.go index 45eee13a19..8da91009cf 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -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 } diff --git a/core/blockchain_partial.go b/core/blockchain_partial.go index 6b50ac1c26..8cf8ab5fa0 100644 --- a/core/blockchain_partial.go +++ b/core/blockchain_partial.go @@ -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.