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: create high nonce #974

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion crates/evm/src/errors.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ pub enum EVMError {
OutOfGas,
Assertion,
DepthLimit,
MemoryLimitOOG
MemoryLimitOOG,
NonceOverflow
}

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

Expand Down
9 changes: 7 additions & 2 deletions crates/evm/src/interpreter.cairo
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use contracts::account_contract::{IAccountDispatcher, IAccountDispatcherTrait};
use contracts::kakarot_core::KakarotCore;
use contracts::kakarot_core::interface::IKakarotCore;
use core::num::traits::Zero;
use core::num::traits::{Bounded, Zero};
use core::ops::SnapshotDeref;
use core::starknet::EthAddress;
use core::starknet::get_tx_info;
Expand All @@ -21,7 +21,7 @@ use evm::model::account::{Account, AccountTrait};
use evm::model::vm::{VM, VMTrait};
use evm::model::{
Message, Environment, Transfer, ExecutionSummary, ExecutionResult, ExecutionResultTrait,
ExecutionResultStatus, AddressTrait, TransactionResult, Address
ExecutionResultStatus, AddressTrait, TransactionResult, TransactionResultTrait, Address
};
use evm::precompiles::Precompiles;
use evm::precompiles::eth_precompile_addresses;
Expand Down Expand Up @@ -117,6 +117,11 @@ pub impl EVMImpl of EVMTrait {
.prepare_message(@tx, @sender_account, ref env, gas_left);

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

env.state.set_account(sender_account);
Expand Down
Loading