Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix RPC closebatch executor error #3272

Merged
merged 6 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion sequencer/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package sequencer
import (
"context"
"encoding/json"
"errors"
"fmt"
"time"

Expand All @@ -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"
)

Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions sequencer/finalizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
10 changes: 6 additions & 4 deletions sequencer/l2block.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sequencer

import (
"context"
"errors"
"fmt"
"time"

Expand All @@ -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"
)

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion state/batchV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion state/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions state/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading