Skip to content

Commit

Permalink
handle new executor errors (0xPolygonHermez#2942)
Browse files Browse the repository at this point in the history
  • Loading branch information
ToniRamirezM authored Dec 19, 2023
1 parent 8c85f0e commit e74fd67
Show file tree
Hide file tree
Showing 9 changed files with 2,042 additions and 1,489 deletions.
1,427 changes: 825 additions & 602 deletions merkletree/hashdb/hashdb.pb.go

Large diffs are not rendered by default.

126 changes: 100 additions & 26 deletions merkletree/hashdb/hashdb_grpc.pb.go

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

27 changes: 24 additions & 3 deletions proto/src/proto/executor/v1/executor.proto
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ message ProcessBatchRequestV2 {
// where each entry specifies some state to be ephemerally overridden
// prior to executing the call.
map<string, OverrideAccountV2> state_override = 23;
DebugV2 debug = 24;
}

message L1DataV2 {
Expand All @@ -300,6 +301,14 @@ message L1DataV2 {
repeated bytes smt_proof = 4;
}

message DebugV2 {
uint64 gas_limit = 1;
bytes new_state_root = 2;
bytes new_acc_input_hash = 3;
bytes new_local_exit_root = 4;
uint64 new_batch_num = 5;
}

message ProcessBatchResponseV2 {
bytes new_state_root = 1;
bytes new_acc_input_hash = 2;
Expand All @@ -323,6 +332,8 @@ message ProcessBatchResponseV2 {
repeated bytes smt_keys = 20;
repeated bytes program_keys = 21;
uint64 fork_id = 22;
uint32 invalid_batch = 23;
RomError error_rom = 24;
}

// Trace configuration request params
Expand Down Expand Up @@ -470,6 +481,8 @@ message ProcessBlockResponseV2 {
repeated ProcessTransactionResponseV2 responses = 11;
// All Logs emited by LOG opcode during the block
repeated LogV2 logs = 12;
// Any error encountered during block execution
RomError error = 13;
}

message ProcessTransactionResponseV2 {
Expand Down Expand Up @@ -608,8 +621,10 @@ enum RomError {
ROM_ERROR_INVALID_DECODE_CHANGE_L2_BLOCK = 31;
// ROM_ERROR_INVALID_NOT_FIRST_TX_CHANGE_L2_BLOCK indicates that the first transaction in a batch is not a change l2 block transaction
ROM_ERROR_INVALID_NOT_FIRST_TX_CHANGE_L2_BLOCK = 32;
// ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK indicates that the change l2 block transaction has trigger an error during while executing
ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK = 33;
// ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_LIMIT_TIMESTAMP indicates that the change l2 block transaction has trigger an error during while executing
ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_LIMIT_TIMESTAMP = 33;
// ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_MIN_TIMESTAMP indicates that the change l2 block transaction has trigger an error during while executing
ROM_ERROR_INVALID_TX_CHANGE_L2_BLOCK_MIN_TIMESTAMP = 34;
}

enum ExecutorError {
Expand Down Expand Up @@ -821,4 +836,10 @@ enum ExecutorError {
EXECUTOR_ERROR_INVALID_BALANCE = 102;
// EXECUTOR_ERROR_SM_MAIN_BINARY_LT4_MISMATCH indicates that the binary instruction less than four opcode failed
EXECUTOR_ERROR_SM_MAIN_BINARY_LT4_MISMATCH = 103;
}
// EXECUTOR_ERROR_INVALID_NEW_STATE_ROOT indicates that the input parameter new_state_root is invalid
EXECUTOR_ERROR_INVALID_NEW_STATE_ROOT = 104;
// EXECUTOR_ERROR_INVALID_NEW_ACC_INPUT_HASH indicates that the input parameter new_acc_input_hash is invalid
EXECUTOR_ERROR_INVALID_NEW_ACC_INPUT_HASH = 105;
// EXECUTOR_ERROR_INVALID_NEW_LOCAL_EXIT_ROOT indicates that the input parameter new_local_exit_root is invalid
EXECUTOR_ERROR_INVALID_NEW_LOCAL_EXIT_ROOT = 106;
}
38 changes: 34 additions & 4 deletions proto/src/proto/hashdb/v1/hashdb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ service HashDBService {
rpc GetProgram(GetProgramRequest) returns (GetProgramResponse) {}
rpc LoadDB(LoadDBRequest) returns (google.protobuf.Empty) {}
rpc LoadProgramDB(LoadProgramDBRequest) returns (google.protobuf.Empty) {}
rpc FinishTx (FinishTxRequest) returns (google.protobuf.Empty) {}
rpc StartBlock (StartBlockRequest) returns (google.protobuf.Empty) {}
rpc FinishBlock (FinishBlockRequest) returns (google.protobuf.Empty) {}
rpc Flush (FlushRequest) returns (FlushResponse) {}
rpc SemiFlush (SemiFlushRequest) returns (google.protobuf.Empty) {}
rpc GetFlushStatus (google.protobuf.Empty) returns (GetFlushStatusResponse) {}
rpc GetFlushData (GetFlushDataRequest) returns (GetFlushDataResponse) {}
rpc ConsolidateState (ConsolidateStateRequest) returns (ConsolidateStateResponse) {}
Expand Down Expand Up @@ -152,12 +154,36 @@ message FlushRequest {
}

/**
* @dev SemiFlushRequest
* @param {batch_uuid} - indicates a unique identifier of the current batch or session which data will be semi-flushed
* @dev FinishTxRequest
* @param {batch_uuid} - indicates a unique identifier of the current batch or session which tx will be finished
* @param {new_state_root} - state root at this point of the execution
* @param {persistence} - indicates if it should be stored only in CACHE, in the SQL DATABASE, or it is just TEMPORARY and should be deleted at the flush of this batch UUID
*/
message SemiFlushRequest {
message FinishTxRequest {
string batch_uuid = 1;
string new_state_root = 2;
Persistence persistence = 3;
}

/**
* @dev StartBlockRequest
* @param {batch_uuid} - indicates a unique identifier of the current batch or session which block started
* @param {new_state_root} - state root at this point of the execution
* @param {persistence} - indicates if it should be stored only in CACHE, in the SQL DATABASE, or it is just TEMPORARY and should be deleted at the flush of this batch UUID
*/
message StartBlockRequest {
string batch_uuid = 1;
string old_state_root = 2;
Persistence persistence = 3;
}

/**
* @dev FinishBlockRequest
* @param {batch_uuid} - indicates a unique identifier of the current batch or session which block will be finished
* @param {new_state_root} - state root at this point of the execution
* @param {persistence} - indicates if it should be stored only in CACHE, in the SQL DATABASE, or it is just TEMPORARY and should be deleted at the flush of this batch UUID
*/
message FinishBlockRequest {
string batch_uuid = 1;
string new_state_root = 2;
Persistence persistence = 3;
Expand Down Expand Up @@ -240,6 +266,8 @@ message GetLatestStateRootResponse {
* @param {proof_hash_counter}
* @param {db_read_log} - list of db records read during the execution of the request
* @param {result} - result code
* @param {sibling_left_child} - on delete not found, use children to hash intermediate node (to be sure that it's a intermediate)
* @param {sibling_right_child} - on delete not found, use children to hash intermediate node (to be sure that it's a intermediate)
*/
message SetResponse {
Fea old_root = 1;
Expand All @@ -255,6 +283,8 @@ message SetResponse {
uint64 proof_hash_counter = 11;
map<string, FeList> db_read_log = 12;
ResultCode result = 13;
Fea sibling_left_child = 14;
Fea sibling_right_child = 15;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions state/convertersV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ func (s *State) convertToProcessBatchResponseV2(batchResponse *executor.ProcessB
SMTKeys_V2: convertToKeys(batchResponse.SmtKeys),
ProgramKeys_V2: convertToKeys(batchResponse.ProgramKeys),
ForkID: batchResponse.ForkId,
InvalidBatch_V2: batchResponse.InvalidBatch != 0,
RomError_V2: executor.RomErr(batchResponse.ErrorRom),
}, nil
}

Expand Down Expand Up @@ -87,6 +89,7 @@ func (s *State) convertToProcessBlockResponseV2(responses []*executor.ProcessBlo
result.BlockHash = common.Hash(response.BlockHash)
result.TransactionResponses = transactionResponses
result.Logs = convertToLogV2(response.Logs)
result.RomError_V2 = executor.RomErr(response.Error)

results = append(results, result)
}
Expand Down
Loading

0 comments on commit e74fd67

Please sign in to comment.