From 878ae5654a1a3af7ce73cfdd50adc29e2f733d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Fri, 15 Mar 2024 14:38:19 +0100 Subject: [PATCH] feat: add zkevm permissionless node (#4) * chore: add comments * feat: enable to generate permissionless node config * chore: refactor dbs * chore: refactor pool_db fn * chore: add start_postgres_db fn * chore: remove start_prover_db * chore: refactor dbs fn * chore: start_trusted_node_databases * chore: lint * feat: start permissionless dbs * chore: rename trusted node config * chore: nit * feat: create permissionless config * feat: generate permissionless prover config * chore: add permissionless configs to zkevm_artifact * feat: start permissionless prover * feat: start permissionless rpc * fix: typo * fi:x typo * fix: dbs init script issue * chore: nit * chore: refactor agglayer and dac dbs * chore: nit * chore: config update * fix: typos * chore: update permissionless node config * chore: avoid renaming databases for migrations checks * chore: for real??? * john comments --- cdk-params.yml | 59 ++- main.star | 412 +++++++++++------- templates/permissionless-node-config.toml | 145 ++++++ templates/permissionless-prover-config.json | 92 ++++ ...e-config.toml => trusted-node-config.toml} | 0 5 files changed, 548 insertions(+), 160 deletions(-) create mode 100644 templates/permissionless-node-config.toml create mode 100644 templates/permissionless-prover-config.json rename templates/{node-config.toml => trusted-node-config.toml} (100%) diff --git a/cdk-params.yml b/cdk-params.yml index bef6000f..1e20366b 100644 --- a/cdk-params.yml +++ b/cdk-params.yml @@ -50,40 +50,71 @@ zkevm_l2_keystore_password: "pSnv6Dh5s9ahuzGzH9RoCDrKAMddaX3m" # Databases zkevm_db_postgres_port: 5432 -zkevm_db_prover_user: "prover_user" -zkevm_db_prover_password: "SR5xq2KZPgvQkPDranCRhvkv6pnqfo77" +## Prover db zkevm_db_prover_name: "prover_db" + zkevm_db_prover_hostname: "prover-db" +zkevm_db_prover_user: "prover_user" +zkevm_db_prover_password: "SR5xq2KZPgvQkPDranCRhvkv6pnqfo77" -zkevm_db_pool_user: "pool_user" -zkevm_db_pool_password: "Qso5wMcLAN3oF7EfaawzgWKUUKWM3Vov" +zkevm_permissionless_db_prover_hostname: "permissionless-prover-db" +zkevm_permissionless_db_prover_user: "permissionless_prover_user" +zkevm_permissionless_db_prover_password: "fJc3BNTnURMNtie4w3HUhtQbe7omWn23" + +## Pool db +# Note: Do not change the name of the db +# https://github.com/0xPolygonHermez/zkevm-node/blob/develop/db/db.go#L19 zkevm_db_pool_name: "pool_db" + zkevm_db_pool_hostname: "pool-db" +zkevm_db_pool_user: "pool_user" +zkevm_db_pool_password: "Qso5wMcLAN3oF7EfaawzgWKUUKWM3Vov" -zkevm_db_event_user: "event_user" -zkevm_db_event_password: "rJXJN6iUAczh4oz8HRKYbVM8yC7tPeZm" +zkevm_permissionless_db_pool_hostname: "permissionless-pool-db" +zkevm_permissionless_db_pool_user: "permissionless_pool_user" +zkevm_permissionless_db_pool_password: "hkqvUnE65RvFjxaurXxNTDf4j6ozkejn" + +## Event db zkevm_db_event_name: "event_db" + zkevm_db_event_hostname: "event-db" +zkevm_db_event_user: "event_user" +zkevm_db_event_password: "rJXJN6iUAczh4oz8HRKYbVM8yC7tPeZm" -zkevm_db_state_user: "state_user" -zkevm_db_state_password: "rHTX7EpajF8zYDPatN32rH3B2pn89dmq" +zkevm_permissionless_db_event_hostname: "permissionless-event-db" +zkevm_permissionless_db_event_user: "permissionless_event_user" +zkevm_permissionless_db_event_password: "d3GSJ8dkWxtMpNbP7w4Za7dF3Gh23XwM" + +## State db +# Note: Do not change the name of the db +# https://github.com/0xPolygonHermez/zkevm-node/blob/develop/db/db.go#L17 zkevm_db_state_name: "state_db" + zkevm_db_state_hostname: "state-db" +zkevm_db_state_user: "state_user" +zkevm_db_state_password: "rHTX7EpajF8zYDPatN32rH3B2pn89dmq" -zkevm_db_bridge_user: "bridge_user" -zkevm_db_bridge_password: "aXPqaRvgo5DfnTbHtpYS9rMhVpjvb6tY" +zkevm_permissionless_db_state_hostname: "permissionless-state-db" +zkevm_permissionless_db_state_user: "permissionless_state_user" +zkevm_permissionless_db_state_password: "BXeRf7Y4QgkB4Z6c7w6mtXzkdptvwixR" + +## Bridge db zkevm_db_bridge_name: "bridge_db" + zkevm_db_bridge_hostname: "bridge-db" +zkevm_db_bridge_user: "bridge_user" +zkevm_db_bridge_password: "aXPqaRvgo5DfnTbHtpYS9rMhVpjvb6tY" -zkevm_db_agglayer_user: "agglayer_user" -zkevm_db_agglayer_password: "PzycR2uB6PQv8ahj465ExvdyRLkknRNW" +## AggLayer db zkevm_db_agglayer_name: "agglayer_db" zkevm_db_agglayer_hostname: "agglayer-db" +zkevm_db_agglayer_user: "agglayer_user" +zkevm_db_agglayer_password: "PzycR2uB6PQv8ahj465ExvdyRLkknRNW" -zkevm_db_dac_user: "dac_user" -zkevm_db_dac_password: "PzycR2uB6PQv8ahj465ExvdyRLkknRNW" zkevm_db_dac_name: "dac_db" zkevm_db_dac_hostname: "dac-db" +zkevm_db_dac_user: "dac_user" +zkevm_db_dac_password: "PzycR2uB6PQv8ahj465ExvdyRLkknRNW" zkevm_deployment_salt: "0x0000000000000000000000000000000000000000000000000000000000000001" zkevm_l2_timelock_address: diff --git a/main.star b/main.star index 2204c2ce..24c723b7 100644 --- a/main.star +++ b/main.star @@ -12,7 +12,7 @@ POSTGRES_PORT_ID = "postgres" def run(plan, args): deployment_label = args["deployment_idx"] - # Determine system architecture. + # Determine system architecture cpu_arch_result = plan.run_sh(run="uname -m | tr -d '\n'") cpu_arch = cpu_arch_result.output plan.print("Running on {} architecture".format(cpu_arch)) @@ -23,8 +23,8 @@ def run(plan, args): if args["zkevm_rollup_consensus"] == "PolygonValidiumEtrog": args["is_cdk"] = True - # Make ethereum package available. For now we'll stick with most - # of the defaults + # Deploy L1 chain + # For now we'll stick with most of the defaults ethereum_package.run( plan, { @@ -38,7 +38,7 @@ def run(plan, args): }, ) - # Deploy Parameters + # Create deploy parameters deploy_parameters_template = read_file(src="./templates/deploy_parameters.json") deploy_parameters_artifact = plan.render_templates( config={ @@ -47,7 +47,7 @@ def run(plan, args): ) } ) - # Create Rollup Paramaters + # Create rollup paramaters create_rollup_parameters_template = read_file( src="./templates/create_rollup_parameters.json" ) @@ -58,7 +58,7 @@ def run(plan, args): ) } ) - # Contract Deployment script + # Create contract deployment script contract_deployment_script_template = read_file( src="./templates/run-contract-setup.sh" ) @@ -69,42 +69,67 @@ def run(plan, args): ) } ) - # Node configuration - node_config_template = read_file(src="./templates/node-config.toml") - node_config_artifact = plan.render_templates( - config={"node-config.toml": struct(template=node_config_template, data=args)} + + # Create trusted node configuration + trusted_node_config_template = read_file(src="./templates/trusted-node-config.toml") + trusted_node_config_artifact = plan.render_templates( + config={ + "trusted-node-config.toml": struct( + template=trusted_node_config_template, data=args + ) + } + ) + # Create permissionless node configuration + permissionless_node_config_template = read_file( + src="./templates/permissionless-node-config.toml" ) - # Bridge configuration + permissionless_node_config_artifact = plan.render_templates( + config={ + "permissionless-node-config.toml": struct( + template=permissionless_node_config_template, data=args + ) + } + ) + # Create bridge configuration bridge_config_template = read_file(src="./templates/bridge-config.toml") bridge_config_artifact = plan.render_templates( config={ "bridge-config.toml": struct(template=bridge_config_template, data=args) } ) - - # agglayer configuration + # Create AggLayer configuration agglayer_config_template = read_file(src="./templates/agglayer-config.toml") agglayer_config_artifact = plan.render_templates( config={ "agglayer-config.toml": struct(template=agglayer_config_template, data=args) } ) - # dac configuration + # Create DAC configuration dac_config_template = read_file(src="./templates/dac-config.toml") dac_config_artifact = plan.render_templates( config={"dac-config.toml": struct(template=dac_config_template, data=args)} ) - - # Prover configuration + # Create prover configuration prover_config_template = read_file(src="./templates/prover-config.json") prover_config_artifact = plan.render_templates( config={ "prover-config.json": struct(template=prover_config_template, data=args) } ) + # Create permissionless prover configuration + permissionless_prover_config_template = read_file( + src="./templates/permissionless-prover-config.json" + ) + permissionless_prover_config_artifact = plan.render_templates( + config={ + "permissionless-prover-config.json": struct( + template=permissionless_prover_config_template, data=args + ) + } + ) + # Create helper service to deploy contracts zkevm_etc_directory = Directory(persistent_key="zkevm-artifacts") - plan.add_service( name="contracts" + args["deployment_idx"], config=ServiceConfig( @@ -116,8 +141,10 @@ def run(plan, args): deploy_parameters_artifact, create_rollup_parameters_artifact, contract_deployment_script_artifact, - node_config_artifact, + trusted_node_config_artifact, prover_config_artifact, + permissionless_node_config_artifact, + permissionless_prover_config_artifact, bridge_config_artifact, agglayer_config_artifact, dac_config_artifact, @@ -127,6 +154,7 @@ def run(plan, args): ), ) + # Debug service plan.add_service( name="netshoot-debug", config=ServiceConfig( @@ -134,14 +162,14 @@ def run(plan, args): ), ) - # check if the contracts were already initialized.. I'm leaving - # this here for now, but it's not useful + # TODO: Check if the contracts were already initialized.. I'm leaving this here for now, but it's not useful!! contract_init_stat = plan.exec( service_name="contracts" + args["deployment_idx"], acceptable_codes=[0, 1], recipe=ExecRecipe(command=["stat", "/opt/zkevm/.init-complete.lock"]), ) + # Deploy contracts plan.exec( service_name="contracts" + args["deployment_idx"], recipe=ExecRecipe( @@ -163,13 +191,11 @@ def run(plan, args): command=["chmod", "a+x", "/opt/contract-deploy/run-contract-setup.sh"] ), ) - plan.print("Running zkEVM contract deployment. This might take some time...") plan.exec( service_name="contracts" + args["deployment_idx"], recipe=ExecRecipe(command=["/opt/contract-deploy/run-contract-setup.sh"]), ) - zkevm_configs = plan.store_service_files( service_name="contracts" + args["deployment_idx"], src="/opt/zkevm", @@ -177,8 +203,21 @@ def run(plan, args): description="These are the files needed to start various node services", ) - add_databases(plan, args) + # Start databases + prover_db_init_script = plan.upload_files( + src="./templates/prover-db-init.sql", name="prover-db-init.sql" + ) + event_db_init_script = plan.upload_files( + src="./templates/event-db-init.sql", name="event-db-init.sql" + ) + start_trusted_node_databases( + plan, args, prover_db_init_script, event_db_init_script + ) + start_permissionless_node_databases( + plan, args, prover_db_init_script, event_db_init_script + ) + # Start prover plan.add_service( name="zkevm-prover" + args["deployment_idx"], config=ServiceConfig( @@ -204,6 +243,42 @@ def run(plan, args): ), ) + # Start permissionless prover + # TODO do a big sed for all of these hard coded ports and make them configurable + plan.add_service( + name="zkevm-permissionless-prover" + args["deployment_idx"], + config=ServiceConfig( + image=args["zkevm_prover_image"], + ports={ + "hash-db-server": PortSpec( + args["zkevm_hash_db_port"], application_protocol="grpc" + ), + "executor-server": PortSpec( + args["zkevm_executor_port"], application_protocol="grpc" + ), + }, + files={ + "/etc/": zkevm_configs, + }, + entrypoint=["/bin/bash", "-c"], + cmd=[ + '[[ "{0}" == "aarch64" || "{0}" == "arm64" ]] && export EXPERIMENTAL_DOCKER_DESKTOP_FORCE_QEMU=1; \ + /usr/local/bin/zkProver -c /etc/zkevm/permissionless-prover-config.json'.format( + cpu_arch + ), + ], + ), + ) + + # Start AggLayer + start_postgres_db( + plan, + name=args["zkevm_db_agglayer_hostname"] + args["deployment_idx"], + port=args["zkevm_db_postgres_port"], + db=args["zkevm_db_agglayer_name"], + user=args["zkevm_db_agglayer_user"], + password=args["zkevm_db_agglayer_password"], + ) plan.add_service( name="zkevm-agglayer" + args["deployment_idx"], config=ServiceConfig( @@ -225,6 +300,16 @@ def run(plan, args): cmd=["run", "--cfg", "/etc/zkevm/agglayer-config.toml"], ), ) + + # Start DAC + start_postgres_db( + plan, + name=args["zkevm_db_dac_hostname"] + args["deployment_idx"], + port=args["zkevm_db_postgres_port"], + db=args["zkevm_db_dac_name"], + user=args["zkevm_db_dac_user"], + password=args["zkevm_db_dac_password"], + ) plan.add_service( name="zkevm-dac" + args["deployment_idx"], config=ServiceConfig( @@ -246,6 +331,7 @@ def run(plan, args): ), ) + # Start synchronizer plan.add_service( name="zkevm-node-synchronizer" + args["deployment_idx"], config=ServiceConfig( @@ -267,7 +353,7 @@ def run(plan, args): cmd=[ "run", "--cfg", - "/etc/zkevm/node-config.toml", + "/etc/zkevm/trusted-node-config.toml", "--network", "custom", "--custom-network-file", @@ -278,6 +364,7 @@ def run(plan, args): ), ) + # Start sequencer plan.add_service( name="zkevm-node-sequencer" + args["deployment_idx"], config=ServiceConfig( @@ -305,7 +392,7 @@ def run(plan, args): cmd=[ "run", "--cfg", - "/etc/zkevm/node-config.toml", + "/etc/zkevm/trusted-node-config.toml", "--network", "custom", "--custom-network-file", @@ -338,7 +425,7 @@ def run(plan, args): cmd=[ "run", "--cfg", - "/etc/zkevm/node-config.toml", + "/etc/zkevm/trusted-node-config.toml", "--network", "custom", "--custom-network-file", @@ -349,6 +436,7 @@ def run(plan, args): ), ) + # Start aggregator plan.add_service( name="zkevm-node-aggregator" + args["deployment_idx"], config=ServiceConfig( @@ -373,7 +461,7 @@ def run(plan, args): cmd=[ "run", "--cfg", - "/etc/zkevm/node-config.toml", + "/etc/zkevm/trusted-node-config.toml", "--network", "custom", "--custom-network-file", @@ -384,6 +472,7 @@ def run(plan, args): ), ) + # Start trusted RPC plan.add_service( name="zkevm-node-rpc" + args["deployment_idx"], config=ServiceConfig( @@ -410,20 +499,52 @@ def run(plan, args): ], cmd=[ "run", - "--cfg", - "/etc/zkevm/node-config.toml", - "--network", - "custom", - "--custom-network-file", - "/etc/zkevm/genesis.json", - "--components", - "rpc", - "--http.api", - "eth,net,debug,zkevm,txpool,web3", + "--cfg=/etc/zkevm/trusted-node-config.toml", + "--network=custom", + "--custom-network-file=/etc/zkevm/genesis.json", + "--components=rpc", + "--http.api=eth,net,debug,zkevm,txpool,web3", ], ), ) + # Start permissionless RPC + plan.add_service( + name="zkevm-permissionless-node-rpc" + args["deployment_idx"], + config=ServiceConfig( + image=args["zkevm_node_image"], + ports={ + "permissionless-rpc": PortSpec( + args["zkevm_rpc_http_port"], application_protocol="http" + ), + "permissionless-ws": PortSpec( + args["zkevm_rpc_ws_port"], application_protocol="ws" + ), + "pprof": PortSpec( + args["zkevm_pprof_port"], application_protocol="http" + ), + "prometheus": PortSpec( + args["zkevm_prometheus_port"], application_protocol="http" + ), + }, + files={ + "/etc/": zkevm_configs, + }, + entrypoint=[ + "/app/zkevm-node", + ], + cmd=[ + "run", + "--cfg=/etc/zkevm/permissionless-node-config.toml", + "--network=custom", + "--custom-network-file=/etc/zkevm/genesis.json", + "--components=rpc,synchronizer", + "--http.api=eth,net,debug,zkevm,txpool,web3", + ], + ), + ) + + # Start eth-tx-manager and l2-gas-pricer plan.add_service( name="zkevm-node-eth-tx-manager" + args["deployment_idx"], config=ServiceConfig( @@ -445,7 +566,7 @@ def run(plan, args): cmd=[ "run", "--cfg", - "/etc/zkevm/node-config.toml", + "/etc/zkevm/trusted-node-config.toml", "--network", "custom", "--custom-network-file", @@ -476,7 +597,7 @@ def run(plan, args): cmd=[ "run", "--cfg", - "/etc/zkevm/node-config.toml", + "/etc/zkevm/trusted-node-config.toml", "--network", "custom", "--custom-network-file", @@ -487,6 +608,7 @@ def run(plan, args): ), ) + # Start bridge plan.add_service( name="zkevm-bridge-service" + args["deployment_idx"], config=ServiceConfig( @@ -510,132 +632,130 @@ def run(plan, args): ) -def add_databases(plan, args): - prover_db_init_artifact = plan.upload_files( - src="./templates/prover-db-init.sql", name="prover-db-init.sql" - ) +def start_trusted_node_databases( + plan, args, prover_db_init_script, event_db_init_script +): + postgres_port = args["zkevm_db_postgres_port"] - prover_db = plan.add_service( + # Start prover db + start_postgres_db( + plan, name=args["zkevm_db_prover_hostname"] + args["deployment_idx"], - config=ServiceConfig( - image=POSTGRES_IMAGE, - ports={ - POSTGRES_PORT_ID: PortSpec( - args["zkevm_db_postgres_port"], application_protocol="postgresql" - ), - }, - env_vars={ - "POSTGRES_DB": args["zkevm_db_prover_name"], - "POSTGRES_USER": args["zkevm_db_prover_user"], - "POSTGRES_PASSWORD": args["zkevm_db_prover_password"], - }, - files={ - "/docker-entrypoint-initdb.d/": prover_db_init_artifact, - }, - ), - ) - pool_db = plan.add_service( - name=args["zkevm_db_pool_hostname"] + args["deployment_idx"], - config=ServiceConfig( - image=POSTGRES_IMAGE, - ports={ - POSTGRES_PORT_ID: PortSpec( - args["zkevm_db_postgres_port"], application_protocol="postgresql" - ), - }, - env_vars={ - "POSTGRES_DB": args["zkevm_db_pool_name"], - "POSTGRES_USER": args["zkevm_db_pool_user"], - "POSTGRES_PASSWORD": args["zkevm_db_pool_password"], - }, - ), + port=postgres_port, + db=args["zkevm_db_prover_name"], + user=args["zkevm_db_prover_user"], + password=args["zkevm_db_prover_password"], + init_script_artifact_name=prover_db_init_script, ) - event_db_init_artifact = plan.upload_files( - src="./templates/event-db-init.sql", name="event-db-init.sql" + # Start pool db + start_postgres_db( + plan, + name=args["zkevm_db_pool_hostname"] + args["deployment_idx"], + port=postgres_port, + db=args["zkevm_db_pool_name"], + user=args["zkevm_db_pool_user"], + password=args["zkevm_db_pool_password"], ) - event_db = plan.add_service( + # Start event db + start_postgres_db( + plan, name=args["zkevm_db_event_hostname"] + args["deployment_idx"], - config=ServiceConfig( - image=POSTGRES_IMAGE, - ports={ - POSTGRES_PORT_ID: PortSpec( - args["zkevm_db_postgres_port"], application_protocol="postgresql" - ), - }, - env_vars={ - "POSTGRES_DB": args["zkevm_db_event_name"], - "POSTGRES_USER": args["zkevm_db_event_user"], - "POSTGRES_PASSWORD": args["zkevm_db_event_password"], - }, - files={ - "/docker-entrypoint-initdb.d/": event_db_init_artifact, - }, - ), + port=postgres_port, + db=args["zkevm_db_event_name"], + user=args["zkevm_db_event_user"], + password=args["zkevm_db_event_password"], + init_script_artifact_name=event_db_init_script, ) - state_db = plan.add_service( + # Start state db + start_postgres_db( + plan, name=args["zkevm_db_state_hostname"] + args["deployment_idx"], - config=ServiceConfig( - image=POSTGRES_IMAGE, - ports={ - POSTGRES_PORT_ID: PortSpec( - args["zkevm_db_postgres_port"], application_protocol="postgresql" - ), - }, - env_vars={ - "POSTGRES_DB": args["zkevm_db_state_name"], - "POSTGRES_USER": args["zkevm_db_state_user"], - "POSTGRES_PASSWORD": args["zkevm_db_state_password"], - }, - ), + port=postgres_port, + db=args["zkevm_db_state_name"], + user=args["zkevm_db_state_user"], + password=args["zkevm_db_state_password"], ) - bridge_db = plan.add_service( + + # Start bridge db + start_postgres_db( + plan, name=args["zkevm_db_bridge_hostname"] + args["deployment_idx"], - config=ServiceConfig( - image=POSTGRES_IMAGE, - ports={ - POSTGRES_PORT_ID: PortSpec( - args["zkevm_db_postgres_port"], application_protocol="postgresql" - ), - }, - env_vars={ - "POSTGRES_DB": args["zkevm_db_bridge_name"], - "POSTGRES_USER": args["zkevm_db_bridge_user"], - "POSTGRES_PASSWORD": args["zkevm_db_bridge_password"], - }, - ), + port=postgres_port, + db=args["zkevm_db_bridge_name"], + user=args["zkevm_db_bridge_user"], + password=args["zkevm_db_bridge_password"], ) - agglayer_db = plan.add_service( - name=args["zkevm_db_agglayer_hostname"] + args["deployment_idx"], - config=ServiceConfig( - image=POSTGRES_IMAGE, - ports={ - POSTGRES_PORT_ID: PortSpec( - args["zkevm_db_postgres_port"], application_protocol="postgresql" - ), - }, - env_vars={ - "POSTGRES_DB": args["zkevm_db_agglayer_name"], - "POSTGRES_USER": args["zkevm_db_agglayer_user"], - "POSTGRES_PASSWORD": args["zkevm_db_agglayer_password"], - }, - ), + + +def start_permissionless_node_databases( + plan, args, prover_db_init_script, event_db_init_script +): + postgres_port = args["zkevm_db_postgres_port"] + + # Start permissionless prover db + start_postgres_db( + plan, + name=args["zkevm_permissionless_db_prover_hostname"] + args["deployment_idx"], + port=postgres_port, + db=args["zkevm_db_prover_name"], + user=args["zkevm_permissionless_db_prover_user"], + password=args["zkevm_permissionless_db_prover_password"], + init_script_artifact_name=prover_db_init_script, ) - dac_db = plan.add_service( - name=args["zkevm_db_dac_hostname"] + args["deployment_idx"], + + # Start permissionless pool db + start_postgres_db( + plan, + name=args["zkevm_permissionless_db_pool_hostname"] + args["deployment_idx"], + port=postgres_port, + db=args["zkevm_db_pool_name"], + user=args["zkevm_permissionless_db_pool_user"], + password=args["zkevm_permissionless_db_pool_password"], + ) + + # Start permissionless event db + start_postgres_db( + plan, + name=args["zkevm_permissionless_db_event_hostname"] + args["deployment_idx"], + port=postgres_port, + db=args["zkevm_db_event_name"], + user=args["zkevm_permissionless_db_event_user"], + password=args["zkevm_permissionless_db_event_password"], + init_script_artifact_name=event_db_init_script, + ) + + # Start permissionless state db + start_postgres_db( + plan, + name=args["zkevm_permissionless_db_state_hostname"] + args["deployment_idx"], + port=postgres_port, + db=args["zkevm_db_state_name"], + user=args["zkevm_permissionless_db_state_user"], + password=args["zkevm_permissionless_db_state_password"], + ) + + +def start_postgres_db( + plan, name, port, db, user, password, init_script_artifact_name="" +): + files = {} + if init_script_artifact_name != "": + files["/docker-entrypoint-initdb.d/"] = init_script_artifact_name + plan.add_service( + name=name, config=ServiceConfig( image=POSTGRES_IMAGE, ports={ - POSTGRES_PORT_ID: PortSpec( - args["zkevm_db_postgres_port"], application_protocol="postgresql" - ), + POSTGRES_PORT_ID: PortSpec(port, application_protocol="postgresql"), }, env_vars={ - "POSTGRES_DB": args["zkevm_db_dac_name"], - "POSTGRES_USER": args["zkevm_db_dac_user"], - "POSTGRES_PASSWORD": args["zkevm_db_dac_password"], + "POSTGRES_DB": db, + "POSTGRES_USER": user, + "POSTGRES_PASSWORD": password, }, + files=files, ), ) diff --git a/templates/permissionless-node-config.toml b/templates/permissionless-node-config.toml new file mode 100644 index 00000000..c1d09ebd --- /dev/null +++ b/templates/permissionless-node-config.toml @@ -0,0 +1,145 @@ +# https://github.com/0xPolygonHermez/zkevm-node/blob/v0.5.13/test/config/test.node.config.toml +IsTrustedSequencer = false + +[Log] +Environment = "production" # "production" or "development" +Level = "debug" +Outputs = ["stderr"] + +[State] + [State.DB] + User = "{{.zkevm_permissionless_db_state_user}}" + Password = "{{.zkevm_permissionless_db_state_password}}" + Name = "{{.zkevm_db_state_name}}" + Host = "{{.zkevm_permissionless_db_state_hostname}}{{.deployment_idx}}" + Port = "{{.zkevm_db_postgres_port}}" + EnableLog = false + MaxConns = 200 + [State.Batch] + [State.Batch.Constraints] + MaxTxsPerBatch = 300 + MaxBatchBytesSize = 120000 + MaxCumulativeGasUsed = 1125899906842624 + MaxKeccakHashes = 2145 + MaxPoseidonHashes = 252357 + MaxPoseidonPaddings = 135191 + MaxMemAligns = 236585 + MaxArithmetics = 236585 + MaxBinaries = 473170 + MaxSteps = 7570538 + MaxSHA256Hashes = 1596 + +[Pool] +FreeClaimGasLimit = 1500000 +IntervalToRefreshBlockedAddresses = "5m" +IntervalToRefreshGasPrices = "5s" +MaxTxBytesSize=100132 +MaxTxDataBytesSize=100000 +DefaultMinGasPriceAllowed = 1000000000 +MinAllowedGasPriceInterval = "5m" +PollMinAllowedGasPriceInterval = "15s" +AccountQueue = 64 +GlobalQueue = 1024 + [Pool.EffectiveGasPrice] + Enabled = false + L1GasPriceFactor = 0.25 + ByteGasCost = 16 + ZeroByteGasCost = 4 + NetProfit = 1 + BreakEvenFactor = 1.1 + FinalDeviationPct = 10 + EthTransferGasPrice = 0 + EthTransferL1GasPriceFactor = 0 + L2GasPriceSuggesterFactor = 0.5 + [Pool.DB] + User = "{{.zkevm_permissionless_db_pool_user}}" + Password = "{{.zkevm_permissionless_db_pool_password}}" + Name = "{{.zkevm_db_pool_name}}" + Host = "{{.zkevm_permissionless_db_pool_hostname}}{{.deployment_idx}}" + Port = "{{.zkevm_db_postgres_port}}" + EnableLog = false + MaxConns = 200 + +[Etherman] +URL = "{{.l1_rpc_url}}" +ForkIDChunkSize = 20000 +MultiGasProvider = false + [Etherscan] + ApiKey = "" + +[RPC] +Host = "0.0.0.0" +Port = {{.zkevm_rpc_http_port}} +ReadTimeout = "60s" +WriteTimeout = "60s" +BatchRequestsEnabled = true +BatchRequestsLimit = 500 +MaxRequestsPerIPAndSecond = 5000 +SequencerNodeURI = "zkevm-node-sequencer{{.deployment_idx}}:{{.zkevm_data_streamer_port}}" +EnableL2SuggestedGasPricePolling = true + [RPC.WebSockets] + Enabled = true + Port = {{.zkevm_rpc_ws_port}} + +[Synchronizer] +SyncInterval = "1s" +SyncChunkSize = 100 +TrustedSequencerURL = "" # If it is empty or not specified, then the value is read from the smc. +L1SynchronizationMode = "sequential" + [Synchronizer.L1ParallelSynchronization] + MaxClients = 10 + MaxPendingNoProcessedBlocks = 25 + RequestLastBlockPeriod = "5s" + RequestLastBlockTimeout = "5s" + RequestLastBlockMaxRetries = 3 + StatisticsPeriod = "5m" + TimeoutMainLoop = "5m" + RollupInfoRetriesSpacing= "5s" + FallbackToSequentialModeOnSynchronized = false + [Synchronizer.L1ParallelSynchronization.PerformanceWarning] + AceptableInacctivityTime = "5s" + ApplyAfterNumRollupReceived = 10 + +[EthTxManager] +ForcedGas = 0 + +[L2GasPriceSuggester] +Type = "default" +UpdatePeriod = "10s" +Factor = 0.5 +DefaultGasPriceWei = 1000000000 +MaxGasPriceWei = 0 + +[MTClient] +URI = "zkevm-permissionless-prover{{.deployment_idx}}:{{.zkevm_hash_db_port}}" + +[Executor] +URI = "zkevm-permissionless-prover{{.deployment_idx}}:{{.zkevm_executor_port}}" +MaxGRPCMessageSize = 100000000 + +[Metrics] +Host = "0.0.0.0" +Port = {{.zkevm_prometheus_port}} +Enabled = true +ProfilingHost = "0.0.0.0" +ProfilingPort = {{.zkevm_pprof_port}} +ProfilingEnabled = true + +[EventLog] + [EventLog.DB] + User = "{{.zkevm_permissionless_db_event_user}}" + Password = "{{.zkevm_permissionless_db_event_password}}" + Name = "{{.zkevm_db_event_name}}" + Host = "{{.zkevm_permissionless_db_event_hostname}}{{.deployment_idx}}" + Port = "{{.zkevm_db_postgres_port}}" + EnableLog = true + MaxConns = 200 + +[HashDB] +User = "{{.zkevm_permissionless_db_prover_user}}" +Password = "{{.zkevm_permissionless_db_prover_password}}" +Name = "{{.zkevm_db_prover_name}}" +Host = "{{.zkevm_permissionless_db_prover_hostname}}{{.deployment_idx}}" +Port = "{{.zkevm_db_postgres_port}}" +EnableLog = false +MaxConns = 200 \ No newline at end of file diff --git a/templates/permissionless-prover-config.json b/templates/permissionless-prover-config.json new file mode 100644 index 00000000..434d43d1 --- /dev/null +++ b/templates/permissionless-prover-config.json @@ -0,0 +1,92 @@ +{ + "_source": "https://github.com/0xPolygonHermez/zkevm-node/blob/v0.5.13/test/config/test.permissionless.prover.config.json", + + "runExecutorServer": true, + "runExecutorClient": false, + "runExecutorClientMultithread": false, + + "runHashDBServer": true, + "runHashDBTest": false, + + "runAggregatorServer": false, + "runAggregatorClient": false, + "runAggregatorClientMock": true, + "aggregatorClientMockTimeout": 15000000, + "proverName": "test-prover", + + "runFileGenBatchProof": false, + "runFileGenAggregatedProof": false, + "runFileGenFinalProof": false, + "runFileProcessBatch": false, + "runFileProcessBatchMultithread": false, + + "runKeccakScriptGenerator": false, + "runKeccakTest": false, + "runStorageSMTest": false, + "runBinarySMTest": false, + "runMemAlignSMTest": false, + "runSHA256Test": false, + "runBlakeTest": false, + + "executeInParallel": true, + "useMainExecGenerated": true, + "saveRequestToFile": false, + "saveInputToFile": false, + "saveDbReadsToFile": false, + "saveDbReadsToFileOnChange": false, + "saveOutputToFile": true, + "saveProofToFile": true, + "saveResponseToFile": false, + "loadDBToMemCache": true, + "opcodeTracer": false, + "logRemoteDbReads": false, + "logExecutorServerResponses": false, + + "proverServerPort": 50051, + "proverServerMockPort": 50052, + "proverServerMockTimeout": 10000000, + "proverClientPort": 50051, + "proverClientHost": "127.0.0.1", + + "executorServerPort": {{.zkevm_executor_port}}, + "executorROMLineTraces": false, + "executorClientPort": {{.zkevm_executor_port}}, + "executorClientHost": "127.0.0.1", + + "hashDBServerPort": {{.zkevm_hash_db_port}}, + "hashDBURL": "local", + + "aggregatorServerPort": {{.zkevm_aggregator_port}}, + "aggregatorClientPort": {{.zkevm_aggregator_port}}, + "aggregatorClientHost": "zkevm-permissionless-node-aggregator{{.deployment_idx}}", + + "mapConstPolsFile": false, + "mapConstantsTreeFile": false, + + "inputFile": "input_executor_0.json", + "inputFile2": "input_executor_1.json", + + "keccakScriptFile": "config/scripts/keccak_script.json", + "storageRomFile": "config/scripts/storage_sm_rom.json", + + "outputPath": "output", + + "databaseURL": "postgresql://{{.zkevm_permissionless_db_prover_user}}:{{.zkevm_permissionless_db_prover_password}}@{{.zkevm_permissionless_db_prover_hostname}}{{.deployment_idx}}:{{.zkevm_db_postgres_port}}/{{.zkevm_db_prover_name}}", + "dbNodesTableName": "state.nodes", + "dbProgramTableName": "state.program", + "dbMultiWrite": true, + "dbFlushInParallel": false, + "dbMTCacheSize": 1024, + "dbProgramCacheSize": 512, + "dbNumberOfPoolConnections": 30, + "dbGetTree": true, + "cleanerPollingPeriod": 600, + "requestsPersistence": 3600, + "maxExecutorThreads": 20, + "maxProverThreads": 8, + "maxHashDBThreads": 8, + "ECRecoverPrecalc": false, + "ECRecoverPrecalcNThreads": 4, + "stateManager": true, + "useAssociativeCache" : false +} diff --git a/templates/node-config.toml b/templates/trusted-node-config.toml similarity index 100% rename from templates/node-config.toml rename to templates/trusted-node-config.toml