diff --git a/src/kakarot/account.cairo b/src/kakarot/account.cairo index 95c2970f5..8c38cdad2 100644 --- a/src/kakarot/account.cairo +++ b/src/kakarot/account.cairo @@ -120,11 +120,6 @@ namespace Account { // Case new Account if (starknet_account_exists == 0) { - // If SELFDESTRUCT, just do nothing - if (self.selfdestruct != 0) { - return (); - } - // Just casting the Summary into an Account to apply has_code_or_nonce // cf Summary note: like an Account, but frozen after squashing all dicts // There is no reason to have has_code_or_nonce available in the public API @@ -135,6 +130,11 @@ namespace Account { // Deploy accounts let (class_hash) = contract_account_class_hash.read(); deploy(class_hash, self.address); + // If SELFDESTRUCT, stops here to leave the account empty + if (self.selfdestruct != 0) { + return (); + } + // Write bytecode IContractAccount.write_bytecode(starknet_address, self.code_len, self.code); // Set nonce diff --git a/src/kakarot/library.cairo b/src/kakarot/library.cairo index 79c642307..40b42dc88 100644 --- a/src/kakarot/library.cairo +++ b/src/kakarot/library.cairo @@ -129,11 +129,10 @@ namespace Kakarot { let (state, success) = State.add_transfer(state, transfer); // Check collision - let is_registered = Account.is_registered(address.evm); - let is_collision = is_registered * is_deploy_tx; - - // Nonce is set to 1 in case of deploy_tx let account = Account.fetch_or_create(address); + let code_or_nonce = Account.has_code_or_nonce(account); + let is_collision = code_or_nonce * is_deploy_tx; + // Nonce is set to 1 in case of deploy_tx let nonce = account.nonce * (1 - is_deploy_tx) + is_deploy_tx; let account = Account.set_nonce(account, nonce); let state = State.set_account(state, address, account); diff --git a/src/kakarot/state.cairo b/src/kakarot/state.cairo index 2900a5f49..42e7a32cd 100644 --- a/src/kakarot/state.cairo +++ b/src/kakarot/state.cairo @@ -432,7 +432,6 @@ namespace Internals { // @notice Iterates through a list of Transfer and makes them // @dev Transfers are made last so as to have all accounts created beforehand. - // Kakarot is not authorized for accounts that are created and SELDESTRUCT in the same transaction // @param transfers_len The length of the transfers array. // @param transfers The array of Transfer. func _transfer_eth{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}(