Skip to content
This repository was archived by the owner on Jan 8, 2025. It is now read-only.

Commit 610ce0e

Browse files
committed
fix: create high nonce
1 parent 01641a7 commit 610ce0e

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

crates/evm/src/errors.cairo

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ pub enum EVMError {
5858
OutOfGas,
5959
Assertion,
6060
DepthLimit,
61-
MemoryLimitOOG
61+
MemoryLimitOOG,
62+
NonceOverflow
6263
}
6364

6465
#[generate_trait]
@@ -83,6 +84,7 @@ pub impl EVMErrorImpl of EVMErrorTrait {
8384
EVMError::Assertion => 'assertion failed'.into(),
8485
EVMError::DepthLimit => 'max call depth exceeded'.into(),
8586
EVMError::MemoryLimitOOG => 'memory limit out of gas'.into(),
87+
EVMError::NonceOverflow => 'nonce overflow'.into(),
8688
}
8789
}
8890

crates/evm/src/interpreter.cairo

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use contracts::account_contract::{IAccountDispatcher, IAccountDispatcherTrait};
22
use contracts::kakarot_core::KakarotCore;
33
use contracts::kakarot_core::interface::IKakarotCore;
4-
use core::num::traits::Zero;
4+
use core::num::traits::{Bounded, Zero};
55
use core::ops::SnapshotDeref;
66
use core::starknet::EthAddress;
77
use core::starknet::get_tx_info;
@@ -21,7 +21,7 @@ use evm::model::account::{Account, AccountTrait};
2121
use evm::model::vm::{VM, VMTrait};
2222
use evm::model::{
2323
Message, Environment, Transfer, ExecutionSummary, ExecutionResult, ExecutionResultTrait,
24-
ExecutionResultStatus, AddressTrait, TransactionResult, Address
24+
ExecutionResultStatus, AddressTrait, TransactionResult, TransactionResultTrait, Address
2525
};
2626
use evm::precompiles::Precompiles;
2727
use evm::precompiles::eth_precompile_addresses;
@@ -117,6 +117,11 @@ pub impl EVMImpl of EVMTrait {
117117
.prepare_message(@tx, @sender_account, ref env, gas_left);
118118

119119
// Increment nonce of sender AFTER computing eventual created address
120+
if sender_account.nonce() == Bounded::<u64>::MAX {
121+
return TransactionResultTrait::exceptional_failure(
122+
EVMError::NonceOverflow.to_bytes(), tx.gas_limit()
123+
);
124+
}
120125
sender_account.set_nonce(sender_account.nonce() + 1);
121126

122127
env.state.set_account(sender_account);

0 commit comments

Comments
 (0)