diff --git a/crates/evm/src/backend/starknet_backend.cairo b/crates/evm/src/backend/starknet_backend.cairo index 105480c5c..92b0be448 100644 --- a/crates/evm/src/backend/starknet_backend.cairo +++ b/crates/evm/src/backend/starknet_backend.cairo @@ -42,7 +42,7 @@ pub fn deploy(evm_address: EthAddress) -> Result
{ // Unlike CAs, there is not check for the existence of an EOA prealably to calling // `EOATrait::deploy` - therefore, we need to check that there is no collision. let mut is_deployed = evm_address.is_deployed(); - ensure(!is_deployed, EVMError::DeployError(EOA_EXISTS))?; + ensure(!is_deployed, EVMError::Collision)?; let mut kakarot_state = KakarotCore::unsafe_new_contract_state(); let uninitialized_account_class_hash = kakarot_state.uninitialized_account_class_hash(); diff --git a/crates/evm/src/errors.cairo b/crates/evm/src/errors.cairo index eab671cad..06543f313 100644 --- a/crates/evm/src/errors.cairo +++ b/crates/evm/src/errors.cairo @@ -54,7 +54,7 @@ pub enum EVMError { InvalidParameter: felt252, InvalidOpcode: u8, WriteInStaticContext, - DeployError: felt252, + Collision, OutOfGas, Assertion, DepthLimit, @@ -78,7 +78,7 @@ pub impl EVMErrorImpl of EVMErrorTrait { // TODO: refactor with dynamic strings once supported EVMError::InvalidOpcode => 'invalid opcode'.into(), EVMError::WriteInStaticContext => 'write protection', - EVMError::DeployError(error_message) => error_message, + EVMError::Collision => 'create collision'.into(), EVMError::OutOfGas => 'out of gas'.into(), EVMError::Assertion => 'assertion failed'.into(), EVMError::DepthLimit => 'max call depth exceeded'.into(), diff --git a/crates/evm/src/interpreter.cairo b/crates/evm/src/interpreter.cairo index cb7f0bfc6..82b39a40a 100644 --- a/crates/evm/src/interpreter.cairo +++ b/crates/evm/src/interpreter.cairo @@ -20,8 +20,8 @@ use evm::instructions::{ use evm::model::account::{Account, AccountTrait}; use evm::model::vm::{VM, VMTrait}; use evm::model::{ - Message, Environment, Transfer, ExecutionSummary, ExecutionSummaryTrait, ExecutionResult, - ExecutionResultTrait, ExecutionResultStatus, AddressTrait, TransactionResult, Address + Message, Environment, Transfer, ExecutionSummary, ExecutionResult, ExecutionResultTrait, + ExecutionResultStatus, AddressTrait, TransactionResult, Address }; use evm::precompiles::Precompiles; use evm::precompiles::eth_precompile_addresses; @@ -170,7 +170,7 @@ pub impl EVMImpl of EVMTrait { // }; TransactionResult { - success: summary.is_success(), + success: summary.status == ExecutionResultStatus::Success, return_data: summary.return_data, gas_used: total_gas_used, state: summary.state, @@ -185,9 +185,13 @@ pub impl EVMImpl of EVMTrait { let result = if is_deploy_tx { // Check collision if target_account.has_code_or_nonce() { - return ExecutionSummaryTrait::exceptional_failure( - EVMError::DeployError(CONTRACT_ACCOUNT_EXISTS).to_bytes(), - ); + return ExecutionSummary { + status: ExecutionResultStatus::Exception, + return_data: EVMError::Collision.to_bytes(), + gas_left: 0, + state: env.state, + gas_refund: 0 + }; } let mut result = Self::process_create_message(message, ref env); diff --git a/crates/evm/src/model.cairo b/crates/evm/src/model.cairo index 97a64ec6f..66954af9a 100644 --- a/crates/evm/src/model.cairo +++ b/crates/evm/src/model.cairo @@ -108,30 +108,6 @@ pub struct ExecutionSummary { pub gas_refund: u64 } -#[generate_trait] -pub impl ExecutionSummaryImpl of ExecutionSummaryTrait { - fn exceptional_failure(error: Span