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: integrate aggoracle #438

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
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
117 changes: 117 additions & 0 deletions cdk_aggkit.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
data_availability_package = import_module("./lib/data_availability.star")
cdk_aggkit_package = import_module("./lib/cdk_aggkit.star")
databases = import_module("./databases.star")
zkevm_bridge_package = import_module("./lib/zkevm_bridge.star")


def run(plan, args, contract_setup_addresses, sovereign_contract_setup_addresses):
db_configs = databases.get_db_configs(
args["deployment_suffix"], args["sequencer_type"]
)

keystore_artifacts = get_keystores_artifacts(plan, args)

# Create the cdk aggoracle config.
aggoracle_config_template = read_file(
src="./templates/sovereign-rollup/cdk-aggkit-config.toml"
)
aggoracle_config_artifact = plan.render_templates(
name="cdk-aggoracle-config-artifact",
config={
"config.toml": struct(
template=aggoracle_config_template,
data=args
| {
"is_cdk_validium": data_availability_package.is_cdk_validium(args),
}
| db_configs
| contract_setup_addresses
| sovereign_contract_setup_addresses,
)
},
)

sovereign_genesis_file = read_file(src=args["sovereign_genesis_file"])
sovereign_genesis_artifact = plan.render_templates(
name="sovereign_genesis",
config={"genesis.json": struct(template=sovereign_genesis_file, data={})},
)

# Start the aggoracle components.
cdk_aggoracle_configs = cdk_aggkit_package.create_cdk_aggoracle_service_config(
args, aggoracle_config_artifact, sovereign_genesis_artifact, keystore_artifacts
)

plan.add_services(
configs=cdk_aggoracle_configs,
description="Starting the cdk aggoracle components",
)

# Start the bridge service.
bridge_config_artifact = create_bridge_config_artifact(
plan,
args,
contract_setup_addresses,
sovereign_contract_setup_addresses,
db_configs,
)
bridge_service_config = zkevm_bridge_package.create_bridge_service_config(
args, bridge_config_artifact, keystore_artifacts.claimtx
)
plan.add_service(
name="sovereign-bridge-service" + args["deployment_suffix"],
config=bridge_service_config,
)


def get_keystores_artifacts(plan, args):
aggoracle_keystore_artifact = plan.store_service_files(
name="aggoracle-keystore",
service_name="contracts" + args["deployment_suffix"],
src="/opt/zkevm/aggoracle.keystore",
)
sovereignadmin_keystore_artifact = plan.store_service_files(
name="sovereignadmin-keystore",
service_name="contracts" + args["deployment_suffix"],
src="/opt/zkevm/sovereignadmin.keystore",
)
claimtx_keystore_artifact = plan.store_service_files(
name="claimtx-keystore",
service_name="contracts" + args["deployment_suffix"],
src="/opt/zkevm/claimtx.keystore",
)
return struct(
aggoracle=aggoracle_keystore_artifact,
sovereignadmin=sovereignadmin_keystore_artifact,
claimtx=claimtx_keystore_artifact,
)


def create_bridge_config_artifact(
plan, args, contract_setup_addresses, sovereign_contract_setup_addresses, db_configs
):
bridge_config_template = read_file(
src="./templates/sovereign-rollup/sovereign-bridge-config.toml"
)
return plan.render_templates(
name="sovereign-bridge-config-artifact",
config={
"bridge-config.toml": struct(
template=bridge_config_template,
data={
"deployment_suffix": args["deployment_suffix"],
"global_log_level": args["global_log_level"],
"l1_rpc_url": args["l1_rpc_url"],
"l2_rpc_name": args["l2_rpc_name"],
"zkevm_l2_keystore_password": args["zkevm_l2_keystore_password"],
# ports
"zkevm_bridge_grpc_port": args["zkevm_bridge_grpc_port"],
"zkevm_bridge_rpc_port": args["zkevm_bridge_rpc_port"],
"zkevm_rpc_http_port": args["zkevm_rpc_http_port"],
}
| contract_setup_addresses
| sovereign_contract_setup_addresses
| db_configs,
)
},
)
14 changes: 14 additions & 0 deletions deploy_sovereign_contracts.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def run(plan, args):
plan.exec(
description="Deploying sovereign contracts on OP Stack",
service_name="contracts" + args["deployment_suffix"],
recipe=ExecRecipe(
command=[
"/bin/sh",
"-c",
"chmod +x {0} && {0}".format(
"/opt/contract-deploy/run-sovereign-setup.sh"
),
]
),
)
4 changes: 4 additions & 0 deletions deploy_zkevm_contracts.star
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ ARTIFACTS = [
"name": "run-l2-contract-setup.sh",
"file": "./templates/contract-deploy/run-l2-contract-setup.sh",
},
{
"name": "run-sovereign-setup.sh",
"file": "./templates/sovereign-rollup/run-sovereign-setup.sh",
},
]


Expand Down
21 changes: 15 additions & 6 deletions input_parser.star
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ DEFAULT_DEPLOYMENT_STAGES = {
}

DEFAULT_IMAGES = {
"agglayer_image": "ghcr.io/agglayer/agglayer:0.2.1-rc.1", # https://github.com/agglayer/agglayer/tags
"agglayer_image": "ghcr.io/agglayer/agglayer:0.2.0-rc.23", # https://github.com/agglayer/agglayer/tags
"cdk_erigon_node_image": "hermeznetwork/cdk-erigon:v2.60.2", # https://hub.docker.com/r/hermeznetwork/cdk-erigon/tags
"cdk_aggkit_image": "jhkimqd/cdk-aggkit:latest", # https://github.com/0xpolygon/cdk/pkgs/container/cdk
"cdk_node_image": "ghcr.io/0xpolygon/cdk:0.5.0-beta10", # https://github.com/0xpolygon/cdk/pkgs/container/cdk
"cdk_validium_node_image": "0xpolygon/cdk-validium-node:0.7.0-cdk", # https://hub.docker.com/r/0xpolygon/cdk-validium-node/tags
"zkevm_bridge_proxy_image": "haproxy:3.1-bookworm", # https://hub.docker.com/_/haproxy/tags
"zkevm_bridge_service_image": "hermeznetwork/zkevm-bridge-service:v0.6.0-RC6", # https://hub.docker.com/r/hermeznetwork/zkevm-bridge-service/tags
"zkevm_bridge_ui_image": "leovct/zkevm-bridge-ui:multi-network", # https://hub.docker.com/r/leovct/zkevm-bridge-ui/tags
"zkevm_contracts_image": "leovct/zkevm-contracts:v8.0.0-fork.12-patch.1", # https://hub.docker.com/repository/docker/leovct/zkevm-contracts/tags
"zkevm_contracts_image": "leovct/zkevm-contracts:v9.0.0-rc.4-pp-fork.12", # https://hub.docker.com/repository/docker/leovct/zkevm-contracts/tags
"zkevm_da_image": "0xpolygon/cdk-data-availability:0.0.11", # https://hub.docker.com/r/0xpolygon/cdk-data-availability/tags
"zkevm_node_image": "hermeznetwork/zkevm-node:v0.7.3", # https://hub.docker.com/r/hermeznetwork/zkevm-node/tags
"zkevm_pool_manager_image": "hermeznetwork/zkevm-pool-manager:v0.1.2", # https://hub.docker.com/r/hermeznetwork/zkevm-pool-manager/tags
Expand Down Expand Up @@ -110,7 +111,7 @@ DEFAULT_STATIC_PORTS = {

# Addresses and private keys of the different components.
# They have been generated using the following command:
# polycli wallet inspect --mnemonic 'lab code glass agree maid neutral vessel horror deny frequent favorite soft gate galaxy proof vintage once figure diary virtual scissors marble shrug drop' --addresses 11 | tee keys.txt | jq -r '.Addresses[] | [.ETHAddress, .HexPrivateKey] | @tsv' | awk 'BEGIN{split("sequencer,aggregator,claimtxmanager,timelock,admin,loadtest,agglayer,dac,proofsigner,l1testing,claimsponsor",roles,",")} {print "# " roles[NR] "\n\"zkevm_l2_" roles[NR] "_address\": \"" $1 "\","; print "\"zkevm_l2_" roles[NR] "_private_key\": \"0x" $2 "\",\n"}'
# polycli wallet inspect --mnemonic 'lab code glass agree maid neutral vessel horror deny frequent favorite soft gate galaxy proof vintage once figure diary virtual scissors marble shrug drop' --addresses 12 | tee keys.txt | jq -r '.Addresses[] | [.ETHAddress, .HexPrivateKey] | @tsv' | awk 'BEGIN{split("sequencer,aggregator,claimtxmanager,timelock,admin,loadtest,agglayer,dac,proofsigner,l1testing,claimsponsor,aggoracle",roles,",")} {print "# " roles[NR] "\n\"zkevm_l2_" roles[NR] "_address\": \"" $1 "\","; print "\"zkevm_l2_" roles[NR] "_private_key\": \"0x" $2 "\",\n"}'
DEFAULT_ACCOUNTS = {
# sequencer
"zkevm_l2_sequencer_address": "0x5b06837A43bdC3dD9F114558DAf4B26ed49842Ed",
Expand Down Expand Up @@ -143,8 +144,15 @@ DEFAULT_ACCOUNTS = {
"zkevm_l2_l1testing_address": "0xfa291C5f54E4669aF59c6cE1447Dc0b3371EF046",
"zkevm_l2_l1testing_private_key": "0x1324200455e437cd9d9dc4aa61c702f06fb5bc495dc8ad94ae1504107a216b59",
# claimsponsor
"zkevm_l2_claimsponsor_address": "0x0b68058E5b2592b1f472AdFe106305295A332A7C",
"zkevm_l2_claimsponsor_private_key": "0x6d1d3ef5765cf34176d42276edd7a479ed5dc8dbf35182dfdb12e8aafe0a4919",
"zkevm_l2_claimsponsor_address": "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266",
"zkevm_l2_claimsponsor_private_key": "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
# AggKit Addresses
"zkevm_l2_aggoracle_address": "0x2Ac2c49Ee3Ac5f663115C86F405Ea855B365D5Ec",
"zkevm_l2_aggoracle_private_key": "0xd65de4634c214d45673528bf55be28fe43b0664c99cc99089ef75a922b3a22fd",
"zkevm_l2_sovereignadmin_address": "0x8281AdB2fC133536ACDC4c923bc573A26f66F260",
"zkevm_l2_sovereignadmin_private_key": "0x45f3ccdaff88ab1b3bb41472f09d5cde7cb20a6cbbc9197fddf64e2f3d67aaf2",
"zkevm_l2_claimtx_address": "0x3754Aa77EE1E8AfB200Ce36a8c943ed8F5AaB7BC",
"zkevm_l2_claimtx_private_key": "0xfa333c42db7bc56277bf67c93ba19e4f414d802ef9886b8b5dc7c450655ae77f",
}

DEFAULT_L1_ARGS = {
Expand Down Expand Up @@ -311,6 +319,7 @@ DEFAULT_PLESS_ZKEVM_NODE_ARGS = {
"trusted_sequencer_node_uri": "zkevm-node-sequencer-001:6900",
"zkevm_aggregator_host": "zkevm-node-aggregator-001",
"genesis_file": "templates/permissionless-node/genesis.json",
"sovereign_genesis_file": "templates/sovereign-genesis.json",
}

DEFAULT_ARGS = (
Expand All @@ -335,7 +344,7 @@ DEFAULT_ARGS = (
# - 'rollup': Transaction data is stored on-chain on L1.
# - 'cdk-validium': Transaction data is stored off-chain using the CDK DA layer and a DAC.
# - 'pessimistic': deploy with pessmistic consensus
"consensus_contract_type": "cdk-validium",
"consensus_contract_type": "pessimistic",
# Additional services to run alongside the network.
# Options:
# - arpeggio
Expand Down
59 changes: 59 additions & 0 deletions lib/cdk_aggkit.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
ports_package = import_module("../src/package_io/ports.star")


def create_cdk_aggoracle_service_config(
args,
config_artifact,
genesis_artifact,
keystore_artifact,
):
cdk_aggoracle_name = "cdk-aggkit" + args["deployment_suffix"]
(ports, public_ports) = get_cdk_aggoracle_ports(args)
service_command = get_cdk_aggoracle_cmd(args)
cdk_aggoracle_service_config = ServiceConfig(
image=args["cdk_aggkit_image"],
ports=ports,
public_ports=public_ports,
files={
"/app": Directory(
artifact_names=[
config_artifact,
genesis_artifact,
keystore_artifact.aggoracle,
keystore_artifact.sovereignadmin,
keystore_artifact.claimtx,
],
),
"/data": Directory(
artifact_names=[],
),
},
entrypoint=["sh", "-c"],
cmd=service_command,
)

return {cdk_aggoracle_name: cdk_aggoracle_service_config}


def get_cdk_aggoracle_ports(args):
ports = {
"rpc": PortSpec(
args["zkevm_cdk_node_port"],
application_protocol="http",
wait=None,
),
}

public_ports = ports_package.get_public_ports(ports, "cdk_node_start_port", args)
return (ports, public_ports)


def get_cdk_aggoracle_cmd(args):
service_command = [
"sleep 20 && cdk-node run "
+ "--cfg=/app/config.toml "
+ "--custom-network-file=/app/genesis.json "
+ "--components=aggoracle,aggsender"
]

return service_command
24 changes: 24 additions & 0 deletions lib/service.star
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,27 @@ def get_l2_rpc_url(plan, args):
l2_rpc_service.ports["ws-rpc"].number,
),
)


def get_sovereign_contract_setup_addresses(plan, args):
extract = {
"sovereign_ger_proxy_addr": "fromjson | .ger_proxy_addr",
"sovereign_bridge_proxy_addr": "fromjson | .bridge_proxy_addr",
"sovereign_rollup_addr": "fromjson | .sovereignRollupContract",
"sovereign_chain_id": "fromjson | .sovereignChainID",
}

exec_recipe = ExecRecipe(
command=["/bin/sh", "-c", "cat /opt/zkevm-contracts/sovereign-rollup-out.json"],
extract=extract,
)
service_name = "contracts"
service_name += args["deployment_suffix"]
result = plan.exec(
description="Getting contract setup addresses from {} service".format(
service_name
),
service_name=service_name,
recipe=exec_recipe,
)
return get_exec_recipe_result(result)
19 changes: 19 additions & 0 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ service_package = import_module("./lib/service.star")
agglayer_package = "./agglayer.star"
cdk_bridge_infra_package = "./cdk_bridge_infra.star"
cdk_central_environment_package = "./cdk_central_environment.star"
cdk_aggkit_package = "./cdk_aggkit.star"
cdk_erigon_package = "./cdk_erigon.star"
databases_package = "./databases.star"
deploy_zkevm_contracts_package = "./deploy_zkevm_contracts.star"
ethereum_package = "./ethereum.star"
optimism_package = "github.com/ethpandaops/optimism-package/[email protected]"
zkevm_pool_manager_package = "./zkevm_pool_manager.star"
deploy_l2_contracts_package = "./deploy_l2_contracts.star"
deploy_sovereign_contracts_package = "./deploy_sovereign_contracts.star"

# Additional service packages.
arpeggio_package = "./src/additional_services/arpeggio.star"
Expand Down Expand Up @@ -149,8 +151,25 @@ def run(plan, args={}):

# Deploy an OP Stack rollup.
if deployment_stages.get("deploy_optimism_rollup", False):
# Deploy OP Stack infrastructure
plan.print("Deploying an OP Stack rollup with args: " + str(op_stack_args))
import_module(optimism_package).run(plan, op_stack_args)
# Deploy Sovereign contracts
plan.print("Deploying sovereign contracts on OP Stack")
import_module(deploy_sovereign_contracts_package).run(plan, args)
# Extract Sovereign contract addresses
sovereign_contract_setup_addresses = (
service_package.get_sovereign_contract_setup_addresses(plan, args)
)
# Deploy AggKit infrastructure + Dedicated Bridge Service
plan.print("Deploying AggKit infrastructure")
central_environment_args = dict(args)
import_module(cdk_aggkit_package).run(
plan,
central_environment_args,
contract_setup_addresses,
sovereign_contract_setup_addresses,
)
else:
plan.print("Skipping the deployment of an Optimism rollup")

Expand Down
4 changes: 3 additions & 1 deletion templates/bridge-infra/bridge-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ FrequencyToMonitorTxs = "5s"
PrivateKey = {Path = "/etc/zkevm/claimtxmanager.keystore", Password = "{{.zkevm_l2_keystore_password}}"}
Enabled = true
RetryInterval = "1s"
RetryNumber = 10
RetryNumber = 10
AuthorizedClaimMessageAddresses = ["0xE34aaF64b29273B7D567FCFc40544c014EEe9970", "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266"]
AreClaimsBetweenL2sEnabled = true
3 changes: 3 additions & 0 deletions templates/contract-deploy/create-keystores.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ create_geth_keystore "agglayer.keystore" "{{.zkevm_l2_agglayer_private_ke
create_geth_keystore "dac.keystore" "{{.zkevm_l2_dac_private_key}}" "{{.zkevm_l2_keystore_password}}"
create_geth_keystore "proofsigner.keystore" "{{.zkevm_l2_proofsigner_private_key}}" "{{.zkevm_l2_keystore_password}}"
create_geth_keystore "claimsponsor.keystore" "{{.zkevm_l2_claimsponsor_private_key}}" "{{.zkevm_l2_keystore_password}}"
create_geth_keystore "aggoracle.keystore" "{{.zkevm_l2_aggoracle_private_key}}" "{{.zkevm_l2_keystore_password}}"
create_geth_keystore "sovereignadmin.keystore" "{{.zkevm_l2_sovereignadmin_private_key}}" "{{.zkevm_l2_keystore_password}}"
create_geth_keystore "claimtx.keystore" "{{.zkevm_l2_claimtx_private_key}}" "{{.zkevm_l2_keystore_password}}"
Loading
Loading