Skip to content

Commit

Permalink
Fix order of deposit inc_nonce in transact
Browse files Browse the repository at this point in the history
  • Loading branch information
sorpaas committed Nov 20, 2023
1 parent debeb73 commit 4aa91a8
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/standard/invoker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ where
let gas_fee = args.gas_limit().saturating_mul(gas_price);
handler.withdrawal(caller, gas_fee)?;

handler.inc_nonce(caller)?;

let address = match &args {
TransactArgs::Call { address, .. } => *address,
TransactArgs::Create {
Expand Down Expand Up @@ -230,8 +232,6 @@ where
handler.mark_hot(address, None);
}

handler.inc_nonce(caller)?;

Ok((invoke, machine))
}
TransactArgs::Create {
Expand Down Expand Up @@ -310,19 +310,19 @@ where
let refunded_fee = refunded_gas.saturating_mul(invoke.gas_price);
let coinbase_reward = invoke.gas_fee.saturating_sub(refunded_fee);

handler.deposit(invoke.caller, refunded_fee);
handler.deposit(handler.block_coinbase(), coinbase_reward);

match result {
Ok(exit) => {
match &result {
Ok(_) => {
handler.pop_substate(MergeStrategy::Commit);
Ok(exit)
}
Err(err) => {
Err(_) => {
handler.pop_substate(MergeStrategy::Discard);
Err(err)
}
}

handler.deposit(invoke.caller, refunded_fee);
handler.deposit(handler.block_coinbase(), coinbase_reward);

result
}

fn enter_substack(
Expand Down

0 comments on commit 4aa91a8

Please sign in to comment.