Skip to content

Commit

Permalink
chore: fix journal naming for inc/dec balance (#1976)
Browse files Browse the repository at this point in the history
  • Loading branch information
FredCoen authored Jan 8, 2025
1 parent 04688b7 commit 7fcbd7d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/context/src/journaled_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,19 +374,19 @@ impl<DB: Database> JournaledState<DB> {
Self::touch_account(self.journal.last_mut().unwrap(), from, from_account);
let from_balance = &mut from_account.info.balance;

let Some(from_balance_incr) = from_balance.checked_sub(balance) else {
let Some(from_balance_decr) = from_balance.checked_sub(balance) else {
return Ok(Some(TransferError::OutOfFunds));
};
*from_balance = from_balance_incr;
*from_balance = from_balance_decr;

// add balance to
let to_account = &mut self.state.get_mut(to).unwrap();
Self::touch_account(self.journal.last_mut().unwrap(), to, to_account);
let to_balance = &mut to_account.info.balance;
let Some(to_balance_decr) = to_balance.checked_add(balance) else {
let Some(to_balance_incr) = to_balance.checked_add(balance) else {
return Ok(Some(TransferError::OverflowPayment));
};
*to_balance = to_balance_decr;
*to_balance = to_balance_incr;
// Overflow of U256 balance is not possible to happen on mainnet. We don't bother to return funds from from_acc.

self.journal
Expand Down

0 comments on commit 7fcbd7d

Please sign in to comment.