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

Commit

Permalink
script: use MAX_SAFE_CHAIN_ID
Browse files Browse the repository at this point in the history
  • Loading branch information
obatirou committed Oct 8, 2024
1 parent f1f79e6 commit 7ad5c07
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 4 additions & 2 deletions kakarot_scripts/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
BLOCK_GAS_LIMIT = 7_000_000
DEFAULT_GAS_PRICE = 1
BEACON_ROOT_ADDRESS = "0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02"
# see https://gist.github.com/rekmarks/a47bd5f2525936c4b8eee31a16345553
MAX_SAFE_CHAIN_ID = 4503599627370476


class NetworkType(Enum):
Expand Down Expand Up @@ -192,7 +194,7 @@ class NetworkType(Enum):
if WEB3.is_connected():
chain_id = WEB3.eth.chain_id
else:
chain_id = starknet_chain_id % 2**53
chain_id = starknet_chain_id % MAX_SAFE_CHAIN_ID
except (
requests.exceptions.ConnectionError,
requests.exceptions.MissingSchema,
Expand All @@ -202,7 +204,7 @@ class NetworkType(Enum):
f"⚠️ Could not get chain Id from {NETWORK['rpc_url']}: {e}, defaulting to KKRT"
)
starknet_chain_id = int.from_bytes(b"KKRT", "big")
chain_id = starknet_chain_id % 2**53
chain_id = starknet_chain_id % MAX_SAFE_CHAIN_ID


class ChainId(IntEnum):
Expand Down
5 changes: 2 additions & 3 deletions tests/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@

import pytest

from kakarot_scripts.constants import BLOCK_GAS_LIMIT
from kakarot_scripts.constants import BLOCK_GAS_LIMIT, MAX_SAFE_CHAIN_ID

BLOCK_GAS_LIMIT = BLOCK_GAS_LIMIT
MIN_BASE_FEE_PER_BLOB_GAS = 1

CHAIN_ID = int.from_bytes(b"KKRT", "big") # KKRT (0x4b4b5254) in ASCII
BIG_CHAIN_ID = int.from_bytes(b"SN_SEPOLIA", "big")
# see https://gist.github.com/rekmarks/a47bd5f2525936c4b8eee31a16345553
MAX_SAFE_CHAIN_ID = 4503599627370476
MAX_SAFE_CHAIN_ID = MAX_SAFE_CHAIN_ID

# Class hash of the cairo1 helpers
CAIRO1_HELPERS_CLASS_HASH = 0xDEADBEEFABDE1E11A5
Expand Down

0 comments on commit 7ad5c07

Please sign in to comment.