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

Hopefully fix noisy submission error alert on eden #481

Merged
merged 13 commits into from
Sep 1, 2022
20 changes: 18 additions & 2 deletions crates/solver/src/settlement_submission/submitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ impl<'a> Submitter<'a> {
let submitter_name = self.submit_api.name();
let target_confirm_time = Instant::now() + params.target_confirm_time;

let mut tx_consecutively_underpriced = 1.;

tracing::debug!(
"submit_with_increasing_gas_prices_until_simulation_fails entered with submitter: {}",
submitter_name
Expand Down Expand Up @@ -453,7 +455,9 @@ impl<'a> Submitter<'a> {

if let Err(err) = method.clone().view().call().await {
if let Some((_, previous_gas_price)) = transactions.last() {
let gas_price = previous_gas_price.bump(GAS_PRICE_BUMP).ceil();
let gas_price = previous_gas_price
.bump(GAS_PRICE_BUMP * tx_consecutively_underpriced)
.ceil();
match self.cancel_transaction(&gas_price, nonce).await {
Ok(handle) => transactions.push((handle, gas_price)),
Err(err) => tracing::warn!("cancellation failed: {:?}", err),
Expand All @@ -467,7 +471,13 @@ impl<'a> Submitter<'a> {
.last()
.map(|(_, previous_gas_price)| previous_gas_price)
{
let previous_gas_price = previous_gas_price.bump(GAS_PRICE_BUMP).ceil();
// Sometimes a tx gets successfully submitted but the API returns an error. When that
// happens the gas price computation will return a gas price which is not big enough to
// replace the supposedly not submitted tx. To get out of that issue the new gas price
// has to be bumped by `GAS_PRICE_BUMP * 2` in order to replace the stuck tx.
let previous_gas_price = previous_gas_price
.bump(GAS_PRICE_BUMP * tx_consecutively_underpriced)
.ceil();
if gas_price.max_priority_fee_per_gas < previous_gas_price.max_priority_fee_per_gas
|| gas_price.max_fee_per_gas < previous_gas_price.max_fee_per_gas
{
Expand All @@ -494,12 +504,18 @@ impl<'a> Submitter<'a> {
"submitted transaction",
);
transactions.push((handle, gas_price));
tx_consecutively_underpriced = 1.;
}
Err(err) => {
tracing::warn!(
submitter = %submitter_name, ?err,
"submission failed",
);
if err.to_string().contains("underpriced") {
tx_consecutively_underpriced += 1.;
MartinquaXD marked this conversation as resolved.
Show resolved Hide resolved
} else {
tx_consecutively_underpriced = 1.;
}
}
}
tokio::time::sleep(params.retry_interval).await;
Expand Down