Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: balance check disabled #751

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions crates/primitives/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,10 @@ impl Env {

/// Validate transaction against state.
#[inline]
pub fn validate_tx_against_state(&self, account: &Account) -> Result<(), InvalidTransaction> {
pub fn validate_tx_against_state(
&self,
account: &mut Account,
) -> Result<(), InvalidTransaction> {
// EIP-3607: Reject transactions from senders with deployed code
// This EIP is introduced after london but there was no collision in past
// so we can leave it enabled always
Expand Down Expand Up @@ -586,11 +589,16 @@ impl Env {

// Check if account has enough balance for gas_limit*gas_price and value transfer.
// Transfer will be done inside `*_inner` functions.
if !self.cfg.is_balance_check_disabled() && balance_check > account.info.balance {
return Err(InvalidTransaction::LackOfFundForMaxFee {
fee: self.tx.gas_limit,
balance: account.info.balance,
});
if balance_check > account.info.balance {
if self.cfg.is_balance_check_disabled() {
// Add transaction cost to balance to ensure execution doesn't fail.
account.info.balance = balance_check;
} else {
return Err(InvalidTransaction::LackOfFundForMaxFee {
fee: self.tx.gas_limit,
balance: account.info.balance,
});
}
}

Ok(())
Expand Down
Loading