Skip to content

Commit

Permalink
chore: update agglayer implementation (#262)
Browse files Browse the repository at this point in the history
* chore: move `deploy_agglayer` param

* chore: remove duplicate key

* chore: move agglayer deployment to main.star

* fix: last issues

* fix

* fix: issues

* chore: remove zkevm in front of agglayer

* fix: typo

* chore: nit

* chore: nit

* fix: ugly

* fix

* fix

* docs: nit

* fix: lint

* chore: remove config diff script
  • Loading branch information
leovct authored Sep 16, 2024
1 parent 9163cb9 commit 88be937
Show file tree
Hide file tree
Showing 30 changed files with 177 additions and 2,076 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ jobs:
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}}")"
agglayer_container_id="$(docker ps --filter "name=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
kurtosis service stop ${{ env.ENCLAVE_NAME }} agglayer
kurtosis service start ${{ env.ENCLAVE_NAME }} agglayer
- name: Monitor verified batches of the first L2 chain (CDK Erigon Permissionless RPC)
working-directory: .github/scripts
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ polycli loadtest --rpc-url "$ETH_RPC_URL" --legacy --private-key "$PK" --verbosi
Pretty often, you will want to check the output from the service. Here is how you can grab some logs:

```bash
kurtosis service logs cdk-v1 zkevm-agglayer-001 --follow
kurtosis service logs cdk-v1 agglayer --follow
```

In other cases, if you see an error, you might want to get a shell in the service to be able to poke around.
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ runs:
cat params.yml
yq -Y --in-place ".args.zkevm_agglayer_image = \"$agglayer_docker_hub:$agglayer_tag\"" params.yml
yq -Y --in-place ".args.agglayer_image = \"$agglayer_docker_hub:$agglayer_tag\"" params.yml
yq -Y --in-place ".args.zkevm_bridge_service_image = \"$bridge_service_docker_hub:$bridge_service_tag\"" params.yml
yq -Y --in-place ".args.zkevm_bridge_ui_image = \"$bridge_ui_docker_hub:$bridge_ui_tag\"" params.yml
yq -Y --in-place ".args.zkevm_da_image = \"$dac_docker_hub:$dac_tag\"" params.yml
Expand Down
12 changes: 6 additions & 6 deletions agglayer-attach-cdk-params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ deploy_cdk_central_environment: true
# Deploy cdk/bridge infrastructure.
deploy_cdk_bridge_infra: true

# Deploy agglayer.
deploy_agglayer: false

# Deploy cdk-erigon node.
deploy_cdk_erigon_node: true

Expand All @@ -35,9 +38,6 @@ args:
# - '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.
Expand Down Expand Up @@ -67,7 +67,7 @@ args:

cdk_node_image: ghcr.io/0xpolygon/cdk:0.0.17
zkevm_da_image: 0xpolygon/cdk-data-availability:0.0.9
zkevm_agglayer_image: ghcr.io/agglayer/agglayer-rs:pr-96
agglayer_image: ghcr.io/agglayer/agglayer-rs:pr-96
zkevm_bridge_service_image: hermeznetwork/zkevm-bridge-service:v0.5.0-RC12
zkevm_bridge_ui_image: leovct/zkevm-bridge-ui:multi-network
zkevm_bridge_proxy_image: haproxy:3.0-bookworm
Expand All @@ -80,14 +80,14 @@ args:
zkevm_executor_port: 50071
zkevm_aggregator_port: 50081
zkevm_pprof_port: 6060
zkevm_prometheus_port: 9091
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
agglayer_port: 4444
zkevm_dac_port: 8484
zkevm_pool_manager_port: 8545

Expand Down
78 changes: 78 additions & 0 deletions agglayer.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
service_package = import_module("./lib/service.star")
databases = import_module("./databases.star")


def run(plan, args):
contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args)
db_configs = databases.get_db_configs(
args["deployment_suffix"], args["sequencer_type"]
)
agglayer_config_artifact = create_agglayer_config_artifact(
plan, args, contract_setup_addresses, db_configs
)

agglayer_keystore_artifact = plan.store_service_files(
name="agglayer-keystore",
service_name="contracts" + args["deployment_suffix"],
src="/opt/zkevm/agglayer.keystore",
)

plan.add_service(
name="agglayer",
config=ServiceConfig(
image=args["agglayer_image"],
ports={
"agglayer": PortSpec(
args["agglayer_port"], application_protocol="http"
),
"prometheus": PortSpec(
args["prometheus_port"], application_protocol="http"
),
},
files={
"/etc/zkevm": Directory(
artifact_names=[
agglayer_config_artifact,
agglayer_keystore_artifact,
]
),
},
entrypoint=[
"/usr/local/bin/agglayer",
],
cmd=["run", "--cfg", "/etc/zkevm/agglayer-config.toml"],
),
)


def create_agglayer_config_artifact(plan, args, contract_setup_addresses, db_configs):
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"],
"global_log_level": args["global_log_level"],
"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"
],
"zkevm_l2_sequencer_address": args["zkevm_l2_sequencer_address"],
# ports
"zkevm_rpc_http_port": args["zkevm_rpc_http_port"],
"agglayer_port": args["agglayer_port"],
"prometheus_port": args["prometheus_port"],
"l2_rpc_name": args["l2_rpc_name"],
}
| contract_setup_addresses
| db_configs,
)
},
)
71 changes: 7 additions & 64 deletions cdk_bridge_infra.star
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
service_package = import_module("./lib/service.star")
zkevm_agglayer_package = import_module("./lib/zkevm_agglayer.star")
zkevm_bridge_package = import_module("./lib/zkevm_bridge.star")
databases = import_module("./databases.star")

Expand All @@ -10,7 +9,7 @@ def run(plan, args):
args["deployment_suffix"], args["sequencer_type"]
)

# Create the bridge service config.
# Start the bridge service.
bridge_config_artifact = create_bridge_config_artifact(
plan, args, contract_setup_addresses, db_configs
)
Expand All @@ -19,82 +18,26 @@ def run(plan, args):
service_name="contracts" + args["deployment_suffix"],
src="/opt/zkevm/claimtxmanager.keystore",
)
bridge_config = zkevm_bridge_package.create_bridge_service_config(
bridge_service_config = zkevm_bridge_package.create_bridge_service_config(
args, bridge_config_artifact, claimtx_keystore_artifact
)

# Create the agglayer service config.
if args["deploy_agglayer"]:
agglayer_config_artifact = create_agglayer_config_artifact(
plan, args, contract_setup_addresses, db_configs
)
agglayer_keystore_artifact = plan.store_service_files(
name="agglayer-keystore",
service_name="contracts" + args["deployment_suffix"],
src="/opt/zkevm/agglayer.keystore",
)
agglayer_config = zkevm_agglayer_package.create_agglayer_service_config(
args, agglayer_config_artifact, agglayer_keystore_artifact
)

# Start the bridge service and the agglayer.
if args["deploy_agglayer"]:
bridge_infra_services = plan.add_services(
configs=bridge_config | agglayer_config,
description="Starting bridge infra",
)
else:
bridge_infra_services = plan.add_services(
configs=bridge_config,
description="Starting bridge infra",
)
plan.add_service(
name="zkevm-bridge-service" + args["deployment_suffix"],
config=bridge_service_config,
)

# Start the bridge UI.
bridge_ui_config_artifact = create_bridge_ui_config_artifact(
plan, args, contract_setup_addresses
)
if args["deploy_agglayer"]:
zkevm_bridge_package.start_bridge_ui(plan, args, bridge_ui_config_artifact)
zkevm_bridge_package.start_bridge_ui(plan, args, bridge_ui_config_artifact)

# Start the bridge UI reverse proxy. This is only relevant / needed if we have a fake l1
if args["deploy_l1"]:
proxy_config_artifact = create_reverse_proxy_config_artifact(plan, args)
zkevm_bridge_package.start_reverse_proxy(plan, args, proxy_config_artifact)


def create_agglayer_config_artifact(plan, args, contract_setup_addresses, db_configs):
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"],
"global_log_level": args["global_log_level"],
"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"
],
"zkevm_l2_sequencer_address": args["zkevm_l2_sequencer_address"],
# ports
"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,
)
},
)


def create_bridge_config_artifact(plan, args, contract_setup_addresses, db_configs):
bridge_config_template = read_file(
src="./templates/bridge-infra/bridge-config.toml"
Expand Down
8 changes: 5 additions & 3 deletions docs/attach-multiple-cdks.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ After running the above additional deployment command, the `agglayer-config.toml

```bash
# Shell into the Agglayer service
kurtosis service shell cdk-v1 zkevm-agglayer-001
kurtosis service shell cdk-v1 agglayer

# Edit the agglayer-config.toml file
vim /etc/zkevm/agglayer-config.toml
```

The `agglayer-config.toml` file should be changed as follows:

```bash
[FullNodeRPCs]
# RPC of the first rollup node
Expand All @@ -33,7 +34,8 @@ The `agglayer-config.toml` file should be changed as follows:
```

Then restart the Agglayer service

```bash
kurtosis service stop cdk-v1 zkevm-agglayer-001
kurtosis service start cdk-v1 zkevm-agglayer-001
kurtosis service stop cdk-v1 agglayer
kurtosis service start cdk-v1 agglayer
```
10 changes: 5 additions & 5 deletions docs/edit-contracts.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ Exit the attached shell when you're done examining the `contracts-001` container
exit
```

Let's observe that proofs are passing verification as expected. Use your preferred method to view the logs for the container `zkevm-agglayer-001`. For example, you could use the Docker Desktop graphical interface, or you could follow in a terminal via
Let's observe that proofs are passing verification as expected. Use your preferred method to view the logs for the container `agglayer`. For example, you could use the Docker Desktop graphical interface, or you could follow in a terminal via

```bash
kurtosis service logs cdk-v1 zkevm-agglayer-001 --follow
kurtosis service logs cdk-v1 agglayer --follow
```

You should see logs like
Expand Down Expand Up @@ -198,8 +198,8 @@ index 5293da7..5e451b6 100644
- zkevm_contracts_image: leovct/zkevm-contracts:v6.0.0-rc.1-fork.9
+ zkevm_contracts_image: local/zkevm-contracts:v6.0.0-rc.1-fork.9

# zkevm_agglayer_image: 0xpolygon/agglayer:0.1.3
zkevm_agglayer_image: ghcr.io/agglayer/agglayer-rs:main
# agglayer_image: 0xpolygon/agglayer:0.1.3
agglayer_image: ghcr.io/agglayer/agglayer-rs:main
```

Optional: by default, your devnet disables fancy dashboards. If you want to view your devnet from a fancy dashboard such as Grafana then open the file `params.yml` and ensure that `args.additional_services` includes `"prometheus_grafana"`.
Expand All @@ -224,7 +224,7 @@ cat zkevm-contracts/contracts/mocks/VerifierRollupHelperMock.sol

You should see your edits in the live code: `return false` instead of `return true`.

Observe that proofs are failing verification as expected in the logs for docker container `zkevm-agglayer-001`. You should see logs like
Observe that proofs are failing verification as expected in the logs for docker container `agglayer`. You should see logs like

```
2024-08-19 15:44:21 2024-08-19T19:44:21.884754Z ERROR agglayer_node::rpc: Failed to dry-run the verify_batches_trusted_aggregator for transaction 0x161e…4e01: Contract call reverted with data: 0x09bde339, tx_hash: "0x161e…4e01"
Expand Down
Loading

0 comments on commit 88be937

Please sign in to comment.