Skip to content

Commit c3caebc

Browse files
temaniarpit27vcastellmStefan-Ethernaljhkimqd
authored
feat: enable bridge service (#547)
* Update aggkit bin name * rename the binary * Update command to run aggkit without the node suffix * feat: enable bridge service for aggkit * network id fixes * support aggkit and cdk (#549) * support aggkit and cdk * debugging * fix * minor change * fix * fix * debugging * debugging * debugging * revert back * debugging * minor fix * fix: use zkevm_l2_l1testing_address in monitor-cdk-chain.sh Signed-off-by: Ji Hwan <jkim@polygon.technology> * fix: revert monitor-cdk-chain + add nonce flag Signed-off-by: Ji Hwan <jkim@polygon.technology> * fix: AggLayerURL param Signed-off-by: Ji Hwan <jkim@polygon.technology> * feat: add agglayer_version for cdk-node-config Signed-off-by: Ji Hwan <jkim@polygon.technology> * fix * chore: revert nonce flag in monitor-cdk-chain Signed-off-by: Ji Hwan <jkim@polygon.technology> * fix * fix review comments * fix * fix * fix * fix * fix: cdk-node-config fix Signed-off-by: Ji Hwan <jkim@polygon.technology> * chore: lint Signed-off-by: Ji Hwan <jkim@polygon.technology> * refactor: change agglayer endpoint naming Signed-off-by: Ji Hwan <jkim@polygon.technology> * fix * fix review comments * fix review comments * fix review comments * fix review comments * chore: cleanup Signed-off-by: Ji Hwan <jkim@polygon.technology> * fix review comments * fix review comments * fix ci * fix ci * fix ci * fix ci * fix ci * fix ci --------- Signed-off-by: Ji Hwan <jkim@polygon.technology> Co-authored-by: Victor Castell <0x@vcastellm.xyz> Co-authored-by: Stefan Negovanović <stefan@ethernal.tech> Co-authored-by: Ji Hwan <jkim@polygon.technology>
1 parent 3ed9fa9 commit c3caebc

10 files changed

Lines changed: 54 additions & 34 deletions

File tree

cdk_central_environment.star

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cdk_node_package = import_module("./lib/cdk_node.star")
88
databases = import_module("./databases.star")
99

1010

11-
def run(plan, args, contract_setup_addresses):
11+
def run(plan, args, deployment_stages, contract_setup_addresses):
1212
db_configs = databases.get_db_configs(
1313
args["deployment_suffix"], args["sequencer_type"]
1414
)
@@ -101,6 +101,7 @@ def run(plan, args, contract_setup_addresses):
101101
)
102102

103103
if args["sequencer_type"] == "erigon":
104+
agglayer_endpoint = get_agglayer_endpoint(plan, args, deployment_stages)
104105
# Create the cdk node config.
105106
node_config_template = read_file(
106107
src="./templates/trusted-node/cdk-node-config.toml"
@@ -118,6 +119,7 @@ def run(plan, args, contract_setup_addresses):
118119
"l1_rpc_url": args["mitm_rpc_url"].get(
119120
"cdk-node", args["l1_rpc_url"]
120121
),
122+
"agglayer_endpoint": agglayer_endpoint,
121123
}
122124
| db_configs
123125
| contract_setup_addresses,
@@ -186,3 +188,18 @@ def create_dac_config_artifact(plan, args, db_configs, contract_setup_addresses)
186188
)
187189
},
188190
)
191+
192+
193+
# Function to allow cdk-node-config to pick whether to use agglayer_readrpc_port or agglayer_grpc_port depending on whether cdk-node or aggkit-node is being deployed.
194+
# On aggkit/cdk-node point of view, only the agglayer_image version is important. Both services can work with both grpc/readrpc and this depends on the agglayer version.
195+
# On Kurtosis point of view, we are checking whether the cdk-node or the aggkit node is being used to filter the grpc/readrpc.
196+
def get_agglayer_endpoint(plan, args, deployment_stages):
197+
if (
198+
"0.3" in args["agglayer_image"]
199+
and args.get("binary_name") == cdk_node_package.AGGKIT_BINARY_NAME
200+
):
201+
return "grpc"
202+
elif deployment_stages["deploy_optimism_rollup"]:
203+
return "grpc"
204+
else:
205+
return "readrpc"

input_parser.star

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -808,15 +808,6 @@ def args_sanity_check(plan, deployment_stages, args, user_args, op_stack_args):
808808
if deployment_stages.get("deploy_optimism_rollup", False):
809809
fail("Gas token is not supported when deploying OP Rollup.")
810810

811-
# Validate the gas token address.
812-
gas_token_address = args.get("gas_token_address", "")
813-
if gas_token_address == constants.ZERO_ADDRESS or gas_token_address == "":
814-
fail(
815-
"Gas token is enabled, but the provided gas token address is either empty or set to the zero address: '{}'.".format(
816-
gas_token_address
817-
)
818-
)
819-
820811
# CDK Erigon normalcy and strict mode check
821812
if args["enable_normalcy"] and args["erigon_strict_mode"]:
822813
fail("normalcy and strict mode cannot be enabled together")

lib/aggkit.star

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def get_aggkit_cmd(args):
5252
service_command = [
5353
"cat /etc/aggkit/config.toml && sleep 20 && aggkit run "
5454
+ "--cfg=/etc/aggkit/config.toml "
55-
+ "--components=aggsender,aggoracle"
55+
+ "--components=aggsender,aggoracle,bridge"
5656
]
5757

5858
return service_command

lib/cdk_node.star

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ constants = import_module("../src/package_io/constants.star")
22
data_availability_package = import_module("./data_availability.star")
33
ports_package = import_module("../src/package_io/ports.star")
44

5+
AGGKIT_BINARY_NAME = "aggkit"
6+
57

68
def create_cdk_node_service_config(
79
args,
@@ -80,6 +82,8 @@ def get_cdk_node_ports(args):
8082

8183

8284
def get_cdk_node_cmd(args):
85+
binary_name = args.get("binary_name")
86+
8387
service_command = [
8488
"sleep 20 && cdk-node run "
8589
+ "--cfg=/etc/cdk/cdk-node-config.toml "
@@ -95,4 +99,13 @@ def get_cdk_node_cmd(args):
9599
+ "--save-config-path=/tmp/ "
96100
+ "--components=aggsender"
97101
]
102+
103+
if binary_name == AGGKIT_BINARY_NAME:
104+
service_command = [
105+
"sleep 20 && aggkit run "
106+
+ "--cfg=/etc/cdk/cdk-node-config.toml "
107+
+ "--save-config-path=/tmp/ "
108+
+ "--components=aggsender,bridge"
109+
]
110+
98111
return service_command

lib/op_succinct.star

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def get_op_succinct_server_ports(args):
187187
"server": PortSpec(
188188
args["op_succinct_server_port"],
189189
application_protocol="http",
190-
wait=None,
190+
wait="5m",
191191
),
192192
}
193193

@@ -199,12 +199,12 @@ def get_op_succinct_proposer_ports(args):
199199
"metrics": PortSpec(
200200
args["op_succinct_proposer_metrics_port"],
201201
application_protocol="http",
202-
wait=None,
202+
wait="5m",
203203
),
204204
"rpc": PortSpec(
205205
args["op_succinct_proposer_rpc_port"],
206206
application_protocol="http",
207-
wait=None,
207+
wait="5m",
208208
),
209209
}
210210

main.star

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,9 @@ def run(plan, args={}):
212212
plan.print("Skipping the deployment of cdk-erigon node")
213213

214214
plan.print("Deploying cdk central/trusted environment")
215-
central_environment_args = dict(args)
216-
central_environment_args["genesis_artifact"] = genesis_artifact
215+
args["genesis_artifact"] = genesis_artifact
217216
import_module(cdk_central_environment_package).run(
218-
plan, central_environment_args, contract_setup_addresses
217+
plan, args, deployment_stages, contract_setup_addresses
219218
)
220219

221220
# Deploy contracts on L2.
@@ -245,10 +244,9 @@ def run(plan, args={}):
245244
# Deploy AggKit infrastructure + Dedicated Bridge Service
246245
if deployment_stages.get("deploy_optimism_rollup", False):
247246
plan.print("Deploying AggKit infrastructure")
248-
central_environment_args = dict(args)
249247
import_module(aggkit_package).run(
250248
plan,
251-
central_environment_args,
249+
args,
252250
contract_setup_addresses,
253251
sovereign_contract_setup_addresses,
254252
deployment_stages,

templates/aggkit/aggkit-config.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
PathRWData = "{{.zkevm_path_rw_data}}"
1414
L1URL="{{.l1_rpc_url}}"
1515
L2URL="{{.op_el_rpc_url}}"
16-
# AggLayerURL="{{.agglayer_readrpc_url}}"
1716
AggLayerURL="{{.agglayer_grpc_url}}"
1817

1918
ForkId = 12
2019
ContractVersions = "banana"
2120
IsValidiumMode = false
21+
NetworkID = {{.zkevm_rollup_id}}
2222

2323
# This is the admin account for now
2424
L2Coinbase = "{{.zkevm_l2_sovereignadmin_address}}"
@@ -502,4 +502,4 @@ URL = "{{.op_el_rpc_url}}"
502502
# Needs to be set to be the sovereign L2 chain id
503503
# If set to 0, the chain ID will be fetched from the RPC endpoint
504504
# ------------------------------------------------------------------------------
505-
L1ChainID = "{{.zkevm_rollup_chain_id}}"
505+
L1ChainID = "{{.zkevm_rollup_chain_id}}"

templates/cdk-erigon/config.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,6 @@ zkevm.reject-low-gas-price-transactions: false
139139
zkevm.reject-low-gas-price-transactions: true
140140
# {{end}}
141141

142-
143-
144142
# Apply a factor to convert L1 gas prices into L2 gas prices.
145143
# A value of 1 means no adjustment; values greater than 1 increase L2 costs proportionally.
146144
# Default: 1

templates/contract-deploy/run-contract-setup.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ sed -i 's#http://127.0.0.1:8545#{{.l1_rpc_url}}#' hardhat.config.ts
102102
printf "[profile.default]\nsrc = 'contracts'\nout = 'out'\nlibs = ['node_modules']\n" > foundry.toml
103103

104104
# Deploy gas token
105-
# {{if .gas_token_enabled}}
106-
107-
# {{if eq .gas_token_address ""}}
105+
# shellcheck disable=SC1054,SC1072,SC1083
106+
{{ if .gas_token_enabled }}
107+
{{ if eq .gas_token_address "" }}
108108
echo_ts "Deploying gas token to L1"
109109
forge create \
110110
--broadcast \
@@ -119,16 +119,16 @@ jq \
119119
'.gasTokenAddress = $c[0].deployedTo' \
120120
/opt/contract-deploy/create_rollup_parameters.json \
121121
> /opt/zkevm-contracts/deployment/v2/create_rollup_parameters.json
122-
# {{else}}
122+
# shellcheck disable=SC1073,SC1009
123+
{{ else }}
123124
echo_ts "Using L1 pre-deployed gas token: {{ .gas_token_address }}"
124125
jq \
125126
--arg c "{{ .gas_token_address }}" \
126127
'.gasTokenAddress = $c' \
127128
/opt/contract-deploy/create_rollup_parameters.json \
128129
> /opt/zkevm-contracts/deployment/v2/create_rollup_parameters.json
129-
# {{end}}
130-
131-
# {{end}}
130+
{{ end }}
131+
{{ end }}
132132

133133
is_first_rollup=0 # an indicator if this deployment is doing the first setup of the agglayer etc
134134
if [[ ! -e /opt/zkevm/combined.json ]]; then
@@ -195,9 +195,9 @@ jq '.polygonZkEVML2BridgeAddress = .polygonZkEVMBridgeAddress' combined.json > c
195195
zkevm_global_exit_root_l2_address=$(jq -r '.genesis[] | select(.contractName == "PolygonZkEVMGlobalExitRootL2 proxy") | .address' /opt/zkevm/genesis.json)
196196
jq --arg a "$zkevm_global_exit_root_l2_address" '.polygonZkEVMGlobalExitRootL2Address = $a' combined.json > c.json; mv c.json combined.json
197197

198-
# {{if .gas_token_enabled}}
198+
{{ if .gas_token_enabled }}
199199
jq --slurpfile cru /opt/zkevm-contracts/deployment/v2/create_rollup_parameters.json '.gasTokenAddress = $cru[0].gasTokenAddress' combined.json > c.json; mv c.json combined.json
200-
# {{end}}
200+
{{ end }}
201201

202202

203203
# There are a bunch of fields that need to be renamed in order for the

templates/trusted-node/cdk-node-config.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
PathRWData = "{{.zkevm_path_rw_data}}"
22
L1URL="{{.l1_rpc_url}}"
33
L2URL="http://{{.l2_rpc_name}}{{.deployment_suffix}}:{{.zkevm_rpc_http_port}}"
4+
{{- if eq .agglayer_endpoint "grpc" }}
5+
AggLayerURL="{{.agglayer_grpc_url}}"
6+
{{- else }}
47
AggLayerURL="{{.agglayer_readrpc_url}}"
5-
8+
{{- end }}
69
ForkId = {{.zkevm_rollup_fork_id}}
710
IsValidiumMode = {{.is_cdk_validium}}
11+
NetworkID = {{.zkevm_rollup_id}}
812

913
{{if eq .zkevm_rollup_fork_id "12"}}
1014
ContractVersions = "banana"
@@ -66,4 +70,3 @@ Outputs = ["stderr"]
6670
[AggSender]
6771
CertificateSendInterval = "1m"
6872
CheckSettledInterval = "5s"
69-

0 commit comments

Comments
 (0)