From 4efa34dd5cb98ace692cd8dad09dca34fe20c4f7 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Sat, 3 Feb 2024 05:14:05 -0300 Subject: [PATCH] state: avoid EIP-158 for history storage address (#359) Signed-off-by: Ignacio Hagopian --- core/state/statedb.go | 2 +- core/state_processor_test.go | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/state/statedb.go b/core/state/statedb.go index 442527a1e906..8c395fae2b6b 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -937,7 +937,7 @@ func (s *StateDB) Finalise(deleteEmptyObjects bool) { // Thus, we can safely ignore it here continue } - if obj.selfDestructed || (deleteEmptyObjects && obj.empty()) { + if (obj.selfDestructed || (deleteEmptyObjects && obj.empty())) && addr != params.HistoryStorageAddress { obj.deleted = true // We need to maintain account deletions explicitly (will remain diff --git a/core/state_processor_test.go b/core/state_processor_test.go index b40e1f31f5ac..e152338ac6e3 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -544,7 +544,7 @@ func TestProcessVerkle(t *testing.T) { } } -func TestProcessVerkleiInvalidContractCreation(t *testing.T) { +func TestProcessVerkleInvalidContractCreation(t *testing.T) { var ( config = ¶ms.ChainConfig{ ChainID: big.NewInt(69420), @@ -682,6 +682,12 @@ func TestProcessVerkleiInvalidContractCreation(t *testing.T) { if stemStateDiff.SuffixDiffs[0].Suffix != 65 { t.Fatalf("invalid suffix diff value found for BLOCKHASH contract at block #2: %d != 65", stemStateDiff.SuffixDiffs[0].Suffix) } + if stemStateDiff.SuffixDiffs[0].NewValue == nil { + t.Fatalf("missing post state value for BLOCKHASH contract at block #2") + } + if *stemStateDiff.SuffixDiffs[0].NewValue != common.HexToHash("53abcdfb284720ea59efe923d3dc774bbb7e787d829599f8ec7a81d344dd3d17") { + t.Fatalf("invalid post state value for BLOCKHASH contract at block #2: %x != ", (*stemStateDiff.SuffixDiffs[0].NewValue)[:]) + } } else if suffixDiff.Suffix > 4 { t.Fatalf("invalid suffix diff found for %x in block #2: %d\n", stemStateDiff.Stem, suffixDiff.Suffix) }