Skip to content

Commit

Permalink
Fix the error usage in cannon (ethereum-optimism#11368)
Browse files Browse the repository at this point in the history
  • Loading branch information
wissyLeeei authored Sep 12, 2024
1 parent 7ff5e6e commit e374443
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cannon/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"context"
"errors"
"fmt"
"os"
"os/exec"
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion cannon/mipsevm/program/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"debug/elf"
"encoding/binary"
"errors"
"fmt"

"github.com/ethereum-optimism/optimism/cannon/mipsevm"
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion cannon/mipsevm/testutil/mips.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down

0 comments on commit e374443

Please sign in to comment.