diff --git a/.github/tests/additional-services.yml b/.github/tests/additional-services.yml new file mode 100644 index 00000000..b4789bc8 --- /dev/null +++ b/.github/tests/additional-services.yml @@ -0,0 +1,7 @@ +args: + additional_services: + - blockscout + - blutgang + - pless_zkevm_node + - prometheus_grafana + - tx_spammer diff --git a/.github/tests/erigon-sequencer-cdk-stack-cdk-validium-da.yml b/.github/tests/erigon-sequencer-cdk-stack-cdk-validium-da.yml new file mode 100644 index 00000000..407576d1 --- /dev/null +++ b/.github/tests/erigon-sequencer-cdk-stack-cdk-validium-da.yml @@ -0,0 +1,7 @@ +args: + sequencer_type: erigon + sequence_sender_aggregator_type: cdk + data_availability_mode: cdk-validium + additional_services: + - pless_zkevm_node + - tx_spammer diff --git a/.github/tests/erigon-sequencer-new-zkevm-stack-cdk-validium-da.yml b/.github/tests/erigon-sequencer-new-zkevm-stack-cdk-validium-da.yml new file mode 100644 index 00000000..db766e90 --- /dev/null +++ b/.github/tests/erigon-sequencer-new-zkevm-stack-cdk-validium-da.yml @@ -0,0 +1,7 @@ +args: + sequencer_type: erigon + sequence_sender_aggregator_type: new-zkevm + data_availability_mode: cdk-validium + additional_services: + - pless_zkevm_node + - tx_spammer diff --git a/.github/tests/gas-token.yml b/.github/tests/gas-token.yml new file mode 100644 index 00000000..20e9f839 --- /dev/null +++ b/.github/tests/gas-token.yml @@ -0,0 +1,2 @@ +args: + zkevm_use_gas_token_contract: true diff --git a/.github/tests/legacy-zkevm-stack-cdk-validium-da.yml b/.github/tests/legacy-zkevm-stack-cdk-validium-da.yml new file mode 100644 index 00000000..02dac2c1 --- /dev/null +++ b/.github/tests/legacy-zkevm-stack-cdk-validium-da.yml @@ -0,0 +1,7 @@ +args: + sequencer_type: zkevm + sequence_sender_aggregator_type: legacy-zkevm + data_availability_mode: cdk-validium + additional_services: + - pless_zkevm_node + - tx_spammer diff --git a/.github/tests/legacy-zkevm-stack-rollup-da.yml b/.github/tests/legacy-zkevm-stack-rollup-da.yml new file mode 100644 index 00000000..fd4e034e --- /dev/null +++ b/.github/tests/legacy-zkevm-stack-rollup-da.yml @@ -0,0 +1,7 @@ +args: + sequencer_type: zkevm + sequence_sender_aggregator_type: legacy-zkevm + data_availability_mode: rollup + additional_services: + - pless_zkevm_node + - tx_spammer diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1af62962..fbe355d4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -16,107 +16,166 @@ env: ENCLAVE_NAME: cdk jobs: - cdk: + # List all .yml files in the .github/tests directory. + list-ymls: runs-on: ubuntu-latest - timeout-minutes: 20 + timeout-minutes: 5 + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v4 + - id: set-matrix + run: echo "matrix=$(ls ./.github/tests/*.yml | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT + + run-without-args: + runs-on: ubuntu-latest + timeout-minutes: 30 steps: - uses: actions/checkout@v4 - name: Install Kurtosis CDK tools uses: ./.github/actions/setup-kurtosis-cdk - # Deploy the CDK environment with cdk-erigon, serving as the sequencer. - # Set up the cdk-node for the remaining components. - # Additionally, deploy cdk-erigon and zkevm-node as permissionless nodes or RPCs. - - name: Deploy L1 chain and a first CDK L2 chain (erigon) + - name: Run Starlark run: | - yq -Y --in-place '.args.additional_services = ["pless_zkevm_node", "tx_spammer"]' params.yml - kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --show-enclave-inspect=false --args-file=params.yml . + kurtosis run \ + --enclave=${{ env.ENCLAVE_NAME }} \ + --show-enclave-inspect=false \ + ${{ github.workspace }} - name: Inspect enclave run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }} - - name: List first CDK L2 chain databases (erigon) + - name: List databases run: | - postgres1_port=$(kurtosis port print ${{ env.ENCLAVE_NAME }} postgres-001 postgres | cut -d':' -f3) - PGPASSWORD=master_password psql --host 127.0.0.1 --port "$postgres1_port" --username master_user --dbname master --list + postgres_port=$(kurtosis port print ${{ env.ENCLAVE_NAME }} postgres-001 postgres | cut -d':' -f3) + PGPASSWORD=master_password psql --host 127.0.0.1 --port "$postgres_port" --username master_user --dbname master --list - - name: Attach a second CDK L2 chain (erigon) + - name: Monitor verified batches (Central RPC) + working-directory: .github/scripts + run: ./monitor-verified-batches.sh --rpc-url $(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-node-001 http-rpc) + + run-with-args: + needs: list-ymls + runs-on: ubuntu-latest + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + file_name: ${{ fromJson(needs.list-ymls.outputs.matrix) }} + + steps: + - uses: actions/checkout@v4 + + - name: Install Kurtosis CDK tools + uses: ./.github/actions/setup-kurtosis-cdk + + - name: Run Starlark run: | - yq -Y --in-place '.args.additional_services = ["pless_zkevm_node", "tx_spammer"]' agglayer-attach-cdk-params.yml - kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --show-enclave-inspect=false --args-file=agglayer-attach-cdk-params.yml . + kurtosis run \ + --enclave=${{ env.ENCLAVE_NAME }} \ + --args-file=${{ matrix.file_name }} \ + --show-enclave-inspect=false \ + ${{ github.workspace }} - name: Inspect enclave run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }} - - name: List second CDK L2 chain databases (erigon) + - name: Monitor verified batches (Central RPC) run: | - postgres2_port=$(kurtosis port print ${{ env.ENCLAVE_NAME }} postgres-002 postgres | cut -d':' -f3) - PGPASSWORD=master_password psql --host 127.0.0.1 --port "$postgres2_port" --username master_user --dbname master --list + sequencer_type=$(yq --raw-output '.args.sequencer_type' ${{ matrix.file_name }}) + rpc_name="" + if [[ "$sequencer_type" == "erigon" ]]; then + rpc_name="cdk-erigon-node-001" + elif [[ "$sequencer_type" == "zkevm" ]]; then + rpc_name="zkevm-node-rpc-001" + elif [[ "$sequencer_type" == "null" ]]; then + rpc_name="cdk-erigon-node-001" + else + echo "Unknown sequencer type: $sequencer_type" + exit 1 + fi + echo "RPC name: $rpc_name" + ./.github/scripts/monitor-verified-batches.sh --rpc-url $(kurtosis port print ${{ env.ENCLAVE_NAME }} $rpc_name http-rpc) - - name: Update the agglayer config + - name: Monitor verified batches (zkEVM Permissionless RPC) run: | - # Download the agglayer config file. - kurtosis files download ${{ env.ENCLAVE_NAME }} agglayer-config-artifact - cd agglayer-config-artifact - - # Update the config by adding the rpc and proof signer of the second chain. - tomlq -Y --toml-output --in-place '.FullNodeRPCs += {"2": "http://cdk-erigon-node-002:8123"}' agglayer-config.toml - proof_signer_2="$(yq --raw-output .args.zkevm_l2_sequencer_address ../agglayer-attach-cdk-params.yml)" - tomlq -Y --toml-output --arg proofSigner2 "$proof_signer_2" --in-place '.ProofSigners += {"2": $proofSigner2}' agglayer-config.toml - - # Replace the agglayer config. - agglayer_container_id="$(docker ps --filter "name=zkevm-agglayer" --format "{{.ID}}")" - docker cp agglayer-config.toml "$agglayer_container_id:/etc/zkevm/agglayer-config.toml" - - # Restart the agglayer service. - kurtosis service stop ${{ env.ENCLAVE_NAME }} zkevm-agglayer-001 - kurtosis service start ${{ env.ENCLAVE_NAME }} zkevm-agglayer-001 - - - name: Monitor verified batches of the first L2 chain (CDK Erigon Permissionless RPC) - working-directory: .github/scripts - run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-node-001 http-rpc)" - - - name: Monitor verified batches of the first L2 chain (zkEVM Node Permissionless RPC) - working-directory: .github/scripts - run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} zkevm-node-rpc-pless-001 http-rpc)" + result=$(yq --raw-output '.args.additional_services // [] | contains(["pless_zkevm_node"])' ${{ matrix.file_name }}) + if [[ "$result" == "true" ]]; then + ./.github/scripts/monitor-verified-batches.sh --rpc-url $(kurtosis port print ${{ env.ENCLAVE_NAME }} zkevm-node-rpc-pless-001 http-rpc) + else + echo "Skipping batch verification as there is no zkevm permissionless RPC in the environment" + fi - - name: Monitor verified batches of the second L2 chain (CDK Erigon Permissionless RPC) - working-directory: .github/scripts - run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-node-002 http-rpc)" + - name: Verify Blutgang RPC + run: | + if [ "${{ matrix.file_name }}" == "./.github/tests/additional-services.yml" ]; then + result=$(yq --raw-output '.args.additional_services | contains(["blutgang"])' ${{ matrix.file_name }}) + if [[ "$result" == "true" ]]; then + cast bn --rpc-url $(kurtosis port print ${{ env.ENCLAVE_NAME }} blutgang-001 http) + else + echo "Blutgang RPC should be deployed" + exit 1 + fi + else + echo "Skipping the verification of blutgang RPC" + fi - - name: Monitor verified batches of the second L2 chain (zkEVM Node Permissionless RPC) - working-directory: .github/scripts - run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} zkevm-node-rpc-pless-002 http-rpc)" + - name: Verify Prometheus collects Panoptichain metrics + run: | + if [ "${{ matrix.file_name }}" == "./.github/tests/additional-services.yml" ]; then + result=$(yq --raw-output '.args.additional_services // [] | contains(["prometheus_grafana"])' ${{ matrix.file_name }}) + if [[ "$result" == "true" ]]; then + echo "Waiting for one minute while Prometheus gathers metrics..." + sleep 60 + + echo "Retrieving Panoptichain metrics from Prometheus..." + panoptichain_metric="panoptichain_system_uptime" + prometheus_url=$(kurtosis port print ${{ env.ENCLAVE_NAME }} prometheus-001 http) + prometheus_query=$(curl "$prometheus_url/api/v1/query?query=$panoptichain_metric") + echo $prometheus_query | jq + if [ "$(jq -r '.data.result[0].metric.__name__' <<<$prometheus_query)" == "$panoptichain_metric" ]; then + echo "Prometheus collected panoptichain metrics!" + else + echo "Prometheus did not collect any panoptichain metrics..." + exit 1 + fi + else + echo "Prometheus and Grafana should be deployed" + exit 1 + fi + else + echo "Skipping the verification of Prometheus metrics" + fi - zkevm: + attach_cdks: runs-on: ubuntu-latest - timeout-minutes: 20 + timeout-minutes: 30 steps: - uses: actions/checkout@v4 - name: Install Kurtosis CDK tools uses: ./.github/actions/setup-kurtosis-cdk - # Deploy the CDK environment with zkevm-node, serving as the sequencer. - # Also set up the zkevm-node for the remaining components. - # Additionally, deploy zkevm-node as permissionless node or RPC. - - name: Deploy L1 chain and a first CDK L2 chain (zkevm) + # Deploy the CDK environment with cdk-erigon, serving as the sequencer. + # Set up the cdk-node for the remaining components. + # Additionally, deploy cdk-erigon and zkevm-node as permissionless nodes or RPCs. + - name: Deploy L1 chain and a first CDK L2 chain (new stack) run: | - yq -Y --in-place '.deploy_cdk_erigon_node = false' params.yml - yq -Y --in-place '.args.sequencer_type = "zkevm"' params.yml + yq -Y --in-place '.args.sequencer_type = "erigon"' params.yml + yq -Y --in-place '.args.sequence_sender_aggregator_type = "cdk"' params.yml yq -Y --in-place '.args.additional_services = ["pless_zkevm_node", "tx_spammer"]' params.yml kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --show-enclave-inspect=false --args-file=params.yml . - name: Inspect enclave run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }} - - name: List first CDK L2 chain databases (zkevm) + - name: List first CDK L2 chain databases (erigon) run: | postgres1_port=$(kurtosis port print ${{ env.ENCLAVE_NAME }} postgres-001 postgres | cut -d':' -f3) PGPASSWORD=master_password psql --host 127.0.0.1 --port "$postgres1_port" --username master_user --dbname master --list - - name: Attach a second CDK L2 chain (erigon) + - name: Attach a second CDK L2 chain (new stack) run: | yq -Y --in-place '.args.additional_services = ["pless_zkevm_node", "tx_spammer"]' agglayer-attach-cdk-params.yml kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --show-enclave-inspect=false --args-file=agglayer-attach-cdk-params.yml . @@ -148,16 +207,14 @@ jobs: kurtosis service stop ${{ env.ENCLAVE_NAME }} zkevm-agglayer-001 kurtosis service start ${{ env.ENCLAVE_NAME }} zkevm-agglayer-001 - - name: Monitor verified batches of the first L2 chain (zkEVM Node Trusted RPC) + - name: Monitor verified batches of the first L2 chain (CDK Erigon Permissionless RPC) working-directory: .github/scripts - run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} zkevm-node-rpc-001 http-rpc)" + run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-node-001 http-rpc)" - name: Monitor verified batches of the first L2 chain (zkEVM Node Permissionless RPC) working-directory: .github/scripts run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} zkevm-node-rpc-pless-001 http-rpc)" - # TODO(nit): Deploy a CDK Erigon Permissionless RPC and check that it can sync. - - name: Monitor verified batches of the second L2 chain (CDK Erigon Permissionless RPC) working-directory: .github/scripts run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-node-002 http-rpc)" @@ -165,45 +222,3 @@ jobs: - name: Monitor verified batches of the second L2 chain (zkEVM Node Permissionless RPC) working-directory: .github/scripts run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} zkevm-node-rpc-pless-002 http-rpc)" - - # TODO(nit): Deploy a CDK Erigon Permissionless RPC and check that it can sync. - - additional_services: - runs-on: ubuntu-latest - timeout-minutes: 20 - steps: - - uses: actions/checkout@v4 - - - name: Install Kurtosis CDK tools - uses: ./.github/actions/setup-kurtosis-cdk - - - name: Deploy Kurtosis CDK package with additional services - run: | - yq -Y --in-place '.args.additional_services = ["blockscout", "blutgang", "pless_zkevm_node", "prometheus_grafana", "tx_spammer"]' params.yml - kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --show-enclave-inspect=false --args-file=params.yml . - - - name: Inspect enclave - run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }} - - - name: Verify Blutgang rpc - run: cast bn --rpc-url $(kurtosis port print ${{ env.ENCLAVE_NAME }} blutgang-001 http) - - - name: Verify permissionless zkevm-node rpc - run: cast bn --rpc-url $(kurtosis port print ${{ env.ENCLAVE_NAME }} zkevm-node-rpc-pless-001 http-rpc) - - - name: Verify Prometheus collects Panoptichain metrics - run: | - echo "Wait for one minute while Prometheus gathers metrics..." - sleep 60 - - echo "Retrieve Panoptichain metrics from Prometheus..." - panoptichain_metric="panoptichain_system_uptime" - prometheus_url=$(kurtosis port print ${{ env.ENCLAVE_NAME }} prometheus-001 http) - prometheus_query=$(curl "$prometheus_url/api/v1/query?query=$panoptichain_metric") - echo $prometheus_query | jq - if [ "$(jq -r '.data.result[0].metric.__name__' <<<$prometheus_query)" == "$panoptichain_metric" ]; then - echo "✅ Prometheus collects panoptichain metrics!" - else - echo "❌ Prometheus does not collect panoptichain metrics..." - exit 1 - fi diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 6d65502f..9199b16d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,7 +11,7 @@ concurrency: cancel-in-progress: true env: - KURTOSIS_VERSION: 0.90.1 + KURTOSIS_VERSION: 1.0.0 jobs: check: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index c1c94ed3..ba7e4f3d 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -49,95 +49,6 @@ jobs: working-directory: scripts/zkevm-config-diff run: diff -r ./default-configs ./kurtosis-cdk-configs || true - # Deploy the CDK environment without specifying any parameter file. - configless: - runs-on: ubuntu-latest - timeout-minutes: 20 - steps: - - uses: actions/checkout@v4 - - - name: Install Kurtosis CDK tools - uses: ./.github/actions/setup-kurtosis-cdk - - - name: Deploy Kurtosis CDK package - run: kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --show-enclave-inspect=false github.com/0xPolygon/kurtosis-cdk - - - name: Inspect enclave - run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }} - - - name: Monitor verified batches (CDK Erigon Permissionless RPC) - working-directory: .github/scripts - run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-node-001 http-rpc)" - - # Deploy the CDK environment with the gas token feature enabled. - gas-token: - runs-on: ubuntu-latest - timeout-minutes: 20 - steps: - - uses: actions/checkout@v4 - - - name: Install Kurtosis CDK tools - uses: ./.github/actions/setup-kurtosis-cdk - - - name: Deploy Kurtosis CDK package - run: | - yq -Y --in-place '.args.zkevm_use_gas_token_contract = true' params.yml - yq -Y --in-place '.args.l1_seconds_per_slot = 1' params.yml # to speed up deployment - kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --show-enclave-inspect=false --args-file=params.yml . - - - name: Inspect enclave - run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }} - - - name: Monitor verified batches (CDK Erigon Permissionless RPC) - working-directory: .github/scripts - run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-node-001 http-rpc)" - - # Deploy the CDK environment in rollup data availability mode. - da-rollup: - runs-on: ubuntu-latest - timeout-minutes: 20 - steps: - - uses: actions/checkout@v4 - - - name: Install Kurtosis CDK tools - uses: ./.github/actions/setup-kurtosis-cdk - - - name: Deploy Kurtosis CDK package - run: | - yq -Y --in-place '.args.data_availability_mode = "rollup"' params.yml - yq -Y --in-place '.args.l1_seconds_per_slot = 1' params.yml # to speed up deployment - kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --show-enclave-inspect=false --args-file=params.yml . - - - name: Inspect enclave - run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }} - - - name: Monitor verified batches (CDK Erigon Permissionless RPC) - working-directory: .github/scripts - run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-node-001 http-rpc)" - - # Deploy the CDK environment in cdk-validium data availability mode. - da-cdk-validium: - runs-on: ubuntu-latest - timeout-minutes: 20 - steps: - - uses: actions/checkout@v4 - - - name: Install Kurtosis CDK tools - uses: ./.github/actions/setup-kurtosis-cdk - - - name: Deploy Kurtosis CDK package - run: | - yq -Y --in-place '.args.data_availability_mode = "cdk-validium"' params.yml - yq -Y --in-place '.args.l1_seconds_per_slot = 1' params.yml # to speed up deployment - kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --show-enclave-inspect=false --args-file=params.yml . - - - name: Inspect enclave - run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }} - - - name: Monitor verified batches (CDK Erigon Permissionless RPC) - working-directory: .github/scripts - run: ./monitor-verified-batches.sh --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-node-001 http-rpc)" - # Deploy the CDK environment against a local l1 chain with pre-deployed zkevm contracts. pre-deployed-contracts: runs-on: ubuntu-latest @@ -242,12 +153,6 @@ jobs: kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --args-file=params.yml . yq -Y --in-place '.deploy_zkevm_permissionless_node = false' params.yml # reset - - name: Deploy CDK erigon node - run: | - yq -Y --in-place '.deploy_cdk_erigon_node = true' params.yml - kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --args-file=params.yml . - yq -Y --in-place '.deploy_cdk_erigon_node = false' params.yml # reset - - name: Deploy observability stack run: | yq -Y --in-place '.deploy_observability = true' params.yml diff --git a/README.md b/README.md index e398d836..b94581bb 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,8 @@ The command above deploys the CDK stack with [cdk-erigon](https://github.com/0xP Note that it is also possible to deploy the CDK stack using the legacy sequencer and the legacy node, referred to as the [zkevm-node](https://github.com/0xPolygonHermez/zkevm-node). In this scenario, you may need to adjust the various commands slightly; instead of targeting the `cdk-erigon-node-001` service, you should target the `zkevm-node-rpc-001`. ```bash -yq -Y --in-place '.deploy_cdk_erigon_node = false' params.yml yq -Y --in-place '.args.sequencer_type = "zkevm"' params.yml +yq -Y --in-place '.args.sequence_sender_aggregator_type = "zkevm"' params.yml kurtosis run --enclave cdk-v1 --args-file params.yml . ``` diff --git a/agglayer-attach-cdk-params.yml b/agglayer-attach-cdk-params.yml index cad23673..a57453c0 100644 --- a/agglayer-attach-cdk-params.yml +++ b/agglayer-attach-cdk-params.yml @@ -17,9 +17,6 @@ deploy_cdk_central_environment: true # Deploy cdk/bridge infrastructure. deploy_cdk_bridge_infra: true -# Deploy cdk-erigon node. -deploy_cdk_erigon_node: true - args: # Suffix appended to service names. # Note: It should be a string. @@ -35,6 +32,12 @@ args: # - 'zkevm': Use the legacy sequencer (https://github.com/0xPolygonHermez/zkevm-node). sequencer_type: erigon + # The type of sequence sender and aggregator to deploy. + # Options: + # - 'cdk': Use the new cdk-node (https://github.com/0xPolygon/cdk). + # - 'zkevm': Use the legacy aggregator and sequence sender (https://github.com/0xPolygonHermez/zkevm-node). + sequence_sender_aggregator_type: cdk + # Deploy agglayer. deploy_agglayer: false @@ -52,7 +55,7 @@ args: zkevm_prover_image: hermeznetwork/zkevm-prover:v6.0.3-RC20 zkevm_node_image: hermeznetwork/zkevm-node:v0.7.0 cdk_validium_node_image: 0xpolygon/cdk-validium-node:0.7.0-cdk - cdk_node_image: ghcr.io/0xpolygon/cdk:0.0.9 + cdk_node_image: ghcr.io/0xpolygon/cdk:0.0.14 zkevm_da_image: 0xpolygon/cdk-data-availability:0.0.7 zkevm_contracts_image: leovct/zkevm-contracts # the tag is automatically replaced by the value of /zkevm_rollup_fork_id/ diff --git a/cdk_bridge_infra.star b/cdk_bridge_infra.star index d8677782..88679073 100644 --- a/cdk_bridge_infra.star +++ b/cdk_bridge_infra.star @@ -7,7 +7,9 @@ databases = import_module("./databases.star") def run(plan, args): contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args) db_configs = databases.get_db_configs( - args["deployment_suffix"], args["sequencer_type"] + args["deployment_suffix"], + args["sequencer_type"], + args["sequence_sender_aggregator_type"], ) # Create the bridge service config. diff --git a/cdk_central_environment.star b/cdk_central_environment.star index dfb9a19b..f3ad92d4 100644 --- a/cdk_central_environment.star +++ b/cdk_central_environment.star @@ -1,21 +1,26 @@ +cdk_erigon_package = import_module("./lib/cdk_erigon.star") +cdk_node_package = import_module("./lib/cdk_node.star") +constants = import_module("./src/package_io/constants.star") data_availability_package = import_module("./lib/data_availability.star") +databases = import_module("./databases.star") +new_zkevm_package = import_module("./lib/new_zkevm.star") service_package = import_module("./lib/service.star") 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") def run(plan, args): + sequencer_type = args["sequencer_type"] + sequence_sender_aggregator_type = args["sequence_sender_aggregator_type"] + db_configs = databases.get_db_configs( - args["deployment_suffix"], args["sequencer_type"] + args["deployment_suffix"], sequencer_type, sequence_sender_aggregator_type ) # Start prover. prover_config_template = read_file( - src="./templates/trusted-node/prover-config.json" + src="./templates/trusted-node/zkevm-prover-config.json" ) prover_config_artifact = plan.render_templates( name="prover-config-artifact", @@ -41,80 +46,80 @@ def run(plan, args): ) keystore_artifacts = get_keystores_artifacts(plan, args) - if args["sequencer_type"] == "zkevm": - # Create the zkevm node config. - node_config_template = read_file( - src="./templates/trusted-node/node-config.toml" + + # Deploy zkevm-node synchronizer if needed. + if (sequencer_type == constants.SEQUENCER_TYPE.zkevm) or ( + sequencer_type == constants.SEQUENCE_SENDER_AGGREGATOR_TYPE.legacy_zkevm + ): + zkevm_node_config_artifact = create_zkevm_node_config_artifact( + plan, args, db_configs ) - 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", + zkevm_node_package.run_synchronizer( + plan, args, zkevm_node_config_artifact, genesis_artifact ) - # Start the synchronizer. - zkevm_node_package.start_synchronizer( - plan, args, node_config_artifact, genesis_artifact + # Deploy sequencer and rpc. + if sequencer_type == constants.SEQUENCER_TYPE.erigon: + run_erigon_sequencer(plan, args, db_configs) + elif sequencer_type == constants.SEQUENCER_TYPE.zkevm: + zkevm_node_package.run_sequencer( + plan, args, zkevm_node_config_artifact, genesis_artifact ) - - # Start the rest of the zkevm node components. - zkevm_node_components_configs = ( - zkevm_node_package.create_zkevm_node_components_config( - args, node_config_artifact, genesis_artifact, keystore_artifacts - ) + zkevm_node_package.run_rpc( + plan, args, zkevm_node_config_artifact, genesis_artifact ) + else: + fail("Unsupported sequencer type: '{}'".format(sequencer_type)) - plan.add_services( - configs=zkevm_node_components_configs, - description="Starting the rest of the zkevm node components", + # Deploy aggregator and sequence sender. + if sequence_sender_aggregator_type == constants.SEQUENCE_SENDER_AGGREGATOR_TYPE.cdk: + cdk_node_config_artifact = create_cdk_node_config_artifact( + plan, args, db_configs ) - - if args["sequencer_type"] == "erigon": - # Create the cdk node config. - node_config_template = read_file( - src="./templates/trusted-node/cdk-node-config.toml" + cdk_node_package.run_cdk_node( + plan, args, cdk_node_config_artifact, genesis_artifact, keystore_artifacts ) - contract_setup_addresses = service_package.get_contract_setup_addresses( - plan, args + elif ( + sequence_sender_aggregator_type + == constants.SEQUENCE_SENDER_AGGREGATOR_TYPE.new_zkevm + ): + zkevm_sequence_sender_config_artifact = ( + create_zkevm_sequence_sender_config_artifact(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, - ) - }, + new_zkevm_package.run_zkevm_sequence_sender( + plan, + args, + zkevm_sequence_sender_config_artifact, + genesis_artifact, + keystore_artifacts.sequencer, ) - # Start the cdk components. - cdk_node_configs = cdk_node_package.create_cdk_node_service_config( - args, node_config_artifact, genesis_artifact, keystore_artifacts + zkevm_aggregator_config_artifact = create_zkevm_aggregator_config_artifact( + plan, args, db_configs ) - - plan.add_services( - configs=cdk_node_configs, - description="Starting the cdk node components", + new_zkevm_package.run_zkevm_aggregator( + plan, + args, + db_configs, + zkevm_aggregator_config_artifact, + genesis_artifact, + keystore_artifacts.aggregator, + ) + elif ( + sequence_sender_aggregator_type + == constants.SEQUENCE_SENDER_AGGREGATOR_TYPE.legacy_zkevm + ): + zkevm_node_package.run_zkevm_components( + plan, args, zkevm_node_config_artifact, genesis_artifact, keystore_artifacts + ) + else: + fail( + "Unsupported sequence sender and aggregator type: '{}'".format( + sequence_sender_aggregator_type + ) ) - # Start the DAC if in validium mode. + # If in cdk-validium mode, deploy the data availability comitee. if data_availability_package.is_cdk_validium(args): dac_config_artifact = create_dac_config_artifact(plan, args, db_configs) dac_config = zkevm_dac_package.create_dac_service_config( @@ -122,7 +127,48 @@ def run(plan, args): ) plan.add_services( configs=dac_config, - description="Starting the DAC", + description="Starting cdk-validium data availability comitee", + ) + + +def run_erigon_sequencer(plan, args, db_configs): + cdk_erigon_sequencer_config_artifact = create_cdk_erigon_sequencer_artifact( + plan, args + ) + cdk_erigon_chain_artifacts = create_cdk_erigon_chain_artifacts(plan, args) + cdk_erigon_package.run_sequencer( + plan, + args, + cdk_erigon_sequencer_config_artifact, + cdk_erigon_chain_artifacts, + ) + + cdk_erigon_rpc_config_artifact = create_cdk_erigon_rpc_artifact(plan, args) + zkevm_pool_manager_config_artifact = create_zkevm_pool_manager_config_artifact( + plan, args, db_configs + ) + cdk_erigon_package.run_rpc( + plan, + args, + cdk_erigon_rpc_config_artifact, + cdk_erigon_chain_artifacts, + zkevm_pool_manager_config_artifact, + ) + + if args["erigon_strict_mode"]: + stateless_executor_config_artifact = plan.render_templates( + name="stateless-executor-config-artifact", + config={ + "stateless-executor-config.json": struct( + template=read_file( + src="./templates/trusted-node/zkevm-prover-config.json" + ), + data=args | {"stateless_executor": True}, + ) + }, + ) + zkevm_prover_package.start_stateless_executor( + plan, args, stateless_executor_config_artifact ) @@ -155,8 +201,203 @@ def get_keystores_artifacts(plan, args): ) +def create_zkevm_node_config_artifact(plan, args, db_configs): + zkevm_node_config_template = read_file( + src="./templates/trusted-node/zkevm-node-config.toml" + ) + return plan.render_templates( + config={ + "node-config.toml": struct( + template=zkevm_node_config_template, + data=args + | db_configs + | { + "is_cdk_validium": data_availability_package.is_cdk_validium(args), + }, + ) + }, + name="trusted-node-config", + ) + + +def create_zkevm_sequence_sender_config_artifact(plan, args): + zkevm_sequence_sender_config_template = read_file( + src="./templates/trusted-node/zkevm-sequence-sender-config.toml" + ) + return plan.render_templates( + name="zkevm-sequence-sender-config-artifact", + config={ + "zkevm-sequence-sender-config.toml": struct( + data=args + | { + "zkevm_is_validium": data_availability_package.is_cdk_validium( + args + ), + }, + template=zkevm_sequence_sender_config_template, + ), + }, + ) + + +def create_zkevm_aggregator_config_artifact(plan, args, db_configs): + zkevm_aggregator_config_template = read_file( + src="./templates/trusted-node/zkevm-aggregator-config.toml" + ) + contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args) + + sequencer_service = plan.get_service( + name=args["sequencer_name"] + args["deployment_suffix"] + ) + sequencer_url = "http://{}:{}".format( + sequencer_service.ip_address, sequencer_service.ports["http-rpc"].number + ) + datastreamer_url = "{}:{}".format( + sequencer_service.ip_address, + sequencer_service.ports["data-streamer"].number, + ) + + return plan.render_templates( + name="zkevm-aggregator-config-artifact", + config={ + "zkevm-aggregator-config.toml": struct( + data=args + | db_configs + | contract_setup_addresses + | { + "zkevm_is_validium": data_availability_package.is_cdk_validium( + args + ), + "sequencer_rpc_url": sequencer_url, + "sequencer_ds_url": datastreamer_url, + }, + template=zkevm_aggregator_config_template, + ), + }, + ) + + +def create_cdk_node_config_artifact(plan, args, db_configs): + cdk_node_config_template = read_file( + src="./templates/trusted-node/cdk-node-config.toml" + ) + contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args) + return plan.render_templates( + name="cdk-node-config-artifact", + config={ + "cdk-node-config.toml": struct( + template=cdk_node_config_template, + data=args + | { + "is_cdk_validium": data_availability_package.is_cdk_validium(args), + } + | db_configs + | contract_setup_addresses, + ) + }, + ) + + +def create_cdk_erigon_sequencer_artifact(plan, args): + node_config_template = read_file(src="./templates/cdk-erigon/config.yml") + contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args) + return plan.render_templates( + name="cdk-erigon-sequencer-config-artifact", + config={ + "config.yaml": struct( + template=node_config_template, + data={ + "zkevm_data_stream_port": args["zkevm_data_streamer_port"], + "is_sequencer": True, + } + | args + | contract_setup_addresses, + ), + }, + ) + + +def create_cdk_erigon_rpc_artifact(plan, args): + node_config_template = read_file(src="./templates/cdk-erigon/config.yml") + contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args) + sequencer_service = plan.get_service( + name=args["sequencer_name"] + args["deployment_suffix"] + ) + sequencer_url = "http://{}:{}".format( + sequencer_service.ip_address, sequencer_service.ports["http-rpc"].number + ) + datastreamer_url = "{}:{}".format( + sequencer_service.ip_address, + sequencer_service.ports["data-streamer"].number, + ) + return plan.render_templates( + name="cdk-erigon-rpc-config-artifact", + config={ + "config.yaml": struct( + template=node_config_template, + data={ + "sequencer_url": sequencer_url, + "datastreamer_url": datastreamer_url, + "is_sequencer": False, + } + | args + | contract_setup_addresses, + ), + }, + ) + + +def create_cdk_erigon_chain_artifacts(plan, args): + chain_spec_template = read_file(src="./templates/cdk-erigon/chainspec.json") + chain_spec_artifact = plan.render_templates( + name="cdk-erigon-node-chain-spec-artifact-sequencer", + config={ + "dynamic-kurtosis-chainspec.json": struct( + template=chain_spec_template, + data={ + "chain_id": args["zkevm_rollup_chain_id"], + }, + ), + }, + ) + + chain_config_artifact = plan.get_files_artifact( + name="cdk-erigon-node-chain-config", + ) + chain_allocs_artifact = plan.get_files_artifact( + name="cdk-erigon-node-chain-allocs", + ) + return struct( + spec=chain_spec_artifact, + config=chain_config_artifact, + allocs=chain_allocs_artifact, + ) + + +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, + ) + }, + ) + + def create_dac_config_artifact(plan, args, db_configs): - dac_config_template = read_file(src="./templates/trusted-node/dac-config.toml") + dac_config_template = read_file(src="./templates/trusted-node/cdk-dac-config.toml") contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args) return plan.render_templates( name="dac-config-artifact", diff --git a/cdk_erigon.star b/cdk_erigon.star deleted file mode 100644 index 5164851d..00000000 --- a/cdk_erigon.star +++ /dev/null @@ -1,136 +0,0 @@ -service_package = import_module("./lib/service.star") -cdk_erigon_package = import_module("./lib/cdk_erigon.star") -zkevm_prover_package = import_module("./lib/zkevm_prover.star") - - -def run_rpc(plan, args): - if args["erigon_strict_mode"]: - stateless_configs = {} - stateless_configs["stateless_executor"] = True - stateless_executor_config_template = read_file( - src="./templates/trusted-node/prover-config.json" - ) - stateless_executor_config_artifact = plan.render_templates( - name="stateless-executor-config-artifact", - config={ - "stateless-executor-config.json": struct( - template=stateless_executor_config_template, - data=args | stateless_configs, - ) - }, - ) - zkevm_prover_package.start_stateless_executor( - plan, args, stateless_executor_config_artifact - ) - - zkevm_sequencer_service = plan.get_service( - name=args["sequencer_name"] + args["deployment_suffix"] - ) - zkevm_sequence_url = "http://{}:{}".format( - zkevm_sequencer_service.ip_address, zkevm_sequencer_service.ports["rpc"].number - ) - zkevm_datastreamer_url = "{}:{}".format( - zkevm_sequencer_service.ip_address, - zkevm_sequencer_service.ports["data-streamer"].number, - ) - - cdk_erigon_node_config_template = read_file(src="./templates/cdk-erigon/config.yml") - contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args) - cdk_erigon_node_config_artifact = plan.render_templates( - name="cdk-erigon-node-config-artifact", - config={ - "config.yaml": struct( - template=cdk_erigon_node_config_template, - data={ - "zkevm_sequencer_url": zkevm_sequence_url, - "zkevm_datastreamer_url": zkevm_datastreamer_url, - "is_sequencer": False, - } - | args - | contract_setup_addresses, - ), - }, - ) - - cdk_erigon_node_chain_spec_template = read_file( - src="./templates/cdk-erigon/chainspec.json" - ) - cdk_erigon_node_chain_spec_artifact = plan.render_templates( - name="cdk-erigon-node-chain-spec-artifact", - config={ - "dynamic-kurtosis-chainspec.json": struct( - template=cdk_erigon_node_chain_spec_template, - data={ - "chain_id": args["zkevm_rollup_chain_id"], - }, - ), - }, - ) - - cdk_erigon_node_chain_config_artifact = plan.get_files_artifact( - name="cdk-erigon-node-chain-config", - ) - cdk_erigon_node_chain_allocs_artifact = plan.get_files_artifact( - name="cdk-erigon-node-chain-allocs", - ) - - cdk_erigon_package.start_node( - plan, - args, - cdk_erigon_node_config_artifact, - cdk_erigon_node_chain_spec_artifact, - cdk_erigon_node_chain_config_artifact, - cdk_erigon_node_chain_allocs_artifact, - False, - ) - - -def run_sequencer(plan, args): - cdk_erigon_node_config_template = read_file(src="./templates/cdk-erigon/config.yml") - contract_setup_addresses = service_package.get_contract_setup_addresses(plan, args) - cdk_erigon_node_config_artifact = plan.render_templates( - name="cdk-erigon-node-config-artifact-sequencer", - config={ - "config.yaml": struct( - template=cdk_erigon_node_config_template, - data={ - "zkevm_data_stream_port": args["zkevm_data_streamer_port"], - "is_sequencer": True, - } - | args - | contract_setup_addresses, - ), - }, - ) - - cdk_erigon_node_chain_spec_template = read_file( - src="./templates/cdk-erigon/chainspec.json" - ) - cdk_erigon_node_chain_spec_artifact = plan.render_templates( - name="cdk-erigon-node-chain-spec-artifact-sequencer", - config={ - "dynamic-kurtosis-chainspec.json": struct( - template=cdk_erigon_node_chain_spec_template, - data={ - "chain_id": args["zkevm_rollup_chain_id"], - }, - ), - }, - ) - - cdk_erigon_node_chain_config_artifact = plan.get_files_artifact( - name="cdk-erigon-node-chain-config", - ) - cdk_erigon_node_chain_allocs_artifact = plan.get_files_artifact( - name="cdk-erigon-node-chain-allocs", - ) - - cdk_erigon_package.start_node( - plan, - args, - cdk_erigon_node_config_artifact, - cdk_erigon_node_chain_spec_artifact, - cdk_erigon_node_chain_config_artifact, - cdk_erigon_node_chain_allocs_artifact, - True, - ) diff --git a/databases.star b/databases.star index bb89467e..072e0561 100644 --- a/databases.star +++ b/databases.star @@ -1,3 +1,5 @@ +constants = import_module("./src/package_io/constants.star") + # We support both local and remote Postgres databases within our Kurtosis-CDK package # When 'USE_REMOTE_POSTGRES' is False, service automatically creates all CDK databases locally # When 'USE_REMOTE_POSTGRES' is True, service is created just as a helper for param injection across pods @@ -26,16 +28,6 @@ POSTGRES_MASTER_PASSWORD = "master_password" # Databases that make up the central environment of an L2 chain, including sequencer, aggregator, # prover, bridge service, and DAC. CENTRAL_ENV_DBS = { - "aggregator_db": { - "name": "aggregator_db", - "user": "aggregator_user", - "password": "redacted", - }, - "aggregator_syncer_db": { - "name": "aggregator_syncer_db", - "user": "aggregator_syncer_db_user", - "password": "redacted", - }, "bridge_db": { "name": "bridge_db", "user": "bridge_user", @@ -88,22 +80,50 @@ CDK_ERIGON_DBS = { } } -DATABASES = CENTRAL_ENV_DBS | PROVER_DB | ZKEVM_NODE_DBS | CDK_ERIGON_DBS +# Databases required for a cdk-node or a zkevm-aggregator to function as an aggregator. +AGGREGATOR_DBS = { + "aggregator_db": { + "name": "aggregator_db", + "user": "aggregator_user", + "password": "redacted", + }, + "aggregator_syncer_db": { + "name": "aggregator_syncer_db", + "user": "aggregator_syncer_db_user", + "password": "redacted", + }, +} + +DATABASES = ( + CENTRAL_ENV_DBS | PROVER_DB | ZKEVM_NODE_DBS | AGGREGATOR_DBS | CDK_ERIGON_DBS +) -def run(plan, suffix, sequencer_type): - db_configs = get_db_configs(suffix, sequencer_type) +def run(plan, suffix, sequencer_type, sequence_sender_aggregator_type): + db_configs = get_db_configs(suffix, sequencer_type, sequence_sender_aggregator_type) create_postgres_service(plan, db_configs, suffix) -def get_db_configs(suffix, sequencer_type): - dbs = None - if sequencer_type == "erigon": - dbs = CENTRAL_ENV_DBS | PROVER_DB | CDK_ERIGON_DBS - elif sequencer_type == "zkevm": - dbs = CENTRAL_ENV_DBS | PROVER_DB | ZKEVM_NODE_DBS - else: - fail("Unsupported sequencer type: %s" % sequencer_type) +def get_db_configs(suffix, sequencer_type, sequence_sender_aggregator_type): + dbs = CENTRAL_ENV_DBS | PROVER_DB + + if sequencer_type == constants.SEQUENCER_TYPE.erigon: + dbs = dbs | CDK_ERIGON_DBS + + if ( + sequencer_type == constants.SEQUENCER_TYPE.zkevm + or sequence_sender_aggregator_type + == constants.SEQUENCE_SENDER_AGGREGATOR_TYPE.legacy_zkevm + ): + dbs = dbs | ZKEVM_NODE_DBS + + if ( + sequence_sender_aggregator_type + == constants.SEQUENCE_SENDER_AGGREGATOR_TYPE.new_zkevm + ) or ( + sequence_sender_aggregator_type == constants.SEQUENCE_SENDER_AGGREGATOR_TYPE.cdk + ): + dbs = dbs | AGGREGATOR_DBS configs = { k: v diff --git a/deploy_zkevm_contracts.star b/deploy_zkevm_contracts.star index 863e0612..947db7e9 100644 --- a/deploy_zkevm_contracts.star +++ b/deploy_zkevm_contracts.star @@ -17,6 +17,10 @@ ARTIFACTS = [ "name": "create-keystores.sh", "file": "./templates/contract-deploy/create-keystores.sh", }, + { + "name": "update-ger.sh", + "file": "./templates/contract-deploy/update-ger.sh", + }, ] @@ -113,6 +117,19 @@ def run(plan, args): ), ) + # Force update GER. + plan.exec( + description="Update the GER so the L1 Info Tree Index is greater than 0", + service_name=contracts_service_name, + recipe=ExecRecipe( + command=[ + "/bin/sh", + "-c", + "chmod +x {0} && {0}".format("/opt/contract-deploy/update-ger.sh"), + ] + ), + ) + # Store CDK configs. cdk_erigon_node_chain_config_artifact = plan.store_service_files( name="cdk-erigon-node-chain-config", diff --git a/docs/migrate/forkid-7-to-9.md b/docs/migrate/forkid-7-to-9.md index da04edd2..331b0d50 100644 --- a/docs/migrate/forkid-7-to-9.md +++ b/docs/migrate/forkid-7-to-9.md @@ -79,10 +79,10 @@ After a few minutes, the number of verified batches should increase (the first b ``` ```diff - diff --git a/templates/trusted-node/node-config.toml b/templates/trusted-node/node-config.toml + diff --git a/templates/trusted-node/zkevm-node-config.toml b/templates/trusted-node/zkevm-node-config.toml index 6c9b9fa..372d904 100644 - --- a/templates/trusted-node/node-config.toml - +++ b/templates/trusted-node/node-config.toml + --- a/templates/trusted-node/zkevm-node-config.toml + +++ b/templates/trusted-node/zkevm-node-config.toml @@ -117,7 +117,7 @@ StateConsistencyCheckInterval = "5s" BatchMaxDeltaTimestamp = "20s" L2BlockMaxDeltaTimestamp = "4s" diff --git a/input_parser.star b/input_parser.star index a70fcba5..56901d24 100644 --- a/input_parser.star +++ b/input_parser.star @@ -4,22 +4,24 @@ DEFAULT_ARGS = { "deployment_suffix": "-001", "global_log_level": "info", "sequencer_type": "erigon", + "sequence_sender_aggregator_type": "cdk", "deploy_agglayer": True, "data_availability_mode": "cdk-validium", "additional_services": [], - "zkevm_prover_image": "hermeznetwork/zkevm-prover:v6.0.3-RC20", + "zkevm_contracts_image": "leovct/zkevm-contracts", "zkevm_node_image": "hermeznetwork/zkevm-node:v0.7.0", "cdk_validium_node_image": "0xpolygon/cdk-validium-node:0.7.0-cdk", - "cdk_node_image": "ghcr.io/0xpolygon/cdk:0.0.9", + "zkevm_sequence_sender_image": "hermeznetwork/zkevm-sequence-sender:v0.2.0-RC4", + "zkevm_aggregator_image": "hermeznetwork/zkevm-aggregator:v0.0.3-RC4", + "zkevm_prover_image": "hermeznetwork/zkevm-prover:v6.0.3-RC21", + "cdk_erigon_node_image": "hermeznetwork/cdk-erigon:v2.0.0-beta17", + "cdk_node_image": "ghcr.io/0xpolygon/cdk:0.0.14", + "zkevm_pool_manager_image": "hermeznetwork/zkevm-pool-manager:v0.1.0-RC1", "zkevm_da_image": "0xpolygon/cdk-data-availability:0.0.7", - "zkevm_contracts_image": "leovct/zkevm-contracts", "zkevm_agglayer_image": "ghcr.io/agglayer/agglayer-rs:main", "zkevm_bridge_service_image": "hermeznetwork/zkevm-bridge-service:v0.5.0-RC9", "zkevm_bridge_ui_image": "leovct/zkevm-bridge-ui:multi-network", "zkevm_bridge_proxy_image": "haproxy:2.9.9-bookworm", - "zkevm_sequence_sender_image": "hermeznetwork/zkevm-sequence-sender:v0.2.0-RC4", - "cdk_erigon_node_image": "hermeznetwork/cdk-erigon:v2.0.0-beta17", - "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, @@ -76,8 +78,15 @@ DEFAULT_ARGS = { def parse_args(args): + args = DEFAULT_ARGS | args + return sanity_check(args) + + +def sanity_check(args): validate_global_log_level(args["global_log_level"]) - return DEFAULT_ARGS | args + sequencer_args = validate_sequencer_type(args["sequencer_type"]) + validate_sequence_sender_aggregator_type(args["sequence_sender_aggregator_type"]) + return args | sequencer_args def validate_global_log_level(global_log_level): @@ -98,3 +107,43 @@ def validate_global_log_level(global_log_level): constants.GLOBAL_LOG_LEVEL.trace, ) ) + + +def validate_sequencer_type(sequencer_type): + sequencer_name = "" + l2_rpc_name = "" + if sequencer_type == constants.SEQUENCER_TYPE.erigon: + sequencer_name = "cdk-erigon-sequencer" + l2_rpc_name = "cdk-erigon-node" + elif sequencer_type == constants.SEQUENCER_TYPE.zkevm: + sequencer_name = "zkevm-node-sequencer" + l2_rpc_name = "zkevm-node-rpc" + else: + fail( + "Unsupported sequencer type: '{}', please use '{}' or '{}'".format( + sequencer_type, + constants.SEQUENCER_TYPE.erigon, + constants.SEQUENCER_TYPE.zkevm, + ) + ) + + return { + "sequencer_name": sequencer_name, + "l2_rpc_name": l2_rpc_name, + } + + +def validate_sequence_sender_aggregator_type(sequence_sender_aggregator_type): + if sequence_sender_aggregator_type not in ( + constants.SEQUENCE_SENDER_AGGREGATOR_TYPE.cdk, + constants.SEQUENCE_SENDER_AGGREGATOR_TYPE.legacy_zkevm, + constants.SEQUENCE_SENDER_AGGREGATOR_TYPE.new_zkevm, + ): + fail( + "Unsupported sequence sender and aggregator type: '{}', please use '{}', '{}' or '{}'".format( + sequence_sender_aggregator_type, + constants.SEQUENCE_SENDER_AGGREGATOR_TYPE.cdk, + constants.SEQUENCE_SENDER_AGGREGATOR_TYPE.legacy_zkevm, + constants.SEQUENCE_SENDER_AGGREGATOR_TYPE.new_zkevm, + ) + ) diff --git a/kurtosis.yml b/kurtosis.yml index 58c14bd1..f5b90110 100644 --- a/kurtosis.yml +++ b/kurtosis.yml @@ -34,6 +34,12 @@ description: |- sequencer_type: erigon + # The type of sequence sender and aggregator to deploy. + # Options: + # - 'cdk': Use the new cdk-node (https://github.com/0xPolygon/cdk). + # - 'zkevm': Use the legacy aggregator and sequence sender (https://github.com/0xPolygonHermez/zkevm-node). + sequence_sender_aggregator_type: cdk + deploy_agglayer: true # The type of data availability to use. @@ -47,28 +53,25 @@ description: |- additional_services: [] # Docker images and repositories used to spin up services. - zkevm_prover_image: hermeznetwork/zkevm-prover:v6.0.3-RC20 - # zkevm_prover_image: hermeznetwork/zkevm-prover:v4.0.19 - + zkevm_contracts_image: leovct/zkevm-contracts # the tag is automatically replaced by the value of /zkevm_rollup_fork_id/ + zkevm_node_image: hermeznetwork/zkevm-node:v0.7.0 cdk_validium_node_image: 0xpolygon/cdk-validium-node:0.7.0-cdk + zkevm_sequence_sender_image: hermeznetwork/zkevm-sequence-sender:v0.2.0-RC14 + zkevm_aggregator_image: hermeznetwork/zkevm-aggregator:v0.0.3-RC4 + zkevm_prover_image: hermeznetwork/zkevm-prover:v6.0.3-RC21 + + cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.0.0-beta17 cdk_node_image: ghcr.io/0xpolygon/cdk:0.0.9 + zkevm_pool_manager_image: hermeznetwork/zkevm-pool-manager:v0.1.0-RC1 zkevm_da_image: 0xpolygon/cdk-data-availability:0.0.7 - # zkevm_da_image: 0xpolygon/cdk-data-availability:0.0.6 - zkevm_contracts_image: leovct/zkevm-contracts # the tag is automatically replaced by the value of /zkevm_rollup_fork_id/ - zkevm_agglayer_image: ghcr.io/agglayer/agglayer-rs:main - zkevm_bridge_service_image: hermeznetwork/zkevm-bridge-service:v0.5.0-RC9 - # temporary fork https://github.com/praetoriansentry/zkevm-bridge-ui/commit/6eaa899997f70e53947d7b067ff7ae37ef1875f3 + zkevm_bridge_service_image: hermeznetwork/zkevm-bridge-service:v0.5.0-RC9 zkevm_bridge_ui_image: leovct/zkevm-bridge-ui:multi-network zkevm_bridge_proxy_image: haproxy:2.9.9-bookworm - zkevm_sequence_sender_image: hermeznetwork/zkevm-sequence-sender:v0.2.0-RC4 - cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.0.0-beta17 - zkevm_pool_manager_image: hermeznetwork/zkevm-pool-manager:v0.1.0-RC1 - # Port configuration. zkevm_hash_db_port: 50061 zkevm_executor_port: 50071 diff --git a/lib/cdk_erigon.star b/lib/cdk_erigon.star index 77688613..2f35848d 100644 --- a/lib/cdk_erigon.star +++ b/lib/cdk_erigon.star @@ -1,3 +1,45 @@ +zkevm_prover_package = import_module("./zkevm_prover.star") +zkevm_pool_manager_package = import_module("./zkevm_pool_manager.star") + + +def run_sequencer( + plan, + args, + node_config_artifact, + chain_artifacts, +): + start_node( + plan, + args, + node_config_artifact, + chain_artifacts.spec, + chain_artifacts.config, + chain_artifacts.allocs, + True, + ) + + +def run_rpc( + plan, + args, + node_config_artifact, + chain_artifacts, + zkevm_pool_manager_config_artifact, +): + start_node( + plan, + args, + node_config_artifact, + chain_artifacts.spec, + chain_artifacts.config, + chain_artifacts.allocs, + False, + ) + zkevm_pool_manager_package.run_zkevm_pool_manager( + plan, args, zkevm_pool_manager_config_artifact + ) + + def start_node( plan, args, @@ -7,40 +49,18 @@ def start_node( cdk_erigon_node_chain_allocs_artifact, is_sequencer, ): + name = args["l2_rpc_name"] + args["deployment_suffix"] envs = {"CDK_ERIGON_SEQUENCER": "1" if is_sequencer else "0"} - ports = {} - ports["pprof"] = PortSpec( - args["zkevm_pprof_port"], - application_protocol="http", - wait=None, - ) - ports["prometheus"] = PortSpec( - args["zkevm_prometheus_port"], - application_protocol="http", - wait=None, - ) + ports = { + "http-rpc": PortSpec(args["zkevm_rpc_http_port"], application_protocol="http"), + "pprof": PortSpec(args["zkevm_pprof_port"], application_protocol="http"), + "prometheus": PortSpec( + args["zkevm_prometheus_port"], application_protocol="http" + ), + } if is_sequencer: name = args["sequencer_name"] + args["deployment_suffix"] - # TODO these port names seem weird... http-rpc / rpc? I don't - # get it. There seem to be a bunch of weird dependencies on - # both of these existing. It seems likt they should be called - # the same thing and the only difference is if this a - # sequencer or an rpc.. the port itself shouldn't be named - # differently and there certainly shouldn't be dependencies on - # those names - ports["rpc"] = PortSpec( - args["zkevm_rpc_http_port"], - application_protocol="http", - ) - else: - name = args["l2_rpc_name"] + args["deployment_suffix"] - ports["http-rpc"] = PortSpec( - args["zkevm_rpc_http_port"], - application_protocol="http", - ) - - if is_sequencer: ports["data-streamer"] = PortSpec( args["zkevm_data_streamer_port"], application_protocol="datastream" ) diff --git a/lib/cdk_node.star b/lib/cdk_node.star index 98615d1d..1bff7406 100644 --- a/lib/cdk_node.star +++ b/lib/cdk_node.star @@ -6,14 +6,14 @@ NODE_COMPONENTS = struct( ) -def create_cdk_node_service_config( +def run_cdk_node( + plan, args, config_artifact, genesis_artifact, keystore_artifact, ): cdk_node_name = "cdk-node" + args["deployment_suffix"] - cdk_node_service_config = ServiceConfig( image=args["cdk_node_image"], ports={ @@ -47,5 +47,8 @@ def create_cdk_node_service_config( + NODE_COMPONENTS.aggregator, ], ) - - return {cdk_node_name: cdk_node_service_config} + plan.add_service( + name=cdk_node_name, + config=cdk_node_service_config, + description="Starting cdk-node aggregator and sequence sender", + ) diff --git a/lib/new_zkevm.star b/lib/new_zkevm.star new file mode 100644 index 00000000..286ce7a4 --- /dev/null +++ b/lib/new_zkevm.star @@ -0,0 +1,58 @@ +def run_zkevm_sequence_sender( + plan, args, config_artifact, genesis_artifact, sequencer_keystore_artifact +): + plan.add_service( + name="zkevm-sequence-sender" + args["deployment_suffix"], + config=ServiceConfig( + image=args["zkevm_sequence_sender_image"], + files={ + "/etc/zkevm": Directory( + artifact_names=[ + config_artifact, + genesis_artifact, + sequencer_keystore_artifact, + ] + ) + }, + cmd=[ + "/bin/sh", + "-c", + "/app/zkevm-seqsender run --network custom --custom-network-file /etc/zkevm/genesis.json --cfg /etc/zkevm/zkevm-sequence-sender-config.toml", + ], + ), + ) + + +def run_zkevm_aggregator( + plan, + args, + db_configs, + config_artifact, + genesis_artifact, + aggregator_keystore_artifact, +): + plan.add_service( + name="zkevm-aggregator" + args["deployment_suffix"], + config=ServiceConfig( + image=args["zkevm_aggregator_image"], + ports={ + "aggregator": PortSpec( + args["zkevm_aggregator_port"], application_protocol="grpc" + ), + }, + files={ + "/etc/zkevm": Directory( + artifact_names=[ + config_artifact, + genesis_artifact, + aggregator_keystore_artifact, + ] + ) + }, + cmd=[ + "/bin/sh", + "-c", + "/app/zkevm-aggregator run --network custom --custom-network-file /etc/zkevm/genesis.json --cfg /etc/zkevm/zkevm-aggregator-config.toml", + ], + ), + ) diff --git a/lib/service.star b/lib/service.star index 7bb2d62f..b4c4d4c3 100644 --- a/lib/service.star +++ b/lib/service.star @@ -6,7 +6,6 @@ def get_contract_setup_addresses(plan, args): "zkevm_bridge_address": "fromjson | .polygonZkEVMBridgeAddress", "zkevm_l2_bridge_address": "fromjson | .polygonZkEVMBridgeAddress", "zkevm_gen_block_number": "fromjson | .deploymentRollupManagerBlockNumber", - "polygon_data_committee_address": "fromjson | .polygonDataCommitteeAddress", "zkevm_rollup_address": "fromjson | .rollupAddress", "zkevm_rollup_manager_address": "fromjson | .polygonRollupManagerAddress", "zkevm_rollup_manager_block_number": "fromjson | .deploymentRollupManagerBlockNumber", diff --git a/lib/zkevm_node.star b/lib/zkevm_node.star index 6db588f5..a73d4220 100644 --- a/lib/zkevm_node.star +++ b/lib/zkevm_node.star @@ -11,32 +11,9 @@ NODE_COMPONENTS = struct( ) -def _create_node_component_service_config( - image, ports, config_files, components, http_api={} -): - cmd = [ - "run", - "--cfg=/etc/zkevm/node-config.toml", - "--network=custom", - "--custom-network-file=/etc/zkevm/genesis.json", - "--components=" + components, - ] - if http_api: - cmd.append("--http.api=" + http_api) - return ServiceConfig( - image=image, - ports=ports, - files={ - "/etc/zkevm": config_files, - }, - entrypoint=["/app/zkevm-node"], - cmd=cmd, - ) - - # The synchronizer is required to run before any other zkevm node component. # This is why this component does not have a `create_service_config` method. -def start_synchronizer(plan, args, config_artifact, genesis_artifact): +def run_synchronizer(plan, args, config_artifact, genesis_artifact): synchronizer_name = "zkevm-node-synchronizer" + args["deployment_suffix"] synchronizer_service_config = _create_node_component_service_config( image=data_availability_package.get_node_image(args), @@ -49,10 +26,14 @@ def start_synchronizer(plan, args, config_artifact, genesis_artifact): config_files=Directory(artifact_names=[config_artifact, genesis_artifact]), components=NODE_COMPONENTS.synchronizer, ) - plan.add_service(name=synchronizer_name, config=synchronizer_service_config) + plan.add_service( + name=synchronizer_name, + config=synchronizer_service_config, + description="Starting zkevm-node synchronizer", + ) -def create_sequencer_service_config(args, config_artifact, genesis_artifact): +def run_sequencer(plan, args, config_artifact, genesis_artifact): sequencer_name = "zkevm-node-sequencer" + args["deployment_suffix"] sequencer_service_config = _create_node_component_service_config( image=data_availability_package.get_node_image(args), @@ -70,10 +51,78 @@ def create_sequencer_service_config(args, config_artifact, genesis_artifact): components=NODE_COMPONENTS.sequencer + "," + NODE_COMPONENTS.rpc, http_api="eth,net,debug,zkevm,txpool,web3", ) - return {sequencer_name: sequencer_service_config} + plan.add_service( + name=sequencer_name, + config=sequencer_service_config, + description="Starting zkevm-node sequencer", + ) + + +def run_rpc(plan, args, config_artifact, genesis_artifact): + rpc_name = "zkevm-node-rpc" + args["deployment_suffix"] + rpc_service_config = _create_node_component_service_config( + image=data_availability_package.get_node_image(args), + ports={ + "http-rpc": PortSpec( + args["zkevm_rpc_http_port"], application_protocol="http" + ), + "ws-rpc": 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" + ), + }, + config_files=Directory(artifact_names=[config_artifact, genesis_artifact]), + components=NODE_COMPONENTS.rpc, + http_api="eth,net,debug,zkevm,txpool,web3", + ) + plan.add_service( + name=rpc_name, + config=rpc_service_config, + description="Starting zkevm-node rpc", + ) + + +# Run every legacy zkevm-node components, except synchronizer, sequencer and rpc. +def run_zkevm_components( + plan, + args, + config_artifact, + genesis_artifact, + keystore_artifacts, +): + sequence_sender_service_config = _create_sequence_sender_service_config( + args, config_artifact, genesis_artifact, keystore_artifacts.sequencer + ) + aggregator_service_config = _create_aggregator_service_config( + args, + config_artifact, + genesis_artifact, + keystore_artifacts.sequencer, + keystore_artifacts.aggregator, + keystore_artifacts.proofsigner, + ) + eth_tx_manager_service_config = _create_eth_tx_manager_service_config( + args, + config_artifact, + genesis_artifact, + keystore_artifacts.sequencer, + keystore_artifacts.aggregator, + ) + l2_gas_pricer_service_config = _create_l2_gas_pricer_service_config( + args, config_artifact, genesis_artifact + ) + + plan.add_services( + configs=sequence_sender_service_config + | aggregator_service_config + | eth_tx_manager_service_config + | l2_gas_pricer_service_config, + description="Starting zkevm-node components sequence sender, aggregator, eth tx manager and l2 gas pricer", + ) -def create_sequence_sender_service_config( +def _create_sequence_sender_service_config( args, config_artifact, genesis_artifact, sequencer_keystore_artifact ): sequence_sender_name = "zkevm-node-sequence-sender" + args["deployment_suffix"] @@ -97,7 +146,7 @@ def create_sequence_sender_service_config( return {sequence_sender_name: sequence_sender_service_config} -def create_aggregator_service_config( +def _create_aggregator_service_config( args, config_artifact, genesis_artifact, @@ -131,28 +180,7 @@ def create_aggregator_service_config( return {aggregator_name: aggregator_service_config} -def create_rpc_service_config(args, config_artifact, genesis_artifact): - rpc_name = "zkevm-node-rpc" + args["deployment_suffix"] - rpc_service_config = _create_node_component_service_config( - image=data_availability_package.get_node_image(args), - ports={ - "http-rpc": PortSpec( - args["zkevm_rpc_http_port"], application_protocol="http" - ), - "ws-rpc": 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" - ), - }, - config_files=Directory(artifact_names=[config_artifact, genesis_artifact]), - components=NODE_COMPONENTS.rpc, - http_api="eth,net,debug,zkevm,txpool,web3", - ) - return {rpc_name: rpc_service_config} - - -def create_eth_tx_manager_service_config( +def _create_eth_tx_manager_service_config( args, config_artifact, genesis_artifact, @@ -181,7 +209,7 @@ def create_eth_tx_manager_service_config( return {eth_tx_manager_name: eth_tx_manager_service_config} -def create_l2_gas_pricer_service_config(args, config_artifact, genesis_artifact): +def _create_l2_gas_pricer_service_config(args, config_artifact, genesis_artifact): l2_gas_pricer_name = "zkevm-node-l2-gas-pricer" + args["deployment_suffix"] l2_gas_pricer_service_config = _create_node_component_service_config( image=data_availability_package.get_node_image(args), @@ -197,47 +225,24 @@ def create_l2_gas_pricer_service_config(args, config_artifact, genesis_artifact) return {l2_gas_pricer_name: l2_gas_pricer_service_config} -def create_zkevm_node_components_config( - args, - config_artifact, - genesis_artifact, - keystore_artifacts, +def _create_node_component_service_config( + image, ports, config_files, components, http_api={} ): - aggregator_config = create_aggregator_service_config( - args, - config_artifact, - genesis_artifact, - keystore_artifacts.sequencer, - keystore_artifacts.aggregator, - keystore_artifacts.proofsigner, - ) - rpc_config = create_rpc_service_config(args, config_artifact, genesis_artifact) - eth_tx_manager_config = create_eth_tx_manager_service_config( - args, - config_artifact, - genesis_artifact, - keystore_artifacts.sequencer, - keystore_artifacts.aggregator, - ) - l2_gas_pricer_config = create_l2_gas_pricer_service_config( - args, config_artifact, genesis_artifact - ) - configs = ( - aggregator_config | rpc_config | eth_tx_manager_config | l2_gas_pricer_config + cmd = [ + "run", + "--cfg=/etc/zkevm/node-config.toml", + "--network=custom", + "--custom-network-file=/etc/zkevm/genesis.json", + "--components=" + components, + ] + if http_api: + cmd.append("--http.api=" + http_api) + return ServiceConfig( + image=image, + ports=ports, + files={ + "/etc/zkevm": config_files, + }, + entrypoint=["/app/zkevm-node"], + cmd=cmd, ) - - if args["sequencer_type"] == "zkevm": - sequencer_config = create_sequencer_service_config( - args, config_artifact, genesis_artifact - ) - - sequence_sender_config = create_sequence_sender_service_config( - args, - config_artifact, - genesis_artifact, - keystore_artifacts.sequencer, - ) - - return configs | sequencer_config | sequence_sender_config - else: - return configs diff --git a/lib/zkevm_pool_manager.star b/lib/zkevm_pool_manager.star index e701ea91..bebc032c 100644 --- a/lib/zkevm_pool_manager.star +++ b/lib/zkevm_pool_manager.star @@ -1,4 +1,4 @@ -def create_zkevm_pool_manager_service_config(args, config_artifact): +def run_zkevm_pool_manager(plan, 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"], @@ -16,4 +16,8 @@ def create_zkevm_pool_manager_service_config(args, config_artifact): "/app/zkevm-pool-manager run --cfg /etc/pool-manager/pool-manager-config.toml", ], ) - return {zkevm_pool_manager_service_name: zkevm_pool_manager_service_config} + plan.add_service( + name=zkevm_pool_manager_service_name, + config=zkevm_pool_manager_service_config, + description="Starting zkevm pool manager", + ) diff --git a/lib/zkevm_sequence_sender.star b/lib/zkevm_sequence_sender.star deleted file mode 100644 index 68525f13..00000000 --- a/lib/zkevm_sequence_sender.star +++ /dev/null @@ -1,43 +0,0 @@ -data_availability_package = import_module("./data_availability.star") - - -def create_zkevm_sequence_sender_config( - plan, args, genesis_artifact, sequencer_keystore_artifact -): - sequence_sender_name = "zkevm-node-sequence-sender" + args["deployment_suffix"] - sequence_sender_config_template = read_file( - src="../templates/trusted-node/sequence-sender-config.toml" - ) - sequence_sender_config_artifact = plan.render_templates( - name="zkevm-sequence-sender-config-artifact", - config={ - "sequence-sender-config.toml": struct( - data=args - | { - "zkevm_is_validium": data_availability_package.is_cdk_validium( - args - ), - }, - template=sequence_sender_config_template, - ), - }, - ) - sequence_sender_service_config = ServiceConfig( - image=args["zkevm_sequence_sender_image"], - files={ - "/etc/zkevm": Directory( - artifact_names=[ - genesis_artifact, - sequencer_keystore_artifact, - sequence_sender_config_artifact, - ] - ) - }, - cmd=[ - "/bin/sh", - "-c", - "/app/zkevm-seqsender run --network custom --custom-network-file /etc/zkevm/genesis.json --cfg /etc/zkevm/sequence-sender-config.toml", - ], - ) - - return {sequence_sender_name: sequence_sender_service_config} diff --git a/main.star b/main.star index c0aa24d2..90a614f4 100644 --- a/main.star +++ b/main.star @@ -1,11 +1,9 @@ cdk_bridge_infra_package = "./cdk_bridge_infra.star" cdk_central_environment_package = "./cdk_central_environment.star" -cdk_erigon_package = import_module("./cdk_erigon.star") databases_package = "./databases.star" deploy_zkevm_contracts_package = "./deploy_zkevm_contracts.star" ethereum_package = "./ethereum.star" input_parser = "./input_parser.star" -zkevm_pool_manager_package = import_module("./zkevm_pool_manager.star") # Additional services packages. blockscout_package = "./src/additional_services/blockscout.star" @@ -28,22 +26,11 @@ def run( deploy_databases=True, deploy_cdk_bridge_infra=True, deploy_cdk_central_environment=True, - deploy_cdk_erigon_node=True, args={}, ): args = import_module(input_parser).parse_args(args) plan.print("Deploying CDK environment with parameters: " + str(args)) - if deploy_cdk_erigon_node: - args["l2_rpc_name"] = "cdk-erigon-node" - else: - args["l2_rpc_name"] = "zkevm-node-rpc" - - if args["sequencer_type"] == "erigon": - args["sequencer_name"] = "cdk-erigon-sequencer" - else: - args["sequencer_name"] = "zkevm-node-sequencer" - # Deploy a local L1. if deploy_l1: plan.print("Deploying a local L1") @@ -78,6 +65,7 @@ def run( plan, suffix=args["deployment_suffix"], sequencer_type=args["sequencer_type"], + sequence_sender_aggregator_type=args["sequence_sender_aggregator_type"], ) else: plan.print("Skipping the deployment of databases") @@ -94,28 +82,6 @@ def run( # Deploy cdk central/trusted environment. if deploy_cdk_central_environment: - # Deploy cdk-erigon sequencer node. - # TODO this is a little weird if the erigon sequencer is deployed before the exector? - if args["sequencer_type"] == "erigon": - plan.print("Deploying cdk-erigon sequencer") - cdk_erigon_package.run_sequencer(plan, args) - 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") - - # 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 diff --git a/params.yml b/params.yml index f7a738b6..3e684ebe 100644 --- a/params.yml +++ b/params.yml @@ -17,9 +17,6 @@ deploy_cdk_central_environment: true # Deploy cdk/bridge infrastructure. deploy_cdk_bridge_infra: true -# Deploy cdk-erigon node. -deploy_cdk_erigon_node: true - args: # Suffix appended to service names. # Note: It should be a string. @@ -35,6 +32,13 @@ args: # - 'zkevm': Use the legacy sequencer (https://github.com/0xPolygonHermez/zkevm-node). sequencer_type: erigon + # The type of sequence sender and aggregator to deploy. + # Options: + # - 'cdk': Use the new cdk-node (https://github.com/0xPolygon/cdk). + # - 'new-zkevm': Use the new zkevm components (https://github.com/0xPolygonHermez/zkevm-sequence-sender and https://github.com/0xPolygonHermez/zkevm-aggregator). + # - 'legacy-zkevm': Use the legacy sequence sender and aggregator (https://github.com/0xPolygonHermez/zkevm-node). + sequence_sender_aggregator_type: cdk + # Deploy agglayer. deploy_agglayer: true @@ -55,21 +59,25 @@ args: additional_services: [] # Docker images and repositories used to spin up services. - zkevm_prover_image: hermeznetwork/zkevm-prover:v6.0.3-RC20 + zkevm_contracts_image: leovct/zkevm-contracts # the tag is automatically replaced by the value of /zkevm_rollup_fork_id/ + zkevm_node_image: hermeznetwork/zkevm-node:v0.7.0 cdk_validium_node_image: 0xpolygon/cdk-validium-node:0.7.0-cdk - cdk_node_image: ghcr.io/0xpolygon/cdk:0.0.9 - zkevm_da_image: 0xpolygon/cdk-data-availability:0.0.7 - zkevm_contracts_image: leovct/zkevm-contracts # the tag is automatically replaced by the value of /zkevm_rollup_fork_id/ + zkevm_sequence_sender_image: hermeznetwork/zkevm-sequence-sender:v0.2.0-RC4 + zkevm_aggregator_image: hermeznetwork/zkevm-aggregator:v0.0.3-RC4 + zkevm_prover_image: hermeznetwork/zkevm-prover:v6.0.3-RC21 - # zkevm_agglayer_image: 0xpolygon/agglayer:0.1.3 + #cdk_erigon_node_image: hermeznetwork/cdk-erigon:2.0.0-beta15 + cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.0.0-beta17 + cdk_node_image: ghcr.io/0xpolygon/cdk:0.0.14 + zkevm_pool_manager_image: hermeznetwork/zkevm-pool-manager:v0.1.0-RC1 + + zkevm_da_image: 0xpolygon/cdk-data-availability:0.0.7 zkevm_agglayer_image: ghcr.io/agglayer/agglayer-rs:main + zkevm_bridge_service_image: hermeznetwork/zkevm-bridge-service:v0.5.0-RC9 zkevm_bridge_ui_image: leovct/zkevm-bridge-ui:multi-network zkevm_bridge_proxy_image: haproxy:2.9.9-bookworm - zkevm_sequence_sender_image: hermeznetwork/zkevm-sequence-sender:v0.2.0-RC4 - cdk_erigon_node_image: hermeznetwork/cdk-erigon:v2.0.0-beta17 - zkevm_pool_manager_image: hermeznetwork/zkevm-pool-manager:v0.1.0-RC1 # Port configuration. zkevm_hash_db_port: 50061 diff --git a/src/additional_services/blutgang.star b/src/additional_services/blutgang.star index 5b634f0c..38b84af4 100644 --- a/src/additional_services/blutgang.star +++ b/src/additional_services/blutgang.star @@ -13,8 +13,8 @@ def run(plan, args): config=ServiceConfig( image=BLUTGANG_IMAGE, ports={ - "http": PortSpec(RPC_PORT_NUMBER), - "admin": PortSpec(ADMIN_PORT_NUMBER), + "http": PortSpec(RPC_PORT_NUMBER, application_protocol="http"), + "admin": PortSpec(ADMIN_PORT_NUMBER, application_protocol="http"), }, files={ "/etc/blutgang": Directory( @@ -34,11 +34,11 @@ def get_blutgang_config(plan, args): src="../../static_files/additional_services/blutgang-config/config.toml" ) - zkevm_sequencer_service = plan.get_service( + sequencer_service = plan.get_service( name=args["sequencer_name"] + args["deployment_suffix"] ) - zkevm_sequencer_http_url = "http://{}:{}".format( - zkevm_sequencer_service.ip_address, zkevm_sequencer_service.ports["rpc"].number + sequencer_url = "http://{}:{}".format( + sequencer_service.ip_address, sequencer_service.ports["http-rpc"].number ) l2_rpc_urls = service_package.get_l2_rpc_urls(plan, args) @@ -63,7 +63,7 @@ def get_blutgang_config(plan, args): data={ "blutgang_rpc_port": RPC_PORT_NUMBER, "blutgang_admin_port": ADMIN_PORT_NUMBER, - "l2_sequencer_url": zkevm_sequencer_http_url, + "l2_sequencer_url": sequencer_url, "l2_rpc_url": l2_rpc_urls.http, "l2_ws_url": l2_rpc_urls.ws, "zkevm_rpc_pless_http_url": zkevm_rpc_pless_http_url, diff --git a/src/additional_services/pless_zkevm_node.star b/src/additional_services/pless_zkevm_node.star index 332feaf5..47923125 100644 --- a/src/additional_services/pless_zkevm_node.star +++ b/src/additional_services/pless_zkevm_node.star @@ -44,14 +44,7 @@ def run(plan, args, genesis_artifact): }, ) - zkevm_node_package.start_synchronizer( + zkevm_node_package.run_synchronizer( plan, args, node_config_artifact, genesis_artifact ) - - rpc_config = zkevm_node_package.create_rpc_service_config( - args, node_config_artifact, genesis_artifact - ) - plan.add_services( - configs=rpc_config, - description="Starting zkevm node rpc", - ) + zkevm_node_package.run_rpc(plan, args, node_config_artifact, genesis_artifact) diff --git a/src/package_io/constants.star b/src/package_io/constants.star index f0cbf6ff..957c0b2e 100644 --- a/src/package_io/constants.star +++ b/src/package_io/constants.star @@ -5,3 +5,14 @@ GLOBAL_LOG_LEVEL = struct( debug="debug", trace="trace", ) + +SEQUENCER_TYPE = struct( + erigon="erigon", + zkevm="zkevm", +) + +SEQUENCE_SENDER_AGGREGATOR_TYPE = struct( + cdk="cdk", + legacy_zkevm="legacy-zkevm", + new_zkevm="new-zkevm", +) diff --git a/templates/cdk-erigon/config.yml b/templates/cdk-erigon/config.yml index af7635de..e64bd52f 100644 --- a/templates/cdk-erigon/config.yml +++ b/templates/cdk-erigon/config.yml @@ -62,6 +62,6 @@ zkevm.data-stream-host: "0.0.0.0" zkevm.data-stream-port: {{.zkevm_data_stream_port}} # rpc node {{else}} txpool.disable: true -zkevm.l2-sequencer-rpc-url: {{.zkevm_sequencer_url}} -zkevm.l2-datastreamer-url: {{.zkevm_datastreamer_url}} +zkevm.l2-sequencer-rpc-url: {{.sequencer_url}} +zkevm.l2-datastreamer-url: {{.datastreamer_url}} # end {{end}} diff --git a/templates/contract-deploy/update-ger.sh b/templates/contract-deploy/update-ger.sh new file mode 100755 index 00000000..e942776c --- /dev/null +++ b/templates/contract-deploy/update-ger.sh @@ -0,0 +1,36 @@ +#!/bin/bash +set -e + +# Setup some vars for use later on +# The private key used to send transactions +private_key="0903a9a721167e2abaa0a33553cbeb209dc9300d28e4e4d6d2fac2452f93e357" # TODO: same + +# The bridge address +bridge_addr="0xD71f8F956AD979Cc2988381B8A743a2fE280537D" # TODO: populate this addr using kurtosis magic + +# Grab the endpoints for l1 +l1_rpc_url="{{.l1_rpc_url}}" +# l1_rpc_url="http://localhost:33201" + +# The signature for bridging is long - just putting it into a var +bridge_sig="bridgeAsset(uint32 destinationNetwork, address destinationAddress, uint256 amount, address token, bool forceUpdateGlobalExitRoot, bytes permitData)" + +# Get our variables organized +destination_net="7" +destination_addr="0x0000000000000000000000000000000000000000" +amount=0 +token="0x0000000000000000000000000000000000000000" +update_ger=true +permit_data="0x" + +# Generate the call data, this is useful just to examine what the call will look loke +echo "Generating the call data for the bridge tx..." +cast calldata "$bridge_sig" "$destination_net" "$destination_addr" "$amount" "$token" "$update_ger" "$permit_data" + +# Perform an eth_call to make sure the tx will work +echo "Performing an eth call to make sure the bridge tx will work..." +cast call --rpc-url "$l1_rpc_url" "$bridge_addr" "$bridge_sig" "$destination_net" "$destination_addr" "$amount" "$token" "$update_ger" "$permit_data" + +# Publish the actual transaction! +echo "Publishing the bridge tx..." +cast send --rpc-url "$l1_rpc_url" --private-key "$private_key" "$bridge_addr" "$bridge_sig" "$destination_net" "$destination_addr" "$amount" "$token" "$update_ger" "$permit_data" diff --git a/templates/trusted-node/dac-config.toml b/templates/trusted-node/cdk-dac-config.toml similarity index 100% rename from templates/trusted-node/dac-config.toml rename to templates/trusted-node/cdk-dac-config.toml diff --git a/templates/trusted-node/sequence-sender-config.toml b/templates/trusted-node/sequence-sender-config.toml deleted file mode 100644 index 20acfac8..00000000 --- a/templates/trusted-node/sequence-sender-config.toml +++ /dev/null @@ -1,35 +0,0 @@ -[Log] -Environment = "development" -Level = "{{.global_log_level}}" -Outputs = ["stdout"] - -[SequenceSender] -IsValidiumMode={{.zkevm_is_validium}} -WaitPeriodSendSequence = "15s" -LastBatchVirtualizationTimeMaxWaitPeriod = "10s" -MaxTxSizeForL1 = 131072 -L2Coinbase = "{{.zkevm_l2_sequencer_address}}" -PrivateKey = {Path = "/etc/zkevm/sequencer.keystore", Password = "{{.zkevm_l2_keystore_password}}"} -SequencesTxFileName = "/app/data/sequencesender.json" -WaitPeriodPurgeTxFile = "48h" -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/zkevm/sequencer.keystore", Password = "{{.zkevm_l2_keystore_password}}"}, - ] - ForcedGas = 0 - GasPriceMarginFactor = 1 - MaxGasPriceLimit = 0 - PersistenceFilename = "/app/data/ethtxmanager.json" - [SequenceSender.EthTxManager.Etherman] - URL = "{{.l1_rpc_url}}" - MultiGasProvider = false - L1ChainID = {{.l1_chain_id}} - HTTPHeaders = [] \ No newline at end of file diff --git a/templates/trusted-node/zkevm-aggregator-config.toml b/templates/trusted-node/zkevm-aggregator-config.toml new file mode 100644 index 00000000..f02fcfb1 --- /dev/null +++ b/templates/trusted-node/zkevm-aggregator-config.toml @@ -0,0 +1,419 @@ +# ============================================================================== +# _ ___ ____ +# | | / _ \ / ___| +# | | | | | | | _ +# | |__| |_| | |_| | +# |_____\___/ \____| +# +# ------------------------------------------------------------------------------ +[Aggregator.Log] +# ------------------------------------------------------------------------------ +# Environment generally dictates the format of the logs and the +# sampling rate. We often default to production even for development +# because of the JSON encoding. +# +# https://github.com/uber-go/zap/blob/a55bdc32f526699c3b4cc51a2cc97e944d02fbbf/config.go#L120 +# https://github.com/uber-go/zap/blob/a55bdc32f526699c3b4cc51a2cc97e944d02fbbf/config.go#L161 +# ------------------------------------------------------------------------------ +Environment = "development" + +# ------------------------------------------------------------------------------ +# Level determines the log level that will be written to the +# log. Generally we'll switch to debug if we want to troubleshoot +# something specifically otherwise we leave it at info +# ------------------------------------------------------------------------------ +Level = "{{.global_log_level}}" + +# ------------------------------------------------------------------------------ +# Outputs define the output paths for writing logs. The default is to +# write to stderr, but other output paths should be supported +# +# https://github.com/uber-go/zap/blob/a55bdc32f526699c3b4cc51a2cc97e944d02fbbf/writer.go#L32-L50 +# ------------------------------------------------------------------------------ +Outputs = ["stderr"] + +# ============================================================================== +# _ ____ ____ ____ _____ ____ _ _____ ___ ____ +# / \ / ___|/ ___| _ \| ____/ ___| / \|_ _/ _ \| _ \ +# / _ \| | _| | _| |_) | _|| | _ / _ \ | || | | | |_) | +# / ___ \ |_| | |_| | _ <| |__| |_| |/ ___ \| || |_| | _ < +# /_/ \_\____|\____|_| \_\_____\____/_/ \_\_| \___/|_| \_\ +# ------------------------------------------------------------------------------ +[Aggregator] + +# ------------------------------------------------------------------------------ +# Host is the IP address that the aggregator server will listen +# on. The provers are clients for the aggregator server. +# ------------------------------------------------------------------------------ +Host = "0.0.0.0" + +# ------------------------------------------------------------------------------ +# Port is the port that the aggregator service will be listening on +# ------------------------------------------------------------------------------ +Port = {{.zkevm_aggregator_port}} + +# ------------------------------------------------------------------------------ +# RetryTime is the amount of time that the main loop will wait between +# checking for proofs to aggregate or batches to prove. +# ------------------------------------------------------------------------------ +RetryTime = "30s" + +# ------------------------------------------------------------------------------ +# VerifyProofInterval is the interval of time to verify and send +# proofs to L1 +# ------------------------------------------------------------------------------ +VerifyProofInterval = "1m0s" + +# ------------------------------------------------------------------------------ +# ProofStatePollingInterval will determine how long we wait between +# successive checks to see if a pending proof has been finished +# ------------------------------------------------------------------------------ +ProofStatePollingInterval = "5s" + +# ------------------------------------------------------------------------------ +# TxProfitabilityCheckerType is used to specify an approach for +# determining if it's profitable for the aggregator to validate a +# batch. +# +# base: would check the amount of pending collateral and compare it to +# the TxProfitabilityMinReward. If the reward surpasses the minimum, +# we will verify the proof, otherwise we'll wait +# +# acceptall: will verify the even if there is very little reward +# ------------------------------------------------------------------------------ +TxProfitabilityCheckerType = "acceptall" + +# ------------------------------------------------------------------------------ +# TxProfitabilityMinReward is used to configure the minimum reward +# if we're using the base model for tx profitability +# ------------------------------------------------------------------------------ +TxProfitabilityMinReward = "1.1" + +# ------------------------------------------------------------------------------ +# ForkId is the fork id that we're currently using +# +# Note: this value is likely overwritten from the values from onchain +# +# Deprecated: it seems like this particular field might not be used +# +# ------------------------------------------------------------------------------ +ForkId = {{.zkevm_rollup_fork_id}} + +# ------------------------------------------------------------------------------ +# CleanupLockedProofsInterval determines the wait duration between +# successive calls to clean up locked proofs. +# ------------------------------------------------------------------------------ +CleanupLockedProofsInterval = "2m0s" + +# ------------------------------------------------------------------------------ +# GeneratingProofCleanupThreshold determines the max amount of time +# that we'd be willing to wait for a proof to be generated. Every +# CleanupLockedProofsInterval we will check for proofs that have been +# generating for longer than GeneratingProofCleanupThreshold. Those +# proofs will be deleted and retried. +# ------------------------------------------------------------------------------ +GeneratingProofCleanupThreshold = "10m" + +# TODO: Not sure about these settings! +{{if .is_cdk_validium}} +## CDK Validium Specific Settings + +# ------------------------------------------------------------------------------ +# SenderAddress is used as input for the prover. The address that's +# configured here must match the ultimate sender of the aggregated +# proof to L1. In this case the final sender is the agglayer itself +# ------------------------------------------------------------------------------ +SenderAddress = "{{.zkevm_l2_agglayer_address}}" + +# ------------------------------------------------------------------------------ +# SettlementBackend determines if we're settling with the `agglayer' +# or `direct' with L1 +# ------------------------------------------------------------------------------ +SettlementBackend = "agglayer" + +# ------------------------------------------------------------------------------ +# AggLayerTxTimeout determines how long we'll wait for the AggLayer to +# respond successfully that a transaction has been mined on L1. The +# current implementation will block while we wait, so it makes sense +# not to push this number overly high. +# ------------------------------------------------------------------------------ +AggLayerTxTimeout = "600s" + +# ------------------------------------------------------------------------------ +# AggLayerURL is the RPC URL of the agglayer itself +# In the case of attaching multiple CDKs, the AgglayerURL +# should always follow the first deployment_suffix "-001" +# by default. +# ------------------------------------------------------------------------------ +{{if .deploy_agglayer}} +AggLayerURL = "http://zkevm-agglayer{{.deployment_suffix}}:{{.zkevm_agglayer_port}}" +{{else}} +AggLayerURL = "http://zkevm-agglayer-001:{{.zkevm_agglayer_port}}" +{{end}} + +{{else}} + +# ------------------------------------------------------------------------------ +# SenderAddress represents the address of the trusted aggregator +# ------------------------------------------------------------------------------ +SenderAddress = "{{.zkevm_l2_aggregator_address}}" +{{end}} + +# ------------------------------------------------------------------------------ +# GasOffset is an incremental last limit added to the estimation in +# order to avoid reverts due to state volatility. +# ------------------------------------------------------------------------------ +GasOffset = 150000 + +# TODO +WitnessURL = "{{.sequencer_rpc_url}}" + +# TODO +LERContract = "{{.zkevm_global_exit_root_l2_address}}" + +# T ODO +UseL1BatchData = true + +# TODO +UseFullWitness = false + +# TODO +BatchProofSanityCheckEnabled = true + +# TODO: DB +[Aggregator.DB] +# ------------------------------------------------------------------------------ +# Name is the identifier of the target database to connect to. +# ------------------------------------------------------------------------------ +Name = "{{.aggregator_db.name}}" + +# ------------------------------------------------------------------------------ +# User specifies the username for database connection authentication. +# ------------------------------------------------------------------------------ +User = "{{.aggregator_db.user}}" + +# ------------------------------------------------------------------------------ +# Password is the authentication credential for the database connection. +# ------------------------------------------------------------------------------ +Password = "{{.aggregator_db.password}}" + +# ------------------------------------------------------------------------------ +# Host is the network address (hostname or IP) used to establish a database +# connection. Append deployment-specific suffixes as needed. +# ------------------------------------------------------------------------------ +Host = "{{.aggregator_db.hostname}}" + +# ------------------------------------------------------------------------------ +# Port defines the network port used for the database connection. +# ------------------------------------------------------------------------------ +Port = {{.aggregator_db.port}} + +# ------------------------------------------------------------------------------ +# EnableLog toggles the logging of all executed queries. Enabling this +# feature will significantly increase log volume and may affect performance. +# ------------------------------------------------------------------------------ +EnableLog = false + +# ------------------------------------------------------------------------------ +# MaxConns sets the maximum number of concurrent connections in the pool. +# Adjust this value based on the database's configuration limits and expected +# client load to optimize performance and resource utilization. +# ------------------------------------------------------------------------------ +MaxConns = 200 + +# TODO: StreamClient +[Aggregator.StreamClient] +# TODO +Server = "{{.sequencer_ds_url}}" # TODO! + +# ============================================================================== +# _____ _____ _ _ _______ ____ __ _ _ _ _ ____ _____ ____ +# | ____|_ _| | | |_ _\ \/ / \/ | / \ | \ | | / \ / ___| ____| _ \ +# | _| | | | |_| | | | \ /| |\/| | / _ \ | \| | / _ \| | _| _| | |_) | +# | |___ | | | _ | | | / \| | | |/ ___ \| |\ |/ ___ \ |_| | |___| _ < +# |_____| |_| |_| |_| |_| /_/\_\_| |_/_/ \_\_| \_/_/ \_\____|_____|_| \_\ +# +# ------------------------------------------------------------------------------ +[Aggregator.EthTxManager] +# ------------------------------------------------------------------------------ +# FrequencyToMonitorTxs determines how often we'll process pending +# monitored transactions. Essentially we'll query the database looking +# for created, sent, and reorged transactions. For each one of those +# txs, we'll try to send it or confirm if it has been sent and update +# the status accordingly. +# +# Setting this duration can potentially create a lot of logs +# especially if there is nothing to do. +# ------------------------------------------------------------------------------ +FrequencyToMonitorTxs = "5s" + +# ------------------------------------------------------------------------------ +# WaitTxToBeMined will determine how long we'll wait for a transaction +# to be mined after it's been published. If this interval is too +# short, you're more likely to run into oddities where the nonce is +# reused. +# +# The code for sending transactions does not create a goroutine. It +# will block for the duration of the wait. +# ------------------------------------------------------------------------------ +WaitTxToBeMined = "4m0s" + +# ------------------------------------------------------------------------------ +# ForcedGas can be used to configure a default gas limit to use in the +# case of a gas estimation error. If this is configured as 0, the +# default behavior would be to return the gas estimation error and +# retry later. +# ------------------------------------------------------------------------------ +ForcedGas = 0 + +# ------------------------------------------------------------------------------ +# GasPriceMarginFactor is used to bias the gas price by whatever the +# configured factor is. If we want to make sure our transactions are +# mined quickly especially if there is volatility, we could set this +# factor to be 1.2 in order to make sure that our transactions are +# attractive. +# +# Generally, we would not recommend setting this below 1. If you're +# looking to save on gas costs, there are better ways. +# ------------------------------------------------------------------------------ +GasPriceMarginFactor = 1.25 + +# ------------------------------------------------------------------------------ +# MaxGasPriceLimit is used to specify in wei the upper limit price +# that we would be willing to pay. If the current gas price exceeds +# this limit, we'll adjust the gas price down to the configured limit +# and try to send the transaction. If the limit is below the base fee, +# the transaction probably would not be accepted by the RPC. +# ------------------------------------------------------------------------------ +MaxGasPriceLimit = 0 + +# TODO +GetReceiptMaxTime = "250ms" + +# TODO +GetReceiptWaitInterval = "1s" + +# ------------------------------------------------------------------------------ +# PrivateKeys is an array of keystores and passwords that are used for +# signing transactions. The keystores are standard go-ethereum style +# keystores that are encrypted with the provided password. Depending +# on your deployment setup, you'll need to configure the sequencer +# and/org aggregator key so that the tx manager for the given +# component can sign and send transactions. +# +# ------------------------------------------------------------------------------ +PrivateKeys = [ +{Path = "/etc/zkevm/aggregator.keystore", Password = "{{.zkevm_l2_keystore_password}}"}, +] + +# TODO +PersistenceFilename = "/ethtxmanager_aggregator.json" +# TODO +ReadPendingL1Txs = false +# TODO +SafeStatusL1NumberOfBlocks = 1 +# TODO +FinalizedStatusL1NumberOfBlocks = 1 +# ConsolidationL1ConfirmationBlocks = 5 +# FinalizationL1ConfirmationBlocks = 10 +# WaitReceiptToBeGenerated = "8s" + +# ============================================================================== +# _____ _____ _ _ _____ ____ __ __ _ _ _ +# | ____|_ _| | | | ____| _ \| \/ | / \ | \ | | +# | _| | | | |_| | _| | |_) | |\/| | / _ \ | \| | +# | |___ | | | _ | |___| _ <| | | |/ ___ \| |\ | +# |_____| |_| |_| |_|_____|_| \_\_| |_/_/ \_\_| \_| +# +# ------------------------------------------------------------------------------ +[Aggregator.EthTxManager.Etherman] +# ------------------------------------------------------------------------------ +# URL should be used to configure your L1 RPC address. +# ------------------------------------------------------------------------------ +URL = "{{.l1_rpc_url}}" + +# TODO +L1ChainID = {{.l1_chain_id}} + +# TODO +HTTPHeaders = [] + +# ============================================================================== +# ______ ___ _ ____ _ _ ____ ___ _ _ ___ __________ ____ +# / ___\ \ / / \ | |/ ___| | | | _ \ / _ \| \ | |_ _|__ / ____| _ \ +# \___ \\ V /| \| | | | |_| | |_) | | | | \| || | / /| _| | |_) | +# ___) || | | |\ | |___| _ | _ <| |_| | |\ || | / /_| |___| _ < +# |____/ |_| |_| \_|\____|_| |_|_| \_\\___/|_| \_|___/____|_____|_| \_\ +# +# ------------------------------------------------------------------------------ +[Aggregator.Synchronizer] + +[Aggregator.Synchronizer.DB] +# ------------------------------------------------------------------------------ +# Name is the identifier of the target database to connect to. +# ------------------------------------------------------------------------------ +Name = "{{.aggregator_syncer_db.name}}" + +# ------------------------------------------------------------------------------ +# User specifies the username for database connection authentication. +# ------------------------------------------------------------------------------ +User = "{{.aggregator_syncer_db.user}}" + +# ------------------------------------------------------------------------------ +# Password is the authentication credential for the database connection. +# ------------------------------------------------------------------------------ +Password = "{{.aggregator_syncer_db.password}}" + +# ------------------------------------------------------------------------------ +# Host is the network address (hostname or IP) used to establish a database +# connection. Append deployment-specific suffixes as needed. +# ------------------------------------------------------------------------------ +Host = "{{.aggregator_syncer_db.hostname}}" + +# ------------------------------------------------------------------------------ +# Port defines the network port used for the database connection. +# ------------------------------------------------------------------------------ +Port = {{.aggregator_syncer_db.port}} + +# ------------------------------------------------------------------------------ +# EnableLog toggles the logging of all executed queries. Enabling this +# feature will significantly increase log volume and may affect performance. +# ------------------------------------------------------------------------------ +EnableLog = false + +# ------------------------------------------------------------------------------ +# MaxConns sets the maximum number of concurrent connections in the pool. +# Adjust this value based on the database's configuration limits and expected +# client load to optimize performance and resource utilization. +# ------------------------------------------------------------------------------ +MaxConns = 10 + + +[Aggregator.Synchronizer.Synchronizer] +# ------------------------------------------------------------------------------ +# SyncInterval defines the wait duration between reading new +# information from the trusted sequencer, DAC, L1. Specifically, this +# controls how long we wait between running sync operations and not +# the frequence of syncs. +# ------------------------------------------------------------------------------ +SyncInterval = "1s" + +# ------------------------------------------------------------------------------ +# SyncChunkSize determines how large of a range of blocks we'll +# attempt to pull while getting the rollup information. +# ------------------------------------------------------------------------------ +SyncChunkSize = 1000 + +# TODO +GenesisBlockNumber = 1 + +# TODO +SyncUpToBlock = "latest" + +# TODO +BlockFinality = "latest" + +[Aggregator.Synchronizer.Etherman] +[Aggregator.Synchronizer.Etherman.Validium] +# TODO +Enabled = {{.zkevm_is_validium}} diff --git a/templates/trusted-node/node-config.toml b/templates/trusted-node/zkevm-node-config.toml similarity index 100% rename from templates/trusted-node/node-config.toml rename to templates/trusted-node/zkevm-node-config.toml diff --git a/templates/trusted-node/prover-config.json b/templates/trusted-node/zkevm-prover-config.json similarity index 100% rename from templates/trusted-node/prover-config.json rename to templates/trusted-node/zkevm-prover-config.json diff --git a/templates/trusted-node/zkevm-sequence-sender-config.toml b/templates/trusted-node/zkevm-sequence-sender-config.toml new file mode 100644 index 00000000..90d62a78 --- /dev/null +++ b/templates/trusted-node/zkevm-sequence-sender-config.toml @@ -0,0 +1,219 @@ +# ============================================================================== +# _ ___ ____ +# | | / _ \ / ___| +# | | | | | | | _ +# | |__| |_| | |_| | +# |_____\___/ \____| +# +# ------------------------------------------------------------------------------ +[Log] +# ------------------------------------------------------------------------------ +# Environment generally dictates the format of the logs and the +# sampling rate. We often default to production even for development +# because of the JSON encoding. +# +# https://github.com/uber-go/zap/blob/a55bdc32f526699c3b4cc51a2cc97e944d02fbbf/config.go#L120 +# https://github.com/uber-go/zap/blob/a55bdc32f526699c3b4cc51a2cc97e944d02fbbf/config.go#L161 +# ------------------------------------------------------------------------------ +Environment = "development" + +# ------------------------------------------------------------------------------ +# Level determines the log level that will be written to the +# log. Generally we'll switch to debug if we want to troubleshoot +# something specifically otherwise we leave it at info +# ------------------------------------------------------------------------------ +Level = "{{.global_log_level}}" + +# ------------------------------------------------------------------------------ +# Outputs define the output paths for writing logs. The default is to +# write to stderr, but other output paths should be supported +# +# https://github.com/uber-go/zap/blob/a55bdc32f526699c3b4cc51a2cc97e944d02fbbf/writer.go#L32-L50 +# ------------------------------------------------------------------------------ +Outputs = ["stderr"] + +# ============================================================================== +# ____ _____ ___ _ _ _____ _ _ ____ _____ ____ _____ _ _ ____ _____ ____ +# / ___|| ____/ _ \| | | | ____| \ | |/ ___| ____/ ___|| ____| \ | | _ \| ____| _ \ +# \___ \| _|| | | | | | | _| | \| | | | _| \___ \| _| | \| | | | | _| | |_) | +# ___) | |__| |_| | |_| | |___| |\ | |___| |___ ___) | |___| |\ | |_| | |___| _ < +# |____/|_____\__\_\\___/|_____|_| \_|\____|_____|____/|_____|_| \_|____/|_____|_| \_\ +# +# ------------------------------------------------------------------------------ +[SequenceSender] +# TODO +IsValidiumMode={{.zkevm_is_validium}} + +# ------------------------------------------------------------------------------ +# WaitPeriodSendSequence will determine how long we wait to check for +# new sequences to send assuming that we came up empty the last time +# we checked. E.g. if we query and find 0 sequences to send, we'll +# wait for WaitPeriodSendSequence before checking again +# ------------------------------------------------------------------------------ +WaitPeriodSendSequence = "5s" + +# ------------------------------------------------------------------------------ +# LastBatchVirtualizationTimeMaxWaitPeriod defines the max amount of +# time that we'll allow to pass before virtualizing. E.g. if we have +# sequences to send and it's been more than +# LastBatchVirtualizationTimeMaxWaitPeriod since the last time we've +# virtualized, we'll send the sequences. Otherwise we'll wait longer. +# ------------------------------------------------------------------------------ +LastBatchVirtualizationTimeMaxWaitPeriod = "5s" + +# ------------------------------------------------------------------------------ +# MaxTxSizeForL1 is the maximum size a single transaction can +# have. This field has non-trivial consequences: larger transactions +# than 128KB are significantly harder and more expensive to propagate; +# larger transactions also take more resources to validate whether +# they fit into the pool or not. +# ------------------------------------------------------------------------------ +MaxTxSizeForL1 = 131072 + +# ------------------------------------------------------------------------------ +# L2Coinbase should generally be the address of the trusted +# sequencer. The coinbase will receive fees on L2. This is also used +# to specify the coinbase in the batch and ultimately is used to +# determine the beneficiary of the proof verification. When we +# sequence batches on L1, we pay a batch fee. When the batches are +# eventually proven that collateral is refunded to the L2Coinbase. +# ------------------------------------------------------------------------------ +L2Coinbase = "{{.zkevm_l2_sequencer_address}}" + +# ------------------------------------------------------------------------------ +# PrivateKey is a object with the keystore and password that are used +# for signing transactions. The keystore is a standard go-ethereum +# style keystore that is encrypted with the provided password. In this +# particular context, this needs to be the sequencers private key. +# ------------------------------------------------------------------------------ +PrivateKey = {Path = "/etc/zkevm/sequencer.keystore", Password = "{{.zkevm_l2_keystore_password}}"} + +# TODO +SequencesTxFileName = "/app/data/sequencesender.json" +# TODO +WaitPeriodPurgeTxFile = "48h" +# TODO +MaxPendingTx = 1 + +# TODO +[SequenceSender.StreamClient] +# TODO +Server = "{{.sequencer_name}}{{.deployment_suffix}}:{{.zkevm_data_streamer_port}}" + +# ============================================================================== +# _____ _____ _ _ _______ ____ __ _ _ _ _ ____ _____ ____ +# | ____|_ _| | | |_ _\ \/ / \/ | / \ | \ | | / \ / ___| ____| _ \ +# | _| | | | |_| | | | \ /| |\/| | / _ \ | \| | / _ \| | _| _| | |_) | +# | |___ | | | _ | | | / \| | | |/ ___ \| |\ |/ ___ \ |_| | |___| _ < +# |_____| |_| |_| |_| |_| /_/\_\_| |_/_/ \_\_| \_/_/ \_\____|_____|_| \_\ +# +# ------------------------------------------------------------------------------ +[SequenceSender.EthTxManager] +# ------------------------------------------------------------------------------ +# FrequencyToMonitorTxs determines how often we'll process pending +# monitored transactions. Essentially we'll query the database looking +# for created, sent, and reorged transactions. For each one of those +# txs, we'll try to send it or confirm if it has been sent and update +# the status accordingly. +# +# Setting this duration can potentially create a lot of logs +# especially if there is nothing to do. +# ------------------------------------------------------------------------------ +FrequencyToMonitorTxs = "5s" + +# ------------------------------------------------------------------------------ +# WaitTxToBeMined will determine how long we'll wait for a transaction +# to be mined after it's been published. If this interval is too +# short, you're more likely to run into oddities where the nonce is +# reused. +# +# The code for sending transactions does not create a goroutine. It +# will block for the duration of the wait. +# ------------------------------------------------------------------------------ +WaitTxToBeMined = "4m0s" + +# TODO +ConsolidationL1ConfirmationBlocks = 5 + +# TODO +FinalizationL1ConfirmationBlocks = 10 + +# TODO +WaitReceiptToBeGenerated = "8s" + +# ------------------------------------------------------------------------------ +# PrivateKeys is an array of keystores and passwords that are used for +# signing transactions. The keystores are standard go-ethereum style +# keystores that are encrypted with the provided password. Depending +# on your deployment setup, you'll need to configure the sequencer +# and/org aggregator key so that the tx manager for the given +# component can sign and send transactions. +# +# ------------------------------------------------------------------------------ +PrivateKeys = [ +{Path = "/etc/zkevm/sequencer.keystore", Password = "{{.zkevm_l2_keystore_password}}"}, +] + +# ------------------------------------------------------------------------------ +# ForcedGas can be used to configure a default gas limit to use in the +# case of a gas estimation error. If this is configured as 0, the +# default behavior would be to return the gas estimation error and +# retry later. +# ------------------------------------------------------------------------------ +ForcedGas = 0 + +# ------------------------------------------------------------------------------ +# GasPriceMarginFactor is used to bias the gas price by whatever the +# configured factor is. If we want to make sure our transactions are +# mined quickly especially if there is volatility, we could set this +# factor to be 1.2 in order to make sure that our transactions are +# attractive. +# +# Generally, we would not recommend setting this below 1. If you're +# looking to save on gas costs, there are better ways. +# ------------------------------------------------------------------------------ +GasPriceMarginFactor = 1.25 + +# ------------------------------------------------------------------------------ +# MaxGasPriceLimit is used to specify in wei the upper limit price +# that we would be willing to pay. If the current gas price exceeds +# this limit, we'll adjust the gas price down to the configured limit +# and try to send the transaction. If the limit is below the base fee, +# the transaction probably would not be accepted by the RPC. +# ------------------------------------------------------------------------------ +MaxGasPriceLimit = 0 + +# TODO +PersistenceFilename = "/app/data/ethtxmanager.json" + +# ============================================================================== +# _____ _____ _ _ _____ ____ __ __ _ _ _ +# | ____|_ _| | | | ____| _ \| \/ | / \ | \ | | +# | _| | | | |_| | _| | |_) | |\/| | / _ \ | \| | +# | |___ | | | _ | |___| _ <| | | |/ ___ \| |\ | +# |_____| |_| |_| |_|_____|_| \_\_| |_/_/ \_\_| \_| +# +# ------------------------------------------------------------------------------ +[SequenceSender.EthTxManager.Etherman] + +# ------------------------------------------------------------------------------ +# URL should be used to configure your L1 RPC address. +# ------------------------------------------------------------------------------ +URL = "{{.l1_rpc_url}}" + +# ------------------------------------------------------------------------------ +# MultiGasProvider can be set to true in order to use a gas station +# provider in addition to using a normal RPC gas pricer. This feature +# is not used as far as we know +# +# Deprecated: This feature currently uses gas station which has been +# decommissioned +# +# ------------------------------------------------------------------------------ +MultiGasProvider = false + +# TODO +L1ChainID = {{.l1_chain_id}} + +# TODO +HTTPHeaders = [] diff --git a/zkevm_pool_manager.star b/zkevm_pool_manager.star deleted file mode 100644 index 5aa42cd2..00000000 --- a/zkevm_pool_manager.star +++ /dev/null @@ -1,45 +0,0 @@ -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"], args["sequencer_type"] - ) - - 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, - ) - }, - )