Skip to content

Commit

Permalink
Merge branch 'main' into ci/composite-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
leovct committed May 30, 2024
2 parents 5ee1ee0 + 20029d9 commit 30cc4f6
Show file tree
Hide file tree
Showing 20 changed files with 352 additions and 66 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ jobs:
- name: Deploy zkEVM permissionless node
run: |
# Retrieve genesis file.
kurtosis files download cdk-v1 genesis /tmp
cp /tmp/genesis.json templates/permissionless-node/genesis.json
# Deploy permisionless node.
yq -Y --in-place '.deploy_zkevm_permissionless_node = true' params.yml
kurtosis run --enclave cdk-v1 --args-file params.yml .
yq -Y --in-place '.deploy_zkevm_permissionless_node = false' params.yml # reset
Expand Down Expand Up @@ -189,3 +194,62 @@ jobs:
- name: Monitor verified batches
uses: ./.github/actions/monitor-verified-batches

# Deploy a standalone permisionless node against Sepolia.
permisionless-node:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

# Deploy components.
- name: Only deploy the permisionless node
run: yq -Y --in-place 'with_entries(if .key == "deploy_zkevm_permissionless_node" then .value = true elif .value | type == "boolean" then .value = false else . end)' params.yml

- name: Configure permisionless node parameters
run: |
yq -Y --in-place '.args.l1_rpc_url = "${{ secrets.ALCHEMY_SEPOLIA_RPC_URL }}"' params.yml
yq -Y --in-place '.args.genesis_file = "templates/permissionless-node/test-genesis.json"' params.yml
- name: Deploy the permisionless node
run: kurtosis run --enclave cdk-v1 --args-file params.yml --image-download always .

# Deploy the CDK environment in rollup mode (data availability).
rollup-da-mode:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

# Deploy components.
- name: Set rollup data availability mode
run: yq -Y --in-place '.args.data_availability_mode = "rollup"' params.yml

- name: Deploy Kurtosis CDK package
run: kurtosis run --enclave cdk-v1 --image-download always .

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

# Deploy the CDK environment in cdk-validium mode (data availability).
cdk-validium-da-mode:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

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

# Deploy components.
- name: Set cdk-validium data availability mode
run: yq -Y --in-place '.args.data_availability_mode = "cdk-validium"' params.yml

- name: Deploy Kurtosis CDK package
run: kurtosis run --enclave cdk-v1 --image-download always .

- name: Monitor verified batches
uses: ./.github/actions/monitor-verified-batches
1 change: 1 addition & 0 deletions .github/workflows/security-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
if: github.repository == '0xPolygon/kurtosis-cdk'
steps:
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ claimable-txs.json
proof.json

# default parameters
default-args.yml
input-parser-args.yml
kurtosis-args.yml
params-args.yml

Expand Down
25 changes: 15 additions & 10 deletions cdk_central_environment.star
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
data_availability_package = import_module("./lib/data_availability.star")
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")
Expand Down Expand Up @@ -42,8 +43,7 @@ def run(plan, args):
template=node_config_template,
data=args
| {
"is_cdk_validium": args["zkevm_rollup_consensus"]
== "PolygonValidiumEtrog",
"is_cdk_validium": data_availability_package.is_cdk_validium(args),
}
| db_configs,
)
Expand All @@ -56,24 +56,29 @@ def run(plan, args):
plan, args, node_config_artifact, genesis_artifact
)

# Start the rest of the zkevm node components along with the dac.
# Start the rest of the zkevm node components.
keystore_artifacts = get_keystores_artifacts(plan, args)
zkevm_node_components_configs = (
zkevm_node_package.create_zkevm_node_components_config(
args, node_config_artifact, genesis_artifact, keystore_artifacts
)
)

dac_config_artifact = create_dac_config_artifact(plan, args, db_configs)
dac_config = zkevm_dac_package.create_dac_service_config(
args, dac_config_artifact, keystore_artifacts.dac
)

plan.add_services(
configs=zkevm_node_components_configs | dac_config,
configs=zkevm_node_components_configs,
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)
dac_config = zkevm_dac_package.create_dac_service_config(
args, dac_config_artifact, keystore_artifacts.dac
)
plan.add_services(
configs=dac_config,
description="Starting the DAC",
)


def get_keystores_artifacts(plan, args):
sequencer_keystore_artifact = plan.store_service_files(
Expand Down
17 changes: 16 additions & 1 deletion deploy_zkevm_contracts.star
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
data_availability_package = import_module("./lib/data_availability.star")

ARTIFACTS = [
{
"name": "deploy_parameters.json",
Expand All @@ -24,7 +26,20 @@ def run(plan, args):
template = read_file(src=artifact_cfg["file"])
artifact = plan.render_templates(
name=artifact_cfg["name"],
config={artifact_cfg["name"]: struct(template=template, data=args)},
config={
artifact_cfg["name"]: struct(
template=template,
data=args
| {
"is_cdk_validium": data_availability_package.is_cdk_validium(
args
),
"zkevm_rollup_consensus": data_availability_package.get_consensus_contract(
args
),
},
)
},
)
artifacts.append(artifact)

Expand Down
15 changes: 15 additions & 0 deletions doc-drafts/da-mode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Data Availability Modes in Kurtosis CDK

Kurtosis CDK supports two modes of data availability for deploying blockchain solutions: `rollup` and `cdk-validium`. The choice between these modes depends on your specific requirements for data availability and security. In the future, we would like to support external DA protocols such as Avail, Celestia and Near.

The two options are:

- `rollup`: Transaction data is stored on-chain on Layer 1 (L1). This approach leverages the security of the main L1 chain (e.g. Ethereum) to ensure data integrity and availability.

> In this mode, the components will run the `zkevm_node_image` and the consensus contract will be `PolygonZkEVMEtrog`.
- `cdk-validium`: Transaction data is stored off-chain using a dedicated CDK Data Availability (DA) layer and a Data Availability Committee (DAC). This approach reduces the load on the main chain and can offer improved scalability and lower costs.

> In this mode, the components will run the `cdk_node_image`, the consensus contract will be `PolygonValidiumEtrog` and the CDK DAC will be deployed and configured.
For more detailed information and technical specifications, refer to the [Polygon Knowledge Layer](https://docs.polygon.technology/cdk/spec/validium-vs-rollup/).
3 changes: 0 additions & 3 deletions docs/how-to/migrate/forkid-7-to-9.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ This document shows you how to migrate from fork 7 to fork 9 using the Kurtosis
# The fork id of the new rollup. It indicates the prover (zkROM/executor) version.
- zkevm_rollup_fork_id: 9
+ zkevm_rollup_fork_id: 7
# The consensus contract name of the new rollup.
zkevm_rollup_consensus: PolygonValidiumEtrog
```

3. Now kick-off a full redeploy:
Expand Down
5 changes: 3 additions & 2 deletions input_parser.star
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
DEFAULT_ARGS = {
"deployment_suffix": "-001",
"data_availability_mode": "cdk-validium",
"zkevm_prover_image": "hermeznetwork/zkevm-prover:v6.0.0",
"zkevm_node_image": "0xpolygon/cdk-validium-node:0.6.5-cdk",
"zkevm_node_image": "hermeznetwork/zkevm-node:v0.6.5",
"cdk_node_image": "0xpolygon/cdk-validium-node:0.6.5-cdk",
"zkevm_da_image": "0xpolygon/cdk-data-availability:0.0.7",
"zkevm_contracts_image": "leovct/zkevm-contracts",
"zkevm_agglayer_image": "0xpolygon/agglayer:0.1.3",
Expand Down Expand Up @@ -51,7 +53,6 @@ DEFAULT_ARGS = {
"l1_additional_services": [],
"zkevm_rollup_chain_id": 10101,
"zkevm_rollup_fork_id": 9,
"zkevm_rollup_consensus": "PolygonValidiumEtrog",
"polygon_zkevm_explorer": "https://explorer.private/",
"l1_explorer_url": "https://sepolia.etherscan.io/",
"zkevm_use_gas_token_contract": False,
Expand Down
17 changes: 11 additions & 6 deletions kurtosis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,20 @@ description: |-
# Note: It should be a string.
deployment_suffix: "-001"
# 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.0
# zkevm_prover_image: hermeznetwork/zkevm-prover:v4.0.19
zkevm_node_image: 0xpolygon/cdk-validium-node:0.6.5-cdk
# zkevm_node_image: 0xpolygon/cdk-validium-node:0.5.13-cdk.3
zkevm_node_image: hermeznetwork/zkevm-node:v0.6.5
cdk_node_image: 0xpolygon/cdk-validium-node:0.6.5-cdk
# cdk_node_image: 0xpolygon/cdk-validium-node:0.5.13-cdk.3
zkevm_da_image: 0xpolygon/cdk-data-availability:0.0.7
# zkevm_da_image: 0xpolygon/cdk-data-availability:0.0.6
Expand All @@ -42,7 +50,7 @@ description: |-
zkevm_agglayer_image: 0xpolygon/agglayer:0.1.3
zkevm_bridge_service_image: hermeznetwork/zkevm-bridge-service:v0.4.2
panoptichain_image: minhdvu/panoptichain
# temporary fork https://github.com/praetoriansentry/zkevm-bridge-ui/commit/6eaa899997f70e53947d7b067ff7ae37ef1875f3
zkevm_bridge_ui_image: leovct/zkevm-bridge-ui:multi-network
zkevm_bridge_proxy_image: haproxy:2.9.7
Expand Down Expand Up @@ -120,9 +128,6 @@ description: |-
# The fork id of the new rollup. It indicates the prover (zkROM/executor) version.
zkevm_rollup_fork_id: 9
# The consensus contract name of the new rollup.
zkevm_rollup_consensus: PolygonValidiumEtrog
polygon_zkevm_explorer: https://explorer.private/
l1_explorer_url: https://sepolia.etherscan.io/
Expand Down
31 changes: 31 additions & 0 deletions lib/data_availability.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# The types of data availability (DA) modes supported in Kurtosis CDK.
# In the future, we would like to support external DA protocols such as Avail, Celestia and Near.
DATA_AVAILABILITY_MODES = struct(
# In rollup mode, transaction data is stored on-chain on L1.
rollup="rollup",
# In cdk-validium mode, transaction data is stored off-chain using the CDK DA layer and a DAC.
cdk_validium="cdk-validium",
)

# Map data availability modes to consensus contracts.
CONSENSUS_CONTRACTS = {
DATA_AVAILABILITY_MODES.rollup: "PolygonZkEVMEtrog",
DATA_AVAILABILITY_MODES.cdk_validium: "PolygonValidiumEtrog",
}


def get_node_image(args):
# Map data availability modes to node images.
node_images = {
DATA_AVAILABILITY_MODES.rollup: args["zkevm_node_image"],
DATA_AVAILABILITY_MODES.cdk_validium: args["cdk_node_image"],
}
return node_images.get(args["data_availability_mode"])


def get_consensus_contract(args):
return CONSENSUS_CONTRACTS.get(args["data_availability_mode"])


def is_cdk_validium(args):
return args["data_availability_mode"] == DATA_AVAILABILITY_MODES.cdk_validium
28 changes: 18 additions & 10 deletions lib/service.star
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
data_availability_package = import_module("./data_availability.star")


def get_contract_setup_addresses(plan, args):
extract = {
"zkevm_bridge_address": "fromjson | .polygonZkEVMBridgeAddress",
"zkevm_rollup_address": "fromjson | .rollupAddress",
"zkevm_rollup_manager_address": "fromjson | .polygonRollupManagerAddress",
"zkevm_rollup_manager_block_number": "fromjson | .deploymentRollupManagerBlockNumber",
"zkevm_global_exit_root_address": "fromjson | .polygonZkEVMGlobalExitRootAddress",
"zkevm_global_exit_root_l2_address": "fromjson | .polygonZkEVMGlobalExitRootL2Address",
"pol_token_address": "fromjson | .polTokenAddress",
}
if data_availability_package.is_cdk_validium(args):
extract[
"polygon_data_committee_address"
] = "fromjson | .polygonDataCommitteeAddress"

exec_recipe = ExecRecipe(
command=["/bin/sh", "-c", "cat /opt/zkevm/combined.json"],
extract={
"zkevm_bridge_address": "fromjson | .polygonZkEVMBridgeAddress",
"zkevm_rollup_address": "fromjson | .rollupAddress",
"zkevm_rollup_manager_address": "fromjson | .polygonRollupManagerAddress",
"zkevm_rollup_manager_block_number": "fromjson | .deploymentRollupManagerBlockNumber",
"zkevm_global_exit_root_address": "fromjson | .polygonZkEVMGlobalExitRootAddress",
"zkevm_global_exit_root_l2_address": "fromjson | .polygonZkEVMGlobalExitRootL2Address",
"polygon_data_committee_address": "fromjson | .polygonDataCommitteeAddress",
"pol_token_address": "fromjson | .polTokenAddress",
},
extract=extract,
)
service_name = "contracts"
if "zkevm_rollup_manager_address" in args:
Expand Down
Loading

0 comments on commit 30cc4f6

Please sign in to comment.