mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-11 09:21:37 +00:00
core/state/partial: fix storage value encoding in trie updates
Trim leading zeros from storage values before passing to UpdateStorage, matching the upstream BALStateTransition behavior. UpdateStorage RLP-encodes the value internally, so passing untrimmed 32-byte values (e.g. [0,0,...,5]) produces different trie nodes than trimmed values ([5]), causing systematic state root mismatches on every BAL-processed block. BuildStateSet already correctly trimmed values for the pathdb layer; this fix aligns the trie update path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a15c05a406
commit
b5d9b12e70
1 changed files with 4 additions and 2 deletions
|
|
@ -444,8 +444,10 @@ func (s *PartialState) applyStorageChanges(
|
||||||
return common.Hash{}, nil, err
|
return common.Hash{}, nil, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Update slot
|
// Update slot — trim leading zeros to match how the EVM stores
|
||||||
if err := storageTrie.UpdateStorage(addr, slot.Bytes(), value.Bytes()); err != nil {
|
// values (as big integers). UpdateStorage RLP-encodes the value,
|
||||||
|
// so [0,0,...,5] vs [5] produce different trie nodes.
|
||||||
|
if err := storageTrie.UpdateStorage(addr, slot.Bytes(), common.TrimLeftZeroes(value.Bytes())); err != nil {
|
||||||
return common.Hash{}, nil, err
|
return common.Hash{}, nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue