forked from cerc-io/testnet-ops
Compare commits
8 Commits
509c00a8e5
...
dc6145f37d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dc6145f37d | ||
|
|
d7e657119a | ||
|
|
8f09e44749 | ||
|
|
17a0ef6c9b | ||
|
|
e669535ca5 | ||
|
|
e5e1a2ff19 | ||
|
|
867499769b | ||
| 88e0b48540 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +0,0 @@
|
||||
nitro-nodes-setup/out/
|
||||
nitro-nodes-setup/nitro-vars.yml
|
||||
l2-setup/out
|
||||
@ -40,3 +40,4 @@
|
||||
|
||||
- [l2-setup](./l2-setup/README.md)
|
||||
- [nitro-node-setup](./nitro-nodes-setup/README.md)
|
||||
- [nitro-bridge-setup](./nitro-bridge-setup/README.md)
|
||||
|
||||
2
example-hosts.ini
Normal file
2
example-hosts.ini
Normal file
@ -0,0 +1,2 @@
|
||||
[nitro_host]
|
||||
<host_name> ansible_host=<TARGET_IP> ansible_user=<SSH_USER> ansible_ssh_common_args='-o ForwardAgent=yes'
|
||||
3
l2-setup/.gitignore
vendored
Normal file
3
l2-setup/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
out
|
||||
l2-vars.yml
|
||||
hosts.ini
|
||||
@ -4,10 +4,53 @@
|
||||
|
||||
To get started, follow the [installation](../README.md#installation) guide to setup ansible on your machine
|
||||
|
||||
## Setup Remote Hosts
|
||||
|
||||
To run the playbook on a remote machine, follow these steps:
|
||||
|
||||
- In the [`l2-setup`](./) directory, create a new file named hosts.ini:
|
||||
|
||||
```bash
|
||||
cp ../example-hosts.ini hosts.ini
|
||||
```
|
||||
|
||||
- Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine
|
||||
|
||||
```bash
|
||||
[nitro_host]
|
||||
<host_name> ansible_host=<TARGET_IP> ansible_user=<SSH_USER> ansible_ssh_common_args='-o ForwardAgent=yes'
|
||||
```
|
||||
|
||||
- Replace `<host_name>` with the alias of your choice.
|
||||
- Replace `<TARGET_IP>` with the IP address or hostname of the target machine.
|
||||
- Replace `<SSH_USER>` 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:
|
||||
|
||||
# <host_name> | SUCCESS => {
|
||||
# "ansible_facts": {
|
||||
# "discovered_interpreter_python": "/usr/bin/python3.10"
|
||||
# },
|
||||
# "changed": false,
|
||||
# "ping": "pong"
|
||||
# }
|
||||
```
|
||||
|
||||
## Setup and Run Optimism
|
||||
|
||||
The following commands have to be executed in [`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
|
||||
|
||||
```bash
|
||||
@ -34,18 +77,26 @@ The following commands have to be executed in [`l2-setup`](./) directory
|
||||
l1_priv_key: ""
|
||||
```
|
||||
|
||||
- To setup and run L2, execute the `run-optimism.yml` Ansible playbook by running the following command.
|
||||
- To setup and run L2, execute the `run-optimism.yml` Ansible playbook by running one of the following commands:
|
||||
|
||||
NOTE: By default, deployments are created in the `l2-setup/out` directory. To change this location, update the `l2_directory` variable in the [setup-vars.yml](./setup-vars.yml) file.
|
||||
- For local deployment, specify the `"target_host": localhost` in the `--extra-vars` parameter:
|
||||
|
||||
```bash
|
||||
LANG=en_US.utf8 ansible-playbook -i localhost, --connection=local run-optimism.yml --extra-vars='{ "target_host": "localhost"}' -kK --user $USER
|
||||
```
|
||||
```bash
|
||||
LANG=en_US.utf8 ansible-playbook run-optimism.yml --extra-vars='{ "target_host": "localhost"}' -kK --user $USER
|
||||
```
|
||||
|
||||
- For remote deployment, provide an inventory and specify the `"target_host": nitro_host` in the `--extra-vars` parameter:
|
||||
|
||||
```bash
|
||||
LANG=en_US.utf8 ansible-playbook -i ./hosts.ini run-optimism.yml --extra-vars='{ "target_host": "nitro_host"}' -kK
|
||||
```
|
||||
|
||||
NOTE: By default, deployments are created in a `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 -i localhost, --connection=local run-optimism.yml --extra-vars='{"target_host" : "localhost", "skip_container_build": true}' -kK --user $USER
|
||||
LANG=en_US.utf8 ansible-playbook -i ./hosts.ini run-optimism.yml --extra-vars='{"target_host" : "nitro_host", "skip_container_build": true}' -kK
|
||||
```
|
||||
|
||||
- To run using existing contracts deployment
|
||||
@ -55,7 +106,7 @@ The following commands have to be executed in [`l2-setup`](./) directory
|
||||
- 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_contracts_deployment": true}' -kK --user $USER
|
||||
LANG=en_US.utf8 ansible-playbook -i ./hosts.ini run-optimism.yml --extra-vars='{"target_host" : "nitro_host", "existing_contracts_deployment": true}' -kK
|
||||
```
|
||||
|
||||
## Check Deployment Status
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
skip_container_build: false
|
||||
l2_directory: "./out"
|
||||
l2_directory: "out"
|
||||
existing_contracts_deployment: false
|
||||
artifact_path: ""
|
||||
|
||||
3
nitro-bridge-setup/.gitignore
vendored
Normal file
3
nitro-bridge-setup/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
out
|
||||
bridge-vars.yml
|
||||
hosts.ini
|
||||
130
nitro-bridge-setup/README.md
Normal file
130
nitro-bridge-setup/README.md
Normal file
@ -0,0 +1,130 @@
|
||||
# nitro-bridge-setup
|
||||
|
||||
## Setup Ansible
|
||||
|
||||
To get started, follow the [installation](../README.md#installation) guide to setup ansible on your machine
|
||||
|
||||
## Setup Remote Hosts
|
||||
|
||||
To run the playbook on a remote machine, follow these steps:
|
||||
|
||||
- In the [`nitro-bridge-setup`](./) directory, create a new file named hosts.ini:
|
||||
|
||||
```bash
|
||||
cp ../example-hosts.ini hosts.ini
|
||||
```
|
||||
|
||||
- Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine
|
||||
|
||||
```bash
|
||||
[nitro_host]
|
||||
<host_name> ansible_host=<TARGET_IP> ansible_user=<SSH_USER> ansible_ssh_common_args='-o ForwardAgent=yes'
|
||||
```
|
||||
|
||||
- Replace `<host_name>` with the alias of your choice.
|
||||
- Replace `<TARGET_IP>` with the IP address or hostname of the target machine.
|
||||
- Replace `<SSH_USER>` 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:
|
||||
|
||||
# <host_name> | SUCCESS => {
|
||||
# "ansible_facts": {
|
||||
# "discovered_interpreter_python": "/usr/bin/python3.10"
|
||||
# },
|
||||
# "changed": false,
|
||||
# "ping": "pong"
|
||||
# }
|
||||
```
|
||||
|
||||
## Run Nitro Bridge
|
||||
|
||||
- Copy the `bridge-vars-example.yml` vars file
|
||||
|
||||
```bash
|
||||
cp bridge-vars-example.yml bridge-vars.yml
|
||||
```
|
||||
|
||||
- Edit [`bridge-vars.yml`](./bridge-vars.yml) and fill in the following values
|
||||
|
||||
```bash
|
||||
# L1 WS endpoint
|
||||
nitro_l1_chain_url: ""
|
||||
|
||||
# L2 WS endpoint
|
||||
nitro_l2_chain_url: ""
|
||||
|
||||
# Private key for the bridge's nitro address
|
||||
nitro_sc_pk: ""
|
||||
|
||||
# Private key for a funded account on L1
|
||||
# This account should have tokens for funding Nitro channels
|
||||
nitro_chain_pk: ""
|
||||
|
||||
# L2 RPC endpoint
|
||||
optimism_url: ""
|
||||
|
||||
# Private key for a funded account on L2 to use for contracts deployment on L2
|
||||
# Use the same account for L1 and L2 deployments
|
||||
optimism_deployer_pk: ""
|
||||
|
||||
# Custom L2 token to be deployed
|
||||
token_name: "LaconicNetworkToken"
|
||||
token_symbol: "LNT"
|
||||
intial_token_supply: "129600"
|
||||
|
||||
# Addresses of the deployed nitro contracts
|
||||
na_address: ""
|
||||
vpa_address: ""
|
||||
ca_address: ""
|
||||
|
||||
# Address of deployed custom L1 token
|
||||
l1_asset_address: ""
|
||||
```
|
||||
|
||||
- To run the nitro bridge, execute the `run-nitro-bridge.yml` Ansible playbook by running one of the following commands:
|
||||
|
||||
- For local deployment, specify the `"target_host": localhost` in the `--extra-vars` parameter:
|
||||
|
||||
```bash
|
||||
LANG=en_US.utf8 ansible-playbook run-nitro-bridge.yml --extra-vars='{ "target_host": "localhost"}' --user $USER -kK
|
||||
```
|
||||
|
||||
- For remote deployment, provide an inventory and specify the `"target_host": nitro_host` in the `--extra-vars` parameter:
|
||||
|
||||
```bash
|
||||
LANG=en_US.utf8 ansible-playbook -i ./hosts.ini run-nitro-bridge.yml --extra-vars='{ "target_host": "nitro_host"}' --user $USER -kK
|
||||
```
|
||||
|
||||
NOTE: By default, deployments are created in the `out` directory. To change this location, update the `nitro_directory` variable in the [setup-vars.yml](./setup-vars.yml) file.
|
||||
|
||||
- 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-bridge.yml --extra-vars='{ "target_host": "nitro_host", "skip_container_build": true }' --user $USER -kK
|
||||
```
|
||||
|
||||
## Check Deployment Status
|
||||
|
||||
- Run the following command in the directory where the bridge-deployment is created:
|
||||
|
||||
- Check logs for deployments:
|
||||
|
||||
```bash
|
||||
# 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"
|
||||
```
|
||||
14
nitro-bridge-setup/bridge-vars-example.yml
Normal file
14
nitro-bridge-setup/bridge-vars-example.yml
Normal file
@ -0,0 +1,14 @@
|
||||
nitro_l1_chain_url: ""
|
||||
nitro_l2_chain_url: ""
|
||||
nitro_chain_pk: ""
|
||||
nitro_sc_pk: ""
|
||||
optimism_chain_id: ""
|
||||
optimism_url: ""
|
||||
optimism_deployer_pk: ""
|
||||
token_name: "LaconicNetworkToken"
|
||||
token_symbol: "LNT"
|
||||
intial_token_supply: "129600"
|
||||
na_address: ""
|
||||
vpa_address: ""
|
||||
ca_address: ""
|
||||
l1_asset_address: ""
|
||||
73
nitro-bridge-setup/run-nitro-bridge.yml
Normal file
73
nitro-bridge-setup/run-nitro-bridge.yml
Normal file
@ -0,0 +1,73 @@
|
||||
- name: Setup go-nitro on host
|
||||
hosts: "{{ target_host }}"
|
||||
|
||||
vars_files:
|
||||
- setup-vars.yml
|
||||
- bridge-vars.yml
|
||||
|
||||
environment:
|
||||
PATH: "{{ ansible_env.PATH }}:/home/{{ansible_user}}/bin"
|
||||
|
||||
tasks:
|
||||
- name: Create directory for nitro bridge deployment
|
||||
file:
|
||||
path: "{{ nitro_directory }}"
|
||||
state: directory
|
||||
become: yes
|
||||
|
||||
- name: Clone go-nitro stack repo
|
||||
command: laconic-so fetch-stack git.vdb.to/cerc-io/nitro-stack --git-ssh --pull
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Change owner of nitro-directory
|
||||
file:
|
||||
path: "{{ nitro_directory }}"
|
||||
owner: "{{ansible_user}}"
|
||||
group: "{{ansible_user}}"
|
||||
state: directory
|
||||
recurse: yes
|
||||
become: yes
|
||||
|
||||
- name: Clone repositories required for nitro-stack
|
||||
command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge setup-repositories --git-ssh --pull
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Build containers
|
||||
command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge build-containers --force-rebuild
|
||||
when: not skip_container_build
|
||||
|
||||
- name: Check if deployment exists for bridge node
|
||||
stat:
|
||||
path: "{{ nitro_directory }}/bridge-deployment"
|
||||
register: bridge_deployment
|
||||
|
||||
- name: Generate spec file for bridge deployment
|
||||
template:
|
||||
src: "./templates/specs/bridge-nitro-spec.yml.j2"
|
||||
dest: "{{ nitro_directory }}/bridge-nitro-spec.yml"
|
||||
when: not bridge_deployment.stat.exists
|
||||
|
||||
- name: Create a deployment for the bridge node
|
||||
command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge deploy create --spec-file bridge-nitro-spec.yml --deployment-dir bridge-deployment
|
||||
args:
|
||||
chdir: "{{ nitro_directory }}"
|
||||
when: not bridge_deployment.stat.exists
|
||||
|
||||
- name: Start the nitro bridge
|
||||
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: 60
|
||||
|
||||
- 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 }}"
|
||||
3
nitro-bridge-setup/setup-vars.yml
Normal file
3
nitro-bridge-setup/setup-vars.yml
Normal file
@ -0,0 +1,3 @@
|
||||
target_host: "localhost"
|
||||
nitro_directory: out
|
||||
skip_container_build: false
|
||||
28
nitro-bridge-setup/templates/specs/bridge-nitro-spec.yml.j2
Normal file
28
nitro-bridge-setup/templates/specs/bridge-nitro-spec.yml.j2
Normal file
@ -0,0 +1,28 @@
|
||||
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_PK: {{ nitro_chain_pk }}
|
||||
NITRO_SC_PK: {{ nitro_sc_pk }}
|
||||
OPTIMISM_CHAIN_ID: {{ optimism_chain_id }}
|
||||
OPTIMISM_URL: {{ optimism_url }}
|
||||
OPTIMISM_DEPLOYER_PK: {{ optimism_deployer_pk }}
|
||||
TOKEN_NAME: {{ token_name }}
|
||||
TOKEN_SYMBOL: {{ token_symbol }}
|
||||
INITIAL_TOKEN_SUPPLY: {{ token_symbol }}
|
||||
NA_ADDRESS: {{ na_address }}
|
||||
VPA_ADDRESS: {{ vpa_address }}
|
||||
CA_ADDRESS: {{ ca_address }}
|
||||
L1_ASSET_ADDRESS: {{ l1_asset_address }}
|
||||
network:
|
||||
ports:
|
||||
nitro-bridge:
|
||||
- 0.0.0.0:3005:3005
|
||||
- 0.0.0.0:3006:3006
|
||||
- 0.0.0.0:4006:4006
|
||||
volumes:
|
||||
nitro_bridge_data: ./data/nitro_bridge_data
|
||||
nitro_bridge_tls: ./data/nitro_bridge_tls
|
||||
nitro_node_caroot: ./data/nitro_node_caroot
|
||||
nitro_deployment: ./data/nitro_deployment
|
||||
3
nitro-contracts-setup/.gitignore
vendored
Normal file
3
nitro-contracts-setup/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
out
|
||||
contract-vars.yml
|
||||
hosts.ini
|
||||
114
nitro-contracts-setup/README.md
Normal file
114
nitro-contracts-setup/README.md
Normal file
@ -0,0 +1,114 @@
|
||||
# nitro-contracts-setup
|
||||
|
||||
## Setup Ansible
|
||||
|
||||
To get started, follow the [installation](../README.md#installation) guide to setup ansible on your machine
|
||||
|
||||
## Setup Remote Hosts
|
||||
|
||||
To run the playbook on a remote machine, follow these steps:
|
||||
|
||||
- In the [`nitro-contracts-setup`](./) directory, create a new file named hosts.ini:
|
||||
|
||||
```bash
|
||||
cp ../example-hosts.ini hosts.ini
|
||||
```
|
||||
|
||||
- Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine
|
||||
|
||||
```bash
|
||||
[nitro_host]
|
||||
<host_name> ansible_host=<TARGET_IP> ansible_user=<SSH_USER> ansible_ssh_common_args='-o ForwardAgent=yes'
|
||||
```
|
||||
|
||||
- Replace `<host_name>` with the alias of your choice.
|
||||
- Replace `<TARGET_IP>` with the IP address or hostname of the target machine.
|
||||
- Replace `<SSH_USER>` 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:
|
||||
|
||||
# <host_name> | SUCCESS => {
|
||||
# "ansible_facts": {
|
||||
# "discovered_interpreter_python": "/usr/bin/python3.10"
|
||||
# },
|
||||
# "changed": false,
|
||||
# "ping": "pong"
|
||||
# }
|
||||
```
|
||||
|
||||
## Deploy Nitro Contracts
|
||||
|
||||
The following commands have to be executed in [`nitro-contracts-setup`](./) directory
|
||||
|
||||
- Copy the `contract-vars-example.yml` vars file
|
||||
|
||||
```bash
|
||||
cp contract-vars-example.yml contract-vars.yml
|
||||
```
|
||||
|
||||
- Edit [`contract-vars.yml`](./contract-vars.yml) and fill in the following values
|
||||
|
||||
```bash
|
||||
# L1 RPC endpoint
|
||||
geth_url: ""
|
||||
|
||||
# L1 chain ID
|
||||
geth_chain_id: ""
|
||||
|
||||
# Private key for a funded account on L1 to use for contracts deployment on L1
|
||||
geth_deployer_pk: ""
|
||||
|
||||
# Custom L1 token to be deployed
|
||||
token_name: "LaconicNetworkToken"
|
||||
token_symbol: "LNT"
|
||||
intial_token_supply: "129600"
|
||||
```
|
||||
|
||||
- To deploy the L1 nitro contracts, execute the `deploy-contracts.yml` Ansible playbook by running one of the following commands:
|
||||
|
||||
- For local deployment, specify the `"target_host": localhost` in the `--extra-vars` parameter:
|
||||
|
||||
```bash
|
||||
LANG=en_US.utf8 ansible-playbook deploy-contracts.yml --extra-vars='{ "target_host": "localhost"}' --user $USER -kK
|
||||
```
|
||||
|
||||
- For remote deployment, provide an inventory and specify the `"target_host": nitro_host` in the `--extra-vars` parameter:
|
||||
|
||||
```bash
|
||||
LANG=en_US.utf8 ansible-playbook -i ./hosts.ini deploy-contracts.yml --extra-vars='{ "target_host": "nitro_host"}' --user $USER -kK
|
||||
```
|
||||
|
||||
|
||||
NOTE: By default, deployments are created in the `nitro-contracts-setup/out` directory. To change this location, update the `nitro_directory` variable in the [setup-vars.yml](./setup-vars.yml) file.
|
||||
|
||||
- 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 deploy-contracts.yml --extra-vars='{ "target_host": "localhost", "skip_container_build": true }' --user $USER -kK
|
||||
```
|
||||
|
||||
## Check Deployment Status
|
||||
|
||||
- Run the following command in the directory where the nitro-contracts-deployment is created:
|
||||
|
||||
- Check logs for deployments:
|
||||
|
||||
```bash
|
||||
# Check the L2 nitro contract deployment logs
|
||||
laconic-so deployment --dir nitro-contracts-deployment logs l2-nitro-contracts -f
|
||||
```
|
||||
|
||||
## Get Contract Addresses
|
||||
|
||||
- Run the following commands in the directory where the deployments are created:
|
||||
|
||||
- Get addresses of L1 nitro contracts:
|
||||
|
||||
```bash
|
||||
laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "cat /app/deployment/nitro-addresses.json"
|
||||
```
|
||||
6
nitro-contracts-setup/contract-vars-example.yml
Normal file
6
nitro-contracts-setup/contract-vars-example.yml
Normal file
@ -0,0 +1,6 @@
|
||||
geth_url: ""
|
||||
geth_chain_id: ""
|
||||
geth_deployer_pk: ""
|
||||
token_name: ""
|
||||
token_symbol: ""
|
||||
intial_token_supply: ""
|
||||
96
nitro-contracts-setup/deploy-contracts.yml
Normal file
96
nitro-contracts-setup/deploy-contracts.yml
Normal file
@ -0,0 +1,96 @@
|
||||
- name: Deploy nitro contracts
|
||||
hosts: "{{ target_host }}"
|
||||
|
||||
vars_files:
|
||||
- setup-vars.yml
|
||||
- contract-vars.yml
|
||||
|
||||
environment:
|
||||
PATH: "{{ ansible_env.PATH }}:/home/{{ansible_user}}/bin"
|
||||
|
||||
tasks:
|
||||
- name: Create directory for nitro bridge deployment
|
||||
file:
|
||||
path: "{{ nitro_directory }}"
|
||||
state: directory
|
||||
become: yes
|
||||
|
||||
- name: Clone go-nitro stack repo
|
||||
command: laconic-so fetch-stack git.vdb.to/cerc-io/nitro-stack --git-ssh --pull
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Change owner of nitro-directory
|
||||
file:
|
||||
path: "{{ nitro_directory }}"
|
||||
owner: "{{ansible_user}}"
|
||||
group: "{{ansible_user}}"
|
||||
state: directory
|
||||
recurse: yes
|
||||
become: yes
|
||||
|
||||
- name: Clone repositories required for nitro-stack
|
||||
command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge setup-repositories --git-ssh --pull
|
||||
ignore_errors: yes
|
||||
|
||||
- name: Build containers
|
||||
command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge build-containers --force-rebuild
|
||||
when: not skip_container_build
|
||||
|
||||
- name: Generate spec file for nitro contracts deployment
|
||||
template:
|
||||
src: "./templates/specs/nitro-contracts-spec.yml.j2"
|
||||
dest: "{{ nitro_directory }}/nitro-contracts-spec.yml"
|
||||
|
||||
- name: Check if deployment exists for nitro contracts
|
||||
stat:
|
||||
path: "{{ nitro_directory }}/nitro-contracts-deployment"
|
||||
register: nitro_contracts_deployment
|
||||
become: yes
|
||||
|
||||
- name: Create a deployment for nitro contracts
|
||||
command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-contracts deploy create --spec-file nitro-contracts-spec.yml --deployment-dir nitro-contracts-deployment
|
||||
args:
|
||||
chdir: "{{ nitro_directory }}"
|
||||
when: not nitro_contracts_deployment.stat.exists
|
||||
|
||||
- name: Start deployment for nitro-contracts
|
||||
command: laconic-so deployment --dir nitro-contracts-deployment start
|
||||
args:
|
||||
chdir: "{{ nitro_directory }}"
|
||||
|
||||
- name: Wait for the contracts to be deployed
|
||||
wait_for:
|
||||
path: "{{ nitro_directory }}/nitro-contracts-deployment/data/nitro_deployment/nitro-addresses.json"
|
||||
timeout: 60
|
||||
|
||||
- name: Export NA_ADDRESS
|
||||
shell: laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"{{ geth_chain_id }}\"[0].contracts.NitroAdjudicator.address' /app/deployment/nitro-addresses.json"
|
||||
args:
|
||||
chdir: "{{ nitro_directory }}"
|
||||
register: na_address
|
||||
- debug:
|
||||
msg: "NA_ADDRESS: {{ na_address.stdout }}"
|
||||
|
||||
- name: Export CA_ADDRESS
|
||||
shell: laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"{{ geth_chain_id }}\"[0].contracts.ConsensusApp.address' /app/deployment/nitro-addresses.json"
|
||||
args:
|
||||
chdir: "{{ nitro_directory }}"
|
||||
register: ca_address
|
||||
- debug:
|
||||
msg: "CA_ADDRESS: {{ ca_address.stdout }}"
|
||||
|
||||
- name: Export VPA_ADDRESS
|
||||
shell: laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"{{ geth_chain_id }}\"[0].contracts.VirtualPaymentApp.address' /app/deployment/nitro-addresses.json"
|
||||
args:
|
||||
chdir: "{{ nitro_directory }}"
|
||||
register: vpa_address
|
||||
- debug:
|
||||
msg: "VPA_ADDRESS: {{ vpa_address.stdout }}"
|
||||
|
||||
- name: Export L1_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
|
||||
- debug:
|
||||
msg: "L1_ASSET_ADDRESS: {{ l1_asset_address.stdout }}"
|
||||
3
nitro-contracts-setup/setup-vars.yml
Normal file
3
nitro-contracts-setup/setup-vars.yml
Normal file
@ -0,0 +1,3 @@
|
||||
target_host: "localhost"
|
||||
nitro_directory: ./out
|
||||
skip_container_build: false
|
||||
@ -0,0 +1,13 @@
|
||||
stack: /home/{{ ansible_user }}/cerc/nitro-stack/stack-orchestrator/stacks/nitro-contracts
|
||||
deploy-to: compose
|
||||
config:
|
||||
GETH_URL: {{ geth_url }}
|
||||
GETH_CHAIN_ID: {{ geth_chain_id }}
|
||||
GETH_DEPLOYER_PK: {{ geth_deployer_pk }}
|
||||
TOKEN_NAME: {{ token_name }}
|
||||
TOKEN_SYMBOL: {{ token_symbol }}
|
||||
INITIAL_TOKEN_SUPPLY: {{ intial_token_supply }}
|
||||
network:
|
||||
ports: {}
|
||||
volumes:
|
||||
nitro_deployment: ./data/nitro_deployment
|
||||
3
nitro-nodes-setup/.gitignore
vendored
Normal file
3
nitro-nodes-setup/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
out
|
||||
nitro-vars.yml
|
||||
hosts.ini
|
||||
@ -4,6 +4,43 @@
|
||||
|
||||
To get started, follow the [installation](../README.md#installation) guide to setup ansible on your machine
|
||||
|
||||
## Setup Remote Hosts
|
||||
|
||||
To run the playbook on a remote machine, follow these steps:
|
||||
|
||||
- In the [`nitro-nodes-setup`](./) directory, create a new file named hosts.ini:
|
||||
|
||||
```bash
|
||||
cp ../example-hosts.ini hosts.ini
|
||||
```
|
||||
|
||||
- Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine
|
||||
|
||||
```bash
|
||||
[nitro_host]
|
||||
<host_name> ansible_host=<TARGET_IP> ansible_user=<SSH_USER> ansible_ssh_common_args='-o ForwardAgent=yes'
|
||||
```
|
||||
|
||||
- Replace `<host_name>` with the alias of your choice.
|
||||
- Replace `<TARGET_IP>` with the IP address or hostname of the target machine.
|
||||
- Replace `<SSH_USER>` 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:
|
||||
|
||||
# <host_name> | SUCCESS => {
|
||||
# "ansible_facts": {
|
||||
# "discovered_interpreter_python": "/usr/bin/python3.10"
|
||||
# },
|
||||
# "changed": false,
|
||||
# "ping": "pong"
|
||||
# }
|
||||
```
|
||||
|
||||
## Run a nitro node
|
||||
|
||||
The following commands have to be executed in [`nitro-nodes-setup`](./) directory
|
||||
@ -56,18 +93,26 @@ The following commands have to be executed in [`nitro-nodes-setup`](./) director
|
||||
nitro_l2_ext_multiaddr: ""
|
||||
```
|
||||
|
||||
- To run a nitro node, execute the `run-nitro-nodes.yml` Ansible playbook by running the following command.
|
||||
- To run a nitro node, execute the `run-nitro-nodes.yml` Ansible playbook by running one of the following commands:
|
||||
|
||||
NOTE: By default, deployments are created in the `nitro-nodes-setup/out` directory. To change this location, update the `nitro_directory` variable in the [setup-vars.yml](./setup-vars.yml) file.
|
||||
- For local deployment, specify the `"target_host": localhost` in the `--extra-vars` parameter:
|
||||
|
||||
```bash
|
||||
LANG=en_US.utf8 ansible-playbook -i localhost, --connection=local run-nitro-nodes.yml --extra-vars='{ "target_host": "localhost"}' -kK --user $USER
|
||||
```
|
||||
```bash
|
||||
LANG=en_US.utf8 ansible-playbook run-nitro-nodes.yml --extra-vars='{ "target_host": "localhost"}' -kK --user $USER
|
||||
```
|
||||
|
||||
- For remote deployment, provide an inventory and specify the `"target_host": nitro_host` 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"}' -kK --user $USER
|
||||
```
|
||||
|
||||
NOTE: By default, deployments are created in a `out` directory. To change this location, update the `nitro_directory` variable in the [setup-vars.yml](./setup-vars.yml) file.
|
||||
|
||||
- For skipping container build, run with `"skip_container_build" : true` in the `--extra-vars` parameter:
|
||||
|
||||
```bash
|
||||
LANG=en_US.utf8 ansible-playbook -i localhost, --connection=local run-nitro-nodes.yml --extra-vars='{ "target_host": "localhost", "skip_container_build": true }' -kK --user $USER
|
||||
LANG=en_US.utf8 ansible-playbook -i ./hosts.ini run-nitro-nodes.yml --extra-vars='{ "target_host": "nitro_host", "skip_container_build": true }' -kK --user $USER
|
||||
```
|
||||
|
||||
## Check Deployment Status
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
target_host: "localhost"
|
||||
nitro_directory: ./out
|
||||
nitro_directory: out
|
||||
skip_container_build: false
|
||||
|
||||
Loading…
Reference in New Issue
Block a user