Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
l1 cost erroring
Browse files Browse the repository at this point in the history
  • Loading branch information
refcell committed Sep 5, 2023
1 parent 128e440 commit 6b868b3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions crates/revm/src/evm_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,21 @@ impl<'a, GSPEC: Spec, DB: Database, const INSPECT: bool> EVMImpl<'a, GSPEC, DB,
.load_account(tx_caller, db)
.map_err(EVMError::Database)?
.0;
let res = acc.info.balance.saturating_sub(l1_cost);
acc.info.balance = res;
if l1_cost.gt(&acc.info.balance) {
let x = l1_cost.as_limbs();
let u64_cost = if x[1] == 0 && x[2] == 0 && x[3] == 0 {
x[0]
} else {
u64::MAX
};
return Err(EVMError::Transaction(
InvalidTransaction::LackOfFundForMaxFee {
fee: u64_cost,
balance: acc.info.balance,
},
));
}
acc.info.balance = acc.info.balance.saturating_sub(l1_cost);
}
Ok(())
}
Expand Down

0 comments on commit 6b868b3

Please sign in to comment.