Skip to content

Commit

Permalink
fix: use u128 for calc data fee result (bluealloy#757)
Browse files Browse the repository at this point in the history
* fix: use u128 for calc data fee result

* use U256 for data fee
  • Loading branch information
Rjected authored Sep 28, 2023
1 parent 4f916be commit ea0d8d8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions crates/primitives/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,10 @@ impl Env {
///
/// [EIP-4844]: https://eips.ethereum.org/EIPS/eip-4844
#[inline]
pub fn calc_data_fee(&self) -> Option<u64> {
self.block
.get_blob_gasprice()
.map(|blob_gas_price| blob_gas_price * self.tx.get_total_blob_gas())
pub fn calc_data_fee(&self) -> Option<U256> {
self.block.get_blob_gasprice().map(|blob_gas_price| {
U256::from(blob_gas_price).saturating_mul(U256::from(self.tx.get_total_blob_gas()))
})
}

/// Validate the block environment.
Expand Down
2 changes: 1 addition & 1 deletion crates/revm/src/evm_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> Transact<DB::Error>
// EIP-4844
if GSPEC::enabled(CANCUN) {
let data_fee = self.data.env.calc_data_fee().expect("already checked");
gas_cost = gas_cost.saturating_add(U256::from(data_fee));
gas_cost = gas_cost.saturating_add(data_fee);
}

caller_account.info.balance = caller_account.info.balance.saturating_sub(gas_cost);
Expand Down

0 comments on commit ea0d8d8

Please sign in to comment.