mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-08 07:58:40 +00:00
core/state/partial: only write modified accounts to trie
Match upstream BALStateTransition behavior: only call UpdateAccount for accounts that were actually modified (balance, nonce, code, or storage changes). Previously, all accounts in the BAL (including read-only ones) were written back to the trie, which could cause root mismatches if the re-encoded RLP differed from the original encoding. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
da476a8eca
commit
fc2d55dd58
1 changed files with 5 additions and 0 deletions
|
|
@ -287,6 +287,11 @@ func (s *PartialState) ApplyBALAndComputeRoot(parentRoot common.Hash, expectedRo
|
|||
continue
|
||||
}
|
||||
|
||||
// Only write accounts that were actually modified to the trie.
|
||||
// Upstream BALStateTransition only processes ModifiedAccounts().
|
||||
if !state.modified {
|
||||
continue
|
||||
}
|
||||
if err := tr.UpdateAccount(state.addr, state.account, 0); err != nil {
|
||||
return common.Hash{}, 0, fmt.Errorf("failed to update account %s: %w",
|
||||
state.addr.Hex(), err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue