Skip to content

Commit

Permalink
feat: cdk-erigon sequencer (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
cffls committed Jun 13, 2024
1 parent 6e1650c commit 33e0681
Show file tree
Hide file tree
Showing 28 changed files with 729 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
#!/bin/bash

# This script monitors the verification progress of zkEVM batches.
# Usage: ./batch_verification_monitor <verified_batches_target> <timeout>

# Check if the required arguments are provided.
if [ "$#" -lt 2 ]; then
echo "Usage: $0 <verified_batches_target> <timeout> [rpc_service]"
exit 1
fi

# The number of batches to be verified.
verified_batches_target="$1"

# The script timeout (in seconds).
timeout="$2"

# Name of RPC service to query
rpc_service="$3"

if [[ -z "$rpc_service" ]]; then
rpc_service="zkevm-node-rpc-001"
fi

start_time=$(date +%s)
end_time=$((start_time + timeout))

rpc_url="$(kurtosis port print cdk-v1 zkevm-node-rpc-001 http-rpc)"
rpc_url="$(kurtosis port print cdk-v1 $rpc_service http-rpc)"
while true; do
verified_batches="$(cast to-dec "$(cast rpc --rpc-url "$rpc_url" zkevm_verifiedBatchNumber | sed 's/"//g')")"
echo "[$(date '+%Y-%m-%d %H:%M:%S')] Verified Batches: $verified_batches"
Expand Down
26 changes: 25 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
steps:
- run: true

# Deploy the CDK environment in one step, with the gas token feature enabled.
# Deploy the CDK environment in one step.
monolithic:
needs: authorize
runs-on: ubuntu-latest
Expand Down Expand Up @@ -119,6 +119,12 @@ jobs:
kurtosis run --enclave cdk-v1 --args-file params.yml .
yq -Y --in-place '.deploy_zkevm_permissionless_node = false' params.yml # reset
- name: Deploy CDK erigon node
run: |
yq -Y --in-place '.deploy_cdk_erigon_node = true' params.yml
kurtosis run --enclave cdk-v1 --args-file params.yml .
yq -Y --in-place '.deploy_cdk_erigon_node = false' params.yml # reset
- name: Deploy observability stack
run: |
yq -Y --in-place '.deploy_observability = true' params.yml
Expand Down Expand Up @@ -301,3 +307,21 @@ jobs:

- name: Monitor verified batches
uses: ./.github/actions/monitor-cdk-verified-batches

# Deploy the CDK environment with cdk-erigon as a sequencer.
cdk-erigon-sequencer:
needs: authorize
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}

- name: Install Kurtosis CDK tools
uses: ./.github/actions/setup-kurtosis-cdk

- name: Deploy Kurtosis CDK package
run: kurtosis run --enclave cdk-v1 --args-file cdk-erigon-sequencer-params.yal --image-download always .

- name: Monitor verified batches
uses: ./.github/actions/monitor-cdk-verified-batches
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ kurtosis clean --all
kurtosis run --enclave cdk-v1 --args-file params.yml --image-download always .
```

The command above launches deploys a CDK stack using [zkevm-node](https://github.com/0xPolygonHermez/zkevm-node) as the sequencer. Alternatively, to launch a CDK stack using [cdk-erigon](https://github.com/0xPolygonHermez/cdk-erigon) as a sequencer, you can run the following command.

```bash
kurtosis run --enclave cdk-v1 --args-file cdk-erigon-sequencer-params.yal --image-download always .
```

Let's do a simple L2 RPC test call.

First, you will need to figure out which port Kurtoiss is using for the RPC. You can get a general feel for the entire network layout by running the following command:
Expand Down
183 changes: 183 additions & 0 deletions cdk-erigon-sequencer-params.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
---
# Deployment parameters.
# The deployment process is divided into various stages.

# Deploy local L1.
deploy_l1: true

# Deploy zkevm contracts on L1 (and also fund accounts).
deploy_zkevm_contracts_on_l1: true

# Deploy zkevm node and cdk peripheral databases.
deploy_databases: true

# Deploy cdk central/trusted environment.
deploy_cdk_central_environment: true

# Deploy cdk/bridge infrastructure.
deploy_cdk_bridge_infra: true

# Deploy permissionless node.
deploy_zkevm_permissionless_node: false

# Deploy cdk-erigon node.
deploy_cdk_erigon_node: true

# Deploy observability stack.
deploy_observability: true

# Deploy Blockscout stack.
deploy_l2_blockscout: false

# Deploy eth load balancer.
deploy_blutgang: false

# Apply workload to the different components of the CDK stack.
apply_workload: false

args:
# Suffix appended to service names.
# Note: It should be a string.
deployment_suffix: "-001"

# Sequence type. Choose from ["erigon", "zkevm-node"]
sequencer_type: "erigon"
# The type of data availability to use.
# Options:
# - '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.
# In the future, we would like to support external DA protocols such as Avail, Celestia and Near.
data_availability_mode: cdk-validium

# Docker images and repositories used to spin up services.
zkevm_prover_image: hermeznetwork/zkevm-prover:v6.0.3-RC9
# zkevm_prover_image: hermeznetwork/zkevm-prover:v4.0.19
zkevm_node_image: hermeznetwork/zkevm-node:v0.6.7
cdk_node_image: 0xpolygon/cdk-validium-node:0.6.7-cdk

zkevm_da_image: 0xpolygon/cdk-data-availability:0.0.7
# zkevm_da_image: 0xpolygon/cdk-data-availability:0.0.6
zkevm_contracts_image: leovct/zkevm-contracts # the tag is automatically replaced by the value of /zkevm_rollup_fork_id/

# zkevm_agglayer_image: 0xpolygon/agglayer:0.1.3
zkevm_agglayer_image: ghcr.io/agglayer/agglayer-rs:0.1.0
zkevm_bridge_service_image: hermeznetwork/zkevm-bridge-service:v0.4.2
cdk_erigon_node_image: hermeznetwork/cdk-erigon:v1.1.3
panoptichain_image: minhdvu/panoptichain
zkevm_bridge_ui_image: leovct/zkevm-bridge-ui:multi-network
zkevm_bridge_proxy_image: haproxy:2.9.7
workload_image: leovct/workload:0.0.1
zkevm_sequence_sender_image: hermeznetwork/zkevm-sequence-sender:v0.2.0-RC5
toolbox_image: leovct/toolbox:0.0.1

# Port configuration.
zkevm_hash_db_port: 50061
zkevm_executor_port: 50071
zkevm_aggregator_port: 50081
zkevm_pprof_port: 6060
zkevm_prometheus_port: 9091
zkevm_data_streamer_port: 6900
zkevm_rpc_http_port: 8123
zkevm_rpc_ws_port: 8133
zkevm_bridge_rpc_port: 8080
zkevm_bridge_grpc_port: 9090
zkevm_bridge_ui_port: 80
zkevm_agglayer_port: 4444
zkevm_dac_port: 8484
blockscout_public_port: 50101

# 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 9 | tee keys.txt | jq -r '.Addresses[] | [.ETHAddress, .HexPrivateKey] | @tsv' | awk 'BEGIN{split("sequencer,aggregator,claimtxmanager,timelock,admin,loadtest,agglayer,dac,proofsigner",roles,",")} {print "zkevm_l2_" roles[NR] "_address: \"" $1 "\""; print "zkevm_l2_" roles[NR] "_private_key: \"0x" $2 "\"\n"}'
zkevm_l2_sequencer_address: "0x5b06837A43bdC3dD9F114558DAf4B26ed49842Ed"
zkevm_l2_sequencer_private_key: "0x183c492d0ba156041a7f31a1b188958a7a22eebadca741a7fe64436092dc3181"

zkevm_l2_aggregator_address: "0xCae5b68Ff783594bDe1b93cdE627c741722c4D4d"
zkevm_l2_aggregator_private_key: "0x2857ca0e7748448f3a50469f7ffe55cde7299d5696aedd72cfe18a06fb856970"

zkevm_l2_claimtxmanager_address: "0x5f5dB0D4D58310F53713eF4Df80ba6717868A9f8"
zkevm_l2_claimtxmanager_private_key: "0x8d5c9ecd4ba2a195db3777c8412f8e3370ae9adffac222a54a84e116c7f8b934"

zkevm_l2_timelock_address: "0x130aA39Aa80407BD251c3d274d161ca302c52B7A"
zkevm_l2_timelock_private_key: "0x80051baf5a0a749296b9dcdb4a38a264d2eea6d43edcf012d20b5560708cf45f"

zkevm_l2_admin_address: "0xE34aaF64b29273B7D567FCFc40544c014EEe9970"
zkevm_l2_admin_private_key: "0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625"

zkevm_l2_loadtest_address: "0x81457240ff5b49CaF176885ED07e3E7BFbE9Fb81"
zkevm_l2_loadtest_private_key: "0xd7df6d64c569ffdfe7c56e6b34e7a2bdc7b7583db74512a9ffe26fe07faaa5de"

zkevm_l2_agglayer_address: "0x351e560852ee001d5D19b5912a269F849f59479a"
zkevm_l2_agglayer_private_key: "0x1d45f90c0a9814d8b8af968fa0677dab2a8ff0266f33b136e560fe420858a419"

zkevm_l2_dac_address: "0x5951F5b2604c9B42E478d5e2B2437F44073eF9A6"
zkevm_l2_dac_private_key: "0x85d836ee6ea6f48bae27b31535e6fc2eefe056f2276b9353aafb294277d8159b"

zkevm_l2_proofsigner_address: "0x7569cc70950726784c8D3bB256F48e43259Cb445"
zkevm_l2_proofsigner_private_key: "0x77254a70a02223acebf84b6ed8afddff9d3203e31ad219b2bf900f4780cf9b51"

# Keystore password.
zkevm_l2_keystore_password: pSnv6Dh5s9ahuzGzH9RoCDrKAMddaX3m

## L1 configuration.
l1_chain_id: 271828
l1_preallocated_mnemonic: code code code code code code code code code code code quality
l1_funding_amount: 100ether
l1_rpc_url: http://el-1-geth-lighthouse:8545
l1_ws_url: ws://el-1-geth-lighthouse:8546
# https://github.com/kurtosis-tech/ethereum-package/tree/main?tab=readme-ov-file#configuration
l1_additional_services: [
# blockscout, # block explorer
# dora, # beaconchain explorer
# el_forkmon, # fork monitor tool
]
l1_preset: minimal
l1_seconds_per_slot: 1

## Rollup configuration.

# The chain id of the new rollup.
zkevm_rollup_chain_id: 10101

# The fork id of the new rollup. It indicates the prover (zkROM/executor) version.
zkevm_rollup_fork_id: 9

# The address of the rollup manager contract on L1.
# If specified, the rollup data will be retrieved from this contract instead of using the contracts service.
# zkevm_rollup_manager_address: ""
# # The block number at which the rollup manager contract was deployed.
# zkevm_rollup_manager_block_number: 0
# # The address of the global exit root contract on L2.
# zkevm_global_exit_root_l2_address: ""
# # The address of the Polygon data committee contract on L1.
# polygon_data_committee_address: ""

polygon_zkevm_explorer: https://explorer.private/
l1_explorer_url: https://sepolia.etherscan.io/

# If this is true, we will automatically deploy an ERC20 contract on
# L1 to be used at the gasTokenAddress
zkevm_use_gas_token_contract: false

## Permissionless node configuration.
trusted_sequencer_node_uri: zkevm-node-sequencer-001:6900
zkevm_aggregator_host: zkevm-node-aggregator-001
genesis_file: templates/permissionless-node/genesis.json

## Tools versions
polycli_version: v0.1.42

## Workload configuration.
workload_commands: [
"polycli_loadtest_on_l2.sh t", # eth transfers
"polycli_loadtest_on_l2.sh 2", # erc20 transfers
"polycli_loadtest_on_l2.sh 7", # erc721 mints
"polycli_loadtest_on_l2.sh v3", # uniswapv3 swaps
"polycli_rpcfuzz_on_l2.sh", # rpc calls
"bridge.sh", # bridge tokens l1 -> l2 and l2 -> l1
]

## ETH Load balancer configuration.
blutgang_image: makemake1337/blutgang:0.3.5
blutgang_rpc_port: 55555
blutgang_admin_port: 55556
2 changes: 1 addition & 1 deletion cdk_blutgang.star
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def run(plan, args):
)

zkevm_sequencer_service = plan.get_service(
name="zkevm-node-sequencer" + args["deployment_suffix"]
name=args["sequencer_name"] + args["deployment_suffix"]
)
zkevm_sequencer_http_url = "http://{}:{}".format(
zkevm_sequencer_service.ip_address, zkevm_sequencer_service.ports["rpc"].number
Expand Down
6 changes: 5 additions & 1 deletion cdk_bridge_infra.star
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def create_agglayer_config_artifact(plan, args, contract_setup_addresses, db_con
"zkevm_rpc_http_port": args["zkevm_rpc_http_port"],
"zkevm_agglayer_port": args["zkevm_agglayer_port"],
"zkevm_prometheus_port": args["zkevm_prometheus_port"],
"l2_rpc_name": args["l2_rpc_name"],
}
| contract_setup_addresses
| db_configs,
Expand All @@ -93,6 +94,7 @@ def create_bridge_config_artifact(plan, args, contract_setup_addresses, db_confi
data={
"deployment_suffix": args["deployment_suffix"],
"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"],
Expand Down Expand Up @@ -129,7 +131,9 @@ def create_reverse_proxy_config_artifact(plan, args):
)

l1rpc_service = plan.get_service("el-1-geth-lighthouse")
l2rpc_service = plan.get_service(name="zkevm-node-rpc" + args["deployment_suffix"])
l2rpc_service = plan.get_service(
name=args["l2_rpc_name"] + args["deployment_suffix"]
)
bridge_service = plan.get_service(
name="zkevm-bridge-service" + args["deployment_suffix"]
)
Expand Down
14 changes: 14 additions & 0 deletions cdk_central_environment.star
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ service_package = import_module("./lib/service.star")
zkevm_dac_package = import_module("./lib/zkevm_dac.star")
zkevm_node_package = import_module("./lib/zkevm_node.star")
zkevm_prover_package = import_module("./lib/zkevm_prover.star")
zkevm_sequence_sender_package = import_module("./lib/zkevm_sequence_sender.star")
databases = import_module("./databases.star")


Expand Down Expand Up @@ -63,11 +64,24 @@ def run(plan, args):
args, node_config_artifact, genesis_artifact, keystore_artifacts
)
)

plan.add_services(
configs=zkevm_node_components_configs,
description="Starting the rest of the zkevm node components",
)

if args["sequencer_type"] == "erigon":
sequence_sender_config = (
zkevm_sequence_sender_package.create_zkevm_sequence_sender_config(
plan, args, genesis_artifact, keystore_artifacts.sequencer
)
)

plan.add_services(
configs=sequence_sender_config,
description="Starting the rest of the zkevm node components",
)

# Start the DAC if in validium mode.
if data_availability_package.is_cdk_validium(args):
dac_config_artifact = create_dac_config_artifact(plan, args, db_configs)
Expand Down
Loading

0 comments on commit 33e0681

Please sign in to comment.