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/3203 panic if batch process fail and must be closed #3206

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
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (s *ProcessorTrustedBatchSync) ExecuteProcessBatch(ctx context.Context, pro
log.Debugf("%s is partially synchronized but we don't have intermediate stateRoot so it needs to be fully reprocessed", processMode.DebugPrefix)
processBatchResp, err = s.Steps.ReProcess(ctx, processMode, dbTx)
}
if processMode.BatchMustBeClosed {
if processBatchResp != nil && err == nil && processMode.BatchMustBeClosed {
err = checkProcessBatchResultMatchExpected(processMode, processBatchResp.ProcessBatchResponse)
if err != nil {
log.Error("%s error verifying batch result! Error: ", processMode.DebugPrefix, err)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package test_l2_shared

import (
"context"
"errors"
"testing"

"github.com/0xPolygonHermez/zkevm-node/jsonrpc/types"
Expand All @@ -9,6 +11,7 @@ import (
"github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync/l2_shared"
mock_l2_shared "github.com/0xPolygonHermez/zkevm-node/synchronizer/l2_sync/l2_shared/mocks"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -321,3 +324,16 @@ func TestGetNextStatusUpdateExecutionResult(t *testing.T) {
require.NoError(t, err)
require.Equal(t, common.HexToHash("0x123"), newStatus.LastTrustedBatches[0].StateRoot)
}

func TestExecuteProcessBatchError(t *testing.T) {
testData := newTestDataForProcessorTrustedBatchSync(t)

data := l2_shared.ProcessData{
Mode: l2_shared.NothingProcessMode,
BatchMustBeClosed: true,
}
returnedError := errors.New("error")
testData.mockExecutor.EXPECT().NothingProcess(mock.Anything, mock.Anything, mock.Anything).Return(nil, returnedError)
_, err := testData.sut.ExecuteProcessBatch(context.Background(), &data, nil)
require.ErrorIs(t, returnedError, err)
}
Loading