Skip to content

Commit

Permalink
dev(scripts): split deployment concerns in multiple files (#1495)
Browse files Browse the repository at this point in the history
Splits the deployment flow in multiple files. leverage the "lazy
execution"

<!-- Reviewable:start -->
- - -
This change is [<img src="https://reviewable.io/review_button.svg"
height="34" align="absmiddle"
alt="Reviewable"/>](https://reviewable.io/reviews/kkrt-labs/kakarot/1495)
<!-- Reviewable:end -->
  • Loading branch information
enitrat authored Oct 11, 2024
1 parent f7eacc8 commit 9c83960
Show file tree
Hide file tree
Showing 15 changed files with 719 additions and 392 deletions.
13 changes: 8 additions & 5 deletions cairo_zero/tests/src/kakarot/accounts/test_account_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
get_storage_var_address,
)

from kakarot_scripts.constants import ARACHNID_PROXY_DEPLOYER, ARACHNID_PROXY_SIGNED_TX
from kakarot_scripts.data.pre_eip155_txs import PRE_EIP155_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
Expand Down Expand Up @@ -344,9 +344,11 @@ def test_should_raise_with_signature_values_not_in_range(
chain_id=CHAIN_ID,
)

@SyscallHandler.patch("Account_evm_address", int(ARACHNID_PROXY_DEPLOYER, 16))
@SyscallHandler.patch(
"Account_evm_address", int(PRE_EIP155_TX["ArachnidProxy"]["deployer"], 16)
)
def test_should_raise_unauthorized_pre_eip155_tx(self, cairo_run):
rlp_decoded = rlp.decode(ARACHNID_PROXY_SIGNED_TX)
rlp_decoded = rlp.decode(PRE_EIP155_TX["ArachnidProxy"]["signed_tx"])
v, r, s = rlp_decoded[-3:]
signature = [
*int_to_uint256(int.from_bytes(r, "big")),
Expand Down Expand Up @@ -400,7 +402,7 @@ def test_should_raise_invalid_signature_for_invalid_chain_id_when_tx_type0_not_p
lambda _, __: [1, 0x68656C6C6F, 1, 1], # hello
)
def test_pass_authorized_pre_eip155_transaction(self, cairo_run):
rlp_decoded = rlp.decode(ARACHNID_PROXY_SIGNED_TX)
rlp_decoded = rlp.decode(PRE_EIP155_TX["ArachnidProxy"]["signed_tx"])
v, r, s = rlp_decoded[-3:]
signature = [
*int_to_uint256(int.from_bytes(r, "big")),
Expand All @@ -416,7 +418,8 @@ def test_pass_authorized_pre_eip155_transaction(self, cairo_run):

with (
SyscallHandler.patch(
"Account_evm_address", int(ARACHNID_PROXY_DEPLOYER, 16)
"Account_evm_address",
int(PRE_EIP155_TX["ArachnidProxy"]["deployer"], 16),
),
SyscallHandler.patch(
"Account_authorized_message_hashes", tx_hash_low, tx_hash_high, 0x1
Expand Down
17 changes: 0 additions & 17 deletions kakarot_scripts/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,6 @@ class ChainId(IntEnum):
BUILD_DIR.mkdir(exist_ok=True, parents=True)
BUILD_DIR_SSJ = BUILD_DIR / "ssj"

DATA_DIR = Path("kakarot_scripts") / "data"


DEPLOYMENTS_DIR = Path("deployments") / NETWORK["name"]
DEPLOYMENTS_DIR.mkdir(exist_ok=True, parents=True)

Expand Down Expand Up @@ -293,20 +290,6 @@ class ChainId(IntEnum):
"UniversalLibraryCaller",
]

# PRE-EIP155 TX
MULTICALL3_DEPLOYER = "0x05f32b3cc3888453ff71b01135b34ff8e41263f2"
MULTICALL3_SIGNED_TX = bytes.fromhex(
json.loads((DATA_DIR / "signed_txs.json").read_text())["multicall3"]
)
ARACHNID_PROXY_DEPLOYER = "0x3fab184622dc19b6109349b94811493bf2a45362"
ARACHNID_PROXY_SIGNED_TX = bytes.fromhex(
json.loads((DATA_DIR / "signed_txs.json").read_text())["arachnid"]
)
CREATEX_DEPLOYER = "0xeD456e05CaAb11d66C4c797dD6c1D6f9A7F352b5"
CREATEX_SIGNED_TX = bytes.fromhex(
json.loads((DATA_DIR / "signed_txs.json").read_text())["createx"]
)

prefix = NETWORK["name"].upper().replace("-", "_")
EVM_PRIVATE_KEY = os.getenv(f"{prefix}_EVM_PRIVATE_KEY")
if EVM_PRIVATE_KEY is None:
Expand Down
26 changes: 26 additions & 0 deletions kakarot_scripts/data/pre_eip155_txs.py

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions kakarot_scripts/data/signed_txs.json

This file was deleted.

Loading

0 comments on commit 9c83960

Please sign in to comment.