diff --git a/cmd/evm/runner.go b/cmd/evm/runner.go index 3a010da9f2dc..d6ec8ae7527d 100644 --- a/cmd/evm/runner.go +++ b/cmd/evm/runner.go @@ -40,6 +40,7 @@ import ( "github.com/ethereum/go-ethereum/internal/flags" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" + "github.com/ethereum/go-ethereum/trie" "github.com/urfave/cli/v2" ) @@ -125,6 +126,7 @@ func runCmd(ctx *cli.Context) error { sender = common.BytesToAddress([]byte("sender")) receiver = common.BytesToAddress([]byte("receiver")) genesisConfig *core.Genesis + preimages = ctx.Bool(DumpFlag.Name) ) if ctx.Bool(MachineFlag.Name) { tracer = logger.NewJSONLogger(logconfig, os.Stdout) @@ -139,10 +141,12 @@ func runCmd(ctx *cli.Context) error { genesisConfig = gen db := rawdb.NewMemoryDatabase() genesis := gen.MustCommit(db) - statedb, _ = state.New(genesis.Root(), state.NewDatabase(db), nil) + sdb := state.NewDatabaseWithConfig(db, &trie.Config{Preimages: preimages}) + statedb, _ = state.New(genesis.Root(), sdb, nil) chainConfig = gen.Config } else { - statedb, _ = state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil) + sdb := state.NewDatabaseWithConfig(rawdb.NewMemoryDatabase(), &trie.Config{Preimages: preimages}) + statedb, _ = state.New(common.Hash{}, sdb, nil) genesisConfig = new(core.Genesis) } if ctx.String(SenderFlag.Name) != "" { diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 98acc468a1d8..14b6fe534169 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -37,6 +37,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" + "github.com/ethereum/go-ethereum/trie" "golang.org/x/crypto/sha3" ) @@ -284,7 +285,7 @@ func (t *StateTest) gasLimit(subtest StateSubtest) uint64 { } func MakePreState(db ethdb.Database, accounts core.GenesisAlloc, snapshotter bool) (*snapshot.Tree, *state.StateDB) { - sdb := state.NewDatabase(db) + sdb := state.NewDatabaseWithConfig(db, &trie.Config{Preimages: true}) statedb, _ := state.New(common.Hash{}, sdb, nil) for addr, a := range accounts { statedb.SetCode(addr, a.Code)