Skip to content

Commit

Permalink
fix(pool): fix candidate gas price (#884)
Browse files Browse the repository at this point in the history
  • Loading branch information
dancoombs authored Oct 23, 2024
1 parent c8c5c35 commit f48c3ba
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion bin/rundler/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ impl TryFrom<&CommonArgs> for PrecheckSettings {
Ok(Self {
max_verification_gas: value.max_verification_gas as u128,
max_total_execution_gas: value.max_bundle_gas,
bundle_base_fee_overhead_percent: value.bundle_priority_fee_overhead_percent,
bundle_base_fee_overhead_percent: value.bundle_base_fee_overhead_percent,
bundle_priority_fee_overhead_percent: value.bundle_priority_fee_overhead_percent,
priority_fee_mode: PriorityFeeMode::try_from(
value.priority_fee_mode_kind.as_str(),
Expand Down
86 changes: 43 additions & 43 deletions crates/pool/src/mempool/uo_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,48 @@ where
.unmined_operations
.increment(unmined_op_count);

// update required bundle fees and update metrics
match self.pool_providers.prechecker().update_fees().await {
Ok((bundle_fees, base_fee)) => {
let max_fee = match format_units(bundle_fees.max_fee_per_gas, "gwei") {
Ok(s) => s.parse::<f64>().unwrap_or_default(),
Err(_) => 0.0,
};
self.metrics.current_max_fee_gwei.set(max_fee);

let max_priority_fee =
match format_units(bundle_fees.max_priority_fee_per_gas, "gwei") {
Ok(s) => s.parse::<f64>().unwrap_or_default(),
Err(_) => 0.0,
};
self.metrics
.current_max_priority_fee_gwei
.set(max_priority_fee);

let base_fee_f64 = match format_units(base_fee, "gwei") {
Ok(s) => s.parse::<f64>().unwrap_or_default(),
Err(_) => 0.0,
};
self.metrics.current_base_fee.set(base_fee_f64);

// cache for the next update
{
let mut state = self.state.write();
state.block_number = update.latest_block_number;
state.block_hash = update.latest_block_hash;
state.gas_fees = bundle_fees;
state.base_fee = base_fee;
}
}
Err(e) => {
tracing::error!("Failed to update fees: {:?}", e);
{
let mut state = self.state.write();
state.block_number = update.latest_block_number;
}
}
}

let da_block_data = if self.config.da_gas_tracking_enabled
&& self.ep_providers.da_gas_oracle_sync().is_some()
{
Expand Down Expand Up @@ -403,7 +445,7 @@ where
da_block_data.as_ref(),
gas_fees,
base_fee,
)
);
}
let maintenance_time = start.elapsed();
tracing::debug!(
Expand All @@ -413,48 +455,6 @@ where
self.ep_specific_metrics
.maintenance_time
.record(maintenance_time.as_micros() as f64);

// update required bundle fees and update metrics
match self.pool_providers.prechecker().update_fees().await {
Ok((bundle_fees, base_fee)) => {
let max_fee = match format_units(bundle_fees.max_fee_per_gas, "gwei") {
Ok(s) => s.parse::<f64>().unwrap_or_default(),
Err(_) => 0.0,
};
self.metrics.current_max_fee_gwei.set(max_fee);

let max_priority_fee =
match format_units(bundle_fees.max_priority_fee_per_gas, "gwei") {
Ok(s) => s.parse::<f64>().unwrap_or_default(),
Err(_) => 0.0,
};
self.metrics
.current_max_priority_fee_gwei
.set(max_priority_fee);

let base_fee_f64 = match format_units(base_fee, "gwei") {
Ok(s) => s.parse::<f64>().unwrap_or_default(),
Err(_) => 0.0,
};
self.metrics.current_base_fee.set(base_fee_f64);

// cache for the next update
{
let mut state = self.state.write();
state.block_number = update.latest_block_number;
state.block_hash = update.latest_block_hash;
state.gas_fees = bundle_fees;
state.base_fee = base_fee;
}
}
Err(e) => {
tracing::error!("Failed to update fees: {:?}", e);
{
let mut state = self.state.write();
state.block_number = update.latest_block_number;
}
}
}
}

fn entry_point(&self) -> Address {
Expand Down

0 comments on commit f48c3ba

Please sign in to comment.