diff --git a/cairo1_contracts/token/src/lib.cairo b/cairo1_contracts/token/src/lib.cairo index 22a9f7028..9b8f06e6a 100644 --- a/cairo1_contracts/token/src/lib.cairo +++ b/cairo1_contracts/token/src/lib.cairo @@ -1,35 +1 @@ -#[starknet::contract] -mod StarknetToken { - use openzeppelin::token::erc20::ERC20Component; - use starknet::ContractAddress; - - component!(path: ERC20Component, storage: erc20, event: ERC20Event); - - #[abi(embed_v0)] - impl ERC20Impl = ERC20Component::ERC20Impl; - #[abi(embed_v0)] - impl ERC20MetadataImpl = ERC20Component::ERC20MetadataImpl; - impl ERC20InternalImpl = ERC20Component::InternalImpl; - - #[storage] - struct Storage { - #[substorage(v0)] - erc20: ERC20Component::Storage - } - - #[event] - #[derive(Drop, starknet::Event)] - enum Event { - #[flat] - ERC20Event: ERC20Component::Event - } - - #[constructor] - fn constructor(ref self: ContractState, initial_supply: u256, recipient: ContractAddress) { - let name = "MyToken"; - let symbol = "MTK"; - - self.erc20.initializer(name, symbol); - self.erc20._mint(recipient, initial_supply); - } -} +mod starknet_token; diff --git a/cairo1_contracts/token/src/starknet_token.cairo b/cairo1_contracts/token/src/starknet_token.cairo new file mode 100644 index 000000000..22a9f7028 --- /dev/null +++ b/cairo1_contracts/token/src/starknet_token.cairo @@ -0,0 +1,35 @@ +#[starknet::contract] +mod StarknetToken { + use openzeppelin::token::erc20::ERC20Component; + use starknet::ContractAddress; + + component!(path: ERC20Component, storage: erc20, event: ERC20Event); + + #[abi(embed_v0)] + impl ERC20Impl = ERC20Component::ERC20Impl; + #[abi(embed_v0)] + impl ERC20MetadataImpl = ERC20Component::ERC20MetadataImpl; + impl ERC20InternalImpl = ERC20Component::InternalImpl; + + #[storage] + struct Storage { + #[substorage(v0)] + erc20: ERC20Component::Storage + } + + #[event] + #[derive(Drop, starknet::Event)] + enum Event { + #[flat] + ERC20Event: ERC20Component::Event + } + + #[constructor] + fn constructor(ref self: ContractState, initial_supply: u256, recipient: ContractAddress) { + let name = "MyToken"; + let symbol = "MTK"; + + self.erc20.initializer(name, symbol); + self.erc20._mint(recipient, initial_supply); + } +} diff --git a/kakarot_scripts/constants.py b/kakarot_scripts/constants.py index d4524bacc..1483a9687 100644 --- a/kakarot_scripts/constants.py +++ b/kakarot_scripts/constants.py @@ -155,7 +155,7 @@ class NetworkType(Enum): if WEB3.is_connected(): chain_id = WEB3.eth.chain_id else: - chain_id = starknet_chain_id + chain_id = starknet_chain_id % 2**53 except ( requests.exceptions.ConnectionError, requests.exceptions.MissingSchema, @@ -164,8 +164,8 @@ class NetworkType(Enum): logger.info( f"⚠️ Could not get chain Id from {NETWORK['rpc_url']}: {e}, defaulting to KKRT" ) - chain_id = int.from_bytes(b"KKRT", "big") starknet_chain_id = int.from_bytes(b"KKRT", "big") + chain_id = starknet_chain_id % 2**53 class ChainId(IntEnum): @@ -181,57 +181,59 @@ class ChainId(IntEnum): or "0x20eB005C0b9c906691F885eca5895338E15c36De", 16, ) -SOURCE_DIR = Path("src") -SOURCE_DIR_FIXTURES = Path("tests/fixtures") -CONTRACTS = {p.stem: p for p in list(SOURCE_DIR.glob("**/*.cairo"))} -CONTRACTS_FIXTURES = {p.stem: p for p in list(SOURCE_DIR_FIXTURES.glob("**/*.cairo"))} +CAIRO_ZERO_DIR = Path("src") +CAIRO_DIR = Path("cairo1_contracts") +TESTS_DIR = Path("tests") + +CONTRACTS = { + p.stem: p + for p in ( + list(CAIRO_ZERO_DIR.glob("**/*.cairo")) + + list(TESTS_DIR.glob("**/*.cairo")) + + list(CAIRO_DIR.glob("**/*.cairo")) + ) +} BUILD_DIR = Path("build") -BUILD_DIR_FIXTURES = BUILD_DIR / "fixtures" BUILD_DIR.mkdir(exist_ok=True, parents=True) -BUILD_DIR_FIXTURES.mkdir(exist_ok=True, parents=True) BUILD_DIR_SSJ = BUILD_DIR / "ssj" DATA_DIR = Path("kakarot_scripts") / "data" -class ArtifactType(Enum): - cairo0 = 0 - cairo1 = 1 - - DEPLOYMENTS_DIR = Path("deployments") / NETWORK["name"] DEPLOYMENTS_DIR.mkdir(exist_ok=True, parents=True) COMPILED_CONTRACTS = [ - {"contract_name": "kakarot", "is_account_contract": False}, {"contract_name": "account_contract", "is_account_contract": True}, - {"contract_name": "uninitialized_account_fixture", "is_account_contract": False}, - {"contract_name": "uninitialized_account", "is_account_contract": False}, + {"contract_name": "BalanceSender", "is_account_contract": False}, + {"contract_name": "Counter", "is_account_contract": False}, + {"contract_name": "ERC20", "is_account_contract": False}, {"contract_name": "EVM", "is_account_contract": False}, + {"contract_name": "kakarot", "is_account_contract": False}, + {"contract_name": "MockPragmaOracle", "is_account_contract": False}, {"contract_name": "OpenzeppelinAccount", "is_account_contract": True}, - {"contract_name": "ERC20", "is_account_contract": False}, {"contract_name": "replace_class", "is_account_contract": False}, - {"contract_name": "Counter", "is_account_contract": False}, + {"contract_name": "StarknetToken", "is_account_contract": False}, + {"contract_name": "uninitialized_account_fixture", "is_account_contract": False}, + {"contract_name": "uninitialized_account", "is_account_contract": False}, + {"contract_name": "UniversalLibraryCaller", "is_account_contract": False}, ] DECLARED_CONTRACTS = [ - {"contract_name": "account_contract", "cairo_version": ArtifactType.cairo0}, - { - "contract_name": "uninitialized_account_fixture", - "cairo_version": ArtifactType.cairo0, - }, - {"contract_name": "uninitialized_account", "cairo_version": ArtifactType.cairo0}, - {"contract_name": "EVM", "cairo_version": ArtifactType.cairo0}, - {"contract_name": "OpenzeppelinAccount", "cairo_version": ArtifactType.cairo0}, - {"contract_name": "Cairo1Helpers", "cairo_version": ArtifactType.cairo1}, - {"contract_name": "Cairo1HelpersFixture", "cairo_version": ArtifactType.cairo1}, - {"contract_name": "replace_class", "cairo_version": ArtifactType.cairo0}, - {"contract_name": "Counter", "cairo_version": ArtifactType.cairo0}, - {"contract_name": "MockPragmaOracle", "cairo_version": ArtifactType.cairo1}, - {"contract_name": "StarknetToken", "cairo_version": ArtifactType.cairo1}, - {"contract_name": "ERC20", "cairo_version": ArtifactType.cairo0}, - {"contract_name": "kakarot", "cairo_version": ArtifactType.cairo0}, - {"contract_name": "UniversalLibraryCaller", "cairo_version": ArtifactType.cairo1}, + "account_contract", + "Cairo1Helpers", + "Cairo1HelpersFixture", + "Counter", + "ERC20", + "EVM", + "kakarot", + "MockPragmaOracle", + "OpenzeppelinAccount", + "replace_class", + "StarknetToken", + "uninitialized_account_fixture", + "uninitialized_account", + "UniversalLibraryCaller", ] # PRE-EIP155 TX diff --git a/kakarot_scripts/deploy_kakarot.py b/kakarot_scripts/deploy_kakarot.py index 219b4ae0c..fc6257e0e 100644 --- a/kakarot_scripts/deploy_kakarot.py +++ b/kakarot_scripts/deploy_kakarot.py @@ -44,10 +44,7 @@ async def main(): account = await get_starknet_account() logger.info(f"ℹ️ Using account 0x{account.address:064x} as deployer") - class_hash = { - contract["contract_name"]: await declare(contract) - for contract in DECLARED_CONTRACTS - } + class_hash = {contract: await declare(contract) for contract in DECLARED_CONTRACTS} dump_declarations(class_hash) # %% Deployments @@ -88,7 +85,7 @@ async def main(): ) freshly_deployed = True - if NETWORK["type"] is NetworkType.STAGING: + if NETWORK["type"] is NetworkType.STAGING or NETWORK["type"] is NetworkType.DEV: starknet_deployments["EVM"] = await upgrade( "EVM", account.address, # owner @@ -101,21 +98,8 @@ async def main(): ) starknet_deployments["Counter"] = await upgrade("Counter") starknet_deployments["MockPragmaOracle"] = await upgrade("MockPragmaOracle") - - if NETWORK["type"] is NetworkType.DEV: - starknet_deployments["EVM"] = await deploy_starknet( - "EVM", - account.address, # owner - ETH_TOKEN_ADDRESS, # native_token_address_ - class_hash["account_contract"], # account_contract_class_hash_ - class_hash["uninitialized_account"], # uninitialized_account_class_hash_ - class_hash["Cairo1Helpers"], - COINBASE, - BLOCK_GAS_LIMIT, - ) - starknet_deployments["Counter"] = await deploy_starknet("Counter") - starknet_deployments["MockPragmaOracle"] = await deploy_starknet( - "MockPragmaOracle" + starknet_deployments["UniversalLibraryCaller"] = await upgrade( + "UniversalLibraryCaller" ) dump_deployments(starknet_deployments) @@ -124,11 +108,7 @@ async def main(): logger.info(f"ℹ️ Found default EVM address {EVM_ADDRESS}") from kakarot_scripts.utils.kakarot import get_eoa - amount = ( - 0.02 - if NETWORK["type"] is not (NetworkType.DEV or NetworkType.STAGING) - else 100 - ) + amount = 100 if NETWORK["type"] is NetworkType.DEV else 0.01 await get_eoa(amount=amount) # Set the base fee if freshly deployed @@ -153,7 +133,7 @@ async def main(): CREATEX_DEPLOYER, CREATEX_SIGNED_TX, amount=0.3, name="CreateX" ) - if NETWORK["type"] is (NetworkType.DEV or NetworkType.STAGING): + if NETWORK["type"] is NetworkType.STAGING or NETWORK["type"] is NetworkType.DEV: bridge = await deploy_evm("CairoPrecompiles", "EthStarknetBridge") evm_deployments["Bridge"] = { "address": int(bridge.address, 16), diff --git a/kakarot_scripts/utils/kakarot.py b/kakarot_scripts/utils/kakarot.py index 808834e3d..881837bc7 100644 --- a/kakarot_scripts/utils/kakarot.py +++ b/kakarot_scripts/utils/kakarot.py @@ -46,9 +46,9 @@ from kakarot_scripts.utils.starknet import get_starknet_account from kakarot_scripts.utils.starknet import invoke as _invoke_starknet from kakarot_scripts.utils.starknet import wait_for_transaction +from kakarot_scripts.utils.uint256 import int_to_uint256 from tests.utils.constants import TRANSACTION_GAS_LIMIT from tests.utils.helpers import pack_calldata, rlp_encode_signed_data -from tests.utils.uint256 import int_to_uint256 logging.basicConfig() logger = logging.getLogger(__name__) @@ -316,7 +316,16 @@ def dump_deployments(deployments): def get_deployments(): try: - return json.load(open(DEPLOYMENTS_DIR / "kakarot_deployments.json", "r")) + return { + name: { + **value, + "address": int(value["address"], 16), + "starknet_address": int(value["starknet_address"], 16), + } + for name, value in json.load( + open(DEPLOYMENTS_DIR / "kakarot_deployments.json", "r") + ).items() + } except FileNotFoundError: return {} @@ -561,7 +570,7 @@ async def eth_send_transaction( payload = { "type": 0x1, - "chainId": NETWORK["chain_id"] % 2**32, + "chainId": NETWORK["chain_id"], "nonce": nonce, "gas": gas, "gasPrice": gas_price, diff --git a/kakarot_scripts/utils/starknet.py b/kakarot_scripts/utils/starknet.py index df529dd5a..31ee9cb2d 100644 --- a/kakarot_scripts/utils/starknet.py +++ b/kakarot_scripts/utils/starknet.py @@ -2,7 +2,9 @@ import json import logging import random +import re import subprocess +from collections import namedtuple from copy import deepcopy from datetime import datetime from functools import cache @@ -35,16 +37,14 @@ from kakarot_scripts.constants import ( BUILD_DIR, - BUILD_DIR_FIXTURES, BUILD_DIR_SSJ, + CAIRO_DIR, + CAIRO_ZERO_DIR, CONTRACTS, - CONTRACTS_FIXTURES, DEPLOYMENTS_DIR, ETH_TOKEN_ADDRESS, NETWORK, RPC_CLIENT, - SOURCE_DIR, - ArtifactType, ChainId, NetworkType, ) @@ -58,12 +58,7 @@ # to have at least 0.1 ETH _max_fee = int(1e17) - -def int_to_uint256(value): - value = int(value) - low = value & ((1 << 128) - 1) - high = value >> 128 - return {"low": low, "high": high} +Artifact = namedtuple("Artifact", ["sierra", "casm"]) @alru_cache @@ -134,21 +129,19 @@ async def get_starknet_account( async def get_eth_contract(provider=None) -> Contract: return Contract( ETH_TOKEN_ADDRESS, - get_abi("ERC20", cairo_version=ArtifactType.cairo0), + get_abi("ERC20"), provider or await get_starknet_account(), - cairo_version=ArtifactType.cairo0, + cairo_version=0, ) @cache -def get_contract( - contract_name, address=None, provider=None, cairo_version=None -) -> Contract: +def get_contract(contract_name, address=None, provider=None) -> Contract: return Contract( address or get_deployments()[contract_name]["address"], - get_abi(contract_name, cairo_version), + get_abi(contract_name), provider or RPC_CLIENT, - cairo_version=get_artifact_version(contract_name).value, + cairo_version=get_cairo_version(contract_name), ) @@ -159,7 +152,7 @@ async def fund_address( Fund a given starknet address with {amount} ETH. """ address = int(address, 16) if isinstance(address, str) else address - amount = amount * 1e18 + amount = int(amount * 1e18) if NETWORK["name"] == "starknet-devnet": response = requests.post( "http://127.0.0.1:5050/mint", @@ -177,9 +170,7 @@ async def fund_address( raise ValueError( f"Cannot send {amount / 1e18} ETH from default account with current balance {balance / 1e18} ETH" ) - prepared = eth_contract.functions["transfer"].prepare_invoke_v1( - address, int_to_uint256(amount) - ) + prepared = eth_contract.functions["transfer"].prepare_invoke_v1(address, amount) tx = await prepared.invoke(max_fee=_max_fee) status = await wait_for_transaction(tx.hash) @@ -250,89 +241,78 @@ def get_deployments(): @cache -def get_artifact(contract_name, cairo_version=None): - if cairo_version is None: - cairo_version = get_artifact_version(contract_name) - if cairo_version == ArtifactType.cairo1: - if artifacts := list(Path("cairo1_contracts").glob(f"**/*{contract_name}*")): - return artifacts[0].with_suffix("").with_suffix(""), ArtifactType.cairo1 - - return (BUILD_DIR_SSJ / f"contracts_{contract_name}", ArtifactType.cairo1) - - return ( - ( - BUILD_DIR / f"{contract_name}.json" - if not is_fixture_contract(contract_name) - else BUILD_DIR_FIXTURES / f"{contract_name}.json" - ), - ArtifactType.cairo0, +def get_artifact(contract_name): + artifacts = list(CAIRO_DIR.glob(f"**/*{contract_name}.*.json")) or list( + BUILD_DIR_SSJ.glob(f"**/*{contract_name}.*.json") ) + if artifacts: + sierra, casm = ( + artifacts + if "sierra.json" in artifacts[0].name + or ".contract_class.json" in artifacts[0].name + else artifacts[::-1] + ) + return Artifact(sierra=sierra, casm=casm) + + artifacts = list(BUILD_DIR.glob(f"**/*{contract_name}*.json")) + if not artifacts: + raise FileNotFoundError(f"No artifact found for {contract_name}") + return Artifact(sierra=None, casm=artifacts[0]) @cache -def get_abi(contract_name, cairo_version=None): - artifact, cairo_version = get_artifact(contract_name, cairo_version) - if cairo_version == ArtifactType.cairo1: - artifact = artifact.with_suffix(".contract_class.json") +def get_abi(contract_name): + artifact = get_artifact(contract_name) + return json.loads( + (artifact.sierra if artifact.sierra else artifact.casm).read_text() + )["abi"] - return json.loads(artifact.read_text())["abi"] +@cache +def get_cairo_version(contract_name): + return get_artifact(contract_name).sierra is not None + +@cache def get_tx_url(tx_hash: int) -> str: return f"{NETWORK['explorer_url']}/tx/0x{tx_hash:064x}" -def is_fixture_contract(contract_name): - return CONTRACTS_FIXTURES.get(contract_name) is not None - - -def get_artifact_version(contract_name): - cairo_0 = contract_name in set(CONTRACTS_FIXTURES).union(set(CONTRACTS)) - cairo_1 = any( - contract_name in str(artifact) - for artifact in list(BUILD_DIR_SSJ.glob("*.json")) - + list(Path("cairo1_contracts").glob("**/*.json")) - ) - if cairo_0 and cairo_1: - raise ValueError(f"Contract {contract_name} is ambiguous") - if cairo_0: - return ArtifactType.cairo0 - if cairo_1: - return ArtifactType.cairo1 - raise ValueError(f"Cannot find artifact for contract {contract_name}") - - def compile_contract(contract): logger.info(f"⏳ Compiling {contract['contract_name']}") start = datetime.now() - is_fixture = is_fixture_contract(contract["contract_name"]) - artifact, cairo_version = get_artifact(contract["contract_name"]) - - if cairo_version == ArtifactType.cairo1: - raise NotImplementedError("SSJ compilation not implemented yet") - - output = subprocess.run( - [ - "starknet-compile-deprecated", - ( - CONTRACTS[contract["contract_name"]] - if not is_fixture - else CONTRACTS_FIXTURES[contract["contract_name"]] - ), - "--output", - artifact, - "--cairo_path", - str(SOURCE_DIR), - *(["--no_debug_info"] if NETWORK["type"] is not NetworkType.DEV else []), - *(["--account_contract"] if contract["is_account_contract"] else []), - *( - ["--disable_hint_validation"] - if NETWORK["type"] is NetworkType.DEV - else [] - ), - ], - capture_output=True, + contract_path = CONTRACTS.get(contract["contract_name"]) or CONTRACTS.get( + re.sub("(?!^)([A-Z]+)", r"_\1", contract["contract_name"]).lower() ) + + if contract_path.is_relative_to(CAIRO_DIR): + output = subprocess.run( + "scarb build", shell=True, cwd=contract_path.parent, capture_output=True + ) + else: + output = subprocess.run( + [ + "starknet-compile-deprecated", + contract_path, + "--output", + BUILD_DIR / f"{contract['contract_name']}.json", + "--cairo_path", + str(CAIRO_ZERO_DIR), + *( + ["--no_debug_info"] + if NETWORK["type"] is not NetworkType.DEV + else [] + ), + *(["--account_contract"] if contract["is_account_contract"] else []), + *( + ["--disable_hint_validation"] + if NETWORK["type"] is NetworkType.DEV + else [] + ), + ], + capture_output=True, + ) + if output.returncode != 0: raise RuntimeError(output.stderr) @@ -380,18 +360,14 @@ async def deploy_starknet_account(class_hash=None, private_key=None, amount=1): } -async def declare(contract): - logger.info(f"ℹ️ Declaring {contract['contract_name']}") - artifact, cairo_version = get_artifact(**contract) +async def declare(contract_name): + logger.info(f"ℹ️ Declaring {contract_name}") + artifact = get_artifact(contract_name) account = await get_starknet_account() - if cairo_version == ArtifactType.cairo1: - casm_compiled_contract = artifact.with_suffix( - ".compiled_contract_class.json" - ).read_text() - sierra_compiled_contract = artifact.with_suffix( - ".contract_class.json" - ).read_text() + if artifact.sierra is not None: + casm_compiled_contract = artifact.casm.read_text() + sierra_compiled_contract = artifact.sierra.read_text() casm_class = create_casm_class(casm_compiled_contract) class_hash = compute_casm_class_hash(casm_class) @@ -414,7 +390,7 @@ async def declare(contract): resp = await account.client.declare(transaction=declare_v2_transaction) else: contract_class = create_compiled_contract( - compiled_contract=artifact.read_text() + compiled_contract=artifact.casm.read_text() ) class_hash = compute_class_hash(contract_class=deepcopy(contract_class)) try: @@ -459,24 +435,14 @@ async def declare(contract): status = await wait_for_transaction(resp.transaction_hash) - logger.info( - f"{status} {contract['contract_name']} class hash: {hex(resp.class_hash)}" - ) + logger.info(f"{status} {contract_name} class hash: {hex(resp.class_hash)}") return deployed_class_hash async def deploy(contract_name, *args): logger.info(f"ℹ️ Deploying {contract_name}") - artifact, cairo_version = get_artifact(contract_name) + abi = get_abi(contract_name) declarations = get_declarations() - if cairo_version == ArtifactType.cairo0: - compiled_contract = Path(artifact).read_text() - abi = json.loads(compiled_contract)["abi"] - else: - sierra_compiled_contract = artifact.with_suffix( - ".contract_class.json" - ).read_text() - abi = json.loads(sierra_compiled_contract)["abi"] account = await get_starknet_account() deploy_result = await Contract.deploy_contract_v1( @@ -485,7 +451,7 @@ async def deploy(contract_name, *args): abi=abi, constructor_args=list(args), max_fee=_max_fee, - cairo_version=cairo_version.value, + cairo_version=get_cairo_version(contract_name), ) status = await wait_for_transaction(deploy_result.hash) logger.info( diff --git a/tests/utils/uint256.py b/kakarot_scripts/utils/uint256.py similarity index 100% rename from tests/utils/uint256.py rename to kakarot_scripts/utils/uint256.py diff --git a/tests/src/kakarot/accounts/test_account_contract.py b/tests/src/kakarot/accounts/test_account_contract.py index d6e776596..d487e1225 100644 --- a/tests/src/kakarot/accounts/test_account_contract.py +++ b/tests/src/kakarot/accounts/test_account_contract.py @@ -15,12 +15,12 @@ ) from kakarot_scripts.constants import ARACHNID_PROXY_DEPLOYER, ARACHNID_PROXY_SIGNED_TX +from kakarot_scripts.utils.uint256 import int_to_uint256 from tests.utils.constants import CHAIN_ID, TRANSACTIONS from tests.utils.errors import cairo_error from tests.utils.helpers import generate_random_private_key, rlp_encode_signed_data from tests.utils.hints import patch_hint from tests.utils.syscall_handler import SyscallHandler -from tests.utils.uint256 import int_to_uint256 CHAIN_ID_OFFSET = 35 V_OFFSET = 27 diff --git a/tests/src/kakarot/instructions/test_environmental_information.py b/tests/src/kakarot/instructions/test_environmental_information.py index f990ac5a1..d8014db5e 100644 --- a/tests/src/kakarot/instructions/test_environmental_information.py +++ b/tests/src/kakarot/instructions/test_environmental_information.py @@ -3,8 +3,8 @@ import pytest from Crypto.Hash import keccak +from kakarot_scripts.utils.uint256 import int_to_uint256 from tests.utils.syscall_handler import SyscallHandler -from tests.utils.uint256 import int_to_uint256 EXISTING_ACCOUNT = 0xABDE1 EXISTING_ACCOUNT_SN_ADDR = 0x1234 diff --git a/tests/src/kakarot/instructions/test_stop_and_math_operations.py b/tests/src/kakarot/instructions/test_stop_and_math_operations.py index a03871da9..c052b5bcd 100644 --- a/tests/src/kakarot/instructions/test_stop_and_math_operations.py +++ b/tests/src/kakarot/instructions/test_stop_and_math_operations.py @@ -1,7 +1,7 @@ import pytest +from kakarot_scripts.utils.uint256 import int_to_uint256 from tests.utils.constants import Opcodes -from tests.utils.uint256 import int_to_uint256 class TestStopMathOperations: diff --git a/tests/src/kakarot/test_account.cairo b/tests/src/kakarot/test_account.cairo index 98d83d5df..79e753100 100644 --- a/tests/src/kakarot/test_account.cairo +++ b/tests/src/kakarot/test_account.cairo @@ -24,7 +24,7 @@ func test__init__should_return_account_with_default_dict_as_storage{ local nonce: felt; local balance_low: felt; %{ - from tests.utils.uint256 import int_to_uint256 + from kakarot_scripts.utils.uint256 import int_to_uint256 ids.evm_address = program_input["evm_address"] ids.code_len = len(program_input["code"]) @@ -68,7 +68,7 @@ func test__copy__should_return_new_account_with_same_attributes{ local nonce: felt; local balance_low: felt; %{ - from tests.utils.uint256 import int_to_uint256 + from kakarot_scripts.utils.uint256 import int_to_uint256 ids.evm_address = program_input["evm_address"] ids.code_len = len(program_input["code"]) @@ -196,7 +196,7 @@ func test__has_code_or_nonce{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, ran let (code_hash_ptr) = alloc(); local nonce: felt; %{ - from tests.utils.uint256 import int_to_uint256 + from kakarot_scripts.utils.uint256 import int_to_uint256 ids.code_len = len(program_input["code"]) segments.write_arg(ids.code, program_input["code"]) diff --git a/tests/src/kakarot/test_account.py b/tests/src/kakarot/test_account.py index b9ebdcf67..046c39d0a 100644 --- a/tests/src/kakarot/test_account.py +++ b/tests/src/kakarot/test_account.py @@ -3,8 +3,8 @@ from hypothesis import given from hypothesis.strategies import binary +from kakarot_scripts.utils.uint256 import int_to_uint256 from tests.utils.syscall_handler import SyscallHandler -from tests.utils.uint256 import int_to_uint256 class TestAccount: diff --git a/tests/src/kakarot/test_gas.cairo b/tests/src/kakarot/test_gas.cairo index 6c57612ec..80b68d8fc 100644 --- a/tests/src/kakarot/test_gas.cairo +++ b/tests/src/kakarot/test_gas.cairo @@ -58,7 +58,7 @@ func test__memory_expansion_cost_saturated{range_check_ptr}() -> felt { let (offset) = alloc(); let (size) = alloc(); %{ - from tests.utils.uint256 import int_to_uint256 + from kakarot_scripts.utils.uint256 import int_to_uint256 ids.words_len = program_input["words_len"] segments.write_arg(ids.offset, int_to_uint256(program_input["offset"])) segments.write_arg(ids.size, int_to_uint256(program_input["size"])) diff --git a/tests/src/kakarot/test_kakarot.cairo b/tests/src/kakarot/test_kakarot.cairo index a97d08208..fef315d67 100644 --- a/tests/src/kakarot/test_kakarot.cairo +++ b/tests/src/kakarot/test_kakarot.cairo @@ -37,7 +37,7 @@ func eth_call{ let (access_list) = alloc(); %{ - from tests.utils.uint256 import int_to_uint256 + from kakarot_scripts.utils.uint256 import int_to_uint256 ids.origin = program_input.get("origin", 0) ids.to.is_some = int(bool(program_input.get("to") is not None)) diff --git a/tests/src/kakarot/test_state.cairo b/tests/src/kakarot/test_state.cairo index 9b0ee80b9..97848cb73 100644 --- a/tests/src/kakarot/test_state.cairo +++ b/tests/src/kakarot/test_state.cairo @@ -113,7 +113,7 @@ func test__is_account_alive__account_alive_in_state{ let (code) = alloc(); let (code_hash_ptr) = alloc(); %{ - from tests.utils.uint256 import int_to_uint256 + from kakarot_scripts.utils.uint256 import int_to_uint256 ids.nonce = program_input["nonce"] ids.balance_low = program_input["balance_low"] diff --git a/tests/src/utils/test_bytes.py b/tests/src/utils/test_bytes.py index 2ea3b5e0a..32b8f866b 100644 --- a/tests/src/utils/test_bytes.py +++ b/tests/src/utils/test_bytes.py @@ -4,9 +4,9 @@ from hypothesis import given from hypothesis.strategies import integers +from kakarot_scripts.utils.uint256 import int_to_uint256 from tests.utils.errors import cairo_error from tests.utils.hints import patch_hint -from tests.utils.uint256 import int_to_uint256 PRIME = 0x800000000000011000000000000000000000000000000000000000000000001 diff --git a/tests/src/utils/test_uint256.py b/tests/src/utils/test_uint256.py index 30313dac2..dbdfdfa37 100644 --- a/tests/src/utils/test_uint256.py +++ b/tests/src/utils/test_uint256.py @@ -2,7 +2,7 @@ from hypothesis import given, settings from hypothesis.strategies import integers -from tests.utils.uint256 import int_to_uint256, uint256_to_int +from kakarot_scripts.utils.uint256 import int_to_uint256, uint256_to_int class TestUint256: diff --git a/tests/utils/helpers.py b/tests/utils/helpers.py index 3df45f6d8..d0fea36a9 100644 --- a/tests/utils/helpers.py +++ b/tests/utils/helpers.py @@ -13,7 +13,7 @@ from starkware.starknet.public.abi import get_storage_var_address from kakarot_scripts.constants import NETWORK -from tests.utils.uint256 import int_to_uint256 +from kakarot_scripts.utils.uint256 import int_to_uint256 PERMIT_TYPEHASH = keccak( text="Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" diff --git a/tests/utils/syscall_handler.py b/tests/utils/syscall_handler.py index 9cd505be7..fbc09f16f 100644 --- a/tests/utils/syscall_handler.py +++ b/tests/utils/syscall_handler.py @@ -16,12 +16,12 @@ get_storage_var_address, ) +from kakarot_scripts.utils.uint256 import int_to_uint256, uint256_to_int from tests.utils.constants import ( ACCOUNT_CLASS_IMPLEMENTATION, CAIRO1_HELPERS_CLASS_HASH, CHAIN_ID, ) -from tests.utils.uint256 import int_to_uint256, uint256_to_int def cairo_keccak(class_hash, calldata):