Skip to content

Commit 72cfa0e

Browse files
committed
feat(polygon-zkevm): migrate from archived zkevm-node to cdk-erigon
zkevm-node is archived; Polygon mainnet zkEVM operators now run cdk-erigon (an Erigon fork). The prior commit only dropped version tracking — this actually migrates the adapter to the new client: - image -> ghcr.io/0xpolygon/cdk-erigon:v2.64.2, VersionPolicy re-added - config rewritten to cdk-erigon hermez-mainnet yaml (datadir /data, http on 8545 with eth/debug/net/trace/web3/erigon/zkevm apis, externalcl, l2-chain-id 1101, sequencer https://zkevm-rpc.com, datastreamer stream.zkevm-rpc.com:6900, canonical L1 contract addresses) - ContainerArgs: --config=/config/hermezconfig.yaml plus --zkevm.l1-rpc-url=$(L1_RPC_URL); image ENTRYPOINT is cdk-erigon so flags append cleanly. L1 URL still defaults to http://ethereum:8545 via env. - resources bumped to 8 CPU / 16Gi / 2Ti for a mainnet zkEVM node Context: pulled the canonical hermezconfig-mainnet.yaml from the upstream cdk-erigon repo, traced how the operator mounts ConfigTemplate (/config, read-only) and applies ContainerArgs/Env in internal/controller, and confirmed the image entrypoint from its Dockerfile. Build, vet, adapter + controller tests green; versioncheck --chain polygon-zkevm resolves cdk-erigon with no error. Datastreamer/sequencer endpoints are the public Polygon ones — worth a live re-sync check before prod. ~1.5h.
1 parent 69618f9 commit 72cfa0e

2 files changed

Lines changed: 76 additions & 44 deletions

File tree

internal/adapters/polygon_zkevm.go

Lines changed: 75 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@ import (
2929
// Constants
3030
// --------------------------------------------------------------------------
3131

32+
// defaultPolygonZkEVML1URL is the in-cluster Ethereum L1 endpoint cdk-erigon
33+
// reads the rollup state from. Override via spec.extraEnv (L1_RPC_URL).
3234
const defaultPolygonZkEVML1URL = "http://ethereum:8545"
3335

3436
// --------------------------------------------------------------------------
3537
// Type
3638
// --------------------------------------------------------------------------
3739

40+
// polygonZkEVMAdapter runs a Polygon zkEVM mainnet node on cdk-erigon, the
41+
// Erigon-based client that replaced the now-archived zkevm-node.
3842
type polygonZkEVMAdapter struct {
3943
protocolAdapter
4044
}
@@ -58,63 +62,91 @@ func (a *polygonZkEVMAdapter) DefaultImage(client string) string {
5862
}
5963

6064
func (a *polygonZkEVMAdapter) ConfigTemplate(_ chainsv1alpha2.ChainInstanceSpec) (string, string, error) {
61-
return "config.toml", polygonZkEVMConfig, nil
65+
return "hermezconfig.yaml", polygonZkEVMConfig, nil
6266
}
6367

64-
func (a *polygonZkEVMAdapter) HealthCheck(ctx context.Context, rpcURL string) (SyncStatus, error) {
65-
return evmHealthCheck(ctx, rpcURL)
68+
// ContainerArgs points cdk-erigon at the mounted config file and injects the L1
69+
// RPC URL from the environment so it can be overridden without rewriting the
70+
// config. Flags override config-file values in Erigon.
71+
func (a *polygonZkEVMAdapter) ContainerArgs(_ chainsv1alpha2.ChainInstanceSpec) []string {
72+
return []string{
73+
"--config=/config/hermezconfig.yaml",
74+
"--zkevm.l1-rpc-url=$(L1_RPC_URL)",
75+
}
6676
}
6777

68-
// --------------------------------------------------------------------------
69-
// Config
70-
// --------------------------------------------------------------------------
78+
// ContainerEnv supplies the default L1 (Ethereum) RPC endpoint used to sync the
79+
// zkEVM rollup state. Override by setting L1_RPC_URL in spec.extraEnv.
80+
func (a *polygonZkEVMAdapter) ContainerEnv(_ chainsv1alpha2.ChainInstanceSpec) []corev1.EnvVar {
81+
return []corev1.EnvVar{
82+
{Name: "L1_RPC_URL", Value: defaultPolygonZkEVML1URL},
83+
}
84+
}
7185

72-
const polygonZkEVMConfig = `# Polygon zkEVM (CDK Validium) node configuration
73-
[Node]
74-
DataDir = "/data"
75-
76-
[Node.StateDB]
77-
Host = "localhost"
78-
Port = 5432
79-
80-
[Node.Executor]
81-
URI = "localhost:50071"
82-
83-
[RPC]
84-
Host = "0.0.0.0"
85-
Port = 8545
86-
WebSockets = true
87-
WebSocketsPort = 8546
88-
ReadTimeout = "60s"
89-
WriteTimeout = "60s"
90-
MaxRequestsPerIPAndSecond = 500
91-
92-
[Metrics]
93-
Host = "0.0.0.0"
94-
Port = 9091
95-
Enabled = true
96-
97-
[Synchronizer]
98-
SyncInterval = "1s"
99-
SyncChunkSize = 100
100-
`
86+
func (a *polygonZkEVMAdapter) HealthCheck(ctx context.Context, rpcURL string) (SyncStatus, error) {
87+
return evmHealthCheck(ctx, rpcURL)
88+
}
10189

10290
func (a *polygonZkEVMAdapter) ContainerPorts(_ chainsv1alpha2.ChainInstanceSpec) []corev1.ContainerPort {
10391
ports := evmPorts(30303)
104-
return append(ports, corev1.ContainerPort{Name: "metrics", ContainerPort: 9091, Protocol: corev1.ProtocolTCP})
92+
return append(ports, corev1.ContainerPort{Name: "metrics", ContainerPort: 6061, Protocol: corev1.ProtocolTCP})
10593
}
10694

107-
// ContainerEnv injects the L1_RPC_URL environment variable required by the zkEVM node.
108-
func (a *polygonZkEVMAdapter) ContainerEnv(_ chainsv1alpha2.ChainInstanceSpec) []corev1.EnvVar {
109-
return []corev1.EnvVar{
110-
{Name: "L1_RPC_URL", Value: defaultPolygonZkEVML1URL},
95+
func (a *polygonZkEVMAdapter) VersionPolicy() ChainVersionPolicy {
96+
return ChainVersionPolicy{
97+
Registry: "ghcr.io",
98+
Repository: "0xpolygon/cdk-erigon",
99+
TagPattern: `^v\d+\.\d+\.\d+$`,
111100
}
112101
}
113102

114103
func (a *polygonZkEVMAdapter) DefaultResources() ResourceDefaults {
115104
return ResourceDefaults{
116-
CPURequest: resource.MustParse("4"),
117-
MemoryRequest: resource.MustParse("8Gi"),
118-
Storage: resource.MustParse("500Gi"),
105+
CPURequest: resource.MustParse("8"),
106+
MemoryRequest: resource.MustParse("16Gi"),
107+
Storage: resource.MustParse("2Ti"),
119108
}
120109
}
110+
111+
// --------------------------------------------------------------------------
112+
// Config
113+
// --------------------------------------------------------------------------
114+
115+
// polygonZkEVMConfig is the cdk-erigon hermez-mainnet RPC node config. The L1
116+
// contract addresses, sequencer RPC and datastreamer endpoint are the canonical
117+
// Polygon zkEVM mainnet values; zkevm.l1-rpc-url is injected via ContainerArgs.
118+
const polygonZkEVMConfig = `# Polygon zkEVM mainnet node (cdk-erigon, hermez-mainnet)
119+
datadir: /data
120+
chain: hermez-mainnet
121+
122+
http: true
123+
http.addr: 0.0.0.0
124+
http.port: 8545
125+
http.api: [eth, debug, net, trace, web3, erigon, zkevm]
126+
http.vhosts: any
127+
http.corsdomain: any
128+
ws: true
129+
130+
private.api.addr: localhost:9091
131+
metrics: true
132+
metrics.addr: 0.0.0.0
133+
metrics.port: 6061
134+
135+
externalcl: true
136+
137+
zkevm.l2-chain-id: 1101
138+
zkevm.l2-sequencer-rpc-url: https://zkevm-rpc.com
139+
zkevm.l2-datastreamer-url: stream.zkevm-rpc.com:6900
140+
zkevm.l1-chain-id: 1
141+
zkevm.l1-rollup-id: 1
142+
zkevm.address-sequencer: "0x148Ee7dAF16574cD020aFa34CC658f8F3fbd2800"
143+
zkevm.address-zkevm: "0x519E42c24163192Dca44CD3fBDCEBF6be9130987"
144+
zkevm.address-rollup: "0x5132A183E9F3CB7C848b0AAC5Ae0c4f0491B7aB2"
145+
zkevm.address-ger-manager: "0x580bda1e7A0CFAe92Fa7F6c20A3794F169CE3CFb"
146+
zkevm.l1-block-range: 20000
147+
zkevm.l1-query-delay: 6000
148+
zkevm.l1-first-block: 16896700
149+
zkevm.default-gas-price: 1000000000
150+
zkevm.max-gas-price: 0
151+
zkevm.gas-price-factor: 0.0375
152+
`

internal/adapters/versions_gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)