diff --git a/sequencer/batch.go b/sequencer/batch.go index 6643ed15ee..53845886e9 100644 --- a/sequencer/batch.go +++ b/sequencer/batch.go @@ -3,6 +3,7 @@ package sequencer import ( "context" "encoding/json" + "errors" "fmt" "time" @@ -11,6 +12,7 @@ import ( "github.com/0xPolygonHermez/zkevm-node/sequencer/metrics" "github.com/0xPolygonHermez/zkevm-node/state" stateMetrics "github.com/0xPolygonHermez/zkevm-node/state/metrics" + "github.com/0xPolygonHermez/zkevm-node/state/runtime" "github.com/ethereum/go-ethereum/common" ) @@ -404,7 +406,7 @@ func (f *finalizer) batchSanityCheck(ctx context.Context, batchNum uint64, initi return nil, ErrProcessBatch } - if batchResponse.ExecutorError != nil { + if batchResponse.ExecutorError != nil && !errors.Is(batchResponse.ExecutorError, runtime.ErrExecutorErrorCloseBatch) { log.Errorf("executor error when reprocessing batch %d, error: %v", batch.BatchNumber, batchResponse.ExecutorError) reprocessError(batch) return nil, ErrExecutorError diff --git a/sequencer/finalizer_test.go b/sequencer/finalizer_test.go index 7c33c2f54e..6aa201fd29 100644 --- a/sequencer/finalizer_test.go +++ b/sequencer/finalizer_test.go @@ -945,6 +945,9 @@ func TestNewFinalizer(t *testing.T) { func TestFinalizer_closeWIPBatch(t *testing.T) { // arrange f = setupFinalizer(true) + // set wip batch has at least one L2 block as it can not be closed empty + f.wipBatch.countOfL2Blocks++ + usedResources := getUsedBatchResources(f.batchConstraints, f.wipBatch.imRemainingResources) receipt := state.ProcessingReceipt{ diff --git a/sequencer/l2block.go b/sequencer/l2block.go index 63dbabf3d1..c2a4a52a7e 100644 --- a/sequencer/l2block.go +++ b/sequencer/l2block.go @@ -2,6 +2,7 @@ package sequencer import ( "context" + "errors" "fmt" "time" @@ -11,6 +12,7 @@ import ( "github.com/0xPolygonHermez/zkevm-node/sequencer/metrics" "github.com/0xPolygonHermez/zkevm-node/state" stateMetrics "github.com/0xPolygonHermez/zkevm-node/state/metrics" + "github.com/0xPolygonHermez/zkevm-node/state/runtime" "github.com/ethereum/go-ethereum/common" ) @@ -279,13 +281,13 @@ func (f *finalizer) executeL2Block(ctx context.Context, initialStateRoot common. return nil, 0, err } - if batchResponse.ExecutorError != nil { - executeL2BLockError(err) + if batchResponse.ExecutorError != nil && !errors.Is(batchResponse.ExecutorError, runtime.ErrExecutorErrorCloseBatch) { + executeL2BLockError(batchResponse.ExecutorError) return nil, 0, ErrExecutorError } if batchResponse.IsRomOOCError { - executeL2BLockError(err) + executeL2BLockError(batchResponse.RomError_V2) return nil, 0, ErrProcessBatchOOC } @@ -557,7 +559,7 @@ func (f *finalizer) executeNewWIPL2Block(ctx context.Context) (*state.ProcessBat return nil, err } - if batchResponse.ExecutorError != nil { + if batchResponse.ExecutorError != nil && !errors.Is(batchResponse.ExecutorError, runtime.ErrExecutorErrorCloseBatch) { return nil, ErrExecutorError } diff --git a/state/batchV2.go b/state/batchV2.go index 9f26e612f6..f10b0ddef7 100644 --- a/state/batchV2.go +++ b/state/batchV2.go @@ -299,7 +299,7 @@ func (s *State) sendBatchRequestToExecutorV2(ctx context.Context, batchRequest * log.Errorf("error executor ProcessBatchV2 response: %v", batchResponse) } else { batchResponseToString := processBatchResponseToString(newBatchNum, batchResponse, elapsed) - if batchResponse.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR { + if batchResponse.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR && batchResponse.Error != executor.ExecutorError_EXECUTOR_ERROR_CLOSE_BATCH { err = executor.ExecutorErr(batchResponse.Error) log.Warnf("executor batch %d response, executor error: %v", newBatchNum, err) log.Warn(batchResponseToString) diff --git a/state/trace.go b/state/trace.go index c227ad85c0..13c66a6aa7 100644 --- a/state/trace.go +++ b/state/trace.go @@ -225,7 +225,7 @@ func (s *State) DebugTransaction(ctx context.Context, transactionHash common.Has endTime = time.Now() if err != nil { return nil, err - } else if processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR { + } else if processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR && processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_CLOSE_BATCH { err = executor.ExecutorErr(processBatchResponseV2.Error) s.eventLog.LogExecutorErrorV2(ctx, processBatchResponseV2.Error, processBatchRequestV2) return nil, err diff --git a/state/transaction.go b/state/transaction.go index c2011c8e30..781be79e21 100644 --- a/state/transaction.go +++ b/state/transaction.go @@ -580,7 +580,7 @@ func (s *State) internalProcessUnsignedTransactionV2(ctx context.Context, tx *ty } } - if err == nil && processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR { + if err == nil && processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR && processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_CLOSE_BATCH { err = executor.ExecutorErr(processBatchResponseV2.Error) s.eventLog.LogExecutorErrorV2(ctx, processBatchResponseV2.Error, processBatchRequestV2) return nil, err @@ -1014,7 +1014,7 @@ func (s *State) internalTestGasEstimationTransactionV2(ctx context.Context, batc log.Errorf("error estimating gas: %v", err) return false, false, gasUsed, nil, err } - if processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR { + if processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_NO_ERROR && processBatchResponseV2.Error != executor.ExecutorError_EXECUTOR_ERROR_CLOSE_BATCH { err = executor.ExecutorErr(processBatchResponseV2.Error) s.eventLog.LogExecutorErrorV2(ctx, processBatchResponseV2.Error, processBatchRequestV2) return false, false, gasUsed, nil, err