Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Commit

Permalink
fix: fix rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Eikix committed Nov 22, 2023
1 parent 8cf9ecb commit c05e37a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
18 changes: 7 additions & 11 deletions src/kakarot/instructions/system_operations.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -774,28 +768,30 @@ 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);
let ctx = ExecutionContext.update_stack(ctx, stack);
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);
Expand Down
2 changes: 1 addition & 1 deletion src/kakarot/state.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c05e37a

Please sign in to comment.