Add ops instructions to setup snowball frontend and backend (#32)

Part of [Service provider auctions for web deployments](https://www.notion.so/Service-provider-auctions-for-web-deployments-104a6b22d47280dbad51d28aa3a91d75)

- Update instructions for nitro node deployments

Co-authored-by: Adw8 <adwaitgharpure@gmail.com>
Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
Co-authored-by: Neeraj <neeraj.rtly@gmail.com>
Reviewed-on: cerc-io/testnet-laconicd-stack#32
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
This commit is contained in:
authored and nabarun committed 2024-10-30 10:16:28 +00:00
1 parent 9f86b2f2b5
commit a8ffb987b1
4 files changed
+572 -90

No files matched your search

+204 -81
View File
@@ -14,6 +14,8 @@
* On deployment machine:
* User with passwordless sudo: see [setup](https://git.vdb.to/cerc-io/testnet-ops/src/branch/main/user-setup/README.md#user-setup)
* laconic-so: see [installation](https://git.vdb.to/cerc-io/testnet-ops/src/branch/main/stack-orchestrator-setup/README.md#setup-stack-orchestrator)
## Setup
@@ -28,43 +30,68 @@
```bash
wget -O nitro-vars.yml https://git.vdb.to/cerc-io/testnet-laconicd-stack/raw/branch/main/ops/stage2/nitro-node-config.yml
# Expected variables in the fetched config file:
# nitro_chain_url: ""
# na_address: ""
# ca_address: ""
# vpa_address: ""
# bridge_nitro_address: ""
# nitro_l1_bridge_multiaddr: ""
# nitro_l2_bridge_multiaddr: ""
```
* Fetch required asset addresses:
```bash
wget -O assets.json https://git.vdb.to/cerc-io/testnet-laconicd-stack/raw/branch/main/ops/stage2/assets.json
# Example output:
# {
# "1212": [
# {
# "name": "geth",
# "chainId": "1212",
# "contracts": {
# "TestToken": {
# "address": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9"
# },
# "TestToken2": {
# "address": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9"
# }
# }
# }
# ]
# }
```
* TODO: Get L1 tokens on your address
* Ask testnet operator to send L1 tokens and ETH to your chain address
* [README for transferring tokens](./ops/nitro-token-ops.md#transfer-deployed-tokens-to-given-address)
* [README for transferring ETH](./ops/nitro-token-ops.md#transfer-eth)
* Check balance of your tokens once they are transferred:
```bash
# Note: Account address should be without "0x"
export ACCOUNT_ADDRESS="<account-address>"
export GETH_CHAIN_ID="1212"
export GETH_CHAIN_URL="https://fixturenet-eth.laconic.com"
export ASSET_ADDRESS_1=$(jq -r --arg chainId "$GETH_CHAIN_ID" '.[$chainId][0].contracts.TestToken.address' assets.json)
export ASSET_ADDRESS_2=$(jq -r --arg chainId "$GETH_CHAIN_ID" '.[$chainId][0].contracts.TestToken2.address' assets.json)
# Check balance of eth account
curl -X POST $GETH_CHAIN_URL \
-H "Content-Type: application/json" \
-d '{
"jsonrpc":"2.0",
"method":"eth_getBalance",
"params":["'"$ACCOUNT_ADDRESS"'", "latest"],
"id":1
}'
# Check balance of first asset address
curl -X POST $GETH_CHAIN_URL \
-H "Content-Type: application/json" \
-d '{
"jsonrpc":"2.0",
"method":"eth_call",
"params":[{
"to": "'"$ASSET_ADDRESS_1"'",
"data": "0x70a08231000000000000000000000000'"$ACCOUNT_ADDRESS"'"
}, "latest"],
"id":1
}'
# Check balance of second asset address
curl -X POST $GETH_CHAIN_URL \
-H "Content-Type: application/json" \
-d '{
"jsonrpc":"2.0",
"method":"eth_call",
"params":[{
"to": "'"$ASSET_ADDRESS_2"'",
"data": "0x70a08231000000000000000000000000'"$ACCOUNT_ADDRESS"'"
}, "latest"],
"id":1
}'
```
* Edit `nitro-vars.yml` and add the following variables:
@@ -90,36 +117,27 @@
nitro_l2_ext_multiaddr: ""
```
* Update the target dir in `setup-vars.yml`:
* Edit the `setup-vars.yml` to update the target directory:
```bash
# Set path to desired deployments dir (under your user)
DEPLOYMENTS_DIR=<path-to-deployments-dir>
# Set absolute path to desired deployments directory (under your user)
# Example: /home/dev/nitro-node-deployments
...
nitro_directory: <path-to-deployments-dir>
...
sed -i "s|^nitro_directory:.*|nitro_directory: $DEPLOYMENTS_DIR/nitro-node|" setup-vars.yml
# Will create deployments at $DEPLOYMENTS_DIR/nitro-node/l1-nitro-deployment and $DEPLOYMENTS_DIR/nitro-node/l2-nitro-deployment
# Will create deployments at <path-to-deployments-dir>/l1-nitro-deployment and <path-to-deployments-dir>/l2-nitro-deployment
```
## Run Nitro Nodes
Nitro nodes can be run using Ansible either locally or on a remote machine; follow corresponding steps for your setup
### On Local Host
* Setup and run a Nitro node (L1+L2) by executing the `run-nitro-nodes.yml` Ansible playbook:
```bash
LANG=en_US.utf8 ansible-playbook -i localhost, --connection=local run-nitro-nodes.yml --extra-vars='{ "target_host": "localhost"}' --user $USER
```
### On Remote Host
Nitro nodes can be set up on a target machine using Ansible:
* In `testnet-ops/nitro-nodes-setup`, create a new `hosts.ini` file:
```bash
cp ../hosts.example.ini hosts.ini
```
```bash
cp ../hosts.example.ini hosts.ini
```
* Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine:
@@ -131,12 +149,12 @@ Nitro nodes can be run using Ansible either locally or on a remote machine; foll
* Replace `<deployment_host>` with `nitro_host`
* 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)
* Replace `<ssh_user>` with the username of the user that you set up on target machine (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
ansible all -m ping -i hosts.ini
# If using password based authentication, enter the ssh password on prompt; otherwise, leave it blank
@@ -151,13 +169,10 @@ Nitro nodes can be run using Ansible either locally or on a remote machine; foll
# }
```
* Execute the `run-nitro-nodes.yml` Ansible playbook for remote deployment:
* Execute the `run-nitro-nodes.yml` Ansible playbook to setup and run a Nitro node (L1+L2):
```bash
LANG=en_US.utf8 ansible-playbook -i hosts.ini run-nitro-nodes.yml --extra-vars='{ "target_host": "nitro_host"}' --user $USER -kK
# If using password based authentication, enter the ssh password on prompt; otherwise, leave it blank
# Enter the sudo password as "BECOME password" on prompt
LANG=en_US.utf8 ansible-playbook -i hosts.ini run-nitro-nodes.yml --extra-vars='{ "target_host": "nitro_host"}' --user $USER
```
### Check Deployment Status
@@ -165,9 +180,7 @@ Nitro nodes can be run using Ansible either locally or on a remote machine; foll
* Run the following commands on deployment machine:
```bash
DEPLOYMENTS_DIR=<path-to-deployments-dir>
cd $DEPLOYMENTS_DIR/nitro-node
cd <path-to-deployments-dir>
# Check the logs, ensure that the nodes are running
laconic-so deployment --dir l1-nitro-deployment logs nitro-node -f
@@ -182,7 +195,7 @@ Nitro nodes can be run using Ansible either locally or on a remote machine; foll
* Get your Nitro node's info:
```bash
laconic-so deployment --dir l1-nitro-deployment exec nitro-rpc-client "nitro-rpc-client get-node-info -p 4005 -h nitro-node"
laconic-so deployment --dir l2-nitro-deployment exec nitro-rpc-client "nitro-rpc-client get-node-info -p 4005 -h nitro-node"
# Expected output:
# {
@@ -202,18 +215,18 @@ Create a ledger channel with the bridge on L1 which is mirrored on L2
* Set required variables:
```bash
DEPLOYMENTS_DIR=<path-to-deployments-dir>
cd $DEPLOYMENTS_DIR/nitro-node
cd <path-to-deployments-dir>
export BRIDGE_NITRO_ADDRESS=$(yq eval '.bridge_nitro_address' nitro-node-config.yml)
export GETH_CHAIN_ID="1212"
# Get asset addresses from assets.json file
export ASSET_ADDRESS_1=$(jq -r --arg chainId "$CHAIN_ID" '.[$chainId][0].contracts.TestToken.address' assets.json)
export ASSET_ADDRESS_2=$(jq -r --arg chainId "$CHAIN_ID" '.[$chainId][0].contracts.TestToken2.address' assets.json)
export ASSET_ADDRESS_1=$(jq -r --arg chainId "$GETH_CHAIN_ID" '.[$chainId][0].contracts.TestToken.address' assets.json)
export ASSET_ADDRESS_2=$(jq -r --arg chainId "$GETH_CHAIN_ID" '.[$chainId][0].contracts.TestToken2.address' assets.json)
```
* Check that check that you have no existing channels on L1 or L2:
* Check that you have no existing channels on L1 or L2:
```bash
laconic-so deployment --dir l1-nitro-deployment exec nitro-rpc-client "nitro-rpc-client get-all-ledger-channels -p 4005 -h nitro-node"
@@ -223,6 +236,8 @@ Create a ledger channel with the bridge on L1 which is mirrored on L2
# []
```
* Ensure that your account has enough balance of tokens from `assets.json`
* Create a ledger channel between your L1 Nitro node and Bridge with custom asset:
```bash
@@ -325,9 +340,7 @@ Perform payments using a virtual payment channel created with another Nitro node
* Switch to the `nitro-node` directory:
```bash
DEPLOYMENTS_DIR=<path-to-deployments-dir>
cd $DEPLOYMENTS_DIR/nitro-node
cd <path-to-deployments-dir>
```
* Check status of the mirrored channel on L2:
@@ -366,9 +379,6 @@ Perform payments using a virtual payment channel created with another Nitro node
```bash
export BRIDGE_NITRO_ADDRESS=$(yq eval '.bridge_nitro_address' nitro-node-config.yml)
# Counterparty to create the payment channel with
export COUNTER_PARTY_ADDRESS=<counterparty-nitro-address>
# Mirrored channel on L2
export L2_CHANNEL_ID=<l2-channel-id>
@@ -376,6 +386,21 @@ Perform payments using a virtual payment channel created with another Nitro node
export PAYMENT_CHANNEL_AMOUNT=500
```
* Set counterparty address
```bash
export COUNTER_PARTY_ADDRESS=<counterparty-nitro-address>
```
* Get the nitro address of the counterparty's node with whom you want create payment channel
* To get the nitro address of the your node:
```bash
laconic-so deployment --dir l2-nitro-deployment exec nitro-rpc-client "nitro-rpc-client get-node-info -p 4005 -h nitro-node"
# `SCAddress` -> nitro address
```
* Check for existing payment channels for the L2 channel:
```bash
@@ -447,6 +472,8 @@ Perform payments using a virtual payment channel created with another Nitro node
* Check L2 mirrored channel's status after the virtual payment channel is closed:
* This can be checked by both nodes
```bash
laconic-so deployment --dir l2-nitro-deployment exec nitro-rpc-client "nitro-rpc-client get-all-ledger-channels -p 4005 -h nitro-node"
@@ -489,9 +516,7 @@ Perform swaps using a swap channel created with another Nitro node over the mirr
* Switch to the `nitro-node` directory:
```bash
DEPLOYMENTS_DIR=<path-to-deployments-dir>
cd $DEPLOYMENTS_DIR/nitro-node
cd <path-to-deployments-dir>
```
* Check status of the mirrored channel on L2:
@@ -530,14 +555,28 @@ Perform swaps using a swap channel created with another Nitro node over the mirr
```bash
export BRIDGE_NITRO_ADDRESS=$(yq eval '.bridge_nitro_address' nitro-node-config.yml)
# Counterparty to create the swap channel with
export COUNTER_PARTY_ADDRESS=<counterparty-nitro-address>
export GETH_CHAIN_ID="1212"
# Get asset addresses from assets.json file
export ASSET_ADDRESS_1=$(jq -r --arg chainId "$CHAIN_ID" '.[$chainId][0].contracts.TestToken.address' assets.json)
export ASSET_ADDRESS_2=$(jq -r --arg chainId "$CHAIN_ID" '.[$chainId][0].contracts.TestToken2.address' assets.json)
export ASSET_ADDRESS_1=$(jq -r --arg chainId "$GETH_CHAIN_ID" '.[$chainId][0].contracts.TestToken.address' assets.json)
export ASSET_ADDRESS_2=$(jq -r --arg chainId "$GETH_CHAIN_ID" '.[$chainId][0].contracts.TestToken2.address' assets.json)
```
* Set counterparty address
```bash
export COUNTER_PARTY_ADDRESS=<counterparty-nitro-address>
```
* Get the nitro address of the counterparty's node with whom you want create swap channel
* To get the nitro address of the your node:
```bash
laconic-so deployment --dir l2-nitro-deployment exec nitro-rpc-client "nitro-rpc-client get-node-info -p 4005 -h nitro-node"
# `SCAddress` -> nitro address
```
* Create swap channel:
```bash
@@ -584,6 +623,90 @@ Perform swaps using a swap channel created with another Nitro node over the mirr
### Performing swaps
* Ensure that environment variables for asset addresses are set (should be done by both parties):
```bash
export GETH_CHAIN_ID="1212"
# Get asset addresses from assets.json file
export ASSET_ADDRESS_1=$(jq -r --arg chainId "$GETH_CHAIN_ID" '.[$chainId][0].contracts.TestToken.address' assets.json)
export ASSET_ADDRESS_2=$(jq -r --arg chainId "$GETH_CHAIN_ID" '.[$chainId][0].contracts.TestToken2.address' assets.json)
```
* Get all active swap channels for a specific mirrored ledger channel (should be done by both parties)
* To get mirrored ledger channels:
```bash
laconic-so deployment --dir l2-nitro-deployment exec nitro-rpc-client "nitro-rpc-client get-all-ledger-channels -p 4005 -h nitro-node"
# Example output:
# [
# {
# "ID": "0xb34210b763d4fdd534190ba11886ad1daa1e411c87be6fd20cff74cd25077c46",
# "Status": "Open",
# "Balances": [
# {
# "AssetAddress": "0xa4351114dae1abeb2d552d441c9733c72682a45d",
# "Me": "0x075400039e303b3fb46c0cff0404c5fa61947c05",
# "Them": "0xf0e6a85c6d23aca9ff1b83477d426ed26f218185",
# "MyBalance": 1000n,
# "TheirBalance": 1000n
# },
# {
# "AssetAddress": "0x314e43f9825b10961859c2a62c2de6a765c1c1f1",
# "Me": "0x075400039e303b3fb46c0cff0404c5fa61947c05",
# "Them": "0xf0e6a85c6d23aca9ff1b83477d426ed26f218185",
# "MyBalance": 1000n,
# "TheirBalance": 1000n
# }
# ],
# "ChannelMode": "Open"
# }
# ]
```
* Export ledger channel ID:
```bash
export LEDGER_CHANNEL_ID=
```
* To get swap channels for a ledger channel:
```bash
laconic-so deployment --dir l2-nitro-deployment exec nitro-rpc-client "nitro-rpc-client get-swap-channels-by-ledger $LEDGER_CHANNEL_ID -p 4005 -h nitro-node"
# Example Output:
# [
# {
# ID: '0x1dbd58d314f123f4b0f4147eee7fd92fa523ba7082d8a75b846f6d1189e2f0e9',
# Status: 'Open',
# Balances: [
# {
# AssetAddress: '0xa4351114dae1abeb2d552d441c9733c72682a45d',
# Me: '0x075400039e303b3fb46c0cff0404c5fa61947c05',
# Them: '0xd0ea8b27591b1d070cccd4d30b8d408fe794fdfc',
# MyBalance: 100,
# TheirBalance: 100n
# },
# {
# AssetAddress: '0x314e43f9825b10961859c2a62c2de6a765c1c1f1',
# Me: '0x075400039e303b3fb46c0cff0404c5fa61947c05',
# Them: '0xd0ea8b27591b1d070cccd4d30b8d408fe794fdfc',
# MyBalance: 100,
# TheirBalance: 100
# }
# ]
# }
# ]
```
* Export swap channel ID:
```bash
export SWAP_CHANNEL_ID=
```
* One of the participants can initiate the swap and other one will either accept it or reject it
* For initiating the swap:
@@ -733,7 +856,7 @@ Perform swaps using a swap channel created with another Nitro node over the mirr
* Switch to deployments dir:
```bash
cd $DEPLOYMENTS_DIR/nitro-node
cd <path-to-deployments-dir>
```
* Stop all Nitro services running in the background:
@@ -775,7 +898,7 @@ Perform swaps using a swap channel created with another Nitro node over the mirr
* Stop the deployment:
```bash
cd $DEPLOYMENTS_DIR/nitro-node
cd <path-to-deployments-dir>
laconic-so deployment --dir l1-nitro-deployment stop
```