From fe0bf325a68504292f910240f8da6243defffa71 Mon Sep 17 00:00:00 2001 From: rjl493456442 Date: Tue, 2 Apr 2024 20:25:06 +0800 Subject: [PATCH] cmd/evm: reopen the statedb for dumping (#29437) --- cmd/evm/runner.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/evm/runner.go b/cmd/evm/runner.go index 7f6f5f6be0..f179e733e6 100644 --- a/cmd/evm/runner.go +++ b/cmd/evm/runner.go @@ -272,8 +272,17 @@ func runCmd(ctx *cli.Context) error { output, leftOverGas, stats, err := timedExec(bench, execFunc) if ctx.Bool(DumpFlag.Name) { - statedb.Commit(genesisConfig.Number, true) - fmt.Println(string(statedb.Dump(nil))) + root, err := statedb.Commit(genesisConfig.Number, true) + if err != nil { + fmt.Printf("Failed to commit changes %v\n", err) + return err + } + dumpdb, err := state.New(root, sdb, nil) + if err != nil { + fmt.Printf("Failed to open statedb %v\n", err) + return err + } + fmt.Println(string(dumpdb.Dump(nil))) } if ctx.Bool(DebugFlag.Name) {