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

feat: add custom configurable forks #59

Merged
merged 11 commits into from
Aug 23, 2024
72 changes: 0 additions & 72 deletions Dockerfile

This file was deleted.

30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ kurtosis clean -a

This will stop and remove all running enclaves and **delete all data**.

# L2 Contract deployer
The enclave will automatically deploy an optimism L2 contract on the L1 network. The contract address will be printed in the logs. You can use this contract address to interact with the L2 network.

Please refer to this Dockerfile if you want to see how the contract deployer image is built: [Dockerfile](https://github.com/ethpandaops/eth-client-docker-image-builder/blob/master/op-contract-deployer/Dockerfile)


## Configuration

To configure the package behaviour, you can modify your `network_params.yaml` file. The full YAML schema that can be passed in is as follows with the defaults provided:
Expand Down Expand Up @@ -70,7 +76,7 @@ optimism_package:

# The Docker image that should be used for the CL client; leave blank to use the default for the client type
# Defaults by client:
# - op-node: parithoshj/op-node:v1
# - op-node: us-docker.pkg.dev/oplabs-tools-artifacts/images/op-node:develop
# - hildr: ghcr.io/optimism-java/hildr:latest
cl_image: ""

Expand All @@ -97,6 +103,28 @@ optimism_package:
# Defaults to "op-kurtosis"
name: "op-kurtosis"

# Triggering future forks in the network
# Fjord fork
# Defaults to 0 (genesis activation) - decimal value
# Offset is in seconds
fjord_time_offset: 0

# Granite fork
# Defaults to None - not activated - decimal value
# Offset is in seconds
granite_time_offset: ""

# Holocene fork
# Defaults to None - not activated - decimal value
# Offset is in seconds
holocene_time_offset: ""

# Interop fork
# Defaults to None - not activated - decimal value
# Offset is in seconds
interop_time_offset: ""


# Additional services to run alongside the network
# Defaults to []
# Available services:
Expand Down
4 changes: 2 additions & 2 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def run(plan, args):

# Deploy Create2 Factory contract (only need to do this once for multiple l2s)
contract_deployer.deploy_factory_contract(plan, l1_priv_key, l1_config_env_vars)

# Deploy L2s
plan.print("Deploying a local L2")
if type(optimism_args) == "dict":
Expand Down Expand Up @@ -72,6 +71,7 @@ def run(plan, args):
network_id
)
)

seen_names[name] = True
seen_network_ids[network_id] = True
l2_services_suffix = "-{0}".format(name)
Expand All @@ -89,7 +89,7 @@ def run(plan, args):

def get_l1_config(all_l1_participants, l1_network_params, l1_network_id):
env_vars = {}
env_vars["L1_RPC_KIND"] = "any"
env_vars["L1_RPC_KIND"] = "standard"
env_vars["WEB3_RPC_URL"] = str(all_l1_participants[0].el_context.rpc_http_url)
env_vars["L1_RPC_URL"] = str(all_l1_participants[0].el_context.rpc_http_url)
env_vars["CL_RPC_URL"] = str(all_l1_participants[0].cl_context.beacon_http_url)
Expand Down
1 change: 1 addition & 0 deletions src/batcher/op-batcher/op_batcher_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def get_batcher_config(
gs_batcher_private_key,
):
cmd = [
"op-batcher",
"--l2-eth-rpc=" + el_context.rpc_http_url,
"--rollup-rpc=" + cl_context.beacon_http_url,
"--poll-interval=1s",
Expand Down
1 change: 1 addition & 0 deletions src/cl/op-node/op_node_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def get_beacon_config(
used_ports = get_used_ports(BEACON_DISCOVERY_PORT_NUM)

cmd = [
"op-node",
"--l2={0}".format(EXECUTION_ENGINE_ENDPOINT),
"--l2.jwt-secret=" + constants.JWT_MOUNT_PATH_ON_CONTAINER,
"--verifier.l1-confs=4",
Expand Down
4 changes: 3 additions & 1 deletion src/contracts/contract_deployer.star
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def deploy_l2_contracts(
l1_config_env_vars,
l2_config_env_vars,
l2_services_suffix,
fork_activation_env,
):
chainspec_files_artifact = plan.upload_files(
src=CHAINSPEC_JQ_FILEPATH,
Expand All @@ -64,7 +65,8 @@ def deploy_l2_contracts(
"DEPLOYMENT_CONTEXT": "getting-started",
}
| l1_config_env_vars
| l2_config_env_vars,
| l2_config_env_vars
| fork_activation_env,
files={
"/workspace/optimism/packages/contracts-bedrock/deploy-config/chainspec-generator/": chainspec_files_artifact,
},
Expand Down
22 changes: 21 additions & 1 deletion src/l2.star
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def launch_l2(
l2_config_env_vars = {}
l2_config_env_vars["L2_CHAIN_ID"] = str(network_params.network_id)
l2_config_env_vars["L2_BLOCK_TIME"] = str(network_params.seconds_per_slot)

fork_activation_env = get_network_fork_activation(network_params)
plan.print(fork_activation_env)
(
el_cl_data,
gs_private_keys,
Expand All @@ -35,6 +36,7 @@ def launch_l2(
l1_config,
l2_config_env_vars,
l2_services_suffix,
fork_activation_env,
)

plan.print("Deploying L2 with name {0}".format(network_params.name))
Expand Down Expand Up @@ -81,3 +83,21 @@ def launch_l2(
l1_bridge_address
)
)


def get_network_fork_activation(network_params):
env_vars = {}
env_vars["FJORD_TIME_OFFSET"] = "0x" + "%x" % network_params.fjord_time_offset
if network_params.granite_time_offset:
env_vars["GRANITE_TIME_OFFSET"] = (
"0x" + "%x" % network_params.granite_time_offset
)
if network_params.holocene_time_offset:
env_vars["HOLOCENE_TIME_OFFSET"] = (
"0x" + "%x" % network_params.holocene_time_offset
)
if network_params.interop_time_offset:
env_vars["INTEROP_TIME_OFFSET"] = (
"0x" + "%x" % network_params.interop_time_offset
)
return env_vars
16 changes: 12 additions & 4 deletions src/package_io/input_parser.star
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ sanity_check = import_module("./sanity_check.star")

DEFAULT_EL_IMAGES = {
"op-geth": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-geth:latest",
"op-reth": "parithoshj/op-reth:latest",
"op-reth": "ghcr.io/paradigmxyz/op-reth:latest",
"op-erigon": "testinprod/op-erigon:latest",
"op-nethermind": "nethermindeth/nethermind:op-c482d56",
}

DEFAULT_CL_IMAGES = {
"op-node": "parithoshj/op-node:v1",
"op-node": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-node:develop",
"hildr": "ghcr.io/optimism-java/hildr:latest",
}

DEFAULT_BATCHER_IMAGES = {
"op-batcher": "parithoshj/op-batcher:v1",
"op-batcher": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-batcher:develop",
}

DEFAULT_PROPOSER_IMAGES = {
"op-proposer": "parithoshj/op-proposer:v1",
"op-proposer": "us-docker.pkg.dev/oplabs-tools-artifacts/images/op-proposer:develop",
}

ATTR_TO_BE_SKIPPED_AT_ROOT = (
Expand Down Expand Up @@ -53,6 +53,10 @@ def input_parser(plan, input_args):
network_id=result["network_params"]["network_id"],
seconds_per_slot=result["network_params"]["seconds_per_slot"],
name=result["network_params"]["name"],
fjord_time_offset=result["network_params"]["fjord_time_offset"],
granite_time_offset=result["network_params"]["granite_time_offset"],
holocene_time_offset=result["network_params"]["holocene_time_offset"],
interop_time_offset=result["network_params"]["interop_time_offset"],
),
additional_services=result.get(
"additional_services", DEFAULT_ADDITIONAL_SERVICES
Expand Down Expand Up @@ -132,6 +136,10 @@ def default_network_params():
"network_id": "2151908",
"name": "op-kurtosis",
"seconds_per_slot": 2,
"fjord_time_offset": 0,
"granite_time_offset": None,
"holocene_time_offset": None,
"interop_time_offset": None,
}


Expand Down
4 changes: 4 additions & 0 deletions src/package_io/sanity_check.star
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ SUBCATEGORY_PARAMS = {
"network_id",
"seconds_per_slot",
"name",
"fjord_time_offset",
"granite_time_offset",
"holocene_time_offset",
"interop_time_offset",
],
}

Expand Down
1 change: 1 addition & 0 deletions src/proposer/op-proposer/op_proposer_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def get_proposer_config(
l2oo_address,
):
cmd = [
"op-proposer",
"--poll-interval=12s",
"--rpc.port=" + str(PROPOSER_HTTP_PORT_NUM),
"--rollup-rpc=" + cl_context.beacon_http_url,
Expand Down