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

Commit

Permalink
New sepolia and fix withdraw script (#1449)
Browse files Browse the repository at this point in the history
<!-- 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/1449)
<!-- Reviewable:end -->
  • Loading branch information
ClementWalter authored Sep 26, 2024
1 parent 697100a commit b4f1db4
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 42 deletions.
25 changes: 13 additions & 12 deletions deployments/starknet-sepolia/declarations.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{
"account_contract": "0x6cb1275516c11f6c1f9d2758bd212d2c40d8136ebd353c316779b754a216d83",
"uninitialized_account_fixture": "0x2957ff0877441dddcd140e6af50a3d45712f4f7205a36a846110a70297036be",
"uninitialized_account": "0x45f7d0803659c3f58b5b6ba46f349178253dadabbfc6ab47fa1ba4bab4699f8",
"EVM": "0x1ce258b332ad964d0d0a472b7795615a84f25196b733a319e101b948f3064a8",
"OpenzeppelinAccount": "0x6153ccf69fd20f832c794df36e19135f0070d0576144f0b47f75a226e4be530",
"account_contract": "0x3c64a1702579c371fc47af9231b5537ba2bfbc82834890216dc0bc5688d1810",
"BalanceSender": "0x652f09b751d24d5ccf79d24d6ddbaae7ffd1e898b036f905dfae567938e95f6",
"BenchmarkCairoCalls": "0x58dc8a979af32668e05579313d1d6c672d3b668f72778780e8b2e97964159c3",
"Cairo1Helpers": "0x28ece3751ecf5bdf2d791eb64a65bfb6a8816432b698870dba2f38a36101d58",
"Cairo1HelpersFixture": "0x4e7811d9bbba41193bd3c77d05c16f7aaa55dd1d601686b50f6fa0e3766a712",
"replace_class": "0xa187318c5e79b010cf45975f589f0a8d441fadde5b1e7ccad46501568437b5",
"Counter": "0x4fc47610d8c9ce0bcfc2f9e03658f0fbcd3e0a9c351a1aa59d465a33533a7c8",
"MockPragmaOracle": "0x675f00328ff84f127d71b179b3f3a3a06ce8432054770cddd5729c8d62866da",
"StarknetToken": "0x27dd8ce628866f1544202ae06ec57b3c9b1f775d5f7c2797de7aa1586ecf693",
"ERC20": "0x3c5ee4bc12f4247cd8071150c3f5d9bee71f40b0ef7aeae59f468d898f60933",
"kakarot": "0x3f9e4ac97c943181453ce74f1fd1c163c154c40d9cbbbe5c2453512ee1a86e6",
"UniversalLibraryCaller": "0x5e84816dcbfd11581d8d5160af5754a4adc71ab35a0c0aaa053773f61838627",
"BalanceSender": "0x2cc118f56b9d3ad311900db5254f3dca75fbf24de3b68ee670a0fb3691ac5b3"
}
"EVM": "0x5ace47f3aa5e8082d48b8ba8c957ba51c7fd29b457408f465d27bf1c6783e21",
"kakarot": "0x764a6eff6f91d769c066a240c29ed2fa756c71cda385188a8cb1437aaeaf79f",
"MockPragmaOracle": "0x675f00328ff84f127d71b179b3f3a3a06ce8432054770cddd5729c8d62866da",
"OpenzeppelinAccount": "0x6153ccf69fd20f832c794df36e19135f0070d0576144f0b47f75a226e4be530",
"replace_class": "0xa187318c5e79b010cf45975f589f0a8d441fadde5b1e7ccad46501568437b5",
"StarknetToken": "0x314a6a9f01e5a28beb6a7e2e8907243469d98a7e364054657e7593bea5dcee7",
"uninitialized_account_fixture": "0x84ca495a2c045060cb2a0a0abe69d089454c41ecf6627cdc36a724618910d9",
"uninitialized_account": "0x5977621f53b7d1b129446775bd7d5a573f8a87297c6287853d52219ffb90c9",
"UniversalLibraryCaller": "0x244fd35db35b48882ca2e6c2966821bd54f302b131fb22ea98e5534da390482"
}
25 changes: 15 additions & 10 deletions deployments/starknet-sepolia/deployments.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"kakarot": {
"address": "0x6f625bb0bd82401b268c1ba9fa0973bb9cdf732c6a6f21fe14dfd4c82a28e89",
"tx": "0x36c51e168146d9c104a4323a2dddf873a9a54d52b02f5cbc83d8cb957426f60",
"artifact": "build/kakarot.json"
"address": "0x78bd079b79aa45111313f200a22e5c52ff7526c746d73b65672cc28acbe2263",
"tx": "0x897e9cb077b13aec370f1dae4807dffb324a621416023e4fd67c4eb1f8d2d3",
"artifact": "None"
},
"EVM": {
"address": "0x41c4025537b9677034f3b58f6e722e19c40a7b77a82e3851fdc6b7adf5ad414",
"tx": "0xa0b92fd60470ac35b5a64236bacbe86d6b5aaea30997aced328123cba74024",
"artifact": "build/fixtures/EVM.json"
"address": "0x6ae512c704e2fafbc06e6a6401e9ce02d534aad4bc34400fc1d8d82e88be316",
"tx": "0x515788cd50f04984c5b5cd6c7f75014abbb0b7bdfe449b4c2d24dd6816db756",
"artifact": "None"
},
"Counter": {
"address": "0x2d6741b182475b7cfc62ec1000fbcba553ea08f2e603fa2840d0288cd2d1e3c",
Expand All @@ -20,8 +20,13 @@
"artifact": "build/ssj/contracts_MockPragmaOracle"
},
"UniversalLibraryCaller": {
"address": "0x01e12ea32baf68b1e11c1ce32595d3a61a22ccdcbc67f94c77268b6ce99fa6d4",
"tx": "0x3d6b91602c1e290bc65c6f85751f5ea156cf982d01c6bf1ea694d7398a9d5a5",
"artifact": "cairo1_contracts/utils/target/dev/library_call_UniversalLibraryCaller"
"address": "0x4e23e34042e1f0198311e2dcfc9565c214a48261574f2b37a7f12d1f65100f1",
"tx": "0x3cdee93215396193d9e08e7be3dccc7f6a650ba35f6f57b8762a540ca117816",
"artifact": "cairo1_contracts/utils/target/dev/utils_UniversalLibraryCaller.contract_class.json"
},
"BenchmarkCairoCalls": {
"address": "0x6ea732a6102b65dc04b54ec35304d5f27d1c3fbc81fd6810bd90b126f2e0d11",
"tx": "0x1c5464c82da97a4e9aeb088da8e5a932e4b14204efb192fe7b81dabe327e2d2",
"artifact": "cairo1_contracts/utils/target/dev/utils_BenchmarkCairoCalls.contract_class.json"
}
}
}
10 changes: 10 additions & 0 deletions deployments/starknet-sepolia/kakarot_deployments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"Bridge": {
"address": "0x5fbdb2315678afecb367f032d93f642f64180aa3",
"starknet_address": "0x231fc0a786be568c112a84dfc0b44dc923d1cee902ff4903b2ef89db010ccb6"
},
"WETH": {
"address": "0xe7f1725e7734ce288f8367e1bb143e90bb3f0512",
"starknet_address": "0x673b8462d6d2e1d1ddb8399e9a3e7a22bcbcb13e038727a8353d3ded1ab2d60"
}
}
4 changes: 1 addition & 3 deletions kakarot_scripts/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,7 @@ class NetworkType(Enum):
if WEB3.is_connected():
chain_id = WEB3.eth.chain_id
else:
chain_id = starknet_chain_id % (
2**53 if NETWORK["name"] != "starknet-sepolia" else 2**32
)
chain_id = starknet_chain_id % 2**53
except (
requests.exceptions.ConnectionError,
requests.exceptions.MissingSchema,
Expand Down
22 changes: 19 additions & 3 deletions kakarot_scripts/deploy_kakarot.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from kakarot_scripts.utils.starknet import (
dump_declarations,
dump_deployments,
get_balance,
get_declarations,
)
from kakarot_scripts.utils.starknet import get_deployments as get_starknet_deployments
Expand All @@ -46,6 +47,7 @@ async def main():
# %% Declarations
account = await get_starknet_account()
logger.info(f"ℹ️ Using account 0x{account.address:064x} as deployer")
balance_pref = await get_balance(account.address)

class_hash = {contract: await declare(contract) for contract in DECLARED_CONTRACTS}
dump_declarations(class_hash)
Expand Down Expand Up @@ -123,13 +125,23 @@ async def main():

# %% Pre-EIP155 deployments
evm_deployments["Multicall3"] = await deploy_with_presigned_tx(
MULTICALL3_DEPLOYER, MULTICALL3_SIGNED_TX, name="Multicall3"
MULTICALL3_DEPLOYER,
MULTICALL3_SIGNED_TX,
name="Multicall3",
max_fee=int(0.1e18),
)
evm_deployments["Arachnid_Proxy"] = await deploy_with_presigned_tx(
ARACHNID_PROXY_DEPLOYER, ARACHNID_PROXY_SIGNED_TX, name="Arachnid Proxy"
ARACHNID_PROXY_DEPLOYER,
ARACHNID_PROXY_SIGNED_TX,
name="Arachnid Proxy",
max_fee=int(0.1e18),
)
evm_deployments["CreateX"] = await deploy_with_presigned_tx(
CREATEX_DEPLOYER, CREATEX_SIGNED_TX, amount=0.3, name="CreateX"
CREATEX_DEPLOYER,
CREATEX_SIGNED_TX,
amount=0.3,
name="CreateX",
max_fee=int(0.2e18),
)

# %% EVM Deployments
Expand Down Expand Up @@ -166,6 +178,10 @@ async def main():
}

dump_evm_deployments(evm_deployments)
balance_after = await get_balance(account.address)
logger.info(
f"ℹ️ Deployer balance changed from {balance_pref / 1e18} to {balance_after / 1e18} ETH"
)


# %% Run
Expand Down
8 changes: 5 additions & 3 deletions kakarot_scripts/utils/kakarot.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ async def send_pre_eip155_transaction(
evm_address: str,
starknet_address: Union[int, str],
signed_tx: bytes,
max_fee: Optional[int] = None,
):
rlp_decoded = rlp.decode(signed_tx)
v, r, s = rlp_decoded[-3:]
Expand Down Expand Up @@ -533,6 +534,7 @@ async def send_pre_eip155_transaction(
signature_s=int.from_bytes(s, "big"),
signature_v=int.from_bytes(v, "big"),
packed_encoded_unsigned_tx=pack_calldata(unsigned_encoded_tx),
max_fee=max_fee,
)


Expand Down Expand Up @@ -705,7 +707,7 @@ async def deploy_and_fund_evm_address(evm_address: str, amount: float):
Deploy an EOA linked to the given EVM address and fund it with amount ETH.
"""
starknet_address = await get_starknet_address(int(evm_address, 16))
account_balance = await get_balance(evm_address)
account_balance = await eth_balance_of(evm_address)
if account_balance < amount:
await fund_address(evm_address, amount - account_balance)
if not await _contract_exists(starknet_address):
Expand Down Expand Up @@ -776,13 +778,13 @@ async def store_bytecode(bytecode: Union[str, bytes], **kwargs):


async def deploy_with_presigned_tx(
deployer_evm_address: str, signed_tx: bytes, amount=0.1, name=""
deployer_evm_address: str, signed_tx: bytes, amount=0.1, name="", max_fee=None
):
deployer_starknet_address = await deploy_and_fund_evm_address(
deployer_evm_address, amount
)
receipt, response, success, gas_used = await send_pre_eip155_transaction(
deployer_evm_address, deployer_starknet_address, signed_tx
deployer_evm_address, deployer_starknet_address, signed_tx, max_fee
)
deployed_address = response[1]
logger.info(f"✅ {name} Deployed at: 0x{deployed_address:040x}")
Expand Down
4 changes: 2 additions & 2 deletions kakarot_scripts/withdraw_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ async def main():
balance = await get_balance(contract["starknet_contract_address"])
if balance == 0:
logger.info(
f"ℹ️ No balance to withdraw from EVM contract {contract['evm_address']}"
f"ℹ️ No balance to withdraw from EVM contract {contract['evm_contract_address']}"
)
continue

logger.info(
f"ℹ️ Withdrawing {balance / 1e18} ETH from EVM contract {contract['evm_address']}"
f"ℹ️ Withdrawing {balance / 1e18} ETH from EVM contract {contract['evm_contract_address']}"
)
current_class = await RPC_CLIENT.get_class_hash_at(
contract["starknet_contract_address"]
Expand Down
11 changes: 2 additions & 9 deletions tests/fixtures/BalanceSender.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,9 @@
from openzeppelin.access.ownable.library import Ownable
from starkware.cairo.common.cairo_builtins import HashBuiltin
from starkware.starknet.common.syscalls import replace_class, get_contract_address
from kakarot.interfaces.interfaces import IERC20

@external
func set_implementation{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}(
new_implementation: felt
) {
Ownable.assert_only_owner();
replace_class(new_implementation);
return ();
}
from kakarot.interfaces.interfaces import IERC20
from kakarot.accounts.account_contract import upgrade

@external
func send_balance{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}(
Expand Down

0 comments on commit b4f1db4

Please sign in to comment.