Skip to content

Commit

Permalink
fix effective gas price calculation to be backward compatible with le…
Browse files Browse the repository at this point in the history
…gacy txs
  • Loading branch information
Santiago Pittella authored and Santiago Pittella committed Feb 28, 2024
1 parent 82efd79 commit 8525ce9
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions core/lib/types/src/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,14 @@ impl Fee {
assert!(block_base_fee_per_gas <= self.max_fee_per_gas);
assert!(self.max_priority_fee_per_gas <= self.max_fee_per_gas);

// For now, we charge only for base fee.
block_base_fee_per_gas
// The following calculation is based on the EIP-1559 formula:
// https://eips.ethereum.org/EIPS/eip-1559
let priority_fee_per_gas = std::cmp::min(
self.max_priority_fee_per_gas,
self.max_fee_per_gas - block_base_fee_per_gas,
);

block_base_fee_per_gas + priority_fee_per_gas
}
}

Expand Down

0 comments on commit 8525ce9

Please sign in to comment.