Conversation
|
cab58c2 to
d34d05d
Compare
| txErr error, | ||
| txStore txm.TxStore, | ||
| setNonce func(common.Address, uint64), | ||
| isFromBroadcastMethod bool, |
There was a problem hiding this comment.
Let's remove the unused isFromBroadcastMethod while we're touching this func anyway
| txStore txm.TxStore, | ||
| setNonce func(common.Address, uint64), | ||
| isFromBroadcastMethod bool, | ||
| ) (noTransmission bool, err error) { |
There was a problem hiding this comment.
Nitpick: I somewhat dislike negations in var names, since it will lead to double negations, which can lead to confusion.
Maybe flip it around and use something like transmissionHappened?
There was a problem hiding this comment.
Seems reasonable to me, but the issue with this particular case is that there is guarantee a transmission happened and we can only be sure about the noTransmission. If we flip the name to transmissionHappened or transmissionMayHappened and we check for the inversed result, the reader might assume that the error handler can deterministically returned if a transaction was broadcasted. It feels like noTransmission provides better conviction as to what happened.
There was a problem hiding this comment.
Ah I see, so otherwise it would be transmissionMightHaveHappened, which is not great 😅
Let's leave it like this then. Might be worthwhile to add a comment to the code about that we can only be 100% sure a transmission has not happened
There was a problem hiding this comment.
I included one on the interface level here: https://github.com/smartcontractkit/chainlink-evm/pull/408/changes#diff-b9fe8b4b005efc03661d7777aebac2846a0ff01a18ffff7d1cb715d6766736f3R60-R61
| } | ||
| setNonce(tx.FromAddress, *tx.Nonce) | ||
| return fmt.Errorf("transaction with txID: %d marked as fatal", tx.ID) | ||
| lggr.Infof("transaction with txID: %d marked as fatal", tx.ID) |
There was a problem hiding this comment.
Can we log the transactionLifecycleID here?
| if hErr != nil { | ||
| return hErr | ||
| } | ||
| if noTransmission { |
There was a problem hiding this comment.
Would it be helpful to add a debug log here?
There was a problem hiding this comment.
For now the only ErrorHandler we have implemented is the MetaErrorHandler which already logs a message if noTransmission is true, so I think we already get the information from that.
5cb2762 to
156bdfc
Compare
156bdfc to
37483bb
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates TXMv2’s error-handling flow to improve observability and to fall back to the “standard” pending-nonce verification path when an error cannot be classified by the error handler.
Changes:
- Change the
txm.ErrorHandlerinterface to return(noTransmission bool, err error)and accept a logger, enabling non-error fatal handling and logging. - Update
Txm.sendTransactionWithErrorto (a) not fail the call when the handler determines “no transmission”, and (b) checkPendingNonceAtwhen the handler cannot classify the error. - Update dualbroadcast error handler + tests to log fatal marking instead of returning a fatal error, and adjust TXM tests accordingly.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/txm/txm.go | Updates ErrorHandler interface and TXM send flow to use handler result + pending nonce fallback. |
| pkg/txm/clientwrappers/dualbroadcast/meta_error_handler.go | Implements new handler contract; logs and marks tx fatal without returning an error. |
| pkg/txm/clientwrappers/dualbroadcast/meta_error_handler_test.go | Updates unit tests for new handler behavior and adds log assertions. |
| pkg/txm/txm_test.go | Updates flow tests to assert log output and pending-nonce fallback behavior. |
Comments suppressed due to low confidence (1)
pkg/txm/txm_test.go:591
- Same issue here:
require.NotNil(t, IDK, tx.IdempotencyKey)will always pass becauseIDKis non-nil. This should assert ontx.IdempotencyKey(and preferably compare it to the expected value).
require.Equal(t, 1, count)
require.NotNil(t, IDK, tx.IdempotencyKey)
require.Equal(t, uint16(2), tx.AttemptCount)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| noTransmission, err := errorHandler.HandleError(t.Context(), logger.Test(t), tx, txErr, txStoreManager, setNonce) | ||
| require.NoError(t, err) | ||
| require.False(t, noTransmission) | ||
| _, unconfirmedCount := txStore.FetchUnconfirmedTransactionAtNonceWithCount(nonce) |
There was a problem hiding this comment.
This subtest no longer returns txErr (it now expects HandleError to return err == nil and noTransmission == false), but the test name still says it does. Rename the test case to match the behavior being asserted to avoid confusion when the test fails in the future.
This PR upgrades error handler for TXMv2. We no longer throw an error if the handler decides there was no transmission, which results in a better observability. Additionally, if the error handler fails to parse the error, txm will check if the pending nonce increased instead of returning an error, which follows the standard flow.