Skip to content

Commit

Permalink
Use cdk repo for erigon sequencer
Browse files Browse the repository at this point in the history
wip

wip

wip

wip

almost working

fix config

config

wip

Tips and tricks

Default to Eldelberry

wip

fix config

Bump prover and erigon
  • Loading branch information
vcastellm committed Jul 31, 2024
1 parent e1c898c commit 3fcbcae
Show file tree
Hide file tree
Showing 8 changed files with 273 additions and 46 deletions.
7 changes: 3 additions & 4 deletions cdk-erigon-sequencer-params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ args:
zkevm_prover_image: hermeznetwork/zkevm-prover:v6.0.3-RC18
# zkevm_prover_image: hermeznetwork/zkevm-prover:v4.0.19
zkevm_node_image: hermeznetwork/zkevm-node:v0.6.7
cdk_node_image: 0xpolygon/cdk-validium-node:0.6.7-cdk
cdk_node_image: ghcr.io/0xpolygon/cdk:0.0.8

zkevm_da_image: 0xpolygon/cdk-data-availability:0.0.7
# zkevm_da_image: 0xpolygon/cdk-data-availability:0.0.6
Expand All @@ -62,13 +62,12 @@ args:
# zkevm_agglayer_image: 0xpolygon/agglayer:0.1.3
zkevm_agglayer_image: ghcr.io/agglayer/agglayer-rs:main
zkevm_bridge_service_image: hermeznetwork/zkevm-bridge-service:v0.4.2
cdk_erigon_node_image: hermeznetwork/cdk-erigon:beta13-candidate3-5225235-amd64
# cdk_erigon_node_image: erigon:loop-wait
cdk_erigon_node_image: hermeznetwork/cdk-erigon:2.0.0-beta13
panoptichain_image: minhdvu/panoptichain
zkevm_bridge_ui_image: leovct/zkevm-bridge-ui:multi-network
zkevm_bridge_proxy_image: haproxy:2.9.9-bookworm
workload_image: leovct/workload:0.0.1
zkevm_sequence_sender_image: hermeznetwork/zkevm-sequence-sender:v0.2.0-RC5
# zkevm_sequence_sender_image: hermeznetwork/zkevm-sequence-sender:v0.2.0-RC5
toolbox_image: leovct/toolbox:0.0.1

# Port configuration.
Expand Down
97 changes: 65 additions & 32 deletions cdk_central_environment.star
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ zkevm_dac_package = import_module("./lib/zkevm_dac.star")
zkevm_node_package = import_module("./lib/zkevm_node.star")
zkevm_prover_package = import_module("./lib/zkevm_prover.star")
zkevm_sequence_sender_package = import_module("./lib/zkevm_sequence_sender.star")
cdk_node_package = import_module("./lib/cdk_node.star")
databases = import_module("./databases.star")


Expand Down Expand Up @@ -36,41 +37,41 @@ def run(plan, args):
config={"genesis.json": struct(template=genesis_file, data={})},
)

# Create the zkevm node config.
node_config_template = read_file(src="./templates/trusted-node/node-config.toml")
node_config_artifact = plan.render_templates(
config={
"node-config.toml": struct(
template=node_config_template,
data=args
| {
"is_cdk_validium": data_availability_package.is_cdk_validium(args),
}
| db_configs,
)
},
name="trusted-node-config",
)

# Start the synchronizer.
zkevm_node_package.start_synchronizer(
plan, args, node_config_artifact, genesis_artifact
)
if args["sequencer_type"] == "zkevm":
# Create the zkevm node config.
node_config_template = read_file(src="./templates/trusted-node/node-config.toml")
node_config_artifact = plan.render_templates(
config={
"node-config.toml": struct(
template=node_config_template,
data=args
| {
"is_cdk_validium": data_availability_package.is_cdk_validium(args),
}
| db_configs,
)
},
name="trusted-node-config",
)

# Start the rest of the zkevm node components.
keystore_artifacts = get_keystores_artifacts(plan, args)
zkevm_node_components_configs = (
zkevm_node_package.create_zkevm_node_components_config(
args, node_config_artifact, genesis_artifact, keystore_artifacts
# Start the synchronizer.
zkevm_node_package.start_synchronizer(
plan, args, node_config_artifact, genesis_artifact
)

# Start the rest of the zkevm node components.
keystore_artifacts = get_keystores_artifacts(plan, args)
zkevm_node_components_configs = (
zkevm_node_package.create_zkevm_node_components_config(
args, node_config_artifact, genesis_artifact, keystore_artifacts
)
)
)

plan.add_services(
configs=zkevm_node_components_configs,
description="Starting the rest of the zkevm node components",
)
plan.add_services(
configs=zkevm_node_components_configs,
description="Starting the rest of the zkevm node components",
)

if args["sequencer_type"] == "erigon":
sequence_sender_config = (
zkevm_sequence_sender_package.create_zkevm_sequence_sender_config(
plan, args, genesis_artifact, keystore_artifacts.sequencer
Expand All @@ -79,7 +80,39 @@ def run(plan, args):

plan.add_services(
configs=sequence_sender_config,
description="Starting the rest of the zkevm node components",
description="Starting the zkevm sequence-sender components",
)

if args["sequencer_type"] == "erigon":
# Create the cdk node config.
node_config_template = read_file(src="./templates/trusted-node/cdk-node-config.toml")
contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args)
node_config_artifact = plan.render_templates(
name="cdk-node-config-artifact",
config={
"cdk-node-config.toml": struct(
template=node_config_template,
data=args
| {
"is_cdk_validium": data_availability_package.is_cdk_validium(args),
}
| db_configs
| contract_setup_addresses,
)
},
)

# Start the cdk components.
keystore_artifacts = get_keystores_artifacts(plan, args)
cdk_node_configs = (
cdk_node_package.create_cdk_node_service_config(
args, node_config_artifact, genesis_artifact, keystore_artifacts
)
)

plan.add_services(
configs=cdk_node_configs,
description="Starting the cdk node components",
)

# Start the DAC if in validium mode.
Expand Down
10 changes: 10 additions & 0 deletions databases.star
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ TRUSTED_DATABASES = {
"user": "state_user",
"password": "redacted",
},
"aggregator_db": {
"name": "aggregator_db",
"user": "aggregator_user",
"password": "redacted",
},
"aggregator_syncer_db": {
"name": "syncer_db",
"user": "syncer_user",
"password": "redacted",
},
}

PERMISSIONLESS_DATABASES = {
Expand Down
4 changes: 2 additions & 2 deletions kurtosis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ description: |-
# zkevm_prover_image: hermeznetwork/zkevm-prover:v4.0.19
zkevm_node_image: hermeznetwork/zkevm-node:v0.7.0
cdk_node_image: 0xpolygon/cdk-validium-node:0.7.0-cdk
# cdk_node_image: 0xpolygon/cdk-validium-node:0.5.13-cdk.3
cdk_validium_node_image: 0xpolygon/cdk-validium-node:0.7.0-cdk
cdk_node_image: ghcr.io/0xpolygon/cdk:0.0.2
zkevm_da_image: 0xpolygon/cdk-data-availability:0.0.7
# zkevm_da_image: 0xpolygon/cdk-data-availability:0.0.6
Expand Down
52 changes: 52 additions & 0 deletions lib/cdk_node.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
data_availability_package = import_module("./data_availability.star")

NODE_COMPONENTS = struct(
sequence_sender="sequence-sender",
aggregator="aggregator",
)

def create_cdk_node_service_config(
args,
config_artifact,
genesis_artifact,
keystore_artifact,
):
cdk_node_name = "cdk-node" + args["deployment_suffix"]

cmd = [
"sleep 20 && cdk-node run " +
"-cfg=/etc/cdk/cdk-node-config.toml " +
"-custom-network-file=/etc/cdk/genesis.json " +
"-components=" + NODE_COMPONENTS.sequence_sender + "," + NODE_COMPONENTS.aggregator,
]

cdk_node_service_config = ServiceConfig(
image=data_availability_package.get_node_image(args),
ports={
"aggregator": PortSpec(
args["zkevm_aggregator_port"], application_protocol="grpc"
),
# "pprof": PortSpec(args["zkevm_pprof_port"], application_protocol="http"),
# "prometheus": PortSpec(
# args["zkevm_prometheus_port"], application_protocol="http"
# ),
},
files={
"/etc/cdk": Directory(
artifact_names=[
config_artifact,
genesis_artifact,
keystore_artifact.aggregator,
keystore_artifact.sequencer,
],
),
"/data": Directory(
artifact_names=[],
),
},
entrypoint=["sh", "-c"],
# entrypoint=["cdk-node"],
cmd=cmd,
)

return {cdk_node_name: cdk_node_service_config}
14 changes: 7 additions & 7 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ def run(
else:
plan.print("Skipping the deployment of cdk-erigon sequencer")

# Deploy cdk-erigon node.
if deploy_cdk_erigon_node:
plan.print("Deploying cdk-erigon node")
cdk_erigon_package.run_rpc(plan, args)
else:
plan.print("Skipping the deployment of cdk-erigon node")

plan.print("Deploying cdk central/trusted environment")
central_environment_args = dict(args)
central_environment_args["genesis_artifact"] = genesis_artifact
Expand All @@ -119,13 +126,6 @@ def run(
else:
plan.print("Skipping the deployment of cdk central/trusted environment")

# Deploy cdk-erigon node.
if deploy_cdk_erigon_node:
plan.print("Deploying cdk-erigon node")
cdk_erigon_package.run_rpc(plan, args)
else:
plan.print("Skipping the deployment of cdk-erigon node")

# Deploy cdk/bridge infrastructure.
if deploy_cdk_bridge_infra:
plan.print("Deploying cdk/bridge infrastructure")
Expand Down
133 changes: 133 additions & 0 deletions templates/trusted-node/cdk-node-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
ForkUpgradeBatchNumber = 0
ForkUpgradeNewForkId = 0

[Common]
IsValidiumMode = {{.is_cdk_validium}}
ContractVersions = "elderberry"

[Log]
Environment = "development" # "production" or "development"
Level = "debug"
Outputs = ["stderr"]

[SequenceSender]
WaitPeriodSendSequence = "15s"
LastBatchVirtualizationTimeMaxWaitPeriod = "10s"
MaxTxSizeForL1 = 131072
L2Coinbase = "{{.zkevm_l2_sequencer_address}}"
PrivateKey = {Path = "/etc/cdk/sequencer.keystore", Password = "{{.zkevm_l2_keystore_password}}"}
SequencesTxFileName = "/data/sequencesender.json"
GasOffset = 80000
WaitPeriodPurgeTxFile = "15m"
MaxPendingTx = 1
[SequenceSender.StreamClient]
Server = "{{.sequencer_name}}{{.deployment_suffix}}:{{.zkevm_data_streamer_port}}"
[SequenceSender.EthTxManager]
FrequencyToMonitorTxs = "1s"
WaitTxToBeMined = "2m"
ConsolidationL1ConfirmationBlocks = 5
FinalizationL1ConfirmationBlocks = 10
WaitReceiptToBeGenerated = "8s"
PrivateKeys = [
{Path = "/etc/cdk/sequencer.keystore", Password = "{{.zkevm_l2_keystore_password}}"},
]
ForcedGas = 0
GasPriceMarginFactor = 1
MaxGasPriceLimit = 0
PersistenceFilename = "/data/ethtxmanager.json"
[SequenceSender.EthTxManager.Etherman]
URL = "{{.l1_rpc_url}}"
L1ChainID = {{.l1_chain_id}}
HTTPHeaders = []

[Aggregator]
Host = "0.0.0.0"
Port = "{{.zkevm_aggregator_port}}"
RetryTime = "30s"
VerifyProofInterval = "30s"
ProofStatePollingInterval = "5s"
TxProfitabilityCheckerType = "acceptall"
TxProfitabilityMinReward = "1.1"
IntervalAfterWhichBatchConsolidateAnyway = "0s"
ChainID = "{{.zkevm_rollup_chain_id}}"
ForkId = 9
CleanupLockedProofsInterval = "2m0s"
GeneratingProofCleanupThreshold = "10m"
GasOffset = 150000
UpgradeEtrogBatchNumber = 0
WitnessURL = "http://{{.l2_rpc_name}}{{.deployment_suffix}}:{{.zkevm_rpc_http_port}}"
{{if .is_cdk_validium}}
SenderAddress = "{{.zkevm_l2_agglayer_address}}"
SettlementBackend = "agglayer"
AggLayerTxTimeout = "600s"
AggLayerURL = "http://zkevm-agglayer{{.deployment_suffix}}:{{.zkevm_agglayer_port}}"
{{else}}

SenderAddress = "{{.zkevm_l2_aggregator_address}}"
{{end}}

[Aggregator.SequencerPrivateKey]
Path = "/etc/cdk/sequencer.keystore"
Password = "{{.zkevm_l2_keystore_password}}"

[Aggregator.DB]
Name = "{{.aggregator_db.name}}"
User = "{{.aggregator_db.user}}"
Password = "{{.aggregator_db.password}}"
Host = "{{.aggregator_db.hostname}}"
Port = "{{.aggregator_db.port}}"
EnableLog = false
MaxConns = 200
[Aggregator.Log]
Environment = "development" # "production" or "development"
Level = "debug"
Outputs = ["stderr"]
[Aggregator.StreamClient]
Server = "{{.sequencer_name}}{{.deployment_suffix}}:{{.zkevm_data_streamer_port}}"
[Aggregator.EthTxManager]
FrequencyToMonitorTxs = "1s"
WaitTxToBeMined = "2m"
GetReceiptMaxTime = "250ms"
GetReceiptWaitInterval = "1s"
PrivateKeys = [
{Path = "/etc/cdk/aggregator.keystore", Password = "{{.zkevm_l2_keystore_password}}"},
]
ForcedGas = 0
GasPriceMarginFactor = 1
MaxGasPriceLimit = 0
PersistenceFilename = ""
ReadPendingL1Txs = false
SafeStatusL1NumberOfBlocks = 0
FinalizedStatusL1NumberOfBlocks = 0
[Aggregator.EthTxManager.Etherman]
URL = "{{.l1_rpc_url}}"
L1ChainID = {{.l1_chain_id}}
HTTPHeaders = []
[Aggregator.Synchronizer]
[Aggregator.Synchronizer.DB]
Name = "{{.aggregator_syncer_db.name}}"
User = "{{.aggregator_syncer_db.user}}"
Password = "{{.aggregator_syncer_db.password}}"
Host = "{{.aggregator_syncer_db.hostname}}"
Port = "{{.aggregator_syncer_db.port}}"
EnableLog = false
MaxConns = 10
[Aggregator.Synchronizer.Synchronizer]
SyncInterval = "10s"
SyncChunkSize = 1000
GenesisBlockNumber = 1
SyncUpToBlock = "latest"
BlockFinality = "latest"
OverrideStorageCheck = false
[Aggregator.Synchronizer.Etherman]
[Aggregator.Synchronizer.Etherman.Validium]
Enabled = {{.is_cdk_validium}}

[RPC]

[NetworkConfig.L1]
ChainID = "{{.l1_chain_id}}"
PolAddr = "{{.pol_token_address}}"
ZkEVMAddr = "{{.zkevm_rollup_address}}"
RollupManagerAddr = "{{.zkevm_rollup_manager_address}}"
GlobalExitRootManagerAddr = "{{.zkevm_global_exit_root_address}}"
2 changes: 1 addition & 1 deletion templates/trusted-node/prover-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
* aggregatorClientHost is the hostname that this prover will
* attempt to use while connecting to the aggregator
*/ -}}
"aggregatorClientHost": "zkevm-node-aggregator{{.deployment_suffix}}",
"aggregatorClientHost": "cdk-node{{.deployment_suffix}}",

{{- /*
* keccakScriptFile is the keccak-f state machine script file
Expand Down

0 comments on commit 3fcbcae

Please sign in to comment.