diff --git a/crates/contracts/src/kakarot_core/kakarot.cairo b/crates/contracts/src/kakarot_core/kakarot.cairo index 5b902f359..cc9ae5960 100644 --- a/crates/contracts/src/kakarot_core/kakarot.cairo +++ b/crates/contracts/src/kakarot_core/kakarot.cairo @@ -122,6 +122,8 @@ mod KakarotCore { new_class_hash: ClassHash, } + // TODO: add ability to pass Span, which should be deployed along with Kakarot + // this can be done once https://github.com/starkware-libs/cairo/issues/4488 is resolved #[constructor] fn constructor( ref self: ContractState, @@ -188,7 +190,6 @@ mod KakarotCore { } } - fn contract_account_nonce(self: @ContractState, evm_address: EthAddress) -> u64 { let ca_address = ContractAccountTrait::at(evm_address) .expect('Fetching CA failed') diff --git a/crates/contracts/src/tests/test_eoa.cairo b/crates/contracts/src/tests/test_eoa.cairo index d3468a853..209044004 100644 --- a/crates/contracts/src/tests/test_eoa.cairo +++ b/crates/contracts/src/tests/test_eoa.cairo @@ -25,9 +25,6 @@ mod test_external_owned_account { use core::starknet::account::{Call, AccountContractDispatcher, AccountContractDispatcherTrait}; - //todo(harsh): remove - use debug::PrintTrait; - use evm::model::{Address, AddressTrait, ContractAccountTrait}; use evm::tests::test_utils::{ kakarot_address, evm_address, other_evm_address, eoa_address, chain_id, gas_limit, gas_price @@ -110,9 +107,6 @@ mod test_external_owned_account { let evm_address = evm_address(); let eoa = kakarot_core.deploy_eoa(evm_address); - //todo(harsh): remove - other_evm_address().print(); - let kakarot_address = kakarot_core.contract_address; let account = deploy_contract_account(other_evm_address(), counter_evm_bytecode()); diff --git a/crates/contracts/src/tests/test_kakarot_core.cairo b/crates/contracts/src/tests/test_kakarot_core.cairo index 0bd565f36..69c616016 100644 --- a/crates/contracts/src/tests/test_kakarot_core.cairo +++ b/crates/contracts/src/tests/test_kakarot_core.cairo @@ -1,8 +1,14 @@ use contracts::contract_account::ContractAccount::TEST_CLASS_HASH as ContractAccountTestClassHash; +use contracts::contract_account::ContractAccount; use contracts::contract_account::{IContractAccountDispatcher, IContractAccountDispatcherTrait}; -use contracts::eoa::ExternallyOwnedAccount; -use contracts::kakarot_core::interface::IExtendedKakarotCoreDispatcherTrait; +use contracts::eoa::{ + ExternallyOwnedAccount, IExternallyOwnedAccountDispatcher, + IExternallyOwnedAccountDispatcherTrait +}; use contracts::kakarot_core::interface::IKakarotCore; +use contracts::kakarot_core::interface::{ + IExtendedKakarotCoreDispatcher, IExtendedKakarotCoreDispatcherTrait +}; use contracts::kakarot_core::kakarot::StoredAccountType; use contracts::kakarot_core::{ interface::IExtendedKakarotCoreDispatcherImpl, KakarotCore, KakarotCore::{KakarotCoreInternal}, @@ -14,6 +20,9 @@ use contracts::tests::test_upgradeable::{ }; use contracts::tests::test_utils as contract_utils; use contracts::uninitialized_account::UninitializedAccount; +use core::option::OptionTrait; + + use core::traits::TryInto; use evm::machine::Status; use evm::model::contract_account::ContractAccountTrait; @@ -490,4 +499,3 @@ fn test_eoa_class_hash() { assert(event.old_class_hash == class_hash, 'wrong old hash'); assert(event.new_class_hash == kakarot_core.eoa_class_hash(), 'wrong new hash'); } - diff --git a/crates/evm/src/instructions/block_information.cairo b/crates/evm/src/instructions/block_information.cairo index d47b6d3c9..1cfc1ad3a 100644 --- a/crates/evm/src/instructions/block_information.cairo +++ b/crates/evm/src/instructions/block_information.cairo @@ -1,3 +1,4 @@ +use contracts::eoa::{IExternallyOwnedAccountDispatcher, IExternallyOwnedAccountDispatcherTrait}; //! Block Information. use contracts::kakarot_core::{KakarotCore, IKakarotCore}; @@ -54,11 +55,11 @@ impl BlockInformation of BlockInformationTrait { let execution_info = get_execution_info_syscall() .map_err(EVMError::SyscallFailed(EXECUTION_INFO_SYSCALL_FAILED))? .unbox(); - let coinbase: EthAddress = execution_info - .block_info - .unbox() - .sequencer_address - .try_into_result()?; + + let coinbase = execution_info.block_info.unbox().sequencer_address; + let eoa = IExternallyOwnedAccountDispatcher { contract_address: coinbase }; + + let coinbase = eoa.evm_address(); self.stack.push(coinbase.into()) } diff --git a/crates/evm/src/model/eoa.cairo b/crates/evm/src/model/eoa.cairo index 3e7519915..6cef071ca 100644 --- a/crates/evm/src/model/eoa.cairo +++ b/crates/evm/src/model/eoa.cairo @@ -5,6 +5,7 @@ use contracts::kakarot_core::{IKakarotCore, KakarotCore, KakarotCore::KakarotCor use contracts::uninitialized_account::{ IUninitializedAccountDispatcher, IUninitializedAccountDispatcherTrait }; + use evm::errors::{EVMError, CONTRACT_SYSCALL_FAILED, EOA_EXISTS}; use evm::model::{Address, AddressTrait}; use starknet::{EthAddress, ContractAddress, get_contract_address, deploy_syscall}; @@ -29,6 +30,7 @@ impl EOAImpl of EOATrait { let calldata: Span = array![kakarot_address.into(), evm_address.into()].span(); let maybe_address = deploy_syscall(account_class_hash, evm_address.into(), calldata, false); + // Panic with err as syscall failure can't be caught, so we can't manage // the error match maybe_address {