Commit e3744430 authored by wissyLeeei's avatar wissyLeeei Committed by GitHub

Fix the error usage in cannon (#11368)

parent 7ff5e6ed
......@@ -2,6 +2,7 @@ package cmd
import (
"context"
"errors"
"fmt"
"os"
"os/exec"
......@@ -375,7 +376,7 @@ func Run(ctx *cli.Context) error {
debugProgram := ctx.Bool(RunDebugFlag.Name)
if debugProgram {
if metaPath := ctx.Path(RunMetaFlag.Name); metaPath == "" {
return fmt.Errorf("cannot enable debug mode without a metadata file")
return errors.New("cannot enable debug mode without a metadata file")
}
if err := vm.InitDebug(); err != nil {
return fmt.Errorf("failed to initialize debug mode: %w", err)
......
......@@ -4,6 +4,7 @@ import (
"bytes"
"debug/elf"
"encoding/binary"
"errors"
"fmt"
"github.com/ethereum-optimism/optimism/cannon/mipsevm"
......@@ -57,7 +58,7 @@ func PatchStack(st mipsevm.FPVMState) error {
sp := uint32(0x7f_ff_d0_00)
// allocate 1 page for the initial stack data, and 16KB = 4 pages for the stack to grow
if err := st.GetMemory().SetMemoryRange(sp-4*memory.PageSize, bytes.NewReader(make([]byte, 5*memory.PageSize))); err != nil {
return fmt.Errorf("failed to allocate page for stack content")
return errors.New("failed to allocate page for stack content")
}
st.GetRegistersRef()[29] = sp
......
......@@ -123,7 +123,7 @@ func EncodePreimageOracleInput(t *testing.T, wit *mipsevm.StepWitness, localCont
return input, nil
case preimage.PrecompileKeyType:
if localOracle == nil {
return nil, fmt.Errorf("local oracle is required for precompile preimages")
return nil, errors.New("local oracle is required for precompile preimages")
}
preimage := localOracle.GetPreimage(preimage.Keccak256Key(wit.PreimageKey).PreimageKey())
precompile := common.BytesToAddress(preimage[:20])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment