Skip to content

Commit

Permalink
use U256 for data fee
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjected committed Sep 28, 2023
1 parent 15adbc4 commit ce99cb0
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 @@ -424,10 +424,10 @@ impl Env {
///
/// [EIP-4844]: https://eips.ethereum.org/EIPS/eip-4844
#[inline]
pub fn calc_data_fee(&self) -> Option<u128> {
self.block
.get_blob_gasprice()
.map(|blob_gas_price| blob_gas_price as u128 * self.tx.get_total_blob_gas() as u128)
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 @@ -162,7 +162,7 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> Transact<DB::Error>
// EIP-4844
if GSPEC::enabled(CANCUN) {
let data_fee = 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 ce99cb0

Please sign in to comment.