Skip to content

Commit

Permalink
fix(api): Improve estimation for gas_per_pubdata_limit
Browse files Browse the repository at this point in the history
  • Loading branch information
popzxc committed Jan 15, 2025
1 parent c156e79 commit 9e3454f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/node/api_server/src/tx_sender/gas_estimation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,11 +530,18 @@ impl<'a> GasEstimator<'a> {
gas_per_pubdata_byte = self.gas_per_pubdata_byte
);

// Given that we scale overall fee, we should also scale the limit for gas per pubdata price that user agrees to.
// However, we should not exceed the limit that was provided by the user in the initial request.
let gas_per_pubdata_limit = std::cmp::min(
((self.gas_per_pubdata_byte as f64 * estimated_fee_scale_factor) as u64).into(),
self.transaction.gas_per_pubdata_byte_limit(),
);

Ok(Fee {
max_fee_per_gas: self.base_fee.into(),
max_priority_fee_per_gas: 0u32.into(),
gas_limit: full_gas_limit.into(),
gas_per_pubdata_limit: self.gas_per_pubdata_byte.into(),
gas_per_pubdata_limit,
})
}
}

0 comments on commit 9e3454f

Please sign in to comment.