eth/tracers: fix codehash in prestate diffmode

This commit is contained in:
Sina Mahmoodi 2026-04-07 11:05:58 +00:00
parent bd6530a1d4
commit 50aceba6c4

View file

@ -277,7 +277,14 @@ func (t *prestateTracer) processDiffState() {
}
if newCodeHash != prevCodeHash {
modified = true
postAccount.CodeHash = &newCodeHash
// If code was cleared, report the canonical empty code hash
// rather than the zero hash used for comparison.
if newCodeHash == (common.Hash{}) {
emptyHash := types.EmptyCodeHash
postAccount.CodeHash = &emptyHash
} else {
postAccount.CodeHash = &newCodeHash
}
}
if !t.config.DisableCode {
newCode := t.env.StateDB.GetCode(addr)