Skip to content

Commit

Permalink
rename isBatchProcessed
Browse files Browse the repository at this point in the history
  • Loading branch information
ToniRamirezM committed May 16, 2023
1 parent 96a6a5a commit a9631c4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,14 @@ func (p *Pool) PreExecuteTx(ctx context.Context, tx types.Transaction) (preExecu

response.usedZkCounters = processBatchResponse.UsedZkCounters

if processBatchResponse.IsBatchProcessed {
if !processBatchResponse.RomOOC {
if processBatchResponse.Responses != nil && len(processBatchResponse.Responses) > 0 {
r := processBatchResponse.Responses[0]
response.isOOC = executor.IsROMOutOfGasError(executor.RomErrorCode(r.RomError))
response.isReverted = errors.Is(r.RomError, runtime.ErrExecutionReverted)
}
} else {
response.isOOG = !processBatchResponse.IsBatchProcessed
response.isOOG = processBatchResponse.RomOOC
}

return response, nil
Expand Down
6 changes: 3 additions & 3 deletions sequencer/finalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func (f *finalizer) newWIPBatch(ctx context.Context) (*WipBatch, error) {

// Reprocess full batch as sanity check
processBatchResponse, err := f.reprocessFullBatch(ctx, f.batch.batchNumber, f.batch.stateRoot)
if err != nil || !processBatchResponse.IsBatchProcessed {
if err != nil || processBatchResponse.RomOOC {
log.Info("halting the finalizer because of a reprocessing error")
if err != nil {
f.halt(ctx, fmt.Errorf("failed to reprocess batch, err: %v", err))
Expand Down Expand Up @@ -400,7 +400,7 @@ func (f *finalizer) handleTxProcessResp(ctx context.Context, tx *TxTracker, resu
// Handle Transaction Error

errorCode := executor.RomErrorCode(result.Responses[0].RomError)
if !result.IsBatchProcessed || executor.IsIntrinsicError(errorCode) {
if result.RomOOC || executor.IsIntrinsicError(errorCode) {
// If intrinsic error or OOC error, we skip adding the transaction to the batch
f.handleTransactionError(ctx, result, tx)
return result.Responses[0].RomError
Expand Down Expand Up @@ -784,7 +784,7 @@ func (f *finalizer) reprocessFullBatch(ctx context.Context, batchNum uint64, exp
return nil, err
}

if !result.IsBatchProcessed {
if result.RomOOC {
log.Errorf("failed to process batch %v because OutOfCounters", batch.BatchNumber)
payload, err := json.Marshal(processRequest)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions state/converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ func (s *State) convertToProcessBatchResponse(txs []types.Transaction, response
return nil, err
}

isBatchProcessed := response.Error == executor.EXECUTOR_ERROR_NO_ERROR
if isBatchProcessed && len(response.Responses) > 0 {
romOOC := response.Error != executor.EXECUTOR_ERROR_NO_ERROR
if romOOC && len(response.Responses) > 0 {
// Check out of counters
errorToCheck := response.Responses[len(response.Responses)-1].Error
isBatchProcessed = !executor.IsROMOutOfCountersError(errorToCheck)
romOOC = executor.IsROMOutOfCountersError(errorToCheck)
}

return &ProcessBatchResponse{
Expand All @@ -63,7 +63,7 @@ func (s *State) convertToProcessBatchResponse(txs []types.Transaction, response
UsedZkCounters: convertToCounters(response),
Responses: responses,
ExecutorError: executor.ExecutorErr(response.Error),
IsBatchProcessed: isBatchProcessed,
RomOOC: romOOC,
ReadWriteAddresses: readWriteAddresses,
}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion state/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type ProcessBatchResponse struct {
UsedZkCounters ZKCounters
Responses []*ProcessTransactionResponse
ExecutorError error
IsBatchProcessed bool
RomOOC bool
ReadWriteAddresses map[common.Address]*InfoReadWrite
}

Expand Down

0 comments on commit a9631c4

Please sign in to comment.