Add vars file for config values

This commit is contained in:
Adw8 2024-09-03 18:21:34 +05:30
parent 9b805dad36
commit b1de7af194
9 changed files with 83 additions and 42 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
l2-setup/out

View File

@ -1,2 +1,41 @@
# testnet-ops
## Installation
- Install [Ansible](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-and-upgrading-ansible-with-pip)
- Add location of the directory containing the ansible binary to your `PATH`
- Optional: Set Locale Encoding to `UTF-8`
Ansible requires the locale encoding to be `UTF-8`. You can either use the `LANG` prefix when running Ansible commands or set the system-wide locale.
- Option 1: Use `LANG` Prefix in Commands
If you prefer not to change the system-wide locale, you can use the `LANG` prefix when running Ansible commands:
```bash
LANG=en_US.UTF-8 ansible-playbook your_playbook.yml
```
- Option 2: Set System-Wide Locale
- Edit the `/etc/default/locale` file:
```bash
sudo nano /etc/default/locale
```
- Set the `LANG` variable to en_US.UTF-8:
```Copy code
LANG="en_US.UTF-8"
```
- Reboot your system or log out and log back in to apply the changes.
- Reference: <https://udhayakumarc.medium.com/error-ansible-requires-the-locale-encoding-to-be-utf-8-detected-iso8859-1-6da808387f7d>
## Playbooks
- [nitro-nodes-setup](./nitro-nodes-setup/README.md)

View File

@ -8,36 +8,30 @@ To get started, follow the [installation](../README.md#installation) guide to se
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
- Edit [`l2-vars.yml`](./l2-vars.yml) with the required values
```bash
# L1 Chain ID
CERC_L1_CHAIN_ID=
# L1 chain ID
l1_chain_id: ""
# L1 RPC endpoint
CERC_L1_RPC=
l1_rpc: ""
# L1 RPC endpoint host or IP address
CERC_L1_HOST=
l1_host: ""
# L1 RPC endpoint port number
CERC_L1_PORT=
l1_port: ""
# L1 Beacon endpoint
CERC_L1_BEACON=
l1_beacon: ""
# Address of the funded account on L1
# Used for optimism contracts deployment
CERC_L1_ADDRESS=
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=
l1_priv_key: ""
```
- To setup and run L2, execute the `run-optimism.yml` Ansible playbook by running the following command.
@ -56,10 +50,10 @@ The following commands have to be executed in [`l2-setup`](./) directory
- To run using existing contracts deployment
- Update the [`vars.yml`](./vars.yml) with paths to required artifacts
- 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_l1_deployment": true` in the `--extra-vars` parameter:
- Run the ansible playbook with `"existing_contracts_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
LANG=en_US.utf8 ansible-playbook -i localhost, --connection=local run-optimism.yml --extra-vars='{"target_host" : "localhost", "existing_contracts_deployment": true}' -kK --user $USER
```

9
l2-setup/l2-vars.yml Normal file
View File

@ -0,0 +1,9 @@
l1_chain_id: ""
l1_rpc: ""
l1_host: ""
l1_port: ""
l1_beacon: ""
l1_address: ""
l1_priv_key: ""
proposer_amount: "0.2 ether"
batcher_amount: "0.1 ether"

View File

@ -2,7 +2,8 @@
hosts: "{{ target_host }}"
vars_files:
- vars.yml
- setup-vars.yml
- l2-vars.yml
environment:
PATH: "{{ ansible_env.PATH }}:/home/{{ansible_user}}/bin"
@ -54,31 +55,32 @@
- name: Generate config.env for L2 deployment
template:
src: "./templates/configs/l2-config.env"
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: "{{ contract_addresses }}"
src: "{{ artifact_path }}/l1_deployment/{{ l1_chain_id }}-deploy.json"
dest: "{{ l2_directory }}/optimism-deployment/data/l1_deployment"
- name: Copy l2 configuration file
copy:
src: "{{ l2_config_file }}"
src: "{{ artifact_path }}/l2_config/{{ l1_chain_id }}.json"
dest: "{{ l2_directory }}/optimism-deployment/data/l2_config"
- name: Copy allocs-l2 file
copy:
src: "{{ allocs_l2_file }}"
src: "{{ artifact_path }}/l2_config/allocs-l2.json"
dest: "{{ l2_directory }}/optimism-deployment/data/l2_config"
- name: Copy l2 jwt file
copy:
src: "{{ l2_jwt_file }}"
src: "{{ artifact_path }}/l2_config/l2-jwt.txt"
dest: "{{ l2_directory }}/optimism-deployment/data/l2_config"
when: existing_l1_deployment
when: existing_contracts_deployment
- name: Start L2-deployment
command: laconic-so deployment --dir optimism-deployment start

4
l2-setup/setup-vars.yml Normal file
View File

@ -0,0 +1,4 @@
skip_container_build: false
l2_directory: "./out"
existing_contracts_deployment: false
artifact_path: ""

View File

@ -1,10 +0,0 @@
CERC_ALLOW_UNPROTECTED_TXS=true
CERC_L1_CHAIN_ID=
CERC_L1_RPC=
CERC_L1_BEACON=
CERC_L1_HOST=
CERC_L1_PORT=
CERC_L1_ADDRESS=
CERC_L1_PRIV_KEY=
CERC_L2_PROPOSER_AMOUNT=
CERC_L2_BATCHER_AMOUNT=

View File

@ -0,0 +1,9 @@
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 }}

View File

@ -1,7 +0,0 @@
skip_container_build: false
l2_directory: 'out'
existing_l1_deployment: false
contract_addresses: ""
l2_config_file: ""
allocs_l2_file: ""
l2_jwt_file: ""