From a4a48172d835d1f4da642529d118fa746d08a12c Mon Sep 17 00:00:00 2001 From: Xavier Romero Date: Mon, 3 Feb 2025 11:10:11 +0100 Subject: [PATCH 1/8] Anvil L1 option --- anvil.star | 56 +++++++++++++++++++++++++++++++++++++++++++++++ input_parser.star | 12 ++++++++++ main.star | 6 ++++- test_anvil.sh | 7 ++++++ 4 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 anvil.star create mode 100755 test_anvil.sh diff --git a/anvil.star b/anvil.star new file mode 100644 index 00000000..1630e40f --- /dev/null +++ b/anvil.star @@ -0,0 +1,56 @@ +ANVIL_IMAGE = "ghcr.io/foundry-rs/foundry:latest" +ANVIL_PORT = 8545 +ANVIL_BLOCK_TIME = 1 +ANVIL_SLOTS_IN_AN_EPOCH = ( + 2 # Setting to X leads to block N-(X+1) being finalized, being N latest block +) + + +def run(plan, args): + chain_id = str(args["l1_chain_id"]) + + plan.add_service( + name="anvil", + config=ServiceConfig( + image=ANVIL_IMAGE, + ports={ + "rpc": PortSpec(ANVIL_PORT, application_protocol="http"), + }, + cmd=[ + "anvil --block-time " + + str(ANVIL_BLOCK_TIME) + + " --slots-in-an-epoch " + + str(ANVIL_SLOTS_IN_AN_EPOCH) + + " --chain-id " + + chain_id + + " --host 0.0.0.0 --port " + + str(ANVIL_PORT) + ], + ), + description="Anvil", + ) + + mnemonic = args.get("l1_preallocated_mnemonic") + cmd = ( + 'cast rpc anvil_setBalance $(cast wallet addr --mnemonic "' + + mnemonic + + '") 0x33b2e3c9fd0803ce8000000' + ) + plan.exec( + description="Funding L1 account", + service_name="anvil", + recipe=ExecRecipe(command=["/bin/sh", "-c", cmd]), + ) + + # Check balance + plan.exec( + description="Checking L1 account balance", + service_name="anvil", + recipe=ExecRecipe( + command=[ + "/bin/sh", + "-c", + 'cast balance $(cast wallet addr --mnemonic "' + mnemonic + '")', + ] + ), + ) diff --git a/input_parser.star b/input_parser.star index d8cefb48..1e55da71 100644 --- a/input_parser.star +++ b/input_parser.star @@ -157,6 +157,8 @@ DEFAULT_ACCOUNTS = { } DEFAULT_L1_ARGS = { + # The L1 engine to use, either "geth" or "anvil". + "l1_engine": "geth", # The L1 network identifier. "l1_chain_id": 271828, # This mnemonic will: @@ -389,6 +391,16 @@ def parse_args(plan, args): op_stack_args = args.get("optimism_package", {}) args = DEFAULT_ARGS | args.get("args", {}) + if args["l1_engine"] == "anvil": + args["l1_rpc_url"] = "http://anvil:8545" + args["l1_ws_url"] = "ws://anvil:8545" + elif args["l1_engine"] != "geth": + fail( + "Unsupported L1 engine: '{}', please use 'geth' or 'anvil'".format( + args["l1_engine"] + ) + ) + # Validation step. verbosity = args.get("verbosity", "") validate_log_level("verbosity", verbosity) diff --git a/main.star b/main.star index cd652107..11522c97 100644 --- a/main.star +++ b/main.star @@ -11,6 +11,7 @@ cdk_erigon_package = "./cdk_erigon.star" databases_package = "./databases.star" deploy_zkevm_contracts_package = "./deploy_zkevm_contracts.star" ethereum_package = "./ethereum.star" +anvil_package = "./anvil.star" optimism_package = "github.com/ethpandaops/optimism-package/main.star" zkevm_pool_manager_package = "./zkevm_pool_manager.star" deploy_l2_contracts_package = "./deploy_l2_contracts.star" @@ -40,7 +41,10 @@ def run(plan, args={}): # Deploy a local L1. if deployment_stages.get("deploy_l1", False): plan.print("Deploying a local L1") - import_module(ethereum_package).run(plan, args) + if args.get("l1_engine", "geth") == "anvil": + import_module(anvil_package).run(plan, args) + else: + import_module(ethereum_package).run(plan, args) else: plan.print("Skipping the deployment of a local L1") diff --git a/test_anvil.sh b/test_anvil.sh new file mode 100755 index 00000000..b36933c4 --- /dev/null +++ b/test_anvil.sh @@ -0,0 +1,7 @@ +ENCLAVE=cdk + +kurtosis run --enclave $ENCLAVE . '{ + "args": { + "l1_engine": "anvil", + } +}' From 15be597a35199710518850a422056619cdcea8d5 Mon Sep 17 00:00:00 2001 From: Xavier Romero Date: Mon, 3 Feb 2025 19:30:30 +0100 Subject: [PATCH 2/8] Anvil dump and restore --- .github/tests/anvil/rollup.yml | 4 ++ .github/workflows/deploy.yml | 45 ++++++++++++++++ .gitignore | 9 +++- anvil.star | 73 +++++++++++++------------- cdk_erigon.star | 53 ++++++++++--------- deploy_zkevm_contracts.star | 5 +- docs/anvil.md | 91 +++++++++++++++++++++++++++++++++ input_parser.star | 8 ++- lib/cdk_erigon.star | 17 +++++- templates/cdk-erigon/config.yml | 3 +- test_anvil.sh | 7 --- 11 files changed, 239 insertions(+), 76 deletions(-) create mode 100644 .github/tests/anvil/rollup.yml create mode 100644 docs/anvil.md delete mode 100755 test_anvil.sh diff --git a/.github/tests/anvil/rollup.yml b/.github/tests/anvil/rollup.yml new file mode 100644 index 00000000..927c2294 --- /dev/null +++ b/.github/tests/anvil/rollup.yml @@ -0,0 +1,4 @@ +args: + verbosity: debug + l1_engine: anvil + consensus_contract_type: rollup diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ea5f0a2b..bfbadbb0 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -841,5 +841,50 @@ jobs: with: name: dump_attach_sovereign_${{ github.run_id }} path: ./dump +<<<<<<< HEAD env : agglayer_prover_sp1_key: ${{ secrets.SP1_PRIVATE_KEY }} +======= + + deploy-to-anvil_l1: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + # This step will only execute if the necessary secrets are available, preventing failures + # on pull requests from forked repositories. + if: ${{ env.DOCKERHUB_USERNAME && env.DOCKERHUB_TOKEN }} + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Install Kurtosis CDK tools + uses: ./.github/actions/setup-kurtosis-cdk + + - name: Deploy stack with anvil + run: kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --args-file=./.github/tests/anvil/rollup.yml . + + - name: Monitor CDK chain verified batches (CDK Erigon Permissionless RPC) + working-directory: .github/scripts + run: | + ./monitor-cdk-chain.sh \ + --enclave ${{ env.ENCLAVE_NAME }} \ + --rpc-url "$(kurtosis port print ${{ env.ENCLAVE_NAME }} cdk-erigon-rpc-001 rpc)" + + - name: Dump enclave + if: ${{ !cancelled() }} + run: kurtosis enclave dump ${{ env.ENCLAVE_NAME }} ./dump + + - name: Upload enclave dump + if: ${{ !cancelled() }} + uses: actions/upload-artifact@v4 + with: + name: dump_deploy_to_anvil_l1_${{ github.run_id }} + path: ./dump +>>>>>>> 971a113 (Anvil dump and restore) diff --git a/.gitignore b/.gitignore index d3d4a7dd..67681feb 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,11 @@ package-lock.json package.json # prod values -*secret* \ No newline at end of file +*secret* + +# Files used for existing L1 +templates/contract-deploy/combined.json +templates/contract-deploy/dynamic-kurtosis-allocs.json +templates/contract-deploy/dynamic-kurtosis-conf.json +templates/contract-deploy/genesis.json +anvil_state.json \ No newline at end of file diff --git a/anvil.star b/anvil.star index 1630e40f..d82f6282 100644 --- a/anvil.star +++ b/anvil.star @@ -4,53 +4,54 @@ ANVIL_BLOCK_TIME = 1 ANVIL_SLOTS_IN_AN_EPOCH = ( 2 # Setting to X leads to block N-(X+1) being finalized, being N latest block ) +STATE_PATH = "/tmp" def run(plan, args): chain_id = str(args["l1_chain_id"]) + service_files = {} + mnemonic = args.get("l1_preallocated_mnemonic") + + cmd = ( + "anvil --block-time " + + str(ANVIL_BLOCK_TIME) + + " --slots-in-an-epoch " + + str(ANVIL_SLOTS_IN_AN_EPOCH) + + " --chain-id " + + chain_id + + " --host 0.0.0.0 --port " + + str(ANVIL_PORT) + + " --dump-state " + + STATE_PATH + + "/state_out.json" + + " --balance 1000000000" + + ' --mnemonic "' + + mnemonic + + '"' + ) + + load_state = bool(args.get("anvil_state_file")) + + if load_state: + anvil_state = plan.upload_files( + name="anvil-state", + src=args["anvil_state_file"], + description="Uploading Anvil State", + ) + service_files = { + STATE_PATH: anvil_state, + } + cmd += " --load-state " + STATE_PATH + "/" + args["anvil_state_file"] plan.add_service( - name="anvil", + name="anvil" + args["deployment_suffix"], config=ServiceConfig( image=ANVIL_IMAGE, ports={ "rpc": PortSpec(ANVIL_PORT, application_protocol="http"), }, - cmd=[ - "anvil --block-time " - + str(ANVIL_BLOCK_TIME) - + " --slots-in-an-epoch " - + str(ANVIL_SLOTS_IN_AN_EPOCH) - + " --chain-id " - + chain_id - + " --host 0.0.0.0 --port " - + str(ANVIL_PORT) - ], + files=service_files, + cmd=[cmd], ), description="Anvil", ) - - mnemonic = args.get("l1_preallocated_mnemonic") - cmd = ( - 'cast rpc anvil_setBalance $(cast wallet addr --mnemonic "' - + mnemonic - + '") 0x33b2e3c9fd0803ce8000000' - ) - plan.exec( - description="Funding L1 account", - service_name="anvil", - recipe=ExecRecipe(command=["/bin/sh", "-c", cmd]), - ) - - # Check balance - plan.exec( - description="Checking L1 account balance", - service_name="anvil", - recipe=ExecRecipe( - command=[ - "/bin/sh", - "-c", - 'cast balance $(cast wallet addr --mnemonic "' + mnemonic + '")', - ] - ), - ) diff --git a/cdk_erigon.star b/cdk_erigon.star index 4b588b92..a6179742 100644 --- a/cdk_erigon.star +++ b/cdk_erigon.star @@ -3,6 +3,29 @@ zkevm_prover_package = import_module("./lib/zkevm_prover.star") def run_sequencer(plan, args, contract_setup_addresses): + # Start the zkevm stateless executor if strict mode is enabled. + 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_stateless_executor_start_port", + ) + cdk_erigon_config_template = read_file(src="./templates/cdk-erigon/config.yml") cdk_erigon_sequencer_config_artifact = plan.render_templates( name="cdk-erigon-sequencer-config-artifact", @@ -13,6 +36,7 @@ def run_sequencer(plan, args, contract_setup_addresses): "zkevm_data_stream_port": args["zkevm_data_streamer_port"], "is_sequencer": True, "consensus_contract_type": args["consensus_contract_type"], + "l1_sync_start_block": 1 if args["anvil_state_file"] else 0, } | args | contract_setup_addresses, @@ -49,12 +73,17 @@ def run_sequencer(plan, args, contract_setup_addresses): name="cdk-erigon-chain-first-batch", ) + cdk_erigon_datadir = Directory( + persistent_key="cdk-erigon-datadir" + args["deployment_suffix"], + ) + config_artifacts = struct( config=cdk_erigon_sequencer_config_artifact, chain_spec=cdk_erigon_chain_spec_artifact, chain_config=cdk_erigon_chain_config_artifact, chain_allocs=cdk_erigon_chain_allocs_artifact, chain_first_batch=cdk_erigon_chain_first_batch_artifact, + datadir=cdk_erigon_datadir, ) cdk_erigon_package.start_cdk_erigon_sequencer( plan, args, config_artifacts, "cdk_erigon_sequencer_start_port" @@ -62,29 +91,6 @@ def run_sequencer(plan, args, contract_setup_addresses): def run_rpc(plan, args, contract_setup_addresses): - # Start the zkevm stateless executor if strict mode is enabled. - 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_stateless_executor_start_port", - ) - zkevm_sequencer_service = plan.get_service( name=args["sequencer_name"] + args["deployment_suffix"] ) @@ -115,6 +121,7 @@ def run_rpc(plan, args, contract_setup_addresses): "is_sequencer": False, "pool_manager_url": pool_manager_url, "consensus_contract_type": args["consensus_contract_type"], + "l1_sync_start_block": 0, } | args | contract_setup_addresses, diff --git a/deploy_zkevm_contracts.star b/deploy_zkevm_contracts.star index 3243ca1a..e463e873 100644 --- a/deploy_zkevm_contracts.star +++ b/deploy_zkevm_contracts.star @@ -44,10 +44,7 @@ def run(plan, args): artifact_paths = list(ARTIFACTS) # If we are configured to use a previous deployment, we'll # dynamically add artifacts for the genesis and combined outputs. - if ( - "use_previously_deployed_contracts" in args - and args["use_previously_deployed_contracts"] - ): + if args.get("use_previously_deployed_contracts"): artifact_paths.append( { "name": "genesis.json", diff --git a/docs/anvil.md b/docs/anvil.md new file mode 100644 index 00000000..1c901259 --- /dev/null +++ b/docs/anvil.md @@ -0,0 +1,91 @@ +# Anvil L1 + +You can configure the stack to use Anvil as L1 by setting +``` +l1_engine: anvil +``` + +Please, understand that by doing: +- l1_chain_id is taken into account +- l1_rpc_url is automatically set to http://anvil-001:8545" +- l1_ws_url is automatically set to ws://anvil-001:8545 +- These params are ignored: + - l1_beacon_url + - l1_additional_services + - l1_preset + - l1_seconds_per_slot + - l1_participants_count + + +## State dump and recover +By using Anvil as L1, you can dump L1 network state, totally remove the network, and recreate again with the same L1 state. +This procedure has been tested with zkEVM rollup mode, for other scenarios you could need to perform additional steps (like dumping/restoring DAC database) or could be even not supported. + +### Procedure +Deploy the network. +```bash +ENCLAVE=cdk +kurtosis run --enclave $ENCLAVE . '{ + "args": { + "l1_engine": "anvil", + "consensus_contract_type": "rollup", + } +}' +``` + +Once deployed, save the required files to recreate again later. These are the files you need: +- ./anvil_state.json +- ./templates/contract-deploy/ +- ./templates/contract-deploy/combined.json +- ./templates/contract-deploy/genesis.json +- ./templates/contract-deploy/dynamic-kurtosis-conf.json +- ./templates/contract-deploy/dynamic-kurtosis-allocs.json + +Let's get them: + +```bash +STATE_FILE=anvil_state.json +DEPLOYMENT_FILES="combined.json genesis.json dynamic-kurtosis-conf.json dynamic-kurtosis-allocs.json" + +contracts_uuid=$(kurtosis enclave inspect --full-uuids $ENCLAVE | grep contracts | awk '{ print $1 }') +for file in $DEPLOYMENT_FILES; do + # Save each file on ./templates/contract-deploy, as they are expecte there for use_previously_deployed_contracts=True + docker cp contracts-001--$contracts_uuid:/opt/zkevm/$file ./templates/contract-deploy/$file +done + +# Dump Anvilstate (L1) +anvil_uuid=$(kurtosis enclave inspect --full-uuids $ENCLAVE | grep anvil | awk '{ print $1 }') +docker cp anvil--001--$anvil_uuid:/tmp/state_out.json $STATE_FILE +``` + +At that point you have all you need, you can totally remove the network. +```bash +kurtosis enclave stop $ENCLAVE +kurtosis enclave rm $ENCLAVE +``` + +To recreate the network, run kurtosis from scratch like this: +```bash +time kurtosis run --enclave $ENCLAVE . '{ + "args": { + "anvil_state_file": '$STATE_FILE', + "use_previously_deployed_contracts": true, + "consensus_contract_type": "rollup", + } +}' +``` + +This will perform the required steps to load the previous state, however, the sequencer needs to recover the state from L1 so it has been set with a specific param, that won't allow it to resume generating new blocks. So you need to manually unlock it: + +```bash +# Check cdk-erigon-sequencer logs until you see lines like this before proceeding. +# "L1 block sync recovery has completed!"" + +# Disable L1 recovery mode +kurtosis service exec $ENCLAVE cdk-erigon-sequencer-001 \ + "sed -i 's/zkevm.l1-sync-start-block: 1/zkevm.l1-sync-start-block: 0/' /etc/cdk-erigon/config.yaml" + +# Restart sequenccer +kurtosis service stop $ENCLAVE cdk-erigon-sequencer-001 +kurtosis service start $ENCLAVE cdk-erigon-sequencer-001 +``` diff --git a/input_parser.star b/input_parser.star index 1e55da71..33c9634d 100644 --- a/input_parser.star +++ b/input_parser.star @@ -219,6 +219,7 @@ DEFAULT_L1_ARGS = { # TODO at some point it would be nice if erigon could recover itself, but this is not going to be easy if there's a DAC "use_previously_deployed_contracts": False, "erigon_datadir_archive": None, + "anvil_state_file": None, } DEFAULT_L2_ARGS = { @@ -391,9 +392,12 @@ def parse_args(plan, args): op_stack_args = args.get("optimism_package", {}) args = DEFAULT_ARGS | args.get("args", {}) + if args["anvil_state_file"] != None: + args["l1_engine"] = "anvil" + if args["l1_engine"] == "anvil": - args["l1_rpc_url"] = "http://anvil:8545" - args["l1_ws_url"] = "ws://anvil:8545" + args["l1_rpc_url"] = "http://anvil" + args["deployment_suffix"] + ":8545" + args["l1_ws_url"] = "ws://anvil" + args["deployment_suffix"] + ":8545" elif args["l1_engine"] != "geth": fail( "Unsupported L1 engine: '{}', please use 'geth' or 'anvil'".format( diff --git a/lib/cdk_erigon.star b/lib/cdk_erigon.star index 8f4e6b63..807a96b7 100644 --- a/lib/cdk_erigon.star +++ b/lib/cdk_erigon.star @@ -4,6 +4,7 @@ CDK_ERIGON_TYPE = struct( sequencer="sequencer", rpc="rpc", ) +CDK_ERIGON_CMD = "cdk-erigon --config /etc/cdk-erigon/config.yaml" def start_cdk_erigon_sequencer(plan, args, config_artifact, start_port_name): @@ -29,7 +30,13 @@ def start_cdk_erigon_rpc(plan, args, config_artifact, start_port_name): def _start_service( - plan, type, args, config_artifact, start_port_name, additional_ports={}, env_vars={} + plan, + type, + args, + config_artifact, + start_port_name, + additional_ports={}, + env_vars={}, ): cdk_erigon_chain_artifact_names = [ config_artifact.chain_spec, @@ -37,6 +44,7 @@ def _start_service( config_artifact.chain_allocs, config_artifact.chain_first_batch, ] + plan_files = { "/etc/cdk-erigon": Directory( artifact_names=[config_artifact.config] + cdk_erigon_chain_artifact_names, @@ -46,6 +54,11 @@ def _start_service( ), } + if hasattr(config_artifact, "datadir"): + plan_files[ + "/home/erigon/data/dynamic-" + args["chain_name"] + "-sequencer" + ] = config_artifact.datadir + proc_runner_file_artifact = plan.upload_files( name="cdk-erigon-" + type + "-proc-runner", src="../templates/proc-runner.sh", @@ -72,7 +85,7 @@ def _start_service( public_ports=public_ports, files=plan_files, entrypoint=["/usr/local/share/proc-runner/proc-runner.sh"], - cmd=["cdk-erigon --config /etc/cdk-erigon/config.yaml"], + cmd=[CDK_ERIGON_CMD], env_vars=env_vars, ), ) diff --git a/templates/cdk-erigon/config.yml b/templates/cdk-erigon/config.yml index 5e8b338d..9a9e8829 100644 --- a/templates/cdk-erigon/config.yml +++ b/templates/cdk-erigon/config.yml @@ -430,7 +430,7 @@ zkevm.address-ger-manager: "{{.zkevm_global_exit_root_address}}" # Used for network recovery from L1 batch data. # Set to 0 to use the datastream instead. # Default: 0 -zkevm.l1-sync-start-block: 0 +zkevm.l1-sync-start-block: {{.l1_sync_start_block}} # Limits the number of batches to sync from L1. # Useful for debugging or partial recoveries. @@ -999,3 +999,4 @@ db.size.limit: 8TB # - config # - lightclient.x # - sentinel.x + diff --git a/test_anvil.sh b/test_anvil.sh deleted file mode 100755 index b36933c4..00000000 --- a/test_anvil.sh +++ /dev/null @@ -1,7 +0,0 @@ -ENCLAVE=cdk - -kurtosis run --enclave $ENCLAVE . '{ - "args": { - "l1_engine": "anvil", - } -}' From 74407b45ac3cb4969ff14f1f5aa56a59b9017992 Mon Sep 17 00:00:00 2001 From: Xavier Romero <47888584+xavier-romero@users.noreply.github.com> Date: Tue, 4 Feb 2025 10:40:31 +0100 Subject: [PATCH 3/8] Update docs/anvil.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Léo Vincent <28714795+leovct@users.noreply.github.com> --- docs/anvil.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/anvil.md b/docs/anvil.md index 1c901259..dee79792 100644 --- a/docs/anvil.md +++ b/docs/anvil.md @@ -7,7 +7,7 @@ l1_engine: anvil Please, understand that by doing: - l1_chain_id is taken into account -- l1_rpc_url is automatically set to http://anvil-001:8545" +- l1_rpc_url is automatically set to http://anvil-001:8545 - l1_ws_url is automatically set to ws://anvil-001:8545 - These params are ignored: - l1_beacon_url From b8fecf6d84c9bc4879abb52d24756d6d3cf9fe28 Mon Sep 17 00:00:00 2001 From: Xavier Romero <47888584+xavier-romero@users.noreply.github.com> Date: Tue, 4 Feb 2025 10:40:39 +0100 Subject: [PATCH 4/8] Update docs/anvil.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Léo Vincent <28714795+leovct@users.noreply.github.com> --- docs/anvil.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/anvil.md b/docs/anvil.md index dee79792..cb0dd9d8 100644 --- a/docs/anvil.md +++ b/docs/anvil.md @@ -53,7 +53,7 @@ for file in $DEPLOYMENT_FILES; do docker cp contracts-001--$contracts_uuid:/opt/zkevm/$file ./templates/contract-deploy/$file done -# Dump Anvilstate (L1) +# Dump Anvil state (L1) anvil_uuid=$(kurtosis enclave inspect --full-uuids $ENCLAVE | grep anvil | awk '{ print $1 }') docker cp anvil--001--$anvil_uuid:/tmp/state_out.json $STATE_FILE ``` From 4c02de55dec28aca92b589b04df49fbd07bc70ab Mon Sep 17 00:00:00 2001 From: Xavier Romero <47888584+xavier-romero@users.noreply.github.com> Date: Tue, 4 Feb 2025 10:40:55 +0100 Subject: [PATCH 5/8] Update docs/anvil.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Léo Vincent <28714795+leovct@users.noreply.github.com> --- docs/anvil.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/anvil.md b/docs/anvil.md index cb0dd9d8..6e05a0d9 100644 --- a/docs/anvil.md +++ b/docs/anvil.md @@ -49,7 +49,7 @@ DEPLOYMENT_FILES="combined.json genesis.json dynamic-kurtosis-conf.json dynamic- contracts_uuid=$(kurtosis enclave inspect --full-uuids $ENCLAVE | grep contracts | awk '{ print $1 }') for file in $DEPLOYMENT_FILES; do - # Save each file on ./templates/contract-deploy, as they are expecte there for use_previously_deployed_contracts=True + # Save each file on ./templates/contract-deploy, as they are expected there for use_previously_deployed_contracts=True docker cp contracts-001--$contracts_uuid:/opt/zkevm/$file ./templates/contract-deploy/$file done From 3051a0bc49dbecd5f43b3e4b13b7f7e71bff2e59 Mon Sep 17 00:00:00 2001 From: Xavier Romero Date: Tue, 4 Feb 2025 11:03:36 +0100 Subject: [PATCH 6/8] Restore erigon cmd --- lib/cdk_erigon.star | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/cdk_erigon.star b/lib/cdk_erigon.star index 807a96b7..0bd339e9 100644 --- a/lib/cdk_erigon.star +++ b/lib/cdk_erigon.star @@ -4,7 +4,6 @@ CDK_ERIGON_TYPE = struct( sequencer="sequencer", rpc="rpc", ) -CDK_ERIGON_CMD = "cdk-erigon --config /etc/cdk-erigon/config.yaml" def start_cdk_erigon_sequencer(plan, args, config_artifact, start_port_name): @@ -85,7 +84,7 @@ def _start_service( public_ports=public_ports, files=plan_files, entrypoint=["/usr/local/share/proc-runner/proc-runner.sh"], - cmd=[CDK_ERIGON_CMD], + cmd=["cdk-erigon --config /etc/cdk-erigon/config.yaml"], env_vars=env_vars, ), ) From 59964799190820f38b9fe08dda17fd24960073cf Mon Sep 17 00:00:00 2001 From: Xavier Romero Date: Tue, 4 Feb 2025 15:09:18 +0100 Subject: [PATCH 7/8] Minor changes --- anvil.star | 8 +++----- docs/anvil.md | 2 +- input_parser.star | 29 +++++++++++++++++++++++------ 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/anvil.star b/anvil.star index d82f6282..7ca1c995 100644 --- a/anvil.star +++ b/anvil.star @@ -1,5 +1,3 @@ -ANVIL_IMAGE = "ghcr.io/foundry-rs/foundry:latest" -ANVIL_PORT = 8545 ANVIL_BLOCK_TIME = 1 ANVIL_SLOTS_IN_AN_EPOCH = ( 2 # Setting to X leads to block N-(X+1) being finalized, being N latest block @@ -20,7 +18,7 @@ def run(plan, args): + " --chain-id " + chain_id + " --host 0.0.0.0 --port " - + str(ANVIL_PORT) + + str(args["anvil_port"]) + " --dump-state " + STATE_PATH + "/state_out.json" @@ -46,9 +44,9 @@ def run(plan, args): plan.add_service( name="anvil" + args["deployment_suffix"], config=ServiceConfig( - image=ANVIL_IMAGE, + image=args["anvil_image"], ports={ - "rpc": PortSpec(ANVIL_PORT, application_protocol="http"), + "rpc": PortSpec(args["anvil_port"], application_protocol="http"), }, files=service_files, cmd=[cmd], diff --git a/docs/anvil.md b/docs/anvil.md index 6e05a0d9..45ea8f81 100644 --- a/docs/anvil.md +++ b/docs/anvil.md @@ -55,7 +55,7 @@ done # Dump Anvil state (L1) anvil_uuid=$(kurtosis enclave inspect --full-uuids $ENCLAVE | grep anvil | awk '{ print $1 }') -docker cp anvil--001--$anvil_uuid:/tmp/state_out.json $STATE_FILE +docker cp anvil-001--$anvil_uuid:/tmp/state_out.json $STATE_FILE ``` At that point you have all you need, you can totally remove the network. diff --git a/input_parser.star b/input_parser.star index 33c9634d..e0f3c37b 100644 --- a/input_parser.star +++ b/input_parser.star @@ -47,6 +47,7 @@ DEFAULT_IMAGES = { "zkevm_pool_manager_image": "hermeznetwork/zkevm-pool-manager:v0.1.2", # https://hub.docker.com/r/hermeznetwork/zkevm-pool-manager/tags "zkevm_prover_image": "hermeznetwork/zkevm-prover:v8.0.0-RC14-fork.12", # https://hub.docker.com/r/hermeznetwork/zkevm-prover/tags "zkevm_sequence_sender_image": "hermeznetwork/zkevm-sequence-sender:v0.2.4", # https://hub.docker.com/r/hermeznetwork/zkevm-sequence-sender/tags + "anvil_image": "ghcr.io/foundry-rs/foundry:v1.0.0-rc", # https://github.com/foundry-rs/foundry/pkgs/container/foundry/versions?filters%5Bversion_type%5D=tagged } DEFAULT_PORTS = { @@ -69,6 +70,7 @@ DEFAULT_PORTS = { "zkevm_rpc_ws_port": 8133, "zkevm_cdk_node_port": 5576, "blockscout_frontend_port": 3000, + "anvil_port": 8545, } DEFAULT_STATIC_PORTS = { @@ -386,18 +388,33 @@ DEFAULT_ARGS = ( SUPPORTED_FORK_IDS = [9, 11, 12, 13] -def parse_args(plan, args): +def parse_args(plan, user_args): # Merge the provided args with defaults. - deployment_stages = DEFAULT_DEPLOYMENT_STAGES | args.get("deployment_stages", {}) - op_stack_args = args.get("optimism_package", {}) - args = DEFAULT_ARGS | args.get("args", {}) + deployment_stages = DEFAULT_DEPLOYMENT_STAGES | user_args.get( + "deployment_stages", {} + ) + op_stack_args = user_args.get("optimism_package", {}) + args = DEFAULT_ARGS | user_args.get("args", {}) if args["anvil_state_file"] != None: args["l1_engine"] = "anvil" if args["l1_engine"] == "anvil": - args["l1_rpc_url"] = "http://anvil" + args["deployment_suffix"] + ":8545" - args["l1_ws_url"] = "ws://anvil" + args["deployment_suffix"] + ":8545" + # We override only is user did not provide explicit values + if not user_args.get("args", {}).get("l1_rpc_url"): + args["l1_rpc_url"] = ( + "http://anvil" + + args["deployment_suffix"] + + ":" + + str(DEFAULT_PORTS.get("anvil_port")) + ) + if not user_args.get("args", {}).get("l1_ws_url"): + args["l1_ws_url"] = ( + "ws://anvil" + + args["deployment_suffix"] + + ":" + + str(DEFAULT_PORTS.get("anvil_port")) + ) elif args["l1_engine"] != "geth": fail( "Unsupported L1 engine: '{}', please use 'geth' or 'anvil'".format( From 7ed8f962d67b048e8933f18119081eda20a5596a Mon Sep 17 00:00:00 2001 From: Xavier Romero Date: Tue, 4 Feb 2025 15:15:25 +0100 Subject: [PATCH 8/8] Fix lint issue on yaml --- .github/workflows/deploy.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index bfbadbb0..7e353149 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -841,10 +841,8 @@ jobs: with: name: dump_attach_sovereign_${{ github.run_id }} path: ./dump -<<<<<<< HEAD - env : + env: agglayer_prover_sp1_key: ${{ secrets.SP1_PRIVATE_KEY }} -======= deploy-to-anvil_l1: runs-on: ubuntu-latest @@ -887,4 +885,3 @@ jobs: with: name: dump_deploy_to_anvil_l1_${{ github.run_id }} path: ./dump ->>>>>>> 971a113 (Anvil dump and restore)