Skip to content

Commit

Permalink
fix(l1): fix effective gas price calculation (#1881)
Browse files Browse the repository at this point in the history
**Description**

This PR fixes the effective gas price calculation, now returning `None`
if the `max_fee_per_gas` is lower than the `base_fee_per_gas`. This is
later converted to a `VMError::InvalidTransaction` before processing the
actual transaction.

---------

Co-authored-by: Julian Ventura <julian.ventura@lambdaclass.com>
  • Loading branch information
JulianVentura and Julian Ventura authored Feb 6, 2025
1 parent 00a3488 commit 93ffd3b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/common/types/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,11 @@ impl Transaction {
}

fn calc_effective_gas_price(&self, base_fee_per_gas: Option<u64>) -> Option<u64> {
if self.max_fee_per_gas()? < base_fee_per_gas? {
// This is invalid, can't calculate
return None;
}

let priority_fee_per_gas = min(
self.max_priority_fee()?,
self.max_fee_per_gas()?.saturating_sub(base_fee_per_gas?),
Expand Down

0 comments on commit 93ffd3b

Please sign in to comment.