Add ansible playbook to setup and run Nitro bridge #4
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,3 +1,7 @@
|
||||
nitro-nodes-setup/out/
|
||||
nitro-nodes-setup/nitro-vars.yml
|
||||
l2-setup/out
|
||||
nitro-bridge-setup/out
|
||||
nitro-bridge-setup/bridge-vars.yml
|
||||
nitro-nodes-setup/nitro-vars.yml
|
||||
nitro-nodes-setup/out
|
||||
nitro-contracts-setup/out
|
||||
nitro-contracts-setup/contract-vars.yml
|
||||
|
@ -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)
|
||||
|
85
nitro-bridge-setup/README.md
Normal file
85
nitro-bridge-setup/README.md
Normal file
@ -0,0 +1,85 @@
|
||||
# nitro-bridge-setup
|
||||
|
||||
## Setup Ansible
|
||||
|
||||
To get started, follow the [installation](../README.md#installation) guide to setup ansible on your machine
|
||||
|
||||
## 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 the following command:
|
||||
|
||||
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.
|
||||
|
||||
```bash
|
||||
LANG=en_US.utf8 ansible-playbook -i localhost, --connection=local run-nitro-bridge.yml --extra-vars='{ "target_host": "localhost"}' --user $USER -kK
|
||||
```
|
||||
|
||||
- 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-bridge.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 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
|
68
nitro-contracts-setup/README.md
Normal file
68
nitro-contracts-setup/README.md
Normal file
@ -0,0 +1,68 @@
|
||||
# nitro-contracts-setup
|
||||
|
||||
## Setup Ansible
|
||||
|
||||
To get started, follow the [installation](../README.md#installation) guide to setup ansible on your machine
|
||||
|
||||
## 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 the following command:
|
||||
|
||||
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.
|
||||
|
||||
```bash
|
||||
LANG=en_US.utf8 ansible-playbook -i localhost, --connection=local deploy-contracts.yml --extra-vars='{ "target_host": "localhost"}' --user $USER -kK
|
||||
```
|
||||
|
||||
- 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 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
|
Loading…
Reference in New Issue
Block a user