Skip to content

Commit

Permalink
fix(polygon): add fallback if computed result is zero
Browse files Browse the repository at this point in the history
  • Loading branch information
0xfourzerofour committed Sep 21, 2023
1 parent 2a00be5 commit f9ae585
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 11 additions & 1 deletion crates/sim/src/gas/gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use rundler_types::{
use rundler_utils::math;
use tokio::try_join;

use super::polygon::Polygon;
use super::polygon::{Polygon, MAINNET_MAX_PRIORITY_FEE_DEFAULT, MUMBAI_MAX_PRIORITY_FEE_DEFAULT};

// Gas overheads for user operations
// used in calculating the pre-verification gas
Expand Down Expand Up @@ -275,6 +275,16 @@ impl<P: Provider> FeeEstimator<P> {
let gas_oracle = Polygon::new(Arc::clone(&self.provider)).category(GasCategory::Fast);

let fees = gas_oracle.estimate_eip1559_fees().await?;

if fees.1.is_zero() {
let fallback = match self.chain_id {
x if x == Chain::Polygon as u64 => MAINNET_MAX_PRIORITY_FEE_DEFAULT,
x if x == Chain::PolygonMumbai as u64 => MUMBAI_MAX_PRIORITY_FEE_DEFAULT,
_ => 0,
};
return Ok(fallback.into());
}

Ok(fees.1)
} else if self.use_bundle_priority_fee {
self.provider.get_max_priority_fee().await
Expand Down
3 changes: 3 additions & 0 deletions crates/sim/src/gas/polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ use ethers::{
use rundler_provider::Provider;
use serde::Deserialize;

pub(crate) const MUMBAI_MAX_PRIORITY_FEE_DEFAULT: u64 = 1_500_000_000;
pub(crate) const MAINNET_MAX_PRIORITY_FEE_DEFAULT: u64 = 30_000_000_000;

#[derive(Debug)]
pub(crate) struct Polygon<P> {
provider: Arc<P>,
Expand Down

0 comments on commit f9ae585

Please sign in to comment.