Skip to content

Commit

Permalink
Merge pull request #205 from jhkimqd/jihwan/pool-manager
Browse files Browse the repository at this point in the history
feat: integrate pool manager into kurtosis-cdk
  • Loading branch information
jhkimqd authored Aug 8, 2024
2 parents 6d3b4fe + cc7db2c commit 06a0c98
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 2 deletions.
5 changes: 5 additions & 0 deletions databases.star
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ TRUSTED_DATABASES = {
"user": "pool_user",
"password": "redacted",
},
"pool_manager_db": {
"name": "pool_manager_db",
"user": "pool_manager_user",
"password": "redacted",
},
"prover_db": {
"name": "prover_db",
"user": "prover_user",
Expand Down
2 changes: 2 additions & 0 deletions input_parser.star
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ DEFAULT_ARGS = {
"zkevm_sequence_sender_image": "hermeznetwork/zkevm-sequence-sender:v0.2.0-RC4",
"cdk_erigon_node_image": "hermeznetwork/cdk-erigon:2.0.0-beta13",
"toolbox_image": "leovct/toolbox:0.0.1",
"zkevm_pool_manager_image": "hermeznetwork/zkevm-pool-manager:v0.1.0-RC1",
"zkevm_hash_db_port": 50061,
"zkevm_executor_port": 50071,
"zkevm_aggregator_port": 50081,
Expand All @@ -29,6 +30,7 @@ DEFAULT_ARGS = {
"zkevm_bridge_ui_port": 80,
"zkevm_agglayer_port": 4444,
"zkevm_dac_port": 8484,
"zkevm_pool_manager_port": 8545,
"blockscout_public_port": 50101, # IANA registered ports up to 49151
"zkevm_l2_sequencer_address": "0x5b06837A43bdC3dD9F114558DAf4B26ed49842Ed",
"zkevm_l2_sequencer_private_key": "0x183c492d0ba156041a7f31a1b188958a7a22eebadca741a7fe64436092dc3181",
Expand Down
2 changes: 2 additions & 0 deletions kurtosis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ description: |-
zkevm_sequence_sender_image: hermeznetwork/zkevm-sequence-sender:v0.2.0-RC4
cdk_erigon_node_image: hermeznetwork/cdk-erigon:2.0.0-beta13
toolbox_image: leovct/toolbox:0.0.1
zkevm_pool_manager_image: hermeznetwork/zkevm-pool-manager:v0.1.0-RC1
# Port configuration.
zkevm_hash_db_port: 50061
Expand All @@ -75,6 +76,7 @@ description: |-
zkevm_bridge_ui_port: 80
zkevm_agglayer_port: 4444
zkevm_dac_port: 8484
zkevm_pool_manager_port: 8545
blockscout_public_port: 50101
# Addresses and private keys of the different components.
Expand Down
19 changes: 19 additions & 0 deletions lib/zkevm_pool_manager.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
def create_zkevm_pool_manager_service_config(args, config_artifact):
zkevm_pool_manager_service_name = "zkevm-pool-manager" + args["deployment_suffix"]
zkevm_pool_manager_service_config = ServiceConfig(
image=args["zkevm_pool_manager_image"],
ports={
"http": PortSpec(
args["zkevm_pool_manager_port"], application_protocol="http"
),
},
files={
"/etc/pool-manager": Directory(artifact_names=[config_artifact]),
},
entrypoint=["/bin/sh", "-c"],
# cmd=["run", "--cfg", "/app/pool-manager-config.toml"],
cmd=[
"/app/zkevm-pool-manager run --cfg /etc/pool-manager/pool-manager-config.toml",
],
)
return {zkevm_pool_manager_service_name: zkevm_pool_manager_service_config}
8 changes: 8 additions & 0 deletions main.star
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ blockscout_package = "./blockscout.star"
workload_package = "./workload.star"
blutgang_package = "./cdk_blutgang.star"
cdk_erigon_package = import_module("./cdk_erigon.star")
zkevm_pool_manager_package = import_module("./zkevm_pool_manager.star")


def run(
Expand Down Expand Up @@ -117,6 +118,13 @@ def run(
else:
plan.print("Skipping the deployment of cdk-erigon node")

# Deploy zkevm-pool-manager service.
if deploy_cdk_erigon_node:
plan.print("Deploying zkevm-pool-manager service")
zkevm_pool_manager_package.run_zkevm_pool_manager(plan, args)
else:
plan.print("Skipping the deployment of zkevm-pool-manager service")

plan.print("Deploying cdk central/trusted environment")
central_environment_args = dict(args)
central_environment_args["genesis_artifact"] = genesis_artifact
Expand Down
2 changes: 2 additions & 0 deletions params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ args:
zkevm_sequence_sender_image: "hermeznetwork/zkevm-sequence-sender:v0.2.0-RC4"
cdk_erigon_node_image: hermeznetwork/cdk-erigon:2.0.0-beta13
toolbox_image: leovct/toolbox:0.0.1
zkevm_pool_manager_image: hermeznetwork/zkevm-pool-manager:v0.1.0-RC1

# Port configuration.
zkevm_hash_db_port: 50061
Expand All @@ -87,6 +88,7 @@ args:
zkevm_bridge_ui_port: 80
zkevm_agglayer_port: 4444
zkevm_dac_port: 8484
zkevm_pool_manager_port: 8545
blockscout_public_port: 50101

# Addresses and private keys of the different components.
Expand Down
4 changes: 2 additions & 2 deletions scripts/reset_postgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# 2. update PGPASSWORD, PGUSER, and PGHOST params per your use case (modify configs)
# 3. run ./scripts/reset_postgres.sh (drop/recreate dbs and permissions)
# 4. kurtosis run --enclave cdk-v1 --args-file params.yml --image-download always . (deploy with fresh dbs)
DB_NAMES=("event_db" "pool_db" "prover_db" "state_db" "bridge_db" "dac_db")
DB_USERS=("event_user" "pool_user" "prover_user" "state_user" "agglayer_user" "bridge_user" "dac_user")
DB_NAMES=("event_db" "pool_db" "prover_db" "state_db" "bridge_db" "dac_db" "pool_manager_db")
DB_USERS=("event_user" "pool_user" "prover_user" "state_user" "bridge_user" "dac_user" "pool_manager_user")

# User must update credentials with master postgres IP/hostname and username
# TO DO: add env var support for credentials
Expand Down
2 changes: 2 additions & 0 deletions templates/cdk-erigon/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ zkevm.sequencer-batch-seal-time: 12s # 12s
zkevm.sequencer-block-seal-time: 6s # 6s
zkevm.sequencer-non-empty-batch-seal-time: 3s # 3s

zkevm.pool-manager-url: "http://zkevm-pool-manager{{.deployment_suffix}}:{{.zkevm_pool_manager_port}}"

zkevm.l1-chain-id: {{.l1_chain_id}}
zkevm.l1-first-block: 1
zkevm.l1-matic-contract-address: "{{.pol_token_address}}"
Expand Down
37 changes: 37 additions & 0 deletions templates/pool-manager/pool-manager-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[Log]
Environment = "development" # "production" or "development"
Level = "debug"
Outputs = ["stderr"]

[Server]
Host = "zkevm-pool-manager{{.deployment_suffix}}"
Port = {{.zkevm_pool_manager_port}}
ReadTimeout = "60s"
WriteTimeout = "60s"
MaxRequestsPerIPAndSecond = 500
EnableHttpLog = true
BatchRequestsEnabled = false
BatchRequestsLimit = 20

[DB]
User = "{{.pool_manager_db.user}}"
Password = "{{.pool_manager_db.password}}"
Name = "{{.pool_manager_db.name}}"
Host = "{{.pool_manager_db.hostname}}"
Port = "{{.pool_manager_db.port}}"
EnableLog = false
MaxConns = 200

[Sender]
SequencerURL = "http://cdk-erigon-sequencer{{.deployment_suffix}}:{{.zkevm_rpc_http_port}}"
ResendTxsCheckInterval = "1s"
Workers = 5
QueueSize = 25

[Monitor]
L2NodeURL = "http://cdk-erigon-node{{.deployment_suffix}}:{{.zkevm_rpc_http_port}}"
Workers = 5
QueueSize = 25
RetryWaitInterval = "3s"
InitialWaitInterval = "1s"
TxLifeTimeMax = "300s"
43 changes: 43 additions & 0 deletions zkevm_pool_manager.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
zkevm_pool_manager_package = import_module("./lib/zkevm_pool_manager.star")
databases = import_module("./databases.star")


def run_zkevm_pool_manager(plan, args):
db_configs = databases.get_db_configs(args["deployment_suffix"])

zkevm_pool_manager_config_artifact = create_zkevm_pool_manager_config_artifact(
plan, args, db_configs
)
zkevm_pool_manager_config = (
zkevm_pool_manager_package.create_zkevm_pool_manager_service_config(
args, zkevm_pool_manager_config_artifact
)
)

# Start the pool manager service.
zkevm_pool_manager_services = plan.add_services(
configs=zkevm_pool_manager_config,
description="Starting pool manager infra",
)


def create_zkevm_pool_manager_config_artifact(plan, args, db_configs):
zkevm_pool_manager_config_template = read_file(
src="./templates/pool-manager/pool-manager-config.toml"
)
return plan.render_templates(
name="pool-manager-config-artifact",
config={
"pool-manager-config.toml": struct(
template=zkevm_pool_manager_config_template,
data=args
| {
"deployment_suffix": args["deployment_suffix"],
"zkevm_pool_manager_port": args["zkevm_pool_manager_port"],
# ports
"zkevm_rpc_http_port": args["zkevm_rpc_http_port"],
}
| db_configs,
)
},
)

0 comments on commit 06a0c98

Please sign in to comment.