Skip to content

Commit

Permalink
Consolidated error logs to avoid duplicate logging by caller
Browse files Browse the repository at this point in the history
  • Loading branch information
amit-momin committed Dec 11, 2023
1 parent c01b243 commit 6f4e4dc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
4 changes: 2 additions & 2 deletions common/txmgr/broadcaster.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,15 +647,15 @@ func (eb *Broadcaster[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, SEQ, FEE]) hand
// If there is only one RPC node, or all RPC nodes have the same
// configured cap, this transaction will get stuck and keep repeating
// forever until the issue is resolved.
logger.Criticalw(lgr, `RPC node rejected this tx as outside Fee Cap`)
logger.Criticalw(lgr, `RPC node rejected this tx as outside Fee Cap`, "attempt", attempt)
fallthrough
default:
// Every error that doesn't fall under one of the above categories will be treated as Unknown.
fallthrough
case client.Unknown:
eb.SvcErrBuffer.Append(err)
logger.Criticalw(lgr, `Unknown error occurred while handling tx queue in ProcessUnstartedTxs. This chain/RPC client may not be supported. `+
`Urgent resolution required, Chainlink is currently operating in a degraded state and may miss transactions`, "err", err, "etx", etx, "attempt", attempt)
`Urgent resolution required, Chainlink is currently operating in a degraded state and may miss transactions`, "attempt", attempt)
nextSequence, e := eb.client.PendingSequenceAt(ctx, etx.FromAddress)
if e != nil {
err = multierr.Combine(e, err)
Expand Down
5 changes: 2 additions & 3 deletions common/txmgr/confirmer.go
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) han
case client.Underpriced:
// This should really not ever happen in normal operation since we
// already bumped above the required minimum in broadcaster.
ec.lggr.Warnw("Got terminally underpriced error for gas bump, this should never happen unless the remote RPC node changed its configuration on the fly, or you are using multiple RPC nodes with different minimum gas price requirements. This is not recommended", "err", sendError, "attempt", attempt)
ec.lggr.Warnw("Got terminally underpriced error for gas bump, this should never happen unless the remote RPC node changed its configuration on the fly, or you are using multiple RPC nodes with different minimum gas price requirements. This is not recommended", "attempt", attempt)
// "Lazily" load attempts here since the overwhelmingly common case is
// that we don't need them unless we enter this path
if err := ec.txStore.LoadTxAttempts(ctx, &etx); err != nil {
Expand Down Expand Up @@ -866,7 +866,6 @@ func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) han
// Broadcaster can never create a TxAttempt that will
// fatally error.
logger.Criticalw(lggr, "Invariant violation: fatal error while re-attempting transaction",
"err", sendError,
"fee", attempt.TxFee,
"feeLimit", etx.FeeLimit,
"signedRawTx", utils.AddHexPrefix(hex.EncodeToString(attempt.SignedRawTx)),
Expand All @@ -878,7 +877,7 @@ func (ec *Confirmer[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) han
case client.TransactionAlreadyKnown:
// Sequence too low indicated that a transaction at this sequence was confirmed already.
// Mark confirmed_missing_receipt and wait for the next cycle to try to get a receipt
lggr.Debugw("Sequence already used", "txAttemptID", attempt.ID, "txHash", attempt.Hash.String(), "err", sendError)
lggr.Debugw("Sequence already used", "txAttemptID", attempt.ID, "txHash", attempt.Hash.String())
timeout := ec.dbConfig.DefaultQueryTimeout()
return ec.txStore.SaveConfirmedMissingReceiptAttempt(ctx, timeout, &attempt, now)
case client.InsufficientFunds:
Expand Down
23 changes: 11 additions & 12 deletions core/chains/evm/client/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,56 +424,55 @@ func ClassifySendError(err error, lggr logger.Logger, tx *types.Transaction, fro
return commonclient.Fatal
}
if sendError.IsNonceTooLowError() || sendError.IsTransactionAlreadyMined() {
lggr.Debugw("Transaction already confirmed for this nonce: %d", tx.Nonce(), "err", sendError)
lggr.Debugw("Transaction already confirmed for this nonce: %d", tx.Nonce(), "err", sendError, "etx", tx)
// Nonce too low indicated that a transaction at this nonce was confirmed already.
// Mark it as TransactionAlreadyKnown.
return commonclient.TransactionAlreadyKnown
}
if sendError.IsReplacementUnderpriced() {
lggr.Errorw(fmt.Sprintf("Replacement transaction underpriced for eth_tx %x. "+
"Eth node returned error: '%s'. "+
"Please note that using your node's private keys outside of the chainlink node is NOT SUPPORTED and can lead to missed transactions.",
tx.Hash(), err), "gasPrice", tx.GasPrice, "gasTipCap", tx.GasTipCap, "gasFeeCap", tx.GasFeeCap)
tx.Hash()), "gasPrice", tx.GasPrice, "gasTipCap", tx.GasTipCap, "gasFeeCap", tx.GasFeeCap, "err", sendError, "etx", tx)

// Assume success and hand off to the next cycle.
return commonclient.Successful
}
if sendError.IsTransactionAlreadyInMempool() {
lggr.Debugw("Transaction already in mempool", "txHash", tx.Hash, "nodeErr", sendError.Error())
lggr.Debugw("Transaction already in mempool", "etx", tx, "err", sendError)
return commonclient.Successful
}
if sendError.IsTemporarilyUnderpriced() {
lggr.Infow("Transaction temporarily underpriced", "err", sendError.Error())
lggr.Infow("Transaction temporarily underpriced", "err", sendError)
return commonclient.Successful
}
if sendError.IsTerminallyUnderpriced() {
lggr.Errorw("Transaction terminally underpriced", "txHash", tx.Hash, "err", sendError)
lggr.Errorw("Transaction terminally underpriced", "etx", tx, "err", sendError)
return commonclient.Underpriced
}
if sendError.L2FeeTooLow() || sendError.IsL2FeeTooHigh() || sendError.IsL2Full() {
if isL2 {
lggr.Errorw("Transaction fee out of range", "err", sendError)
lggr.Errorw("Transaction fee out of range", "err", sendError, "etx", tx)
return commonclient.FeeOutOfValidRange
}
lggr.Errorw("this error type only handled for L2s", "err", sendError)
lggr.Errorw("this error type only handled for L2s", "err", sendError, "etx", tx)
return commonclient.Unsupported
}
if sendError.IsNonceTooHighError() {
// This error occurs when the tx nonce is greater than current_nonce + tx_count_in_mempool,
// instead of keeping the tx in mempool. This can happen if previous transactions haven't
// reached the client yet. The correct thing to do is to mark it as retryable.
lggr.Warnw("Transaction has a nonce gap.", "err", err)
lggr.Warnw("Transaction has a nonce gap.", "err", sendError, "etx", tx)
return commonclient.Retryable
}
if sendError.IsInsufficientEth() {
logger.Criticalw(lggr, fmt.Sprintf("Tx %x with type 0x%d was rejected due to insufficient eth: %s\n"+
"ACTION REQUIRED: Chainlink wallet with address 0x%x is OUT OF FUNDS",
tx.Hash(), tx.Type(), sendError.Error(), fromAddress,
), "err", sendError)
), "err", sendError, "etx", tx)
return commonclient.InsufficientFunds
}
if sendError.IsTimeout() {
lggr.Errorw("timeout while sending transaction %s", tx.Hash().Hex(), "err", sendError)
lggr.Errorw("timeout while sending transaction %x", tx.Hash(), "err", sendError, "etx", tx)
return commonclient.Retryable
}
if sendError.IsTxFeeExceedsCap() {
Expand All @@ -484,7 +483,7 @@ func ClassifySendError(err error, lggr logger.Logger, tx *types.Transaction, fro
)
return commonclient.ExceedsMaxFee
}
lggr.Errorw("Unknown error encountered when sending transaction", "err", err)
lggr.Errorw("Unknown error encountered when sending transaction", "err", err, "etx", tx)
return commonclient.Unknown
}

Expand Down

0 comments on commit 6f4e4dc

Please sign in to comment.