|
|
@@ -147,37 +147,37 @@ func (t *StateTest) Subtests() []StateSubtest {
|
|
|
}
|
|
|
|
|
|
// Run executes a specific subtest and verifies the post-state and logs
|
|
|
-func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config, snapshotter bool) (*state.StateDB, error) {
|
|
|
- statedb, root, err := t.RunNoVerify(subtest, vmconfig, snapshotter)
|
|
|
+func (t *StateTest) Run(subtest StateSubtest, vmconfig vm.Config, snapshotter bool) (*snapshot.Tree, *state.StateDB, error) {
|
|
|
+ snaps, statedb, root, err := t.RunNoVerify(subtest, vmconfig, snapshotter)
|
|
|
if err != nil {
|
|
|
- return statedb, err
|
|
|
+ return snaps, statedb, err
|
|
|
}
|
|
|
post := t.json.Post[subtest.Fork][subtest.Index]
|
|
|
// N.B: We need to do this in a two-step process, because the first Commit takes care
|
|
|
// of suicides, and we need to touch the coinbase _after_ it has potentially suicided.
|
|
|
if root != common.Hash(post.Root) {
|
|
|
- return statedb, fmt.Errorf("post state root mismatch: got %x, want %x", root, post.Root)
|
|
|
+ return snaps, statedb, fmt.Errorf("post state root mismatch: got %x, want %x", root, post.Root)
|
|
|
}
|
|
|
if logs := rlpHash(statedb.Logs()); logs != common.Hash(post.Logs) {
|
|
|
- return statedb, fmt.Errorf("post state logs hash mismatch: got %x, want %x", logs, post.Logs)
|
|
|
+ return snaps, statedb, fmt.Errorf("post state logs hash mismatch: got %x, want %x", logs, post.Logs)
|
|
|
}
|
|
|
- return statedb, nil
|
|
|
+ return snaps, statedb, nil
|
|
|
}
|
|
|
|
|
|
// RunNoVerify runs a specific subtest and returns the statedb and post-state root
|
|
|
-func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapshotter bool) (*state.StateDB, common.Hash, error) {
|
|
|
+func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapshotter bool) (*snapshot.Tree, *state.StateDB, common.Hash, error) {
|
|
|
config, eips, err := getVMConfig(subtest.Fork)
|
|
|
if err != nil {
|
|
|
- return nil, common.Hash{}, UnsupportedForkError{subtest.Fork}
|
|
|
+ return nil, nil, common.Hash{}, UnsupportedForkError{subtest.Fork}
|
|
|
}
|
|
|
vmconfig.ExtraEips = eips
|
|
|
block := t.genesis(config).ToBlock(nil)
|
|
|
- statedb := MakePreState(rawdb.NewMemoryDatabase(), t.json.Pre, snapshotter)
|
|
|
+ snaps, statedb := MakePreState(rawdb.NewMemoryDatabase(), t.json.Pre, snapshotter)
|
|
|
|
|
|
post := t.json.Post[subtest.Fork][subtest.Index]
|
|
|
msg, err := t.json.Tx.toMessage(post)
|
|
|
if err != nil {
|
|
|
- return nil, common.Hash{}, err
|
|
|
+ return nil, nil, common.Hash{}, err
|
|
|
}
|
|
|
context := core.NewEVMContext(msg, block.Header(), nil, &t.json.Env.Coinbase)
|
|
|
context.GetHash = vmTestBlockHash
|
|
|
@@ -199,14 +199,14 @@ func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapsh
|
|
|
statedb.AddBalance(block.Coinbase(), new(big.Int))
|
|
|
// And _now_ get the state root
|
|
|
root := statedb.IntermediateRoot(config.IsEIP158(block.Number()))
|
|
|
- return statedb, root, nil
|
|
|
+ return snaps, statedb, root, nil
|
|
|
}
|
|
|
|
|
|
func (t *StateTest) gasLimit(subtest StateSubtest) uint64 {
|
|
|
return t.json.Tx.GasLimit[t.json.Post[subtest.Fork][subtest.Index].Indexes.Gas]
|
|
|
}
|
|
|
|
|
|
-func MakePreState(db ethdb.Database, accounts core.GenesisAlloc, snapshotter bool) *state.StateDB {
|
|
|
+func MakePreState(db ethdb.Database, accounts core.GenesisAlloc, snapshotter bool) (*snapshot.Tree, *state.StateDB) {
|
|
|
sdb := state.NewDatabase(db)
|
|
|
statedb, _ := state.New(common.Hash{}, sdb, nil)
|
|
|
for addr, a := range accounts {
|
|
|
@@ -225,7 +225,7 @@ func MakePreState(db ethdb.Database, accounts core.GenesisAlloc, snapshotter boo
|
|
|
snaps = snapshot.New(db, sdb.TrieDB(), 1, root, false)
|
|
|
}
|
|
|
statedb, _ = state.New(root, sdb, snaps)
|
|
|
- return statedb
|
|
|
+ return snaps, statedb
|
|
|
}
|
|
|
|
|
|
func (t *StateTest) genesis(config *params.ChainConfig) *core.Genesis {
|