Skip to content

Commit 71a79d6

Browse files
authored
refactor: zkevm-bridge-ui additional service (#870)
* feat: enable bridge-ui for op-geth * feat: same * feat: add helper to build zkevm-bridge-ui * refactor: move zkevm-bridge-ui to additional services * chore: bump zkevm-bridge-ui * chore: move files * chore: l1 context * fix: typos * chore: rename * fix: l1 context * fix: l1 rpc url * fix: remove prefix in urls for haproxy
1 parent 85c64a5 commit 71a79d6

32 files changed

Lines changed: 158 additions & 154 deletions

.github/tests/additional-services.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ args:
1212
- status_checker
1313
- test_runner
1414
- tx_spammer
15+
- zkevm_bridge_ui

docker/Makefile

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Image names
2-
TOOLBOX_IMAGE_NAME := toolbox:0.0.12
32
AGGLAYER_CONTRACTS_IMAGE_NAME := agglayer-contracts:v12.2.1
3+
TOOLBOX_IMAGE_NAME := toolbox:0.0.12
4+
ZKEVM_BRIDGE_UI_IMAGE_NAME := zkevm-bridge-ui:3f1a3a0
45

56
# GCR registry
67
GCR_REGISTRY := europe-west2-docker.pkg.dev/prj-polygonlabs-devtools-dev/public
@@ -11,13 +12,17 @@ help: ## Display this help.
1112

1213
##@ Build
1314

15+
.PHONY: build-agglayer-contracts
16+
build-agglayer-contracts: ## Build agglayer contracts image
17+
docker build --tag $(AGGLAYER_CONTRACTS_IMAGE_NAME) --file agglayer-contracts.Dockerfile .
18+
1419
.PHONY: build-toolbox
1520
build-toolbox: ## Build toolbox image
1621
docker build --tag $(TOOLBOX_IMAGE_NAME) --file toolbox.Dockerfile .
1722

18-
.PHONY: build-agglayer-contracts
19-
build-agglayer-contracts: ## Build agglayer contracts image
20-
docker build --tag $(AGGLAYER_CONTRACTS_IMAGE_NAME) --file agglayer-contracts.Dockerfile .
23+
.PHONY: build-zkevm-bridge-ui
24+
build-zkevm-bridge-ui: ## Build zkevm-bridge-ui image
25+
docker build --tag $(ZKEVM_BRIDGE_UI_IMAGE_NAME) --file zkevm-bridge-ui/Dockerfile zkevm-bridge-ui
2126

2227
##@ Push
2328

@@ -26,12 +31,17 @@ auth: ## Authenticate with Google Cloud Registry
2631
gcloud config set project prj-polygonlabs-devtools-dev
2732
gcloud auth configure-docker europe-west2-docker.pkg.dev
2833

34+
.PHONY: push-agglayer-contracts
35+
push-agglayer-contracts: ## Push agglayer contracts image to GCR
36+
docker tag $(AGGLAYER_CONTRACTS_IMAGE_NAME) $(GCR_REGISTRY)/$(AGGLAYER_CONTRACTS_IMAGE_NAME)
37+
docker push $(GCR_REGISTRY)/$(AGGLAYER_CONTRACTS_IMAGE_NAME)
38+
2939
.PHONY: push-toolbox
3040
push-toolbox: ## Push toolbox image to GCR
3141
docker tag $(TOOLBOX_IMAGE_NAME) $(GCR_REGISTRY)/$(TOOLBOX_IMAGE_NAME)
3242
docker push $(GCR_REGISTRY)/$(TOOLBOX_IMAGE_NAME)
3343

34-
.PHONY: push-agglayer-contracts
35-
push-agglayer-contracts: ## Push agglayer contracts image to GCR
36-
docker tag $(AGGLAYER_CONTRACTS_IMAGE_NAME) $(GCR_REGISTRY)/$(AGGLAYER_CONTRACTS_IMAGE_NAME)
37-
docker push $(GCR_REGISTRY)/$(AGGLAYER_CONTRACTS_IMAGE_NAME)
44+
.PHONY: push-zkevm-bridge-ui
45+
push-zkevm-bridge-ui: ## Push zkevm-bridge-ui image to GCR
46+
docker tag $(ZKEVM_BRIDGE_UI_IMAGE_NAME) $(GCR_REGISTRY)/$(ZKEVM_BRIDGE_UI_IMAGE_NAME)
47+
docker push $(GCR_REGISTRY)/$(ZKEVM_BRIDGE_UI_IMAGE_NAME)

docker/README.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,6 @@ image_name="status-checker-cdk:v0.2.8"
6161
docker build --tag "${image_name}" --file docker/status-checker-cdk.Dockerfile .
6262
```
6363

64-
### ZkEVM Bridge UI (deprecated)
65-
66-
Web interface to bridge ETH and ERC-20 tokens from L1 to L2.
67-
68-
Repository: <https://github.com/0xPolygon/zkevm-bridge-ui>
69-
70-
```bash
71-
image_name="zkevm-bridge-ui:0006445"
72-
docker build --tag "${image_name}" --file zkevm-bridge-ui/zkevm-bridge-ui.Dockerfile zkevm-bridge-ui
73-
```
74-
7564
### Agglayer Dashboard
7665

7766
Build and create image from here:

docker/zkevm-bridge-ui/zkevm-bridge-ui.Dockerfile renamed to docker/zkevm-bridge-ui/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM alpine:3.20 AS builder
22
ARG ZKEVM_BRIDGE_UI_BRANCH="develop"
3-
ARG ZKEVM_BRIDGE_UI_TAG_OR_COMMIT_SHA="0006445" # 2024-03-13
3+
ARG ZKEVM_BRIDGE_UI_TAG_OR_COMMIT_SHA="3f1a3a0" # 2025-01-09
44

55
WORKDIR /opt/zkevm-bridge-ui
66
# WARNING (DL3018): Pin versions in apk add.

docs/docs/advanced/attaching-multiple-rollups.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ Repeat the steps for Rollup consensus.
6464
deployment_stages:
6565
deploy_l1: false
6666
deploy_agglayer: false
67-
deploy_cdk_bridge_ui: false
6867
args:
6968
verbosity: debug
7069
agglayer_contracts_image: leovct/zkevm-contracts:v9.0.0-rc.6-pp-fork.12
@@ -101,7 +100,6 @@ Repeat the steps for PP consensus.
101100
deployment_stages:
102101
deploy_l1: false
103102
deploy_agglayer: false
104-
deploy_cdk_bridge_ui: false
105103
args:
106104
deployment_suffix: '-003'
107105
l2_chain_id: 30303

main.star

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,17 @@ def run(plan, args={}):
2323
consensus_type = args.get("consensus_contract_type")
2424

2525
# Deploy a local L1.
26+
l1_context = None
2627
if deployment_stages.get("deploy_l1", False):
2728
plan.print("Deploying a local L1")
2829
l1_context = l1_launcher.launch(plan, args)
2930
else:
3031
plan.print("Skipping the deployment of a local L1")
31-
l1_context = None # TODO: Populate from dev args
32+
l1_context = struct(
33+
chain_id=args.get("l1_chain_id"),
34+
rpc_url=args.get("l1_rpc_url"),
35+
all_participants=[],
36+
) # TODO: Populate from dev args
3237

3338
# Retrieve L1 genesis and rename it to <l1_chain_id>.json for op-succinct
3439
# TODO: Fix the logic when using anvil and op-succinct
@@ -204,8 +209,9 @@ def run(plan, args={}):
204209
plan.print("Skipping the deployment of the agglayer")
205210

206211
# Deploy cdk central/trusted environment.
212+
l2_context = None
207213
if deployment_stages.get("deploy_cdk_central_environment", False):
208-
chain_launcher.launch(
214+
l2_context = chain_launcher.launch(
209215
plan,
210216
args,
211217
contract_setup_addresses,
@@ -228,6 +234,8 @@ def run(plan, args={}):
228234
genesis_artifact,
229235
deployment_stages,
230236
sequencer_type,
237+
l1_context,
238+
l2_context,
231239
)
232240

233241

src/additional_services/launcher.star

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ def launch(
99
genesis_artifact,
1010
deployment_stages,
1111
sequencer_type,
12+
l1_context,
13+
l2_context,
1214
):
1315
for svc in args.get("additional_services", []):
1416
if svc == constants.ADDITIONAL_SERVICES.agglogger:
@@ -58,5 +60,19 @@ def launch(
5860
import_module("./agglayer_dashboard.star").run(
5961
plan, args, contract_setup_addresses
6062
)
63+
elif svc == constants.ADDITIONAL_SERVICES.zkevm_bridge_ui:
64+
zkevm_bridge_ui_url = import_module("./zkevm_bridge_ui/server.star").run(
65+
plan, args, contract_setup_addresses
66+
)
67+
68+
if deployment_stages.get("deploy_l1"):
69+
import_module("./zkevm_bridge_ui/proxy.star").run(
70+
plan,
71+
args,
72+
l1_context.rpc_url,
73+
l2_context.rpc_url,
74+
l2_context.zkevm_bridge_service_url,
75+
zkevm_bridge_ui_url,
76+
)
6177
else:
6278
fail("Invalid additional service: %s" % (svc))
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Port identifiers and numbers.
2+
SERVER_PORT_ID = "web-ui"
3+
SERVER_PORT_NUMBER = 80
4+
5+
6+
def run(
7+
plan, args, l1_rpc_url, l2_rpc_url, zkevm_bridge_service_url, zkevm_bridge_ui_url
8+
):
9+
config_artifact = plan.render_templates(
10+
name="zkevm-bridge-proxy-config{}".format(args.get("deployment_suffix")),
11+
config={
12+
"haproxy.cfg": struct(
13+
template=read_file(
14+
src="../../../static_files/additional_services/zkevm-bridge-ui/proxy/haproxy.cfg"
15+
),
16+
data={
17+
"l1_rpc_url": l1_rpc_url.removeprefix("http://"),
18+
"l2_rpc_url": l2_rpc_url.removeprefix("http://"),
19+
"zkevm_bridge_service_url": zkevm_bridge_service_url.removeprefix(
20+
"http://"
21+
),
22+
"zkevm_bridge_ui_url": zkevm_bridge_ui_url.removeprefix("http://"),
23+
},
24+
)
25+
},
26+
)
27+
28+
plan.add_service(
29+
name="zkevm-bridge-proxy{}".format(args.get("deployment_suffix")),
30+
config=ServiceConfig(
31+
image=args.get("zkevm_bridge_proxy_image"),
32+
files={
33+
"/usr/local/etc/haproxy/": Directory(artifact_names=[config_artifact]),
34+
},
35+
ports={
36+
SERVER_PORT_ID: PortSpec(
37+
SERVER_PORT_NUMBER, application_protocol="http"
38+
)
39+
},
40+
),
41+
)

src/chain/cdk-erigon/zkevm_bridge_ui.star renamed to src/additional_services/zkevm_bridge_ui/server.star

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def run(plan, args, contract_setup_addresses):
99
config={
1010
".env": struct(
1111
template=read_file(
12-
"../../../static_files/chain/cdk-erigon/zkevm-bridge-ui/.env"
12+
"../../../static_files/additional_services/zkevm-bridge-ui/server/.env"
1313
),
1414
data={
1515
"l1_explorer_url": args["l1_explorer_url"],
@@ -20,7 +20,7 @@ def run(plan, args, contract_setup_addresses):
2020
},
2121
)
2222

23-
plan.add_service(
23+
result = plan.add_service(
2424
name="zkevm-bridge-ui{}".format(args.get("deployment_suffix")),
2525
config=ServiceConfig(
2626
image=args.get("zkevm_bridge_ui_image"),
@@ -41,3 +41,5 @@ def run(plan, args, contract_setup_addresses):
4141
# user=User(uid=0, gid=0), # Run the container as root user.
4242
),
4343
)
44+
server_url = result.ports[SERVER_PORT_ID].url
45+
return server_url

src/chain/cdk-erigon/launcher.star

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ cdk_data_availability = import_module("./cdk_data_availability.star")
88
ports_package = import_module("../shared/ports.star")
99
zkevm_pool_manager = import_module("./zkevm_pool_manager.star")
1010
zkevm_prover = import_module("./zkevm_prover.star")
11-
zkevm_bridge_service = import_module("../shared/zkevm_bridge_service.star")
12-
zkevm_bridge_ui = import_module("./zkevm_bridge_ui.star")
13-
zkevm_bridge_proxy = import_module("./zkevm_bridge_proxy.star")
1411

1512

1613
def launch(
@@ -90,30 +87,6 @@ def launch(
9087
# fund cdk-erigon account on L2
9188
agglayer_contracts_package.l2_legacy_fund_accounts(plan, args)
9289

93-
# Deploy cdk/bridge infrastructure only if using CDK Node instead of Aggkit. This can be inferred by the consensus_contract_type.
94-
deploy_cdk_bridge_infra = deployment_stages.get("deploy_cdk_bridge_infra")
95-
if deploy_cdk_bridge_infra and (
96-
consensus_type
97-
in [
98-
constants.CONSENSUS_TYPE.rollup,
99-
constants.CONSENSUS_TYPE.cdk_validium,
100-
]
101-
):
102-
plan.print("Deploying zkevm-bridge infrastructure (legacy)")
103-
zkevm_bridge_service.run(
104-
plan,
105-
args,
106-
contract_setup_addresses,
107-
sovereign_contract_setup_addresses,
108-
rpc_url,
109-
)
110-
111-
if deployment_stages.get("deploy_cdk_bridge_ui"):
112-
zkevm_bridge_ui.run(plan, args, contract_setup_addresses)
113-
114-
if deployment_stages.get("deploy_l1"):
115-
zkevm_bridge_proxy.run(plan, args)
116-
11790
# Deploy aggkit infrastructure + dedicated bridge service
11891
if consensus_type in [
11992
constants.CONSENSUS_TYPE.pessimistic,
@@ -125,6 +98,9 @@ def launch(
12598
args,
12699
contract_setup_addresses,
127100
sovereign_contract_setup_addresses,
128-
deploy_cdk_bridge_infra,
129-
False,
101+
deployment_stages,
130102
)
103+
104+
return struct(
105+
rpc_url=rpc_url,
106+
)

0 commit comments

Comments
 (0)