From fd74979033ce44924f451f288fdcb2916511ad43 Mon Sep 17 00:00:00 2001 From: mh0lt Date: Thu, 4 Jun 2026 16:13:32 +0000 Subject: [PATCH] db/state/execctx: decode AccountsDomain codeHash with DeserialiseV3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit codeHashForAddr resolves an account's codeHash from the AccountsDomain so the CodeDomain ethHash bypass can serve shared bytecode without an addr-keyed file read. decodeAccountCodeHash decoded the account value with acc.DecodeForStorage, but AccountsDomain values are SerialiseV3-encoded. DecodeForStorage is the legacy MDBX bitmask format with an incompatible binary layout; applied to V3 bytes it silently misparses and leaves CodeHash empty. As a result codeHashForAddr returned nil for every account and the ethHash bypass never engaged for any contract — every CodeDomain read that missed the addr cache fell through to a file read. This is a decoding-correctness bug: the wrong decoder is applied to the stored encoding. Use accounts.DeserialiseV3, the matching decoder for AccountsDomain values. Co-Authored-By: Claude Opus 4.8 (1M context) --- db/state/execctx/domain_shared.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/db/state/execctx/domain_shared.go b/db/state/execctx/domain_shared.go index ea8c923140c..2b660f4a580 100644 --- a/db/state/execctx/domain_shared.go +++ b/db/state/execctx/domain_shared.go @@ -1121,7 +1121,12 @@ func decodeAccountCodeHash(enc []byte) []byte { return nil } var acc accounts.Account - if err := acc.DecodeForStorage(enc); err != nil { + // AccountsDomain values are SerialiseV3-encoded, so they must be decoded + // with DeserialiseV3. DecodeForStorage is the legacy MDBX bitmask format + // with an incompatible binary layout; applied to V3 bytes it silently + // misparses and leaves CodeHash empty, so codeHashForAddr returned nil for + // every contract and the CodeDomain ethHash bypass never fired. + if err := accounts.DeserialiseV3(&acc, enc); err != nil { return nil } if acc.CodeHash.IsEmpty() {