Skip to content

Commit

Permalink
feat: compare kurtosis-cdk configs with default configs (#56)
Browse files Browse the repository at this point in the history
* feat: track kurtosis-cdk config changes

* chore: nit

* fix: go cache path

* same

* chore: update dump default api

* chore: update dump current api

* chore: update compare api

* chore: nit

* chore: find missign and unnecessary keys

* chore: use cdk-validium instead of zkevm-node dependency

* feat: improve script

* ci: update monolithic part

* chore: clean up

* feat: also store diffs

* chore: remove `_source` from prover config

* chore: update `go.sum`

* chore: nit

* fix: sed cmd to work for ubuntu

* chore: nit

* chore: show diffs for files other than toml and json

* feat: dump zkevm bridge service default config

* chore: clean up
  • Loading branch information
leovct authored Apr 23, 2024
1 parent fd076bb commit 7a31545
Show file tree
Hide file tree
Showing 11 changed files with 2,020 additions and 80 deletions.
46 changes: 44 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@ concurrency:

env:
CHECK_VERIFIED_BATCHES_TIMEOUT_MINUTES: 10
GO_VERSION: "1.21"

jobs:
# Deploy the CDK environment in one step, with the gas token feature enabled.
monolithic_cdk:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: scripts/zkevm-config-diff/go.sum

# Install tools.
- name: Install kurtosis
Expand All @@ -41,7 +46,6 @@ jobs:
- name: Deploy Kurtosis CDK package
run: kurtosis run --enclave cdk-v1 --args-file params.yml --image-download always .

# Check that batches are being verified.
- name: Check that batches are being verified
run: |
timeout_minutes="${CHECK_VERIFIED_BATCHES_TIMEOUT_MINUTES}"
Expand All @@ -67,11 +71,33 @@ jobs:
sleep 10
done
# Compare configs.
- name: Dump configs
working-directory: ./scripts/zkevm-config-diff
run: |
mkdir -p default-configs kurtosis-cdk-configs
sh zkevm_config.sh dump default ./default-configs
echo
sh zkevm_config.sh dump kurtosis-cdk ./kurtosis-cdk-configs
- name: Compare configs
working-directory: ./scripts/zkevm-config-diff
run: sh zkevm_config.sh compare configs ./default-configs ./kurtosis-cdk-configs

- name: Diff configs
working-directory: ./scripts/zkevm-config-diff
run: diff -r ./default-configs ./kurtosis-cdk-configs || true


# Deploy the CDK environment incrementally, stage by stage.
incremental_cdk:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: scripts/zkevm-config-diff/go.sum

# Install tools.
- name: Install kurtosis
Expand Down Expand Up @@ -140,7 +166,6 @@ jobs:
kurtosis run --enclave cdk-v1 --args-file params.yml .
yq -Y --in-place '.deploy_observability = false' params.yml # reset
# Check that batches are being verified.
- name: Check that batches are being verified
run: |
timeout_minutes="${CHECK_VERIFIED_BATCHES_TIMEOUT_MINUTES}"
Expand All @@ -165,3 +190,20 @@ jobs:
sleep 10
done
# Compare configs.
- name: Dump configs
working-directory: scripts/zkevm-config-diff
run: |
mkdir default-configs kurtosis-cdk-configs
sh zkevm_config.sh dump default ./default-configs
echo
sh zkevm_config.sh dump kurtosis-cdk ./kurtosis-cdk-configs
- name: Compare configs
working-directory: scripts/zkevm-config-diff
run: sh zkevm_config.sh compare configs ./default-configs ./kurtosis-cdk-configs

- name: Diff configs
working-directory: scripts/zkevm-config-diff
run: diff -r ./default-configs ./kurtosis-cdk-configs || true
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ cast rpc zkevm_verifiedBatchNumber

If the number of verified batches is increasing, then it means the system works properly.

To access the `zkevm-bridge` user interface, open this URL in your web browser.

```bash
open $(kurtosis port print cdk-v1 zkevm-bridge-proxy-001 bridge-interface)
```

When everything is done, you might want to clean up with this command which stops everything and deletes it.

```bash
Expand Down
106 changes: 47 additions & 59 deletions cdk_bridge_infra.star
Original file line number Diff line number Diff line change
Expand Up @@ -39,43 +39,49 @@ def run(plan, args):
)

# Start the bridge UI.
l1_el_1_service = plan.get_service("el-1-geth-lighthouse")
# Note: We do not rely on args["l1_rpc_url"] because macOS browser can not resolve hostnames.
l1_rpc_url = "http://{}:{}".format(
l1_el_1_service.ip_address, l1_el_1_service.ports["rpc"].number
bridge_ui_config_artifact = create_bridge_ui_config_artifact(
plan, args, contract_setup_addresses
)
zkevm_bridge_package.start_bridge_ui(plan, args, bridge_ui_config_artifact)

zkevm_node_rpc_service = plan.get_service(
name="zkevm-node-rpc" + args["deployment_suffix"]
)
# Note: Use `.ip_address` instead of `.hostname` to make it work on macOS.
zkevm_rpc_url = "http://{}:{}".format(
zkevm_node_rpc_service.ip_address,
zkevm_node_rpc_service.ports["http-rpc"].number,
)
# Start the bridge UI reverse proxy.
proxy_config_artifact = create_reverse_proxy_config_artifact(plan, args)
zkevm_bridge_package.start_reverse_proxy(plan, args, proxy_config_artifact)

bridge_service = bridge_infra_services[
"zkevm-bridge-service" + args["deployment_suffix"]
]
# Note: Use `.ip_address` instead of `.hostname` to make it work on macOS.
bridge_api_url = "http://{}:{}".format(
bridge_service.ip_address, bridge_service.ports["bridge-rpc"].number
)

config = struct(
l1_rpc_url=l1_rpc_url,
zkevm_rpc_url=zkevm_rpc_url,
bridge_api_url=bridge_api_url,
zkevm_bridge_address=contract_setup_addresses["zkevm_bridge_address"],
zkevm_rollup_address=contract_setup_addresses["zkevm_rollup_address"],
zkevm_rollup_manager_address=contract_setup_addresses[
"zkevm_rollup_manager_address"
],
def create_agglayer_config_artifact(plan, args, contract_setup_addresses):
agglayer_config_template = read_file(
src="./templates/bridge-infra/agglayer-config.toml"
)
return plan.render_templates(
name="agglayer-config-artifact",
config={
"agglayer-config.toml": struct(
template=agglayer_config_template,
# TODO: Organize those args.
data={
"deployment_suffix": args["deployment_suffix"],
"l1_chain_id": args["l1_chain_id"],
"l1_rpc_url": args["l1_rpc_url"],
"zkevm_l2_keystore_password": args["zkevm_l2_keystore_password"],
"zkevm_l2_proofsigner_address": args[
"zkevm_l2_proofsigner_address"
],
# agglayer db
"zkevm_db_agglayer_hostname": args["zkevm_db_agglayer_hostname"],
"zkevm_db_agglayer_name": args["zkevm_db_agglayer_name"],
"zkevm_db_agglayer_user": args["zkevm_db_agglayer_user"],
"zkevm_db_agglayer_password": args["zkevm_db_agglayer_password"],
# ports
"zkevm_db_postgres_port": args["zkevm_db_postgres_port"],
"zkevm_rpc_http_port": args["zkevm_rpc_http_port"],
"zkevm_agglayer_port": args["zkevm_agglayer_port"],
"zkevm_prometheus_port": args["zkevm_prometheus_port"],
}
| contract_setup_addresses,
)
},
)
zkevm_bridge_package.start_bridge_ui(plan, args, config)

proxy_config_artifact = create_proxy_config_artifact(plan, args)
zkevm_bridge_package.add_reverse_proxy(plan, args, proxy_config_artifact)


def create_bridge_config_artifact(plan, args, contract_setup_addresses):
Expand Down Expand Up @@ -108,47 +114,29 @@ def create_bridge_config_artifact(plan, args, contract_setup_addresses):
)


def create_agglayer_config_artifact(plan, args, contract_setup_addresses):
agglayer_config_template = read_file(
src="./templates/bridge-infra/agglayer-config.toml"
)
def create_bridge_ui_config_artifact(plan, args, contract_setup_addresses):
bridge_ui_config_template = read_file("./templates/bridge-infra/.env")
return plan.render_templates(
name="agglayer-config-artifact",
name="bridge-ui-config-artifact",
config={
"agglayer-config.toml": struct(
template=agglayer_config_template,
# TODO: Organize those args.
".env": struct(
template=bridge_ui_config_template,
data={
"deployment_suffix": args["deployment_suffix"],
"l1_chain_id": args["l1_chain_id"],
"l1_rpc_url": args["l1_rpc_url"],
"zkevm_l2_keystore_password": args["zkevm_l2_keystore_password"],
"zkevm_l2_proofsigner_address": args[
"zkevm_l2_proofsigner_address"
],
# agglayer db
"zkevm_db_agglayer_hostname": args["zkevm_db_agglayer_hostname"],
"zkevm_db_agglayer_name": args["zkevm_db_agglayer_name"],
"zkevm_db_agglayer_user": args["zkevm_db_agglayer_user"],
"zkevm_db_agglayer_password": args["zkevm_db_agglayer_password"],
# ports
"zkevm_db_postgres_port": args["zkevm_db_postgres_port"],
"zkevm_rpc_http_port": args["zkevm_rpc_http_port"],
"zkevm_agglayer_port": args["zkevm_agglayer_port"],
"zkevm_prometheus_port": args["zkevm_prometheus_port"],
"l1_explorer_url": args["l1_explorer_url"],
"zkevm_explorer_url": args["polygon_zkevm_explorer"],
}
| contract_setup_addresses,
)
},
)


def create_proxy_config_artifact(plan, args):
def create_reverse_proxy_config_artifact(plan, args):
bridge_ui_proxy_config_template = read_file(
src="./templates/bridge-infra/haproxy.cfg"
)
l1rpc_service = plan.get_service("el-1-geth-lighthouse")

l1rpc_service = plan.get_service("el-1-geth-lighthouse")
l2rpc_service = plan.get_service(name="zkevm-node-rpc" + args["deployment_suffix"])
bridge_service = plan.get_service(
name="zkevm-bridge-service" + args["deployment_suffix"]
Expand Down
28 changes: 9 additions & 19 deletions lib/zkevm_bridge.star
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def create_bridge_service_config(args, config_artifact, claimtx_keystore_artifac
return {bridge_service_name: bridge_service_config}


def start_bridge_ui(plan, args, config):
def start_bridge_ui(plan, args, config_artifact):
plan.add_service(
name="zkevm-bridge-ui" + args["deployment_suffix"],
config=ServiceConfig(
Expand All @@ -33,29 +33,19 @@ def start_bridge_ui(plan, args, config):
args["zkevm_bridge_ui_port"], application_protocol="http"
),
},
env_vars={
"ETHEREUM_RPC_URL": "/l1rpc",
"POLYGON_ZK_EVM_RPC_URL": "/l2rpc",
"BRIDGE_API_URL": "/bridgeservice",
"ETHEREUM_BRIDGE_CONTRACT_ADDRESS": config.zkevm_bridge_address,
"POLYGON_ZK_EVM_BRIDGE_CONTRACT_ADDRESS": config.zkevm_bridge_address,
"ETHEREUM_FORCE_UPDATE_GLOBAL_EXIT_ROOT": "true",
"ETHEREUM_PROOF_OF_EFFICIENCY_CONTRACT_ADDRESS": config.zkevm_rollup_address,
"ETHEREUM_ROLLUP_MANAGER_ADDRESS": config.zkevm_rollup_manager_address,
"ETHEREUM_EXPLORER_URL": args["l1_explorer_url"],
"POLYGON_ZK_EVM_EXPLORER_URL": args["polygon_zkevm_explorer"],
"POLYGON_ZK_EVM_NETWORK_ID": "1",
"ENABLE_FIAT_EXCHANGE_RATES": "false",
"ENABLE_OUTDATED_NETWORK_MODAL": "false",
"ENABLE_DEPOSIT_WARNING": "true",
"ENABLE_REPORT_FORM": "false",
files={
"/etc/zkevm": Directory(artifact_names=[config_artifact]),
},
cmd=["run"],
entrypoint=["/bin/sh", "-c"],
cmd=[
"set -a; source /etc/zkevm/.env; set +a; sh /app/scripts/deploy.sh run"
],
# user=User(uid=0, gid=0), # Run the container as root user.
),
)


def add_reverse_proxy(plan, args, config_artifact):
def start_reverse_proxy(plan, args, config_artifact):
plan.add_service(
name="zkevm-bridge-proxy" + args["deployment_suffix"],
config=ServiceConfig(
Expand Down
3 changes: 3 additions & 0 deletions scripts/zkevm-config-diff/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
default-configs/
kurtosis-cdk-configs/
diff/
43 changes: 43 additions & 0 deletions scripts/zkevm-config-diff/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# zkEVM/CDK Config Diff Tool

A simple tool to compare our kurtosis-cdk configurations with the default ones and list any missing or unnecessary fields.

## Usage

1. Deploy the CDK stack using [kurtosis-cdk](https://github.com/0xPolygon/kurtosis-cdk).

2. Create folders to hold zkevm default and kurtosis-cdk configuration files.

```bash
mkdir -p default-configs kurtosis-cdk-configs
```

Or clean those folders if they are not empty.

```bash
rm -rf ./default-configs/* ./kurtosis-cdk-configs/*
```

3. Dump default configurations.

```bash
sh zkevm_config.sh dump default ./default-configs
```

4. Dump kurtosis-cdk configurations.

```bash
sh zkevm_config.sh dump kurtosis-cdk ./kurtosis-cdk-configs
```

5. Compare configurations. You'll find diffs in `./diff`.

```bash
sh zkevm_config.sh compare configs ./default-configs ./kurtosis-cdk-configs
```

6. Compare two specific files.

```bash
sh zkevm_config.sh compare files ./default-configs/cdk-data-availability-config.toml ./kurtosis-cdk-configs/cdk-data-availability-config.toml
```
Loading

0 comments on commit 7a31545

Please sign in to comment.