From 9b805dad364b527afdc7d970edb50dacd1794020 Mon Sep 17 00:00:00 2001 From: Adw8 Date: Tue, 3 Sep 2024 16:06:59 +0530 Subject: [PATCH] Copy artifact files if contracts are already deployed --- l2-setup/README.md | 27 +++++++++++++----- l2-setup/run-optimism.yml | 36 ++++++++++++++++++++---- l2-setup/templates/configs/l2-config.env | 5 ++-- l2-setup/vars.yml | 7 +++++ 4 files changed, 60 insertions(+), 15 deletions(-) create mode 100644 l2-setup/vars.yml diff --git a/l2-setup/README.md b/l2-setup/README.md index 961b5cf..e0eb709 100644 --- a/l2-setup/README.md +++ b/l2-setup/README.md @@ -11,30 +11,33 @@ The following commands have to be executed in [`l2-setup`](./) directory - Edit [`l2-config.env`](./templates/configs/l2-config.env) and fill in the following values ```bash - # Chain ID of the L1 chain + # L1 Chain ID CERC_L1_CHAIN_ID= # L1 RPC endpoint CERC_L1_RPC= - # Amount to send the proposer on L2 (default: 0.2 ether) - CERC_L2_PROPOSER_AMOUNT= - - # Amount to send the batcher on L2 (default: 0.1 ether) - CERC_L2_BATCHER_AMOUNT= - # L1 RPC endpoint host or IP address CERC_L1_HOST= # L1 RPC endpoint port number CERC_L1_PORT= + # L1 Beacon endpoint + CERC_L1_BEACON= + # Address of the funded account on L1 # Used for optimism contracts deployment CERC_L1_ADDRESS= # Private key of the funded account on L1 CERC_L1_PRIV_KEY= + + # Funding amount for Optimism Proposer account on L1 (default: 0.2 ether) + CERC_PROPOSER_AMOUNT= + + # Amount to send the batcher on L2 (default: 0.1 ether) + CERC_BATCHER_AMOUNT= ``` - To setup and run L2, execute the `run-optimism.yml` Ansible playbook by running the following command. @@ -50,3 +53,13 @@ The following commands have to be executed in [`l2-setup`](./) directory ```bash LANG=en_US.utf8 ansible-playbook -i localhost, --connection=local run-optimism.yml --extra-vars='{"target_host" : "localhost", "skip_container_build": true}' -kK --user $USER ``` + +- To run using existing contracts deployment + + - Update the [`vars.yml`](./vars.yml) with paths to required artifacts + + - Run the ansible playbook with `"existing_l1_deployment": true` in the `--extra-vars` parameter: + + ```bash + LANG=en_US.utf8 ansible-playbook -i localhost, --connection=local run-optimism.yml --extra-vars='{"target_host" : "localhost", "existing_l1_deployment": true}' -kK --user $USER + ``` diff --git a/l2-setup/run-optimism.yml b/l2-setup/run-optimism.yml index 5099f71..f700173 100644 --- a/l2-setup/run-optimism.yml +++ b/l2-setup/run-optimism.yml @@ -20,6 +20,7 @@ group: "{{ansible_user}}" state: directory recurse: yes + become: yes - name: Clone fixturenet-optimism-stack command: laconic-so fetch-stack git.vdb.to/cerc-io/fixturenet-optimism-stack --pull @@ -38,25 +39,48 @@ - name: Copy over spec file for L2 deployment template: src: "./templates/specs/l2-spec.yml.j2" - dest: "{{ l2_directory }}/fixturenet-optimism-spec.yml" + dest: "{{ l2_directory }}/optimism-spec.yml" - name: Check if the deployment directory exists for L2 stat: - path: "{{ l2_directory }}/fixturenet-optimism-deployment" + path: "{{ l2_directory }}/optimism-deployment" register: l2_deployment_dir - name: Create a deployment from the spec file for L2 - command: laconic-so --stack ~/cerc/fixturenet-optimism-stack/stack/fixturenet-optimism deploy create --spec-file fixturenet-optimism-spec.yml --deployment-dir fixturenet-optimism-deployment + command: laconic-so --stack ~/cerc/fixturenet-optimism-stack/stack/fixturenet-optimism deploy create --spec-file optimism-spec.yml --deployment-dir optimism-deployment args: chdir: "{{ l2_directory }}" when: not l2_deployment_dir.stat.exists - - name: Copy config.env for L2 deployment + - name: Generate config.env for L2 deployment template: src: "./templates/configs/l2-config.env" - dest: "{{ l2_directory }}/fixturenet-optimism-deployment/config.env" + dest: "{{ l2_directory }}/optimism-deployment/config.env" + + - name: Copy deployed contract addresses and configuration files + block: + - name: Copy l1 deployment file + copy: + src: "{{ contract_addresses }}" + dest: "{{ l2_directory }}/optimism-deployment/data/l1_deployment" + + - name: Copy l2 configuration file + copy: + src: "{{ l2_config_file }}" + dest: "{{ l2_directory }}/optimism-deployment/data/l2_config" + + - name: Copy allocs-l2 file + copy: + src: "{{ allocs_l2_file }}" + dest: "{{ l2_directory }}/optimism-deployment/data/l2_config" + + - name: Copy l2 jwt file + copy: + src: "{{ l2_jwt_file }}" + dest: "{{ l2_directory }}/optimism-deployment/data/l2_config" + when: existing_l1_deployment - name: Start L2-deployment - command: laconic-so deployment --dir fixturenet-optimism-deployment start + command: laconic-so deployment --dir optimism-deployment start args: chdir: "{{ l2_directory }}" diff --git a/l2-setup/templates/configs/l2-config.env b/l2-setup/templates/configs/l2-config.env index 02087b7..dc5be92 100644 --- a/l2-setup/templates/configs/l2-config.env +++ b/l2-setup/templates/configs/l2-config.env @@ -1,9 +1,10 @@ CERC_ALLOW_UNPROTECTED_TXS=true CERC_L1_CHAIN_ID= CERC_L1_RPC= -CERC_L2_PROPOSER_AMOUNT= -CERC_L2_BATCHER_AMOUNT= +CERC_L1_BEACON= CERC_L1_HOST= CERC_L1_PORT= CERC_L1_ADDRESS= CERC_L1_PRIV_KEY= +CERC_L2_PROPOSER_AMOUNT= +CERC_L2_BATCHER_AMOUNT= diff --git a/l2-setup/vars.yml b/l2-setup/vars.yml new file mode 100644 index 0000000..c40cd92 --- /dev/null +++ b/l2-setup/vars.yml @@ -0,0 +1,7 @@ +skip_container_build: false +l2_directory: 'out' +existing_l1_deployment: false +contract_addresses: "" +l2_config_file: "" +allocs_l2_file: "" +l2_jwt_file: ""