Skip to content

Commit

Permalink
use unwrap_or_default to cover non-blob txs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rjected committed Jan 16, 2024
1 parent d3988d7 commit e522f14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion crates/primitives/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ impl Env {
.ok_or(InvalidTransaction::OverflowPaymentInTransaction)?;

if SPEC::enabled(SpecId::CANCUN) {
let data_fee = self.calc_data_fee().expect("already checked");
// if the tx is not a blob tx, this will be None, so we add zero
let data_fee = self.calc_max_data_fee().unwrap_or_default();
balance_check = balance_check
.checked_add(U256::from(data_fee))
.ok_or(InvalidTransaction::OverflowPaymentInTransaction)?;
Expand Down
3 changes: 2 additions & 1 deletion crates/revm/src/handler/mainnet/pre_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ pub fn deduct_caller_inner<SPEC: Spec>(caller_account: &mut Account, env: &Env)

// EIP-4844
if SPEC::enabled(CANCUN) {
let data_fee = env.calc_max_data_fee().expect("already checked");
// if the tx is not a blob tx, this will be None, so we add zero
let data_fee = env.calc_max_data_fee().unwrap_or_default();
gas_cost = gas_cost.saturating_add(data_fee);
}

Expand Down

0 comments on commit e522f14

Please sign in to comment.