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 error handling in sequencer #1730

Merged
merged 6 commits into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 12 additions & 2 deletions sequencer/finalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ func (f *finalizer) processTransaction(ctx context.Context, tx *TxTracker) error
}
result, err := f.executor.ProcessBatch(ctx, f.processRequest, false)
if err != nil {
log.Errorf("failed to process transaction, err: %s", err)
log.Errorf("failed to process transaction, isClaim: %v, err: %s", tx.IsClaim, err)
return err
}

Expand Down Expand Up @@ -461,7 +461,7 @@ func (f *finalizer) handleTransactionError(ctx context.Context, result *state.Pr
log.Errorf("failed to update status to failed in the pool for tx: %s, err: %s", tx.Hash.String(), err)
}
}()
} else if executor.IsIntrinsicError(errorCode) {
} else if (executor.IsInvalidNonceError(errorCode) || executor.IsInvalidBalanceError(errorCode)) && !tx.IsClaim {
log.Errorf("intrinsic error, moving tx with Hash: %s to NOT READY, to not ready, err: %s", tx.Hash, txResponse.RomError)
var (
nonce *uint64
Expand All @@ -480,6 +480,16 @@ func (f *finalizer) handleTransactionError(ctx context.Context, result *state.Pr
}
}
metrics.WorkerProcessingTime(time.Since(start))
} else {
// Delete the transaction from the efficiency list
f.worker.DeleteTx(tx.Hash, tx.From)
log.Debug("tx deleted from efficiency list", "txHash", tx.Hash.String(), "from", tx.From.Hex())

// Update the status of the transaction to failed
err := f.dbManager.UpdateTxStatus(ctx, tx.Hash, pool.TxStatusFailed, false)
if err != nil {
log.Errorf("failed to update status to failed in the pool for tx: %s, err: %s", tx.Hash.String(), err)
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions state/runtime/executor/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,16 @@ func IsIntrinsicError(error pb.RomError) bool {
return int32(error) >= ROM_ERROR_INTRINSIC_INVALID_SIGNATURE && int32(error) <= ROM_ERROR_INTRINSIC_TX_GAS_OVERFLOW
}

// IsInvalidNonceError indicates if the error is due to a invalid nonce
func IsInvalidNonceError(error pb.RomError) bool {
return int32(error) == ROM_ERROR_INTRINSIC_INVALID_NONCE
}

// IsInvalidBalanceError indicates if the error is due to a invalid balance
func IsInvalidBalanceError(error pb.RomError) bool {
return int32(error) == ROM_ERROR_INTRINSIC_INVALID_BALANCE
}

// ExecutorErr returns an instance of error related to the ExecutorError
func ExecutorErr(errorCode pb.ExecutorError) error {
e := int32(errorCode)
Expand Down