From 50aceba6c4fcde2b82c2645be1eac5c692af09c4 Mon Sep 17 00:00:00 2001 From: Sina Mahmoodi Date: Tue, 7 Apr 2026 11:05:58 +0000 Subject: [PATCH] eth/tracers: fix codehash in prestate diffmode --- eth/tracers/native/prestate.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/eth/tracers/native/prestate.go b/eth/tracers/native/prestate.go index 159a91b310..d39fb186c9 100644 --- a/eth/tracers/native/prestate.go +++ b/eth/tracers/native/prestate.go @@ -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)