-
Notifications
You must be signed in to change notification settings - Fork 342
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
feat: aggregator bump fee if transaction was not included #1286
feat: aggregator bump fee if transaction was not included #1286
Conversation
…eceipt-for-1-minute-if-not-bump-the-fee-v2
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.
Looks good and works on my machine
…t-for-receipt-for-1-minute-if-not-bump-the-fee-v2
I tried to reproduce the behavior but I couldn't. Would you try again with the latest changes pls. |
// Sends AggregatedResponse and waits for the receipt for three blocks, if not received | ||
// it will try again bumping the last tx gas price based on `CalculateGasPriceBump` | ||
// This process happens indefinitely until the transaction is included. |
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.
Maybe for a separate PR, but we need to add some numbers to graph the retry logic. See:
aligned_layer/batcher/aligned-batcher/src/lib.rs
Line 1422 in b03a625
pub async fn cancel_create_new_task_tx(&self, old_tx_gas_price: U256) { |
core/utils/eth_client_utils.go
Outdated
// the currentGasPrice, a base bump percentage, a retry percentage, and the retry count. | ||
// Formula: currentGasPrice + (currentGasPrice * (baseBumpPercentage + retryCount * incrementalRetryPercentage) / 100) | ||
func CalculateGasPriceBumpBasedOnRetry(currentGasPrice *big.Int, baseBumpPercentage uint, retryAttemptPercentage uint, retryCount int) *big.Int { | ||
// Incremental percentage increase for each retry attempt (i*5%) |
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.
// Incremental percentage increase for each retry attempt (i*5%) | |
// Incremental percentage increase for each retry attempt (i*2%) |
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.
LGTM! Left some nit comments
txOpts.GasPrice = bumpedGasPrice | ||
} else { | ||
// bump the last tx gas price a little by `gasBumpIncrementalPercentage` to replace it. | ||
txOpts.GasPrice = utils.CalculateGasPriceBumpBasedOnRetry(txOpts.GasPrice, gasBumpIncrementalPercentage, 0, 0) |
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.
We should add comments explaining how we are using this function. We are using different bump percentages depending on which price that we are bumping.
Before merging this pr, pr #1304 should be merged first, as it depends on the retry logic.
Changes
Bumps the
gasPrice
in the aggregator when sending a responded task:ReponseToTask
with a higher bumped gas price.gas_base_bump_percentage
: how much to bump the gas price. Configured to10%
gas_bump_incremental_percentage
: an extra percentage to bump every retryi*5
. Configured to2%
time_to_wait_before_bump
: the time to wait for the receipt once we sent the tx. Configured to36s
Considerations:
For every retry, the gas price is bumped a
10%
+2% * i
, wherei
is the iteration number.i
is only incremented when the receipt timeout has passed. That is, if the rpc node fails the feei
won't be incremented. This will run infinitely until the transaction gets accepted unless thecheckRespondToTaskFeeLimit
fails. In that case, we stop retrying and leave the tx in the mempool. Issue #1389 has been created to cover this case.Another note is that
waitForTransactionReceipt
has been refactored. Now it does not have amaxTries
anymore (set to0
) and instead receives a new parameterwaitTimeout
which defines the retries based on a timeout. Also, themaxInterval
has been modified to2
seconds because we can't reliably measure the specific time the tx will be included in a block. Setting a higher value will imply doing fewer retries across the waitTimeout so we might lose the receipt.Test
Setup a local testnet as usual and introduce the following lines in the
avs_writer.go
file:You should check through the aggregator logs, telemetry traces, and grafana charts, that the gas price was indeed bumped.