Skip to content

Commit

Permalink
fix rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
greged93 committed Oct 19, 2023
1 parent 17f418d commit 8d2ee15
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions crates/evm/src/bytecode.cairo
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
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<u8> {
fn bytecode(evm_address: EthAddress) -> Result<Span<u8>, EVMError> {
// Get access to Kakarot State locally
let kakarot_state = KakarotCore::unsafe_new_contract_state();

let eoa_starknet_address = kakarot_state.eoa_starknet_address(evm_address);

// 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());
}

2 changes: 1 addition & 1 deletion crates/evm/src/call_helpers.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion crates/evm/src/instructions/system_operations.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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(());
Expand Down

0 comments on commit 8d2ee15

Please sign in to comment.