Skip to content

Commit

Permalink
New executor error: Balance Mismatch (0xPolygonHermez#1720)
Browse files Browse the repository at this point in the history
* new executor error

* fix test
  • Loading branch information
ToniRamirezM authored Mar 7, 2023
1 parent 420f1d0 commit 296d97e
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 16 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 @@ -276,4 +276,6 @@ enum ExecutorError {
EXECUTOR_ERROR_COUNTERS_OVERFLOW_POSEIDON = 7;
// EXECUTOR_ERROR_UNSUPPORTED_FORK_ID indicates that the fork id is not supported
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;
}
6 changes: 6 additions & 0 deletions state/runtime/executor/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ const (
EXECUTOR_ERROR_COUNTERS_OVERFLOW_POSEIDON = 7
// EXECUTOR_ERROR_UNSUPPORTED_FORK_ID indicates that the fork id is not supported
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
)

// RomErr returns an instance of error related to the ExecutorError
Expand Down Expand Up @@ -261,6 +263,8 @@ func ExecutorErr(errorCode pb.ExecutorError) error {
return runtime.ErrOutOfCountersPoseidon
case EXECUTOR_ERROR_UNSUPPORTED_FORK_ID:
return runtime.ErrUnsupportedForkId
case EXECUTOR_ERROR_BALANCE_MISMATCH:
return runtime.ErrBalanceMismatch
}
return fmt.Errorf("unknown error")
}
Expand All @@ -284,6 +288,8 @@ func ExecutorErrorCode(err error) pb.ExecutorError {
return pb.ExecutorError(EXECUTOR_ERROR_COUNTERS_OVERFLOW_POSEIDON)
case runtime.ErrUnsupportedForkId:
return pb.ExecutorError(EXECUTOR_ERROR_UNSUPPORTED_FORK_ID)
case runtime.ErrBalanceMismatch:
return pb.ExecutorError(EXECUTOR_ERROR_BALANCE_MISMATCH)
}
return math.MaxInt32
}
34 changes: 20 additions & 14 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.

2 changes: 2 additions & 0 deletions state/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ var (
ErrIntrinsicInvalidTxGasOverflow = errors.New("gas overflow")
// ErrUnsupportedForkId indicates that the fork id is not supported
ErrUnsupportedForkId = errors.New("unsupported fork id")
// ErrBalanceMismatch indicates that the balance mismatch in the ROM
ErrBalanceMismatch = errors.New("balance mismatch")
)

// ExecutionResult includes all output after executing given evm
Expand Down
2 changes: 1 addition & 1 deletion state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -1690,7 +1690,7 @@ func (s *State) LogExecutorError(responseError pb.ExecutorError, processBatchReq
log.Errorf("error marshaling payload: %v", err)
} else {
debugInfo := &DebugInfo{
ErrorType: DebugInfoErrorType_EXECUTOR_ERROR,
ErrorType: DebugInfoErrorType_EXECUTOR_ERROR + " " + responseError.String(),
Timestamp: timestamp,
Payload: string(payload),
}
Expand Down
2 changes: 1 addition & 1 deletion state/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2746,7 +2746,7 @@ func TestStoreDebugInfo(t *testing.T) {

err = testState.PostgresStorage.QueryRow(ctx, "SELECT * FROM state.debug").Scan(&debugInfo.ErrorType, &debugInfo.Timestamp, &debugInfo.Payload)
assert.NoError(t, err)
assert.Equal(t, state.DebugInfoErrorType_EXECUTOR_ERROR, debugInfo.ErrorType)
assert.Equal(t, state.DebugInfoErrorType_EXECUTOR_ERROR+" "+executorclientpb.ExecutorError_EXECUTOR_ERROR_COUNTERS_OVERFLOW_KECCAK.String(), debugInfo.ErrorType)
assert.Equal(t, string(payload), debugInfo.Payload)
}

Expand Down

0 comments on commit 296d97e

Please sign in to comment.