From 8d2ee150598a2d7a1315a47d447985106743fd05 Mon Sep 17 00:00:00 2001 From: Gregory Edison Date: Thu, 19 Oct 2023 19:09:12 +0200 Subject: [PATCH] fix rebase --- crates/evm/src/bytecode.cairo | 13 +++++++------ crates/evm/src/call_helpers.cairo | 2 +- crates/evm/src/instructions/system_operations.cairo | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/crates/evm/src/bytecode.cairo b/crates/evm/src/bytecode.cairo index 2bc4fc381..6cd982fff 100644 --- a/crates/evm/src/bytecode.cairo +++ b/crates/evm/src/bytecode.cairo @@ -1,9 +1,11 @@ +use contracts::contract_account::{ContractAccount, ContractAccountTrait}; +use contracts::kakarot_core::{KakarotCore}; use contracts::kakarot_core::interface::{IKakarotCore}; -use contracts::kakarot_core::{ContractAccountStorage, KakarotCore}; +use evm::errors::{EVMError}; use starknet::EthAddress; /// Returns the bytecode of the EVM account (EOA or CA) -fn bytecode(evm_address: EthAddress) -> Span { +fn bytecode(evm_address: EthAddress) -> Result, EVMError> { // Get access to Kakarot State locally let kakarot_state = KakarotCore::unsafe_new_contract_state(); @@ -11,12 +13,11 @@ fn bytecode(evm_address: EthAddress) -> Span { // Case 1: EOA is deployed if !eoa_starknet_address.is_zero() { - return Default::default().span(); + return Result::Ok(Default::default().span()); } // Case 2: EOA is not deployed and CA is deployed - let ca_storage = kakarot_state.contract_account_storage(evm_address); - // Once bytecode is implemented: return ca_storage.bytecode; - return Default::default().span(); + let ca = ContractAccountTrait::new(evm_address); + return Result::Ok(Default::default().span()); } diff --git a/crates/evm/src/call_helpers.cairo b/crates/evm/src/call_helpers.cairo index 8b17f6bcb..8e33ab78e 100644 --- a/crates/evm/src/call_helpers.cairo +++ b/crates/evm/src/call_helpers.cairo @@ -72,7 +72,7 @@ impl MachineCallHelpersImpl of MachineCallHelpers { // Case 2: `to` address is not a precompile // We enter the standard flow - let bytecode = bytecode(call_args.to); + let bytecode = bytecode(call_args.to)?; // The caller in the subcontext is the current context's current address let caller = self.evm_address(); diff --git a/crates/evm/src/instructions/system_operations.cairo b/crates/evm/src/instructions/system_operations.cairo index 39793615f..a2b356d73 100644 --- a/crates/evm/src/instructions/system_operations.cairo +++ b/crates/evm/src/instructions/system_operations.cairo @@ -72,7 +72,7 @@ impl SystemOperations of SystemOperationsTrait { // If sender_balance > value, return early, pushing // 0 on the stack to indicate call failure. let caller_address = self.evm_address(); - let sender_balance = balance(caller_address); + let sender_balance = balance(caller_address)?; if sender_balance < value { self.stack.push(0); return Result::Ok(());