state: avoid EIP-158 for history storage address (#359)

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
This commit is contained in:
Ignacio Hagopian 2024-02-03 05:14:05 -03:00 committed by Guillaume Ballet
parent afcfa5af07
commit 953338b22b
2 changed files with 8 additions and 2 deletions

View file

@ -937,7 +937,7 @@ func (s *StateDB) Finalise(deleteEmptyObjects bool) {
// Thus, we can safely ignore it here // Thus, we can safely ignore it here
continue continue
} }
if obj.selfDestructed || (deleteEmptyObjects && obj.empty()) { if (obj.selfDestructed || (deleteEmptyObjects && obj.empty())) && addr != params.HistoryStorageAddress {
obj.deleted = true obj.deleted = true
// We need to maintain account deletions explicitly (will remain // We need to maintain account deletions explicitly (will remain

View file

@ -544,7 +544,7 @@ func TestProcessVerkle(t *testing.T) {
} }
} }
func TestProcessVerkleiInvalidContractCreation(t *testing.T) { func TestProcessVerkleInvalidContractCreation(t *testing.T) {
var ( var (
config = &params.ChainConfig{ config = &params.ChainConfig{
ChainID: big.NewInt(69420), ChainID: big.NewInt(69420),
@ -682,6 +682,12 @@ func TestProcessVerkleiInvalidContractCreation(t *testing.T) {
if stemStateDiff.SuffixDiffs[0].Suffix != 65 { 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) 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 { } else if suffixDiff.Suffix > 4 {
t.Fatalf("invalid suffix diff found for %x in block #2: %d\n", stemStateDiff.Stem, suffixDiff.Suffix) t.Fatalf("invalid suffix diff found for %x in block #2: %d\n", stemStateDiff.Stem, suffixDiff.Suffix)
} }