Skip to content

Commit b6a1aef

Browse files
libreloisRomarQ
authored andcommitted
fix: increment the nonce before any gas cost record
1 parent ddeffd4 commit b6a1aef

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/executor/stack/executor.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,12 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
622622
gas_limit,
623623
});
624624

625+
// The nonce must be incremented before any gas record,
626+
// otherwise we might OOG without incrementing the nonce!
627+
if let Err(e) = self.state.inc_nonce(caller) {
628+
return (e.into(), Vec::new());
629+
}
630+
625631
let transaction_cost = gasometer::call_transaction_cost(&data, &access_list);
626632
let gasometer = &mut self.state.metadata_mut().gasometer;
627633
match gasometer.record_transaction(transaction_cost) {
@@ -647,9 +653,6 @@ impl<'config, 'precompiles, S: StackState<'config>, P: PrecompileSet>
647653
if let Err(e) = self.record_external_operation(crate::ExternalOperation::AccountBasicRead) {
648654
return (e.into(), Vec::new());
649655
}
650-
if let Err(e) = self.state.inc_nonce(caller) {
651-
return (e.into(), Vec::new());
652-
}
653656

654657
let context = Context {
655658
caller,

0 commit comments

Comments
 (0)