Skip to content

Commit 0900aae

Browse files
holimankaralabe
authored andcommitted
cmd/evm: print stateroot in evm utility (#15341)
1 parent eea996e commit 0900aae

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎cmd/evm/staterunner.go‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,20 @@ func stateTestCmd(ctx *cli.Context) error {
9494
for _, st := range test.Subtests() {
9595
// Run the test and aggregate the result
9696
result := &StatetestResult{Name: key, Fork: st.Fork, Pass: true}
97-
if state, err := test.Run(st, cfg); err != nil {
97+
state, err := test.Run(st, cfg)
98+
if err != nil {
9899
// Test failed, mark as so and dump any state to aid debugging
99100
result.Pass, result.Error = false, err.Error()
100101
if ctx.GlobalBool(DumpFlag.Name) && state != nil {
101102
dump := state.RawDump()
102103
result.State = &dump
103104
}
104105
}
106+
// print state root for evmlab tracing (already committed above, so no need to delete objects again
107+
if ctx.GlobalBool(MachineFlag.Name) && state != nil {
108+
fmt.Fprintf(os.Stderr, "{\"stateRoot\": \"%x\"}\n", state.IntermediateRoot(false))
109+
}
110+
105111
results = append(results, *result)
106112

107113
// Print any structured logs collected

0 commit comments

Comments
 (0)