From 9a30dc95618b86ed2bf458067106777c2fcfc36e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20Ram=C3=ADrez?= <58293609+ToniRamirezM@users.noreply.github.com> Date: Fri, 31 Mar 2023 09:21:28 +0200 Subject: [PATCH] tos32 error handling (#1959) --- proto/src/proto/executor/v1/executor.proto | 2 ++ state/runtime/executor/errors.go | 12 +++++++++ state/runtime/executor/pb/executor.pb.go | 31 +++++++++++++--------- state/runtime/runtime.go | 4 +++ 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/proto/src/proto/executor/v1/executor.proto b/proto/src/proto/executor/v1/executor.proto index 110ebc4cb4..d377578cb8 100644 --- a/proto/src/proto/executor/v1/executor.proto +++ b/proto/src/proto/executor/v1/executor.proto @@ -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; } diff --git a/state/runtime/executor/errors.go b/state/runtime/executor/errors.go index ceee9f8195..e60a4cd6e4 100644 --- a/state/runtime/executor/errors.go +++ b/state/runtime/executor/errors.go @@ -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 @@ -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") } @@ -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 } diff --git a/state/runtime/executor/pb/executor.pb.go b/state/runtime/executor/pb/executor.pb.go index cd47976721..85a2facf14 100644 --- a/state/runtime/executor/pb/executor.pb.go +++ b/state/runtime/executor/pb/executor.pb.go @@ -199,6 +199,8 @@ const ( ExecutorError_EXECUTOR_ERROR_BALANCE_MISMATCH ExecutorError = 9 // EXECUTOR_ERROR_FEA2SCALAR indicates that there is a fea2scalar error in the execution ExecutorError_EXECUTOR_ERROR_FEA2SCALAR ExecutorError = 10 + // EXECUTOR_ERROR_TOS32 indicates that there is a TOS32 error in the execution + ExecutorError_EXECUTOR_ERROR_TOS32 ExecutorError = 11 ) // Enum value maps for ExecutorError. @@ -215,6 +217,7 @@ var ( 8: "EXECUTOR_ERROR_UNSUPPORTED_FORK_ID", 9: "EXECUTOR_ERROR_BALANCE_MISMATCH", 10: "EXECUTOR_ERROR_FEA2SCALAR", + 11: "EXECUTOR_ERROR_TOS32", } ExecutorError_value = map[string]int32{ "EXECUTOR_ERROR_UNSPECIFIED": 0, @@ -228,6 +231,7 @@ var ( "EXECUTOR_ERROR_UNSUPPORTED_FORK_ID": 8, "EXECUTOR_ERROR_BALANCE_MISMATCH": 9, "EXECUTOR_ERROR_FEA2SCALAR": 10, + "EXECUTOR_ERROR_TOS32": 11, } ) @@ -1901,7 +1905,7 @@ var file_executor_proto_rawDesc = []byte{ 0x52, 0x5f, 0x42, 0x41, 0x54, 0x43, 0x48, 0x5f, 0x44, 0x41, 0x54, 0x41, 0x5f, 0x54, 0x4f, 0x4f, 0x5f, 0x42, 0x49, 0x47, 0x10, 0x1b, 0x12, 0x21, 0x0a, 0x1d, 0x52, 0x4f, 0x4d, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x55, 0x4e, 0x53, 0x55, 0x50, 0x50, 0x4f, 0x52, 0x54, 0x45, 0x44, 0x5f, - 0x46, 0x4f, 0x52, 0x4b, 0x5f, 0x49, 0x44, 0x10, 0x1c, 0x2a, 0xc5, 0x03, 0x0a, 0x0d, 0x45, 0x78, + 0x46, 0x4f, 0x52, 0x4b, 0x5f, 0x49, 0x44, 0x10, 0x1c, 0x2a, 0xdf, 0x03, 0x0a, 0x0d, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x6f, 0x72, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x12, 0x1e, 0x0a, 0x1a, 0x45, 0x58, 0x45, 0x43, 0x55, 0x54, 0x4f, 0x52, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1b, 0x0a, 0x17, 0x45, @@ -1930,18 +1934,19 @@ var file_executor_proto_rawDesc = []byte{ 0x42, 0x41, 0x4c, 0x41, 0x4e, 0x43, 0x45, 0x5f, 0x4d, 0x49, 0x53, 0x4d, 0x41, 0x54, 0x43, 0x48, 0x10, 0x09, 0x12, 0x1d, 0x0a, 0x19, 0x45, 0x58, 0x45, 0x43, 0x55, 0x54, 0x4f, 0x52, 0x5f, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x5f, 0x46, 0x45, 0x41, 0x32, 0x53, 0x43, 0x41, 0x4c, 0x41, 0x52, 0x10, - 0x0a, 0x32, 0x68, 0x0a, 0x0f, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x12, 0x55, 0x0a, 0x0c, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x42, - 0x61, 0x74, 0x63, 0x68, 0x12, 0x20, 0x2e, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x6f, 0x72, 0x2e, - 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x6f, - 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x42, 0x61, 0x74, 0x63, - 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x41, 0x5a, 0x3f, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x30, 0x78, 0x50, 0x6f, 0x6c, 0x79, - 0x67, 0x6f, 0x6e, 0x48, 0x65, 0x72, 0x6d, 0x65, 0x7a, 0x2f, 0x7a, 0x6b, 0x65, 0x76, 0x6d, 0x2d, - 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x2f, 0x72, 0x75, 0x6e, 0x74, 0x69, - 0x6d, 0x65, 0x2f, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x6f, 0x72, 0x2f, 0x70, 0x62, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x0a, 0x12, 0x18, 0x0a, 0x14, 0x45, 0x58, 0x45, 0x43, 0x55, 0x54, 0x4f, 0x52, 0x5f, 0x45, 0x52, + 0x52, 0x4f, 0x52, 0x5f, 0x54, 0x4f, 0x53, 0x33, 0x32, 0x10, 0x0b, 0x32, 0x68, 0x0a, 0x0f, 0x45, + 0x78, 0x65, 0x63, 0x75, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x55, + 0x0a, 0x0c, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x42, 0x61, 0x74, 0x63, 0x68, 0x12, 0x20, + 0x2e, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x6f, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, + 0x63, 0x65, 0x73, 0x73, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x21, 0x2e, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x6f, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x50, + 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x41, 0x5a, 0x3f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x30, 0x78, 0x50, 0x6f, 0x6c, 0x79, 0x67, 0x6f, 0x6e, 0x48, 0x65, 0x72, + 0x6d, 0x65, 0x7a, 0x2f, 0x7a, 0x6b, 0x65, 0x76, 0x6d, 0x2d, 0x6e, 0x6f, 0x64, 0x65, 0x2f, 0x73, + 0x74, 0x61, 0x74, 0x65, 0x2f, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2f, 0x65, 0x78, 0x65, + 0x63, 0x75, 0x74, 0x6f, 0x72, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/state/runtime/runtime.go b/state/runtime/runtime.go index 6d30beef96..901a76099a 100644 --- a/state/runtime/runtime.go +++ b/state/runtime/runtime.go @@ -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