-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Expose CheckAttempt to TxManager, saves some unnecessary calls #1327
Expose CheckAttempt to TxManager, saves some unnecessary calls #1327
Conversation
dedd94a
to
fb62842
Compare
fb62842
to
b5669ea
Compare
This allows the transaction manager to save on some unnecessary calls to the database and chain on initial transaction attempt.
b5669ea
to
ba12f49
Compare
Make sure receipt confirmed at is far enough ago that it has met minimum number of confirmations because this test does not simulate new heads
a7a3add
to
03391f6
Compare
By returning the state from BumpGasUntilSafe the EthTx adapter can distinguish between fatal errors that should kill the job, and those that we can retry on (failing to get the tx receipt). It is now orthogonal to CheckAttempt and has simpler "success" logic.
03391f6
to
61cae6c
Compare
842e630
to
57ccbd1
Compare
b70dc5d
to
c83e3ed
Compare
c83e3ed
to
32e57ce
Compare
core/adapters/eth_tx_test.go
Outdated
@@ -176,9 +168,9 @@ func TestEthTxAdapter_Perform_ConfirmedWithBytesAndNoDataPrefix(t *testing.T) { | |||
return nil | |||
}) | |||
ethMock.Register("eth_blockNumber", utils.Uint64ToHex(sentAt)) | |||
receipt := models.TxReceipt{Hash: hash, BlockNumber: cltest.Int(confirmed)} | |||
safe := sentAt - store.Config.MinOutgoingConfirmations() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional
This line originally threw me off, because conceptually it's impossible for something to be safe
before something that's sent
. I later discovered you're using the receipt's BlockNumber
to gauge whether something is safe so this works out.
If possible, I would recommend renaming sentAt
to something else, perhaps currentHeight
?
I would also rename the test TestEthTxAdapter_Perform_ConfirmedWithBytesAndNoDataPrefix
from using the language Confirmed to using the more appropriate language Safe: TestEthTxAdapter_Perform_SafeWithBytesAndNoDataPrefix
…ithBytesAndNoDataPrefix
The initial phase of the EthTx adapter creates a transaction, then attempts to do gas bumping on it.
Gas Bumping is never needed on the initial transaction so half of this code is redundant, and because the existing records/information is not pushed into the BumpGasUntilSafe method, which is meant to be used with a freshly retrieved Tx, it creates a lot of redundant work. BumpGasUntilSafe actually needing to do any work in real life is highly unlikely, so I have optimised this path: instead just check for a receipt on the odd chance that the chain was quick to accept.
Full list of changes: