Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cw/fix tests e2e staging #1590

Merged
merged 31 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8a6f2cf
Some initial fixes
ClementWalter Nov 7, 2024
6d17d2f
Update deployment folders, works on katana
ClementWalter Nov 7, 2024
1ffcfe3
Fix DualVMToken for legacy sn ERC20
ClementWalter Nov 7, 2024
baca8a7
Fix declaration for StarknetToken
ClementWalter Nov 7, 2024
b44fa1f
Remove useless fixtures
ClementWalter Nov 7, 2024
7996570
Refacto relayers
ClementWalter Nov 7, 2024
b24a88c
Fix Safe test missing caller_eoa
ClementWalter Nov 8, 2024
cfc4473
Fix relayers withdraw is a classmethod
ClementWalter Nov 8, 2024
68184d8
Move relayes to starknet main file
ClementWalter Nov 8, 2024
297dad0
floor fund_address to required amount
ClementWalter Nov 8, 2024
7ffca84
Fix execute_calls missing before WEHT9 deployment
ClementWalter Nov 8, 2024
92dff11
Use public_key as salt and allow main account to ease withdrawals
ClementWalter Nov 8, 2024
5354b29
Use lazy call for funding relayers
ClementWalter Nov 8, 2024
0381357
Add nonce management
ClementWalter Nov 8, 2024
1da71a6
Wait for network nonce to match estimated nonce
ClementWalter Nov 8, 2024
bbd8745
Catch all errors in wait for tx
ClementWalter Nov 8, 2024
25309e0
Update .env.example
ClementWalter Nov 8, 2024
a6d4124
Fix nonce for declare and deployer account in conftest uses relayerpool
ClementWalter Nov 9, 2024
0addb4a
Managed EVM nonces
ClementWalter Nov 9, 2024
6bd198a
Fix teardown woth coinbase owner
ClementWalter Nov 9, 2024
cd52c8a
Use pending block for eth_call
ClementWalter Nov 9, 2024
2b778ec
Fix missing gas=40000 for coinbase test
ClementWalter Nov 9, 2024
957ebd7
Fix managed nonce is not decreased when tx reverts
ClementWalter Nov 9, 2024
921833a
Fix messaging tests for staging
ClementWalter Nov 10, 2024
232b3c4
Fix argent multisig API update
ClementWalter Nov 10, 2024
5a3518b
Fix ruff unused argument
ClementWalter Nov 10, 2024
add7e1b
Fix patch_deploy
ClementWalter Nov 11, 2024
40df278
New declarations
ClementWalter Nov 11, 2024
3ac8b41
Fix messaging L1 to L2 with more sleep
ClementWalter Nov 11, 2024
de818b5
Use managed nonce even when web3 is connected, and un xfail some tests
ClementWalter Nov 11, 2024
50d3802
Add staging-core deployments
ClementWalter Nov 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 25 additions & 41 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,64 +1,48 @@
# A Github token to download the CI artifacts
# Used for fetching resources in the kakarot_scripts
# Tokens for coverage and CI
CODECOV_TOKEN=
GITHUB_TOKEN=

# An infura RPC key for mainnet/testnet
# API keys
INFURA_KEY=
VOYAGER_API_KEY=
NETHERMIND_API_KEY=

# Account used by default in all kakarot_scripts
# Prefixed accounts {NETWORK}_ will take precedeance over the default one
MADARA_ACCOUNT_ADDRESS=0x3
MADARA_PRIVATE_KEY=0x00c1cf1490de1352865301bb8705143f3ef938f97fdf892f1090dcb5ac7bcd1d

SHARINGAN_ACCOUNT_ADDRESS=
SHARINGAN_PRIVATE_KEY=
SHARINGAN_RPC_URL="https://sharingan.madara.zone"

# First account when using these networks with seed = 0
STARKNET_DEVNET_ACCOUNT_ADDRESS=0x64b48806902a367c8598f4f95c305e8c1a1acba5f082d294a43793113115691
STARKNET_DEVNET_PRIVATE_KEY=0x71d7bb07b9a64f6f78ac4c816aff4da9

STARKNET_SEPOLIA_RELAYER_ACCOUNT_ADDRESS=
STARKNET_SEPOLIA_RELAYER_PRIVATE_KEY=
STARKNET_SEPOLIA_ACCOUNT_ADDRESS=
STARKNET_SEPOLIA_PRIVATE_KEY=
# Starknet accounts
STARKNET_DEVNET_ACCOUNT_ADDRESS=
STARKNET_DEVNET_PRIVATE_KEY=
# This default value is Anvil first account private key
STARKNET_DEVNET_EVM_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

KATANA_ACCOUNT_ADDRESS=0xb3ff441a68610b30fd5e2abbf3a1548eb6ba6f3559f2862bf2dc757e5828ca
KATANA_PRIVATE_KEY=0x2bbf4f9fd0bbb2e60b0316c1fe0b76cf7a4d0198bd493ced9b8df2a3a24d68a
# This default value is Anvil first account private key
KATANA_EVM_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
ClementWalter marked this conversation as resolved.
Show resolved Hide resolved

# Kakarot Sepolia (Testnet production and Testnet staging)
KAKAROT_SEPOLIA_ACCOUNT_ADDRESS=
KAKAROT_SEPOLIA_PRIVATE_KEY=
KAKAROT_SEPOLIA_RPC_URL=https://juno-kakarot-dev.karnot.xyz/

KAKAROT_STAGING_ACCOUNT_ADDRESS=
KAKAROT_STAGING_PRIVATE_KEY=
KAKAROT_STAGING_RPC_URL=https://juno-kakarot-testnet-stage.karnot.xyz
SEPOLIA_ACCOUNT_ADDRESS=
SEPOLIA_PRIVATE_KEY=
SEPOLIA_EVM_PRIVATE_KEY=

# An EVM address that receives the fees
KAKAROT_COINBASE_RECIPIENT=0x20eB005C0b9c906691F885eca5895338E15c36De
STAGING_ACCOUNT_ADDRESS=
STAGING_PRIVATE_KEY=
STAGING_EVM_PRIVATE_KEY=

# Default values in case no network match
ACCOUNT_ADDRESS=
PRIVATE_KEY=
MAINNET_ACCOUNT_ADDRESS=
MAINNET_PRIVATE_KEY=
MAINNET_EVM_PRIVATE_KEY=

# An EVM private to define a default EOA for EVM related kakarot_scripts
STARKNET_SEPOLIA_EVM_PRIVATE_KEY=
# This default value is Anvil first account private key
KATANA_EVM_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
# Network
STARKNET_NETWORK=katana

# Set to python to use the python implementation of Protocol Buffers
# Because cairo-land generated files used protobuf<=3.20 and web3.py uses protobuf ~4
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python

# To override the default web3 provider uri http://localhost:8545, putting as default
# the default Kakarot RPC URL of kakarot-rpc repo
WEB3_HTTP_PROVIDER_URI="http://0.0.0.0:3030"

# Hypothesis profile
HYPOTHESIS_PROFILE=dev

VOYAGER_API_URL=
VOYAGER_API_KEY=

# Private key to sign transactions for RLP scripts/compute_rlp_encoding.ts
# Warning: Do not use this key in production systems
PRIVATE_KEY_RLP_SCRIPT=0x6be0067ba259624aa28f796b703e7d095925a470b17786767bd09aaa3fc2ceea
1 change: 0 additions & 1 deletion .github/workflows/ssj-ef-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ permissions: read-all

jobs:
ef-tests:
# trunk-ignore(actionlint/runner-label)
runs-on: ubuntu-latest-16-cores
steps:
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ssj-tests-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions: read-all

jobs:
unit-tests:
runs-on: ubuntu-latest-16-cores # trunk-ignore(actionlint/runner-label)
runs-on: ubuntu-latest-16-cores
steps:
- uses: actions/checkout@v4
- uses: foundry-rs/setup-snfoundry@v3
Expand Down
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ venv

# starknet
deployments/*
!deployments/kakarot-sepolia/
!deployments/starknet-sepolia/
!deployments/starknet-sepolia-staging/
!deployments/starknet-mainnet/
!deployments/kakarot-staging/
!deployments/mainnet/
!deployments/sepolia/
!deployments/staging/
!deployments/staging-core/
artifacts
build

Expand Down
2 changes: 1 addition & 1 deletion .trunk/configs/.codespellrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[codespell]
ignore-words-list = keypair,astroid,uvloop,crate
ignore-words-list = keypair,astroid,uvloop,crate,amountIn
skip = '.git'
check-filenames =
check-hidden =
2 changes: 1 addition & 1 deletion .trunk/configs/ruff.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Generic, formatter-friendly config.
select = ["B", "D3", "D4", "E", "F"]
select = ["B", "D3", "D4", "E", "F", "ARG"]

# Never enforce `E501` (line length violations). This should be handled by formatters.
ignore = ["E501"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ build: $(SSJ_DIR)
declare: build build-sol
uv run declare

deploy: build build-sol
deploy: declare
uv run deploy

fetch-ef-tests:
Expand Down
4 changes: 2 additions & 2 deletions cairo_zero/tests/src/backend/test_starknet.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def test_should_return_env_with_given_origin_and_gas_price(self, cairo_run):
class TestSaveValidJumpdests:
@SyscallHandler.patch(
"IERC20.balanceOf",
lambda addr, data: [0, 0],
lambda *_: [0, 0],
)
@SyscallHandler.patch("IAccount.write_jumpdests", lambda addr, data: [])
@SyscallHandler.patch("IAccount.write_jumpdests", lambda *_: [])
def test_should_save_jumpdests_to_storage(self, cairo_run):
jumpdests = {0x1: True, 0x10: False, 0x101: True}
contract_address = 0x97283590
Expand Down
26 changes: 13 additions & 13 deletions cairo_zero/tests/src/kakarot/accounts/test_account_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ def bytecode(self, request):
return random.randbytes(request.param)

class TestInitialize:
@SyscallHandler.patch("IKakarot.register_account", lambda addr, data: [])
@SyscallHandler.patch("IKakarot.get_native_token", lambda addr, data: [0xDEAD])
@SyscallHandler.patch("IERC20.approve", lambda addr, data: [1])
@SyscallHandler.patch("IKakarot.register_account", lambda *_: [])
@SyscallHandler.patch("IKakarot.get_native_token", lambda *_: [0xDEAD])
@SyscallHandler.patch("IERC20.approve", lambda *_: [1])
@SyscallHandler.patch("Ownable_owner", 0x1234)
def test_should_set_storage_variables(self, cairo_run):
cairo_run("test__initialize", evm_address=0xABDE1)
Expand All @@ -64,7 +64,7 @@ def test_should_set_storage_variables(self, cairo_run):
calldata=[0xABDE1],
)

@SyscallHandler.patch("IKakarot.register_account", lambda addr, data: [])
@SyscallHandler.patch("IKakarot.register_account", lambda *_: [])
@SyscallHandler.patch("Account_is_initialized", 1)
def test_should_run_only_once(self, cairo_run):
with cairo_error(message="Account already initialized"):
Expand Down Expand Up @@ -270,7 +270,7 @@ def test_should_execute_starknet_call(self, cairo_run):
int(True)
]
with SyscallHandler.patch(
function_selector, lambda addr, data: expected_return_data
function_selector, lambda *_: expected_return_data
):
return_data, success = cairo_run(
"test__execute_starknet_call",
Expand Down Expand Up @@ -383,11 +383,11 @@ def test_should_raise_invalid_signature_for_invalid_chain_id_when_tx_type0_not_p
chain_id=CHAIN_ID + 1,
)

@SyscallHandler.patch("IKakarot.get_native_token", lambda _, __: [0xDEAD])
@SyscallHandler.patch("IERC20.balanceOf", lambda _, __: int_to_uint256(10**128))
@SyscallHandler.patch("IKakarot.get_native_token", lambda *_: [0xDEAD])
@SyscallHandler.patch("IERC20.balanceOf", lambda *_: int_to_uint256(10**128))
@SyscallHandler.patch(
"IKakarot.eth_send_raw_unsigned_tx",
lambda _, __: [1, 0x68656C6C6F, 1, 1], # hello
lambda *_: [1, 0x68656C6C6F, 1, 1], # hello
)
def test_pass_authorized_pre_eip155_transaction(self, cairo_run):
rlp_decoded = rlp.decode(PRE_EIP155_TX["ArachnidProxy"]["signed_tx"])
Expand Down Expand Up @@ -429,13 +429,13 @@ def test_pass_authorized_pre_eip155_transaction(self, cairo_run):
assert output_len == 1
assert output[0] == 0x68656C6C6F

@SyscallHandler.patch("IERC20.balanceOf", lambda _, __: int_to_uint256(10**128))
@SyscallHandler.patch("IERC20.balanceOf", lambda *_: int_to_uint256(10**128))
@SyscallHandler.patch(
"IKakarot.eth_send_raw_unsigned_tx",
lambda _, __: [1, 0x68656C6C6F, 1, 1], # hello
lambda *_: [1, 0x68656C6C6F, 1, 1], # hello
)
@pytest.mark.parametrize("transaction", TRANSACTIONS)
def test_pass_all_transactions_types(self, cairo_run, seed, transaction):
def test_pass_all_transactions_types(self, cairo_run, transaction):
"""
Note: the seeds 41 and 42 have been manually selected after observing that some private keys
were making the Counter deploy transaction failing because their signature parameters length (s and v)
Expand Down Expand Up @@ -466,10 +466,10 @@ def test_pass_all_transactions_types(self, cairo_run, seed, transaction):
assert output_len == 1
assert output[0] == 0x68656C6C6F

@SyscallHandler.patch("IERC20.balanceOf", lambda _, __: int_to_uint256(10**128))
@SyscallHandler.patch("IERC20.balanceOf", lambda *_: int_to_uint256(10**128))
@SyscallHandler.patch(
"IKakarot.eth_send_raw_unsigned_tx",
lambda _, __: [1, 0x68656C6C6F, 1, 1], # hello
lambda *_: [1, 0x68656C6C6F, 1, 1], # hello
)
def test_should_pass_all_data_len(self, cairo_run, bytecode):
transaction = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,15 @@ def test_should_push_address(self, cairo_run):
cairo_run("test__exec_address__should_push_address_to_stack")

class TestExtCodeSize:
@SyscallHandler.patch("IERC20.balanceOf", lambda addr, data: [0, 1])
@SyscallHandler.patch("IAccount.get_nonce", lambda addr, data: [1])
@SyscallHandler.patch("IERC20.balanceOf", lambda *_: [0, 1])
@SyscallHandler.patch("IAccount.get_nonce", lambda *_: [1])
@SyscallHandler.patch(
"Kakarot_evm_to_starknet_address", EXISTING_ACCOUNT, 0x1234
)
@SyscallHandler.patch(
"IAccount.get_code_hash", lambda sn_addr, data: [0x1, 0x1]
)
@SyscallHandler.patch("IAccount.get_code_hash", lambda *_: [0x1, 0x1])
def test_extcodesize_should_push_code_size(self, cairo_run, bytecode, address):
with SyscallHandler.patch(
"IAccount.bytecode", lambda addr, data: [len(bytecode), *bytecode]
"IAccount.bytecode", lambda *_: [len(bytecode), *bytecode]
):
output = cairo_run("test__exec_extcodesize", address=address)

Expand All @@ -66,20 +64,18 @@ class TestExtCodeCopy:
"offset_is_bytecodelen",
],
)
@SyscallHandler.patch("IERC20.balanceOf", lambda addr, data: [0, 1])
@SyscallHandler.patch("IAccount.get_nonce", lambda addr, data: [1])
@SyscallHandler.patch("IERC20.balanceOf", lambda *_: [0, 1])
@SyscallHandler.patch("IAccount.get_nonce", lambda *_: [1])
@SyscallHandler.patch(
"Kakarot_evm_to_starknet_address", EXISTING_ACCOUNT, 0x1234
)
@SyscallHandler.patch(
"IAccount.get_code_hash", lambda sn_addr, data: [0x1, 0x1]
)
@SyscallHandler.patch("IAccount.get_code_hash", lambda *_: [0x1, 0x1])
def test_extcodecopy_should_copy_code(
self, cairo_run, size, offset, dest_offset, bytecode, address
):

with SyscallHandler.patch(
"IAccount.bytecode", lambda addr, data: [len(bytecode), *bytecode]
"IAccount.bytecode", lambda *_: [len(bytecode), *bytecode]
):
memory = cairo_run(
"test__exec_extcodecopy",
Expand Down Expand Up @@ -109,21 +105,19 @@ def test_extcodecopy_should_copy_code(
"size_is_0",
],
)
@SyscallHandler.patch("IERC20.balanceOf", lambda addr, data: [0, 1])
@SyscallHandler.patch("IAccount.get_nonce", lambda addr, data: [1])
@SyscallHandler.patch("IERC20.balanceOf", lambda *_: [0, 1])
@SyscallHandler.patch("IAccount.get_nonce", lambda *_: [1])
@SyscallHandler.patch(
"Kakarot_evm_to_starknet_address", EXISTING_ACCOUNT, 0x1234
)
@SyscallHandler.patch(
"IAccount.get_code_hash", lambda sn_addr, data: [0x1, 0x1]
)
@SyscallHandler.patch("IAccount.get_code_hash", lambda *_: [0x1, 0x1])
def test_extcodecopy_offset_high_zellic_issue_1258(
self, cairo_run, size, bytecode, address
):
offset_high = 1

with SyscallHandler.patch(
"IAccount.bytecode", lambda addr, data: [len(bytecode), *bytecode]
"IAccount.bytecode", lambda *_: [len(bytecode), *bytecode]
):
memory = cairo_run(
"test__exec_extcodecopy_zellic_issue_1258",
Expand Down Expand Up @@ -228,13 +222,13 @@ def test_gasprice(self, cairo_run):
class TestExtCodeHash:
@SyscallHandler.patch(
"IERC20.balanceOf",
lambda sn_addr, data: (
lambda sn_addr, _: (
[0, 1] if sn_addr == EXISTING_ACCOUNT_SN_ADDR else [0, 0]
),
)
@SyscallHandler.patch(
"IAccount.get_nonce",
lambda sn_addr, data: [1] if sn_addr == EXISTING_ACCOUNT_SN_ADDR else [0],
lambda sn_addr, _: [1] if sn_addr == EXISTING_ACCOUNT_SN_ADDR else [0],
)
@SyscallHandler.patch(
"Kakarot_evm_to_starknet_address",
Expand All @@ -247,11 +241,11 @@ def test_extcodehash__should_push_hash(
with (
SyscallHandler.patch(
"IAccount.bytecode",
lambda sn_addr, data: [len(bytecode), *bytecode],
lambda *_: [len(bytecode), *bytecode],
),
SyscallHandler.patch(
"IAccount.get_code_hash",
lambda sn_addr, data: [*int_to_uint256(bytecode_hash)],
lambda *_: [*int_to_uint256(bytecode_hash)],
),
):
output = cairo_run("test__exec_extcodehash", address=address)
Expand Down
8 changes: 4 additions & 4 deletions cairo_zero/tests/src/kakarot/precompiles/test_precompiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ class TestKakarotPrecompiles:
AUTHORIZED_CALLER_CODE,
1,
)
@SyscallHandler.patch_deploy(lambda class_hash, data: [0])
@SyscallHandler.patch("deploy", lambda *_: [0])
@SyscallHandler.patch("Kakarot_evm_to_starknet_address", CALLER_ADDRESS, 0)
@SyscallHandler.patch("ICairo.inc", lambda addr, data: [])
@SyscallHandler.patch("ICairo.inc", lambda *_: [])
def test_should_deploy_account_when_sender_starknet_address_zero(
self,
cairo_run,
Expand Down Expand Up @@ -188,10 +188,10 @@ def test__cairo_precompiles(
]
with SyscallHandler.patch(
"ICairo.inc",
lambda addr, data: [],
lambda *_: [],
), SyscallHandler.patch(
"ICairo.get",
lambda addr, data: cairo_return_data,
lambda *_: cairo_return_data,
):
return_data, reverted, gas_used = cairo_run(
"test__precompiles_run",
Expand Down
6 changes: 2 additions & 4 deletions cairo_zero/tests/src/kakarot/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_should_store_value_at_key(self, cairo_run, key, value):

class TestOriginalStorage:
@pytest.mark.parametrize("key, value", [(0, 0), (2**256 - 1, 2**256 - 1)])
@SyscallHandler.patch("IAccount.storage", lambda addr, data: [0x1337, 0])
@SyscallHandler.patch("IAccount.storage", lambda *_: [0x1337, 0])
@SyscallHandler.patch("Kakarot_evm_to_starknet_address", 0xABDE1, 0x1234)
def test_should_return_original_storage_when_state_modified(
self, cairo_run, key, value
Expand Down Expand Up @@ -97,9 +97,7 @@ class TestHasCodeOrNonce:
(1, [1], True),
),
)
@SyscallHandler.patch(
"IAccount.get_code_hash", lambda sn_addr, data: [0x1, 0x1]
)
@SyscallHandler.patch("IAccount.get_code_hash", lambda *_: [0x1, 0x1])
def test_should_return_true_when_nonce(
self, cairo_run, nonce, code, expected_result
):
Expand Down
Loading
Loading