Add ansible playbook to setup and run Nitro bridge #4
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
nitro-nodes-setup/out/
|
|
||||||
nitro-nodes-setup/nitro-vars.yml
|
|
||||||
l2-setup/out
|
l2-setup/out
|
||||||
|
nitro-bridge-setup/out
|
||||||
|
nitro-bridge-setup/bridge-vars.yml
|
||||||
|
nitro-nodes-setup/nitro-vars.yml
|
||||||
|
nitro-nodes-setup/out/
|
||||||
|
@ -40,3 +40,4 @@
|
|||||||
|
|
||||||
- [l2-setup](./l2-setup/README.md)
|
- [l2-setup](./l2-setup/README.md)
|
||||||
- [nitro-node-setup](./nitro-nodes-setup/README.md)
|
- [nitro-node-setup](./nitro-nodes-setup/README.md)
|
||||||
|
- [nitro-bridge-setup](./nitro-bridge-setup/README.md)
|
||||||
|
10
nitro-bridge-setup/bridge-vars-example.yml
Normal file
10
nitro-bridge-setup/bridge-vars-example.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
nitro_directory: './out'
|
||||||
|
l1_nitro_chain_url: ''
|
||||||
|
l2_nitro_chain_url: ''
|
||||||
|
nitro_chain_pk: ''
|
||||||
|
nitro_sc_pk: ''
|
||||||
|
geth_url: ''
|
||||||
|
optimism_url: ''
|
||||||
|
geth_deployer_pk: ''
|
||||||
|
optimism_deployer_pk: ''
|
||||||
|
geth_chain_id: ''
|
114
nitro-bridge-setup/run-nitro-bridge.yml
Normal file
114
nitro-bridge-setup/run-nitro-bridge.yml
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
- name: Setup go-nitro on host
|
||||||
|
hosts: "{{ target_host }}"
|
||||||
|
|
||||||
|
vars_files:
|
||||||
|
- bridge-vars.yml
|
||||||
|
|
||||||
|
environment:
|
||||||
|
PATH: "{{ ansible_env.PATH }}:/home/{{ansible_user}}/bin"
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- 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: Clone repositories required for nitro-stack
|
||||||
|
command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node setup-repositories --git-ssh --pull
|
||||||
|
ignore_errors: yes
|
||||||
|
|
||||||
|
- name: Build containers
|
||||||
|
command: laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node build-containers --force-rebuild
|
||||||
|
when: not skip_container_build
|
||||||
|
|
||||||
|
- name: Copy over 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
|
||||||
|
|
||||||
|
- 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 '.\"1212\"[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 '.\"1212\"[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 '.\"1212\"[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 '.\"1212\"[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 }}"
|
||||||
|
|
||||||
|
- name: Copy over spec file for bridge deployment
|
||||||
|
template:
|
||||||
|
src: "./templates/specs/bridge-nitro-spec.yml.j2"
|
||||||
|
dest: "{{ nitro_directory }}/bridge-nitro-spec.yml"
|
||||||
|
|
||||||
|
- name: Check if deployment exists for bridge node
|
||||||
|
stat:
|
||||||
|
path: "{{ nitro_directory }}/bridge-deployment"
|
||||||
|
register: bridge_deployment
|
||||||
|
|
||||||
|
- 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 '.\"42069\"[0].contracts.Bridge.address' /app/deployment/nitro-addresses.json"
|
||||||
|
args:
|
||||||
|
chdir: "{{ nitro_directory }}"
|
||||||
|
register: bridge_address
|
||||||
|
- debug:
|
||||||
|
msg: "BRIDGE_ADDRESS: {{ bridge_address.stdout }}"
|
30
nitro-bridge-setup/templates/specs/bridge-nitro-spec.yml.j2
Normal file
30
nitro-bridge-setup/templates/specs/bridge-nitro-spec.yml.j2
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
stack: /home/{{ ansible_user }}/cerc/nitro-stack/stack-orchestrator/stacks/bridge
|
||||||
|
deploy-to: compose
|
||||||
|
config:
|
||||||
|
NITRO_L1_CHAIN_URL: {{ l1_nitro_chain_url }}
|
||||||
|
NITRO_L2_CHAIN_URL: {{ l2_nitro_chain_url }}
|
||||||
|
NITRO_CHAIN_PK: '{{ nitro_chain_pk }}'
|
||||||
|
NITRO_SC_PK: '{{ nitro_sc_pk }}'
|
||||||
|
GETH_CHAIN_ID: '{{ geth_chain_id }}'
|
||||||
|
GETH_URL: {{ geth_url }}
|
||||||
|
OPTIMISM_URL: {{ optimism_url }}
|
||||||
|
GETH_DEPLOYER_PK: '{{ geth_deployer_pk }}'
|
||||||
|
OPTIMISM_DEPLOYER_PK: '{{ optimism_deployer_pk }}'
|
||||||
|
TOKEN_NAME: LaconicNetworkToken
|
||||||
|
TOKEN_SYMBOL: LNT
|
||||||
|
INITIAL_TOKEN_SUPPLY: '129600'
|
||||||
|
NA_ADDRESS: '{{ na_address.stdout }}'
|
||||||
|
VPA_ADDRESS: '{{ vpa_address.stdout }}'
|
||||||
|
CA_ADDRESS: '{{ ca_address.stdout }}'
|
||||||
|
L1_ASSET_ADDRESS: '{{ l1_asset_address.stdout }}'
|
||||||
|
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
|
Loading…
Reference in New Issue
Block a user