mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-03 01:27:38 +00:00
Fix genesis storage collision state tests (#4462)
* Enable a couple of tests that work now * Fix genesis storage collision state tests * IncarnationMap in t8ntool MakePreState
This commit is contained in:
parent
631d485476
commit
bca563fd0f
@ -18,6 +18,7 @@ package t8ntool
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
@ -297,7 +298,11 @@ func MakePreState(chainRules *params.Rules, tx kv.RwTx, accounts core.GenesisAll
|
||||
}
|
||||
|
||||
if len(a.Code) > 0 || len(a.Storage) > 0 {
|
||||
statedb.SetIncarnation(addr, 1)
|
||||
statedb.SetIncarnation(addr, state.FirstContractIncarnation)
|
||||
|
||||
var b [8]byte
|
||||
binary.BigEndian.PutUint64(b[:], state.FirstContractIncarnation)
|
||||
tx.Put(kv.IncarnationMap, addr[:], b[:])
|
||||
}
|
||||
}
|
||||
// Commit and re-open to start with a clean state.
|
||||
|
@ -338,7 +338,7 @@ func (g *Genesis) ToBlock() (*types.Block, *state.IntraBlockState, error) {
|
||||
}
|
||||
|
||||
if len(account.Code) > 0 || len(account.Storage) > 0 {
|
||||
statedb.SetIncarnation(addr, 1)
|
||||
statedb.SetIncarnation(addr, state.FirstContractIncarnation)
|
||||
}
|
||||
}
|
||||
if err := statedb.FinalizeTx(¶ms.Rules{}, w); err != nil {
|
||||
@ -401,7 +401,7 @@ func (g *Genesis) WriteGenesisState(tx kv.RwTx) (*types.Block, *state.IntraBlock
|
||||
return nil, nil, err
|
||||
}
|
||||
for addr, account := range g.Alloc {
|
||||
if len(account.Code) == 0 && len(account.Storage) > 0 {
|
||||
if len(account.Code) > 0 || len(account.Storage) > 0 {
|
||||
// Special case for weird tests - inaccessible storage
|
||||
var b [8]byte
|
||||
binary.BigEndian.PutUint64(b[:], state.FirstContractIncarnation)
|
||||
|
@ -46,15 +46,6 @@ func TestState(t *testing.T) {
|
||||
st.skipLoad(`^stTimeConsuming/`)
|
||||
st.skipLoad(`.*vmPerformance/loop.*`)
|
||||
|
||||
// Broken tests:
|
||||
st.skipLoad(`^stCreate2/create2collisionStorage.json`)
|
||||
st.skipLoad(`^stExtCodeHash/dynamicAccountOverwriteEmpty.json`)
|
||||
st.skipLoad(`^stSStoreTest/InitCollision.json`)
|
||||
st.skipLoad(`^stEIP1559/typeTwoBerlin.json`)
|
||||
|
||||
// value exceeding 256 bit is not supported
|
||||
st.skipLoad(`^stTransactionTest/ValueOverflow.json`)
|
||||
|
||||
st.walk(t, stateTestDir, func(t *testing.T, name string, test *StateTest) {
|
||||
db := memdb.NewTestDB(t)
|
||||
for _, subtest := range test.Subtests() {
|
||||
|
@ -17,6 +17,7 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"math/big"
|
||||
@ -274,9 +275,16 @@ func MakePreState(rules *params.Rules, tx kv.RwTx, accounts core.GenesisAlloc, b
|
||||
}
|
||||
|
||||
if len(a.Code) > 0 || len(a.Storage) > 0 {
|
||||
statedb.SetIncarnation(addr, 1)
|
||||
statedb.SetIncarnation(addr, state.FirstContractIncarnation)
|
||||
|
||||
var b [8]byte
|
||||
binary.BigEndian.PutUint64(b[:], state.FirstContractIncarnation)
|
||||
if err := tx.Put(kv.IncarnationMap, addr[:], b[:]); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Commit and re-open to start with a clean state.
|
||||
if err := statedb.FinalizeTx(rules, state.NewPlainStateWriter(tx, nil, blockNr+1)); err != nil {
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user