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 naming for incrementing and decrementing balance in transfer function #1976

Merged
merged 1 commit into from
Jan 8, 2025
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
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
Loading