Skip to content

Commit

Permalink
dev: initialize chain-id after upgrade (#1631)
Browse files Browse the repository at this point in the history
Initializes the chain_id after upgrading kakarot if it's unset
Fixes an issue where eth_send_transaction would use the `eth_chain_id()`
of the network instead of the one that is defined in the constants,
leading to tests passing even though the onchain `chain_id` was not
correct

Closes #1629
  • Loading branch information
enitrat authored Nov 21, 2024
1 parent 204b3d7 commit 5966c26
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions kakarot_scripts/deployment/kakarot_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
RPC_CLIENT,
NetworkType,
)
from kakarot_scripts.utils.kakarot import eth_chain_id
from kakarot_scripts.utils.starknet import deploy as deploy_starknet
from kakarot_scripts.utils.starknet import (
dump_deployments,
Expand Down Expand Up @@ -52,6 +53,11 @@ async def deploy_or_upgrade_kakarot(owner):
"set_cairo1_helpers_class_hash",
class_hash["Cairo1Helpers"],
)

# Initialize the chain_id if it's value is not set
if await eth_chain_id() == 0:
await invoke("kakarot", "initialize_chain_id", NETWORK["chain_id"])

else:
logger.info("✅ Kakarot already up to date.")
else:
Expand Down
2 changes: 1 addition & 1 deletion kakarot_scripts/utils/kakarot.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ async def eth_send_transaction(

payload = {
"type": 0x1,
"chainId": await eth_chain_id(),
"chainId": NETWORK["chain_id"],
"nonce": nonce,
"gas": gas,
"gasPrice": gas_price,
Expand Down

0 comments on commit 5966c26

Please sign in to comment.