cmd/evm: compare errors by value in timedExec instead of interface identity

timedExec compares errors by direct interface inequality (haveErr != err). If execFunc returns newly constructed errors with the same message each run, this will panic even though behavior is equivalent.
This commit is contained in:
Daniel Liu 2026-04-16 14:45:02 +08:00
parent 0b35ad95f5
commit f45cd01ea2

View file

@ -166,8 +166,11 @@ func timedExec(bench bool, execFunc func() ([]byte, uint64, error)) ([]byte, exe
if haveGasUsed != gasUsed { if haveGasUsed != gasUsed {
panic(fmt.Sprintf("gas differs, have %v want %v", haveGasUsed, gasUsed)) panic(fmt.Sprintf("gas differs, have %v want %v", haveGasUsed, gasUsed))
} }
if haveErr != err { if (haveErr == nil) != (err == nil) {
panic(fmt.Sprintf("err differs, have %v want %v", haveErr, err)) panic(fmt.Sprintf("err differs in nil-ness, have %v want %v", haveErr, err))
}
if haveErr != nil && err != nil && haveErr.Error() != err.Error() {
panic(fmt.Sprintf("err differs, have %q want %q", haveErr.Error(), err.Error()))
} }
} }
}) })