Skip to content

Commit

Permalink
feat: attach multiple cdks (#209)
Browse files Browse the repository at this point in the history
* feat: attaching cdks to agglayer

Signed-off-by: Ji Hwan <[email protected]>

* feat: attaching cdk to agglayer contract deployment automation

Signed-off-by: Ji Hwan <[email protected]>

* feat: extract L2 bridge address from contract deployment

Signed-off-by: Ji Hwan <[email protected]>

* feat: change log levels to debug

Signed-off-by: Ji Hwan <[email protected]>

* feat: add agglayer-attach-cdk-params.yml

Signed-off-by: Ji Hwan <[email protected]>

* chore: change configs

Signed-off-by: Ji Hwan <[email protected]>

* chore: change configs

Signed-off-by: Ji Hwan <[email protected]>

* fix: change sender address to the agglayer

Signed-off-by: Ji Hwan <[email protected]>

* fix: always grant aggregator role to agglayer

Signed-off-by: Ji Hwan <[email protected]>

* feat: add dac signature req

Signed-off-by: Ji Hwan <[email protected]>

* style: directly get rollupmanager address from contracts output

Signed-off-by: Ji Hwan <[email protected]>

* fix: point dac address to the newly deployed address

Signed-off-by: Ji Hwan <[email protected]>

* fix: redirect dac to use correct rollup address

Signed-off-by: Ji Hwan <[email protected]>

* fix: cdk bridge genesis block number

Signed-off-by: Ji Hwan <[email protected]>

* fix: bridge genesis block number

Signed-off-by: Ji Hwan <[email protected]>

* feat: add mint_gas_token_on_l1 function withhin contract setup script

Signed-off-by: Ji Hwan <[email protected]>

* fix: deploy_agglayer arg

Signed-off-by: Ji Hwan <[email protected]>

* fix: make grantRole() to agglayer conditional based on deploy_agglayer

Signed-off-by: Ji Hwan <[email protected]>

* chore: cleanup

Signed-off-by: Ji Hwan <[email protected]>

* docs: add deployment step to readme

Signed-off-by: Ji Hwan <[email protected]>

* fix: contract deployment conditionals fix

Signed-off-by: Ji Hwan <[email protected]>

* chore: sort conflicts

Signed-off-by: Ji Hwan <[email protected]>

* chore: cleanup

Signed-off-by: Ji Hwan <[email protected]>

* chore: keep sequencer as zkevm-node for now

Signed-off-by: Ji Hwan <[email protected]>

* fix: bridge service syncing issues

Signed-off-by: Ji Hwan <[email protected]>

* chore: have consistency in params.yml files

Signed-off-by: Ji Hwan <[email protected]>

* fix: erigon agglayer rpc for attaching cdk

Signed-off-by: Ji Hwan <[email protected]>

* chore: fix sequencer_type comment

Signed-off-by: Ji Hwan <[email protected]>

* chore: lint

Signed-off-by: Ji Hwan <[email protected]>

* chore: cleanup + lint

Signed-off-by: Ji Hwan <[email protected]>

* docs: erigon-node rpc for agglayer-config

Signed-off-by: Ji Hwan <[email protected]>

* fix: move deploy_agglayer param within args section

Signed-off-by: Ji Hwan <[email protected]>

* feat: use params for zkevm_rollup_id variable for Erigon

Signed-off-by: Ji Hwan <[email protected]>

* fix: bridge setup to work with L1<->Ly

Signed-off-by: Ji Hwan <[email protected]>

* chore: config changes

Signed-off-by: Ji Hwan <[email protected]>

* chore: clean up agglayer attach params

* chore: clean up

* chore: lint

* chore: change default agglayer-config values for kurtosis

Signed-off-by: Ji Hwan <[email protected]>

* chore: change default agglayer-config values for kurtosis

Signed-off-by: Ji Hwan <[email protected]>

* docs: add agglayer integration docs

Signed-off-by: Ji Hwan <[email protected]>

* docs: tweak attaching rollup docs

Signed-off-by: Ji Hwan <[email protected]>

* ci: attach multiple cdks test

* chore: nit (additional services)

* ci: fix issues

* chore: nit

* fix: rpcs

* fix: wrong param file

* docs: remove redundant flag

Signed-off-by: Ji Hwan <[email protected]>

* ci: remove `--experimental=NO_INSTRUCTIONS_CACHING`

* chore: revert `Level = "debug"`

* Revert "chore: revert `Level = "debug"`"

This reverts commit 7ce196e.

* chore: set `info` log level instead of `debug`

---------

Signed-off-by: Ji Hwan <[email protected]>
Co-authored-by: leovct <[email protected]>
  • Loading branch information
jhkimqd and leovct authored Aug 20, 2024
1 parent e6d1d24 commit 7d9e817
Show file tree
Hide file tree
Showing 21 changed files with 522 additions and 109 deletions.
144 changes: 87 additions & 57 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,57 @@ jobs:
# Deploy the CDK environment with cdk-erigon, serving as the sequencer.
# Set up the cdk-node for the remaining components.
# Additionally, deploy cdk-erigon and zkevm-node as permissionless nodes or RPCs.
- name: Deploy Kurtosis CDK package
- name: Deploy L1 chain and a first CDK L2 chain (erigon)
run: |
kurtosis run \
--enclave=${{ env.ENCLAVE_NAME }} \
--show-enclave-inspect=false \
--args-file=params.yml \
. \
'{
"deploy_cdk_erigon_node": true,
"args": {
"sequencer_type": "erigon",
"l1_seconds_per_slot": 1,
"additional_services": [
"pless_zkevm_node",
"tx_spammer"
]
}
}'
yq -Y --in-place '.args.additional_services = ["pless_zkevm_node", "tx_spammer"]' params.yml
kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --show-enclave-inspect=false --args-file=params.yml .
- name: Inspect enclave
run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }}

- name: Monitor verified batches (CDK Erigon Permissionless RPC)
- name: Attach a second CDK L2 chain (erigon)
run: |
yq -Y --in-place '.args.additional_services = ["pless_zkevm_node", "tx_spammer"]' agglayer-attach-cdk-params.yml
kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --show-enclave-inspect=false --args-file=agglayer-attach-cdk-params.yml .
- name: Inspect enclave
run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }}

- name: Update the agglayer config
run: |
# Download the agglayer config file.
kurtosis files download ${{ env.ENCLAVE_NAME }} agglayer-config-artifact
cd agglayer-config-artifact
# Update the config by adding the rpc and proof signer of the second chain.
tomlq -Y --toml-output --in-place '.FullNodeRPCs += {"2": "http://cdk-erigon-node-002:8123"}' agglayer-config.toml
proof_signer_2="$(yq --raw-output .args.zkevm_l2_sequencer_address ../agglayer-attach-cdk-params.yml)"
tomlq -Y --toml-output --arg proofSigner2 "$proof_signer_2" --in-place '.ProofSigners += {"2": $proofSigner2}' agglayer-config.toml
# Replace the agglayer config.
agglayer_container_id="$(docker ps --filter "name=zkevm-agglayer" --format "{{.ID}}")"
docker cp agglayer-config.toml "$agglayer_container_id:/etc/zkevm/agglayer-config.toml"
# Restart the agglayer service.
kurtosis service stop ${{ env.ENCLAVE_NAME }} zkevm-agglayer-001
kurtosis service start ${{ env.ENCLAVE_NAME }} zkevm-agglayer-001
- name: Monitor verified batches of the first L2 chain (CDK Erigon Permissionless RPC)
working-directory: .github/scripts
run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-node-001 http-rpc)"

- name: Monitor verified batches (zkEVM Node Permissionless RPC)
- name: Monitor verified batches of the first L2 chain (zkEVM Node Permissionless RPC)
working-directory: .github/scripts
run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} zkevm-node-rpc-pless-001 http-rpc)"

- name: Monitor verified batches of the second L2 chain (CDK Erigon Permissionless RPC)
working-directory: .github/scripts
run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-node-002 http-rpc)"

- name: Monitor verified batches of the second L2 chain (zkEVM Node Permissionless RPC)
working-directory: .github/scripts
run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} zkevm-node-rpc-pless-002 http-rpc)"

zkevm:
runs-on: ubuntu-latest
timeout-minutes: 20
Expand All @@ -70,38 +91,63 @@ jobs:
# Deploy the CDK environment with zkevm-node, serving as the sequencer.
# Also set up the zkevm-node for the remaining components.
# Additionally, deploy zkevm-node as permissionless node or RPC.
- name: Deploy Kurtosis CDK package
- name: Deploy L1 chain and a first CDK L2 chain (zkevm)
run: |
yq -Y --in-place '.deploy_cdk_erigon_node = false' params.yml
yq -Y --in-place '.args.sequencer_type = "zkevm"' params.yml
yq -Y --in-place '.args.additional_services = ["pless_zkevm_node", "tx_spammer"]' params.yml
kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --show-enclave-inspect=false --args-file=params.yml .
- name: Inspect enclave
run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }}

- name: Attach a second CDK L2 chain (erigon)
run: |
kurtosis run \
--enclave=${{ env.ENCLAVE_NAME }} \
--show-enclave-inspect=false \
--args-file=params.yml \
. \
'{
"deploy_cdk_erigon_node": false,
"args": {
"sequencer_type": "zkevm",
"l1_seconds_per_slot": 1,
"additional_services": [
"pless_zkevm_node",
"tx_spammer"
]
}
}'
yq -Y --in-place '.args.additional_services = ["pless_zkevm_node", "tx_spammer"]' agglayer-attach-cdk-params.yml
kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --show-enclave-inspect=false --args-file=agglayer-attach-cdk-params.yml .
- name: Inspect enclave
run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }}

- name: Monitor verified batches (zkEVM Node Trusted RPC)
- name: Update the agglayer config
run: |
# Download the agglayer config file.
kurtosis files download ${{ env.ENCLAVE_NAME }} agglayer-config-artifact
cd agglayer-config-artifact
# Update the config by adding the rpc and proof signer of the second chain.
tomlq -Y --toml-output --in-place '.FullNodeRPCs += {"2": "http://cdk-erigon-node-002:8123"}' agglayer-config.toml
proof_signer_2="$(yq --raw-output .args.zkevm_l2_sequencer_address ../agglayer-attach-cdk-params.yml)"
tomlq -Y --toml-output --arg proofSigner2 "$proof_signer_2" --in-place '.ProofSigners += {"2": $proofSigner2}' agglayer-config.toml
# Replace the agglayer config.
agglayer_container_id="$(docker ps --filter "name=zkevm-agglayer" --format "{{.ID}}")"
docker cp agglayer-config.toml "$agglayer_container_id:/etc/zkevm/agglayer-config.toml"
# Restart the agglayer service.
kurtosis service stop ${{ env.ENCLAVE_NAME }} zkevm-agglayer-001
kurtosis service start ${{ env.ENCLAVE_NAME }} zkevm-agglayer-001
- name: Monitor verified batches of the first L2 chain (zkEVM Node Trusted RPC)
working-directory: .github/scripts
run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} zkevm-node-rpc-001 http-rpc)"

- name: Monitor verified batches (zkEVM Node Permissionless RPC)
- name: Monitor verified batches of the first L2 chain (zkEVM Node Permissionless RPC)
working-directory: .github/scripts
run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} zkevm-node-rpc-pless-001 http-rpc)"

# TODO(nit): Deploy a CDK Erigon Permissionless RPC and check that it can sync.

- name: Monitor verified batches of the second L2 chain (CDK Erigon Permissionless RPC)
working-directory: .github/scripts
run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-node-002 http-rpc)"

- name: Monitor verified batches of the second L2 chain (zkEVM Node Permissionless RPC)
working-directory: .github/scripts
run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} zkevm-node-rpc-pless-002 http-rpc)"

# TODO(nit): Deploy a CDK Erigon Permissionless RPC and check that it can sync.

additional_services:
runs-on: ubuntu-latest
timeout-minutes: 20
Expand All @@ -111,26 +157,10 @@ jobs:
- name: Install Kurtosis CDK tools
uses: ./.github/actions/setup-kurtosis-cdk

# Deploy the default CDK environment with all additional services enabled.
- name: Deploy Kurtosis CDK package
- name: Deploy Kurtosis CDK package with additional services
run: |
kurtosis run \
--enclave=${{ env.ENCLAVE_NAME }} \
--show-enclave-inspect=false \
--args-file=params.yml \
. \
'{
"args": {
"l1_seconds_per_slot": 1,
"additional_services": [
"blockscout",
"blutgang",
"panoptichain",
"pless_zkevm_node",
"prometheus_grafana",
]
}
}'
yq -Y --in-place '.args.additional_services = ["blockscout", "blutgang", "pless_zkevm_node", "prometheus_grafana", "tx_spammer"]' params.yml
kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --show-enclave-inspect=false --args-file=params.yml .
- name: Inspect enclave
run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ Below is a list of services available for deployment using Kurtosis:
| `blutgang` | Deploys [Blutgang](https://github.com/rainshowerLabs/blutgang), an Ethereum load balancer that distributes network traffic evenly across multiple nodes to ensure high availability. |
| `pless_zkevm_node` | Deploys a permissionless [zkevm-node](https://github.com/0xPolygonHermez/zkevm-node). |
| `prometheus_grafana` | Deploys [Prometheus](https://github.com/prometheus/prometheus) and [Grafana](https://github.com/grafana/grafana), two powerful monitoring tools that collect and visualize metrics for blockchain infrastructure health and performance. Additionally, it deploys [Panoptichain](https://github.com/0xPolygon/panoptichain), enhancing monitoring capabilities by allowing users to observe on-chain data and generate detailed Polygon CDK blockchain metrics. |
| `tx_spammer` | Deploys a transaction spammer. |

Here is a simple example that deploys Blockscout, Prometheus, Grafana, and Panoptichain:

Expand Down
170 changes: 170 additions & 0 deletions agglayer-attach-cdk-params.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
---
# Deployment parameters.
# The deployment process is divided into various stages.

# Deploy local L1.
deploy_l1: false

# 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 cdk-erigon node.
deploy_cdk_erigon_node: true

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

# The type of the sequencer to deploy.
# Options:
# - 'erigon': Use the new sequencer (https://github.com/0xPolygonHermez/cdk-erigon).
# - 'zkevm': Use the legacy sequencer (https://github.com/0xPolygonHermez/zkevm-node).
sequencer_type: erigon

# Deploy agglayer.
deploy_agglayer: false

# 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

# Additional services to run alongside the network.
additional_services: []

# Docker images and repositories used to spin up services.
zkevm_prover_image: hermeznetwork/zkevm-prover:v6.0.3-RC20
zkevm_node_image: hermeznetwork/zkevm-node:v0.7.0
cdk_validium_node_image: 0xpolygon/cdk-validium-node:0.7.0-cdk
cdk_node_image: ghcr.io/0xpolygon/cdk:0.0.9
zkevm_da_image: 0xpolygon/cdk-data-availability:0.0.7
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:main
zkevm_bridge_service_image: hermeznetwork/zkevm-bridge-service:v0.5.0-RC9
zkevm_bridge_ui_image: leovct/zkevm-bridge-ui:multi-network
zkevm_bridge_proxy_image: haproxy:2.9.9-bookworm
zkevm_sequence_sender_image: hermeznetwork/zkevm-sequence-sender:v0.2.0-RC4
cdk_erigon_node_image: hermeznetwork/cdk-erigon:2.0.0-beta15
zkevm_pool_manager_image: hermeznetwork/zkevm-pool-manager:v0.1.0-RC1

# 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
zkevm_pool_manager_port: 8545

# 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: "0xF4ee37aAc3ccd6B71A4a795700b065d2CA479581"
zkevm_l2_sequencer_private_key: "39fa0e0993fdde70f16434fe5085cc7992bb82aa8acc765acc9f8c79d7751350"

zkevm_l2_aggregator_address: "0x78DE6D4fD4848d7A79cBB5117FED025e2d482bED"
zkevm_l2_aggregator_private_key: "a624aee34e44e828a03bd8ecbeca5807d9187351e6772995b82c15f5610a4cf2"

zkevm_l2_claimtxmanager_address: "0xf909b5F902D19CACB8B06c037bEf0a5345E99331"
zkevm_l2_claimtxmanager_private_key: "410affbfff4ba53a8784d3c71f983feeb410d3be0e4f7fec4dba1612bbcc4acf"

zkevm_l2_timelock_address: "0x901b68102f6C695D62692499EB92e2B02E69A106"
zkevm_l2_timelock_private_key: "58397f0a1789f1d97cb9d9eb986fb05831d18b410b496d7baf66bac9baa7c952"

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

zkevm_l2_loadtest_address: "0x2d1bd6e35fD386066fDebbf54eb75B436DFa93b4"
zkevm_l2_loadtest_private_key: "c63cd87974fc7742a5f92df58e365517e4ef134864cd8b1d600d1fdf3d3d5049"

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

zkevm_l2_dac_address: "0xfA2542aca48930aae82C9291f1F029a189C6921b"
zkevm_l2_dac_private_key: "3d7ca1abd8651954b6d060e06c2d2cee72cb95252f2ec48c0034c3fb078eecf1"

zkevm_l2_proofsigner_address: "0x101026E7dADbDd880Bef32884eb63A414C939bb6"
zkevm_l2_proofsigner_private_key: "f46b741e1571a2186b7f4f0a9c6dc25697b36eabbe7ea03da3a3f1b2d060b56c"

# 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/ethpandaops/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: 20202

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

# If erigon is being used as the sequencer, this flag will enable a stateless executor to verify the execution of the batches.
erigon_strict_mode: true

# The address of the rollup manager contract deployer on L1.
zkevm_rollup_manager_deployer: "0xE34aaF64b29273B7D567FCFc40544c014EEe9970"
zkevm_rollup_manager_deployer_private_key: "0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625"
rollup_manager_address: "0x2F50ef6b8e8Ee4E579B17619A92dE3E2ffbD8AD2"
# The address of the L2 gas token.
zkevm_gas_token_address: "0xEdE9cf798E0fE25D35469493f43E88FeA4a5da0E"
# The rollup type ID.
zkevm_rollup_type_id: "1"
# The rollup ID. This should increment by 1 with each additional CDKs being created using the rollup manager contract.
zkevm_rollup_id: 2

# 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
Loading

0 comments on commit 7d9e817

Please sign in to comment.