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

fix: re-add networkid #464

Merged
merged 2 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion src/el/erigon/erigon_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def launch(
launcher.el_cl_genesis_data,
launcher.jwt_file,
launcher.network,
launcher.networkid,
image,
service_name,
existing_el_clients,
Expand Down Expand Up @@ -152,6 +153,7 @@ def get_config(
el_cl_genesis_data,
jwt_file,
network,
networkid,
image,
service_name,
existing_el_clients,
Expand All @@ -177,6 +179,7 @@ def get_config(
"--chain={0}".format(
network if network in constants.PUBLIC_NETWORKS else "dev"
),
"--networkid={0}".format(networkid),
"--log.console.verbosity=" + verbosity_level,
"--datadir=" + EXECUTION_DATA_DIRPATH_ON_CLIENT_CONTAINER,
"--port={0}".format(DISCOVERY_PORT_NUM),
Expand Down Expand Up @@ -276,9 +279,10 @@ def get_config(
)


def new_erigon_launcher(el_cl_genesis_data, jwt_file, network):
def new_erigon_launcher(el_cl_genesis_data, jwt_file, network, networkid):
return struct(
el_cl_genesis_data=el_cl_genesis_data,
jwt_file=jwt_file,
network=network,
networkid=networkid,
)
5 changes: 5 additions & 0 deletions src/el/geth/geth_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def launch(
launcher.el_cl_genesis_data,
launcher.jwt_file,
launcher.network,
launcher.networkid,
image,
service_name,
existing_el_clients,
Expand Down Expand Up @@ -163,6 +164,7 @@ def get_config(
el_cl_genesis_data,
jwt_file,
network,
networkid,
image,
service_name,
existing_el_clients,
Expand Down Expand Up @@ -235,6 +237,7 @@ def get_config(
"{0}".format(
"--{}".format(network) if network in constants.PUBLIC_NETWORKS else ""
),
"--networkid={0}".format(networkid),
"--verbosity=" + verbosity_level,
"--datadir=" + EXECUTION_DATA_DIRPATH_ON_CLIENT_CONTAINER,
"--http",
Expand Down Expand Up @@ -338,6 +341,7 @@ def new_geth_launcher(
el_cl_genesis_data,
jwt_file,
network,
networkid,
final_genesis_timestamp,
capella_fork_epoch,
electra_fork_epoch=None,
Expand All @@ -346,6 +350,7 @@ def new_geth_launcher(
el_cl_genesis_data=el_cl_genesis_data,
jwt_file=jwt_file,
network=network,
networkid=networkid,
final_genesis_timestamp=final_genesis_timestamp,
capella_fork_epoch=capella_fork_epoch,
electra_fork_epoch=electra_fork_epoch,
Expand Down
8 changes: 8 additions & 0 deletions src/package_io/constants.star
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ PUBLIC_NETWORKS = (
"sepolia",
"holesky",
)

NETWORK_ID = {
"mainnet": 1,
"goerli": 5,
"sepolia": 11155111,
"holesky": 17000,
}

CHECKPOINT_SYNC_URL = {
"mainnet": "https://beaconstate.info",
"goerli": "https://checkpoint-sync.goerli.ethpandaops.io",
Expand Down
10 changes: 10 additions & 0 deletions src/participant_network.star
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def launch_participant_network(

plan.print(json.indent(json.encode(validator_data)))

network_id = network_params.network_id

# We need to send the same genesis time to both the EL and the CL to ensure that timestamp based forking works as expected
final_genesis_timestamp = get_final_genesis_timestamp(
plan,
Expand Down Expand Up @@ -161,6 +163,7 @@ def launch_participant_network(
constants.GENESIS_VALIDATORS_ROOT[network_params.network],
)
final_genesis_timestamp = constants.GENESIS_TIME[network_params.network]
network_id = constants.NETWORK_ID[network_params.network]
validator_data = None
else:
# We are running a devnet
Expand All @@ -175,13 +178,17 @@ def launch_participant_network(
files={"/opt": el_cl_genesis_uuid},
)
genesis_validators_root = read_file(url + "/genesis_validators_root.txt")

el_cl_data = el_cl_genesis_data.new_el_cl_genesis_data(
el_cl_genesis_data_uuid.files_artifacts[0],
genesis_validators_root,
)
final_genesis_timestamp = shared_utils.read_genesis_timestamp_from_config(
plan, el_cl_genesis_uuid
)
network_id = shared_utils.read_genesis_network_id_from_config(
plan, el_cl_genesis_uuid
)
validator_data = None

el_launchers = {
Expand All @@ -190,6 +197,7 @@ def launch_participant_network(
el_cl_data,
jwt_file,
network_params.network,
network_id,
final_genesis_timestamp,
network_params.capella_fork_epoch,
network_params.electra_fork_epoch,
Expand All @@ -201,6 +209,7 @@ def launch_participant_network(
el_cl_data,
jwt_file,
network_params.network,
network_id,
final_genesis_timestamp,
network_params.capella_fork_epoch,
network_params.electra_fork_epoch,
Expand All @@ -220,6 +229,7 @@ def launch_participant_network(
el_cl_data,
jwt_file,
network_params.network,
network_id,
),
"launch_method": erigon.launch,
},
Expand Down
18 changes: 16 additions & 2 deletions src/shared_utils/shared_utils.star
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,25 @@ import yaml
with open("/network-configs/config.yaml", "r") as f:
yaml_data = yaml.safe_load(f)

# Get values from the YAML content
min_genesis_time = int(yaml_data.get("MIN_GENESIS_TIME", 0))
genesis_delay = int(yaml_data.get("GENESIS_DELAY", 0))
print(min_genesis_time + genesis_delay, end="")
""",
)
return value.output

print(int(min_genesis_time + genesis_delay), end="")

def read_genesis_network_id_from_config(plan, filename):
value = plan.run_python(
files={constants.GENESIS_DATA_MOUNTPOINT_ON_CLIENTS: filename},
wait=None,
packages=["PyYAML"],
run="""
import yaml
with open("/network-configs/config.yaml", "r") as f:
yaml_data = yaml.safe_load(f)
network_id = int(yaml_data.get("DEPOSIT_NETWORK_ID", 0))
print(network_id, end="")
""",
)
return value.output