From 4a448ab38bf8aa617468d3a64c358b58019c62bb Mon Sep 17 00:00:00 2001 From: Neeraj Date: Mon, 23 Sep 2024 10:02:28 +0530 Subject: [PATCH 1/2] Remove L2 setup playbook --- l2-setup/.gitignore | 3 - l2-setup/README.md | 147 -------------------- l2-setup/l2-vars.example.yml | 9 -- l2-setup/run-optimism.yml | 97 ------------- l2-setup/setup-vars.yml | 4 - l2-setup/templates/configs/l2-config.env.j2 | 9 -- l2-setup/templates/specs/l2-spec.yml.j2 | 18 --- 7 files changed, 287 deletions(-) delete mode 100644 l2-setup/.gitignore delete mode 100644 l2-setup/README.md delete mode 100644 l2-setup/l2-vars.example.yml delete mode 100644 l2-setup/run-optimism.yml delete mode 100644 l2-setup/setup-vars.yml delete mode 100644 l2-setup/templates/configs/l2-config.env.j2 delete mode 100644 l2-setup/templates/specs/l2-spec.yml.j2 diff --git a/l2-setup/.gitignore b/l2-setup/.gitignore deleted file mode 100644 index fb4396e..0000000 --- a/l2-setup/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -out -l2-vars.yml -hosts.ini diff --git a/l2-setup/README.md b/l2-setup/README.md deleted file mode 100644 index 64863ae..0000000 --- a/l2-setup/README.md +++ /dev/null @@ -1,147 +0,0 @@ -# l2-setup - -## Setup Ansible - -To get started, follow the [installation](../README.md#installation) guide to setup ansible on your machine - -## Setup - -The following commands have to be executed in the [`l2-setup`](./) directory: - -- Copy the `l2-vars.example.yml` vars file: - - ```bash - cp l2-vars.example.yml l2-vars.yml - ``` - -- Edit [`l2-vars.yml`](./l2-vars.yml) with the required values: - - ```yaml - # L1 chain ID - l1_chain_id: "" - - # L1 RPC endpoint - l1_rpc: "" - - # L1 RPC endpoint host or IP address - l1_host: "" - - # L1 RPC endpoint port number - l1_port: "" - - # L1 Beacon endpoint - l1_beacon: "" - - # Address of the funded account on L1 - # Used for optimism contracts deployment - l1_address: "" - - # Private key of the funded account on L1 - l1_priv_key: "" - ``` - -## Run L2 - -### On Local Host - -- To setup and run L2 locally, execute the `run-optimism.yml` Ansible playbook: - - ```bash - LANG=en_US.utf8 ansible-playbook run-optimism.yml --extra-vars='{ "target_host": "localhost"}' --user $USER -kK - ``` - - NOTE: By default, deployments are created in an `out` directory. To change this location, update the `l2_directory` variable in the [setup-vars.yml](./setup-vars.yml) file - -- For skipping container build, set `"skip_container_build" : true` in the `--extra-vars` parameter: - - ```bash - LANG=en_US.utf8 ansible-playbook run-optimism.yml --extra-vars='{"target_host" : "localhost", "skip_container_build": true}' --user $USER -kK - ``` - -- To run using existing contracts deployment: - - - Update `artifact_path` in [`setup-vars.yml`](./setup-vars.yml) file with path to data directory of the existing deployment - - - Run the ansible playbook with `"existing_contracts_deployment": true` in the `--extra-vars` parameter: - - ```bash - LANG=en_US.utf8 ansible-playbook run-optimism.yml --extra-vars='{"target_host" : "localhost", "existing_contracts_deployment": true}' --user $USER -kK - ``` - -### On Remote Host - -To run the playbook on a remote host: - -- Create a new `hosts.ini` file: - - ```bash - cp ../hosts.example.ini hosts.ini - ``` - -- Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine: - - ```ini - [] - ansible_host= ansible_user= ansible_ssh_common_args='-o ForwardAgent=yes' - ``` - - - Replace `` with `l2_host` - - Replace `` with the alias of your choice - - Replace `` with the IP address or hostname of the target machine - - Replace `` with the SSH username (e.g., dev, ubuntu) - -- Verify that you are able to connect to the host using the following command - - ```bash - ansible all -m ping -i hosts.ini -k - - # Expected output: - - # | SUCCESS => { - # "ansible_facts": { - # "discovered_interpreter_python": "/usr/bin/python3.10" - # }, - # "changed": false, - # "ping": "pong" - # } - ``` - -- Execute the `run-optimism.yml` Ansible playbook for remote deployment: - - ```bash - LANG=en_US.utf8 ansible-playbook -i hosts.ini run-optimism.yml --extra-vars='{ "target_host": "l2_host"}' --user $USER -kK - ``` - -- For skipping container build, set `"skip_container_build" : true` in the `--extra-vars` parameter: - - ```bash - LANG=en_US.utf8 ansible-playbook -i hosts.ini run-optimism.yml --extra-vars='{"target_host" : "l2_host", "skip_container_build": true}' --user $USER -kK - ``` - -- To run using existing contracts deployment: - - - Update `artifact_path` in [`setup-vars.yml`](./setup-vars.yml) file with path to data directory of the existing deployment - - - Run the ansible playbook with `"existing_contracts_deployment": true` in the `--extra-vars` parameter: - - ```bash - LANG=en_US.utf8 ansible-playbook -i hosts.ini run-optimism.yml --extra-vars='{"target_host" : "l2_host", "existing_contracts_deployment": true}' --user $USER -kK - ``` - -## Check Deployment Status - -Run the following commands in the directory where the optimism-deployment is created: - -- Follow optimism contracts deployment logs: - - ```bash - laconic-so deployment --dir optimism-deployment logs -f fixturenet-optimism-contracts - ``` - -- Check L2 logs: - - ```bash - laconic-so deployment --dir optimism-deployment logs -f op-geth - - # Ensure new blocks are getting created - ``` diff --git a/l2-setup/l2-vars.example.yml b/l2-setup/l2-vars.example.yml deleted file mode 100644 index 13796c9..0000000 --- a/l2-setup/l2-vars.example.yml +++ /dev/null @@ -1,9 +0,0 @@ -l1_chain_id: "" -l1_rpc: "" -l1_host: "" -l1_port: "" -l1_beacon: "" -l1_address: "" -l1_priv_key: "" -proposer_amount: "0.2ether" -batcher_amount: "0.1ether" diff --git a/l2-setup/run-optimism.yml b/l2-setup/run-optimism.yml deleted file mode 100644 index bdbb76e..0000000 --- a/l2-setup/run-optimism.yml +++ /dev/null @@ -1,97 +0,0 @@ -- name: Setup L2 on host - hosts: "{{ target_host }}" - - vars_files: - - setup-vars.yml - - l2-vars.yml - - environment: - PATH: "{{ ansible_env.PATH }}:/home/{{ansible_user}}/bin" - - tasks: - - name: Create directory for L2 - file: - path: "{{ l2_directory }}" - state: directory - - - name: Change owner of l2-directory - file: - path: "{{ l2_directory }}" - owner: "{{ansible_user}}" - group: "{{ansible_user}}" - state: directory - recurse: yes - - - name: Clone fixturenet-optimism-stack - expect: - command: laconic-so fetch-stack git.vdb.to/cerc-io/fixturenet-optimism-stack --pull - responses: - "Are you sure you want to continue connecting \\(yes/no/\\[fingerprint\\]\\)\\?": "yes" - timeout: 300 - ignore_errors: yes - - - name: Clone required repositories for fixturenet-optimism - expect: - command: laconic-so --stack {{ ansible_env.HOME }}/cerc/fixturenet-optimism-stack/stack/fixturenet-optimism setup-repositories --pull - responses: - "Are you sure you want to continue connecting \\(yes/no/\\[fingerprint\\]\\)\\?": "yes" - timeout: 300 - ignore_errors: yes - - - name: Build container images for L2 - command: laconic-so --stack ~/cerc/fixturenet-optimism-stack/stack/fixturenet-optimism build-containers --force-rebuild - when: not skip_container_build - - - name: Generate spec file for L2 deployment - template: - src: "./templates/specs/l2-spec.yml.j2" - dest: "{{ l2_directory }}/optimism-spec.yml" - - - name: Check if the deployment directory exists for L2 - stat: - 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 optimism-spec.yml --deployment-dir optimism-deployment - args: - chdir: "{{ l2_directory }}" - when: not l2_deployment_dir.stat.exists - - - name: Generate config.env for L2 deployment - template: - src: "./templates/configs/l2-config.env.j2" - dest: "{{ l2_directory }}/optimism-deployment/config.env" - - - name: Copy deployed contract addresses and configuration files - block: - - name: Copy l1 deployment file - copy: - src: "{{ artifact_path }}/l1_deployment/{{ l1_chain_id }}-deploy.json" - dest: "{{ l2_directory }}/optimism-deployment/data/l1_deployment" - remote_src: "{{ target_host != 'localhost' }}" - - - name: Copy l2 configuration file - copy: - src: "{{ artifact_path }}/l2_config/{{ l1_chain_id }}.json" - dest: "{{ l2_directory }}/optimism-deployment/data/l2_config" - remote_src: "{{ target_host != 'localhost' }}" - - - name: Copy allocs-l2 file - copy: - src: "{{ artifact_path }}/l2_config/allocs-l2.json" - dest: "{{ l2_directory }}/optimism-deployment/data/l2_config" - remote_src: "{{ target_host != 'localhost' }}" - - - name: Copy l2 accounts file - copy: - src: "{{ artifact_path }}/l2_accounts/accounts.json" - dest: "{{ l2_directory }}/optimism-deployment/data/l2_accounts" - remote_src: "{{ target_host != 'localhost' }}" - - when: existing_contracts_deployment - - - name: Start L2-deployment - command: laconic-so deployment --dir optimism-deployment start - args: - chdir: "{{ l2_directory }}" diff --git a/l2-setup/setup-vars.yml b/l2-setup/setup-vars.yml deleted file mode 100644 index 3615a0c..0000000 --- a/l2-setup/setup-vars.yml +++ /dev/null @@ -1,4 +0,0 @@ -skip_container_build: false -l2_directory: "out" -existing_contracts_deployment: false -artifact_path: "" diff --git a/l2-setup/templates/configs/l2-config.env.j2 b/l2-setup/templates/configs/l2-config.env.j2 deleted file mode 100644 index 11fdfaf..0000000 --- a/l2-setup/templates/configs/l2-config.env.j2 +++ /dev/null @@ -1,9 +0,0 @@ -CERC_L1_CHAIN_ID={{ l1_chain_id }} -CERC_L1_RPC={{ l1_rpc }} -CERC_L1_HOST={{ l1_host }} -CERC_L1_PORT={{ l1_port }} -CERC_L1_BEACON={{ l1_beacon }} -CERC_L1_ADDRESS={{ l1_address }} -CERC_L1_PRIV_KEY={{ l1_priv_key }} -CERC_PROPOSER_AMOUNT={{ proposer_amount }} -CERC_BATCHER_AMOUNT={{ batcher_amount }} diff --git a/l2-setup/templates/specs/l2-spec.yml.j2 b/l2-setup/templates/specs/l2-spec.yml.j2 deleted file mode 100644 index 456e557..0000000 --- a/l2-setup/templates/specs/l2-spec.yml.j2 +++ /dev/null @@ -1,18 +0,0 @@ -stack: /home/{{ansible_user}}/cerc/fixturenet-optimism-stack/stack/fixturenet-optimism -deploy-to: compose -network: - ports: - op-geth: - - '9545:8545' - - '9546:8546' - op-node: - - '8547' - op-batcher: - - '8548' - op-proposer: - - '8560' -volumes: - l1_deployment: ./data/l1_deployment - l2_accounts: ./data/l2_accounts - l2_config: ./data/l2_config - l2_geth_data: ./data/l2_geth_data -- 2.45.2 From 72635966ccc7fe39dafb78ecd8d0d1ee20a659f2 Mon Sep 17 00:00:00 2001 From: Neeraj Date: Mon, 23 Sep 2024 10:28:21 +0530 Subject: [PATCH 2/2] Remove L2 chain opts and L2 contract addresses --- nitro-bridge-setup/README.md | 24 +------------------ nitro-bridge-setup/bridge-vars.example.yml | 9 +------ nitro-bridge-setup/run-nitro-bridge.yml | 14 ----------- .../templates/specs/bridge-nitro-spec.yml.j2 | 10 +------- nitro-contracts-setup/deploy-contracts.yml | 6 ++--- nitro-nodes-setup/README.md | 10 ++------ nitro-nodes-setup/nitro-vars.example.yml | 4 +--- .../templates/configs/l1-nitro-config.env.j2 | 2 +- .../templates/configs/l2-nitro-config.env.j2 | 4 ---- 9 files changed, 10 insertions(+), 73 deletions(-) diff --git a/nitro-bridge-setup/README.md b/nitro-bridge-setup/README.md index 26db1e6..345fce1 100644 --- a/nitro-bridge-setup/README.md +++ b/nitro-bridge-setup/README.md @@ -18,10 +18,7 @@ The following commands have to be executed in the [`nitro-bridge-setup`](./) dir ```yaml # L1 WS endpoint - nitro_l1_chain_url: "" - - # L2 WS endpoint - nitro_l2_chain_url: "" + nitro_chain_url: "" # Private key for the bridge's nitro address nitro_sc_pk: "" @@ -30,12 +27,6 @@ The following commands have to be executed in the [`nitro-bridge-setup`](./) dir # This account should have tokens for funding Nitro channels nitro_chain_pk: "" - # L2 chain ID - optimism_chain_id: "" - - # L2 RPC endpoint - optimism_url: "" - # Custom L2 token to be deployed token_name: "LaconicNetworkToken" token_symbol: "LNT" @@ -45,9 +36,6 @@ The following commands have to be executed in the [`nitro-bridge-setup`](./) dir na_address: "" vpa_address: "" ca_address: "" - - # Address of deployed custom L1 token - l1_asset_address: "" ``` ## Run Nitro Bridge @@ -128,13 +116,3 @@ To run the playbook on a remote host: # Check the bridge deployment logs, ensure that the node is running laconic-so deployment --dir bridge-deployment logs nitro-bridge -f ``` - -## Get Contract Addresses - -- Run the following commands in the directory where the deployments are created: - - - Get addresses of L2 nitro contracts: - - ```bash - laconic-so deployment --dir bridge-deployment exec nitro-bridge "cat /app/deployment/nitro-addresses.json" - ``` diff --git a/nitro-bridge-setup/bridge-vars.example.yml b/nitro-bridge-setup/bridge-vars.example.yml index 409d7c9..bf55c4e 100644 --- a/nitro-bridge-setup/bridge-vars.example.yml +++ b/nitro-bridge-setup/bridge-vars.example.yml @@ -1,13 +1,6 @@ -nitro_l1_chain_url: "" -nitro_l2_chain_url: "" +nitro_chain_url: "" nitro_chain_pk: "" nitro_sc_pk: "" -optimism_chain_id: "" -optimism_url: "" -token_name: "LaconicNetworkToken" -token_symbol: "LNT" -initial_token_supply: "129600" na_address: "" vpa_address: "" ca_address: "" -l1_asset_address: "" diff --git a/nitro-bridge-setup/run-nitro-bridge.yml b/nitro-bridge-setup/run-nitro-bridge.yml index 4693179..0d3f2a5 100644 --- a/nitro-bridge-setup/run-nitro-bridge.yml +++ b/nitro-bridge-setup/run-nitro-bridge.yml @@ -63,17 +63,3 @@ command: laconic-so deployment --dir bridge-deployment start args: chdir: "{{ nitro_directory }}" - - - name: Wait for nitro-addresses.json to be created - wait_for: - path: "{{ nitro_directory }}/bridge-deployment/data/nitro_deployment/nitro-addresses.json" - state: present - timeout: 180 - - - name: Print BRIDGE_ADDRESS - shell: laconic-so deployment --dir bridge-deployment exec nitro-bridge "jq -r '.\"{{ optimism_chain_id }}\"[0].contracts.Bridge.address' /app/deployment/nitro-addresses.json" - args: - chdir: "{{ nitro_directory }}" - register: bridge_address - - debug: - msg: "BRIDGE_ADDRESS: {{ bridge_address.stdout }}" diff --git a/nitro-bridge-setup/templates/specs/bridge-nitro-spec.yml.j2 b/nitro-bridge-setup/templates/specs/bridge-nitro-spec.yml.j2 index 1adec23..58eaff2 100644 --- a/nitro-bridge-setup/templates/specs/bridge-nitro-spec.yml.j2 +++ b/nitro-bridge-setup/templates/specs/bridge-nitro-spec.yml.j2 @@ -1,20 +1,12 @@ stack: /home/{{ ansible_user }}/cerc/nitro-stack/stack-orchestrator/stacks/bridge deploy-to: compose config: - NITRO_L1_CHAIN_URL: {{ nitro_l1_chain_url }} - NITRO_L2_CHAIN_URL: {{ nitro_l2_chain_url }} + NITRO_CHAIN_URL: {{ nitro_chain_url }} NITRO_CHAIN_PK: {{ nitro_chain_pk }} NITRO_SC_PK: {{ nitro_sc_pk }} - OPTIMISM_CHAIN_ID: {{ optimism_chain_id }} - OPTIMISM_URL: {{ optimism_url }} - OPTIMISM_DEPLOYER_PK: {{ nitro_chain_pk }} - TOKEN_NAME: {{ token_name }} - TOKEN_SYMBOL: {{ token_symbol }} - INITIAL_TOKEN_SUPPLY: {{ initial_token_supply }} NA_ADDRESS: "{{ na_address }}" VPA_ADDRESS: "{{ vpa_address }}" CA_ADDRESS: "{{ ca_address }}" - L1_ASSET_ADDRESS: "{{ l1_asset_address }}" network: ports: nitro-bridge: diff --git a/nitro-contracts-setup/deploy-contracts.yml b/nitro-contracts-setup/deploy-contracts.yml index 57a70c1..e68caaa 100644 --- a/nitro-contracts-setup/deploy-contracts.yml +++ b/nitro-contracts-setup/deploy-contracts.yml @@ -93,10 +93,10 @@ - debug: msg: "VPA_ADDRESS: {{ vpa_address.stdout }}" - - name: Export L1_ASSET_ADDRESS + - name: Export ASSET_ADDRESS shell: laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"{{ geth_chain_id }}\"[0].contracts.Token.address' /app/deployment/nitro-addresses.json" args: chdir: "{{ nitro_directory }}" - register: l1_asset_address + register: asset_address - debug: - msg: "L1_ASSET_ADDRESS: {{ l1_asset_address.stdout }}" + msg: "ASSET_ADDRESS: {{ asset_address.stdout }}" diff --git a/nitro-nodes-setup/README.md b/nitro-nodes-setup/README.md index 8d86ba9..fd2de53 100644 --- a/nitro-nodes-setup/README.md +++ b/nitro-nodes-setup/README.md @@ -26,10 +26,7 @@ The following commands have to be executed in [`nitro-nodes-setup`](./) director ```bash # L1 WS endpoint - nitro_l1_chain_url: "" - - # L2 WS endpoint - nitro_l2_chain_url: "" + nitro_chain_url: "" # Private key for your nitro address nitro_sc_pk: "" @@ -46,9 +43,6 @@ The following commands have to be executed in [`nitro-nodes-setup`](./) director # Contract address of ConsensusApp ca_address: "" - # Address of the bridge node - bridge_contract_address: "" - # Multiaddr of the L1 bridge node nitro_l1_bridge_multiaddr: "" @@ -79,7 +73,7 @@ The following commands have to be executed in [`nitro-nodes-setup`](./) director - For skipping container build, run with `"skip_container_build" : true` in the `--extra-vars` parameter: ```bash - LANG=en_US.utf8 ansible-playbook -i hosts.ini run-nitro-nodes.yml --extra-vars='{ "target_host": "nitro_host", "skip_container_build": true }' --user $USER -kK + LANG=en_US.utf8 ansible-playbook -i hosts.ini run-nitro-nodes.yml --extra-vars='{ "target_host": "localhost", "skip_container_build": true }' --user $USER -kK ``` ### On Remote Host diff --git a/nitro-nodes-setup/nitro-vars.example.yml b/nitro-nodes-setup/nitro-vars.example.yml index 8b03de2..1ff9bc9 100644 --- a/nitro-nodes-setup/nitro-vars.example.yml +++ b/nitro-nodes-setup/nitro-vars.example.yml @@ -1,11 +1,9 @@ -nitro_l1_chain_url: "" -nitro_l2_chain_url: "" +nitro_chain_url: "" nitro_sc_pk: "" nitro_chain_pk: "" na_address: "" vpa_address: "" ca_address: "" -bridge_contract_address: "" nitro_l1_bridge_multiaddr: "" nitro_l2_bridge_multiaddr: "" nitro_l1_ext_multiaddr: "" diff --git a/nitro-nodes-setup/templates/configs/l1-nitro-config.env.j2 b/nitro-nodes-setup/templates/configs/l1-nitro-config.env.j2 index aca42b5..e8cd934 100644 --- a/nitro-nodes-setup/templates/configs/l1-nitro-config.env.j2 +++ b/nitro-nodes-setup/templates/configs/l1-nitro-config.env.j2 @@ -1,4 +1,4 @@ -NITRO_CHAIN_URL={{ nitro_l1_chain_url }} +NITRO_CHAIN_URL={{ nitro_chain_url }} NITRO_SC_PK={{ nitro_sc_pk }} NITRO_CHAIN_PK={{ nitro_chain_pk }} NA_ADDRESS="{{ na_address }}" diff --git a/nitro-nodes-setup/templates/configs/l2-nitro-config.env.j2 b/nitro-nodes-setup/templates/configs/l2-nitro-config.env.j2 index 709a2ea..a317722 100644 --- a/nitro-nodes-setup/templates/configs/l2-nitro-config.env.j2 +++ b/nitro-nodes-setup/templates/configs/l2-nitro-config.env.j2 @@ -1,10 +1,6 @@ -NITRO_CHAIN_URL={{ nitro_l2_chain_url }} NITRO_SC_PK={{ nitro_sc_pk }} -NITRO_CHAIN_PK={{ nitro_chain_pk }} -NA_ADDRESS="{{ na_address }}" VPA_ADDRESS="{{ vpa_address }}" CA_ADDRESS="{{ ca_address }}" -BRIDGE_ADDRESS="{{ bridge_contract_address }}" NITRO_BOOTPEERS={{ nitro_l2_bridge_multiaddr }} NITRO_EXT_MULTIADDR={{ nitro_l2_ext_multiaddr }} NITRO_L2=true -- 2.45.2