From c05e37aa31822f51d826506e9a7eba4eb004618b Mon Sep 17 00:00:00 2001 From: Elias Tazartes Date: Wed, 22 Nov 2023 16:26:08 +0100 Subject: [PATCH] fix: fix rebase --- .../instructions/system_operations.cairo | 18 +++++++----------- src/kakarot/state.cairo | 2 +- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/kakarot/instructions/system_operations.cairo b/src/kakarot/instructions/system_operations.cairo index 319ac0f78f..5518ead8ff 100644 --- a/src/kakarot/instructions/system_operations.cairo +++ b/src/kakarot/instructions/system_operations.cairo @@ -10,12 +10,7 @@ from starkware.cairo.common.cairo_keccak.keccak import cairo_keccak_bigend, fina from starkware.cairo.common.math import split_felt, unsigned_div_rem from starkware.cairo.common.math_cmp import is_le, is_not_zero, is_nn from starkware.cairo.common.memcpy import memcpy -from starkware.cairo.common.uint256 import Uint256, uint256_eq, uint256_lt -from starkware.starknet.common.syscalls import ( - deploy as deploy_syscall, - get_contract_address, - get_tx_info, -) +from starkware.cairo.common.uint256 import Uint256, uint256_lt from starkware.cairo.common.registers import get_fp_and_pc // Internal dependencies @@ -760,7 +755,6 @@ namespace CreateHelper { let offset = popped[1]; let size = popped[2]; - // Load CallContext bytecode code from memory let (bytecode: felt*) = alloc(); let (memory, gas_cost) = Memory.load_n( self=ctx.memory, element_len=size.low, element=bytecode, offset=offset.low @@ -774,8 +768,9 @@ namespace CreateHelper { let (starknet_contract_address) = Account.compute_starknet_address(evm_contract_address); tempvar address = new model.Address(starknet_contract_address, evm_contract_address); - let (state, balance) = State.read_balance(state, ctx.call_context.address); + let (state, sender) = State.get_account(state, ctx.call_context.address); let ctx = ExecutionContext.update_state(ctx, state); + let balance = [sender.balance]; let (insufficient_balance) = uint256_lt(balance, value); if (insufficient_balance != 0) { let stack = Stack.push_uint128(ctx.stack, 0); @@ -783,19 +778,20 @@ namespace CreateHelper { return ctx; } - let (state, sender) = State.get_account(state, ctx.call_context.address); let sender = Account.set_nonce(sender, sender.nonce + 1); let state = State.set_account(state, ctx.call_context.address, sender); let ctx = ExecutionContext.update_state(ctx, state); - - let account = Account.fetch_or_create(address); + let (state, account) = State.get_account(state, address); let is_collision = Account.has_code_or_nonce(account); if (is_collision != 0) { let stack = Stack.push_uint128(ctx.stack, 0); let ctx = ExecutionContext.update_stack(ctx, stack); + let ctx = ExecutionContext.update_state(ctx, state); return ctx; } let account = Account.set_nonce(account, 1); + let state = State.set_account(state, address, account); + let ctx = ExecutionContext.update_state(ctx, state); // Create sub context with copied state let state = State.copy(ctx.state); diff --git a/src/kakarot/state.cairo b/src/kakarot/state.cairo index eb6b39222d..698cf18e0b 100644 --- a/src/kakarot/state.cairo +++ b/src/kakarot/state.cairo @@ -9,7 +9,7 @@ from starkware.cairo.common.dict import dict_read, dict_write from starkware.cairo.common.dict_access import DictAccess from starkware.cairo.common.memcpy import memcpy from starkware.cairo.common.registers import get_fp_and_pc -from starkware.cairo.common.uint256 import Uint256, uint256_add, uint256_sub, uint256_le +from starkware.cairo.common.uint256 import Uint256, uint256_add, uint256_sub, uint256_le, uint256_eq from kakarot.account import Account from kakarot.model import model