Skip to content

Commit

Permalink
tos32 error handling (0xPolygonHermez#1959)
Browse files Browse the repository at this point in the history
  • Loading branch information
ToniRamirezM authored Mar 31, 2023
1 parent f8f54cd commit 9a30dc9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
2 changes: 2 additions & 0 deletions proto/src/proto/executor/v1/executor.proto
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,6 @@ enum ExecutorError {
EXECUTOR_ERROR_BALANCE_MISMATCH = 9;
// EXECUTOR_ERROR_FEA2SCALAR indicates that there is a fea2scalar error in the execution
EXECUTOR_ERROR_FEA2SCALAR = 10;
// EXECUTOR_ERROR_TOS32 indicates that there is a TOS32 error in the execution
EXECUTOR_ERROR_TOS32 = 11;
}
12 changes: 12 additions & 0 deletions state/runtime/executor/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ const (
EXECUTOR_ERROR_UNSUPPORTED_FORK_ID = 8
// EXECUTOR_ERROR_BALANCE_MISMATCH indicates that there is a balance mismatch error in the ROM
EXECUTOR_ERROR_BALANCE_MISMATCH = 9
// EXECUTOR_ERROR_FEA2SCALAR indicates that there is a fea2scalar error in the execution
EXECUTOR_ERROR_FEA2SCALAR = 10
// EXECUTOR_ERROR_TOS32 indicates that there is a TOS32 error in the execution
EXECUTOR_ERROR_TOS32 = 11
)

// RomErr returns an instance of error related to the ExecutorError
Expand Down Expand Up @@ -275,6 +279,10 @@ func ExecutorErr(errorCode pb.ExecutorError) error {
return runtime.ErrUnsupportedForkId
case EXECUTOR_ERROR_BALANCE_MISMATCH:
return runtime.ErrBalanceMismatch
case EXECUTOR_ERROR_FEA2SCALAR:
return runtime.ErrFea2Scalar
case EXECUTOR_ERROR_TOS32:
return runtime.ErrTos32
}
return fmt.Errorf("unknown error")
}
Expand All @@ -300,6 +308,10 @@ func ExecutorErrorCode(err error) pb.ExecutorError {
return pb.ExecutorError(EXECUTOR_ERROR_UNSUPPORTED_FORK_ID)
case runtime.ErrBalanceMismatch:
return pb.ExecutorError(EXECUTOR_ERROR_BALANCE_MISMATCH)
case runtime.ErrFea2Scalar:
return pb.ExecutorError(EXECUTOR_ERROR_FEA2SCALAR)
case runtime.ErrTos32:
return pb.ExecutorError(EXECUTOR_ERROR_TOS32)
}
return math.MaxInt32
}
31 changes: 18 additions & 13 deletions state/runtime/executor/pb/executor.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions state/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ var (
ErrUnsupportedForkId = errors.New("unsupported fork id")
// ErrBalanceMismatch indicates that the balance mismatch in the ROM
ErrBalanceMismatch = errors.New("balance mismatch")
// ErrFea2Scalar indicates a fea2scalar error in the ROM
ErrFea2Scalar = errors.New("fea2scalar")
// ErrTos32 indicates a tos32 error in the ROM
ErrTos32 = errors.New("tos32")
)

// ExecutionResult includes all output after executing given evm
Expand Down

0 comments on commit 9a30dc9

Please sign in to comment.