Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: integrate pool manager into kurtosis-cdk #205

Merged
merged 5 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cdk-erigon-sequencer-params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ args:
workload_image: leovct/workload:0.0.1
zkevm_sequence_sender_image: hermeznetwork/zkevm-sequence-sender:v0.2.0-RC5
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 @@ -85,6 +86,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
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
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"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove?

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 @@ -126,6 +127,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")

# Deploy cdk/bridge infrastructure.
if deploy_cdk_bridge_infra:
plan.print("Deploying cdk/bridge infrastructure")
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" "agglayer_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" "agglayer_db" "bridge_db" "dac_db" "pool_manager_db")
DB_USERS=("event_user" "pool_user" "prover_user" "state_user" "agglayer_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,
)
},
)