Compare commits

..
Author SHA1 Message Date
Neeraj dbf7c12042 Update README to start nodes from contract deployed block 2024-10-16 19:58:25 +05:30
nabarunandNeeraj 92e91ec50c Remove use of L2 chain & contracts for running the nitro-bridge (#29)
Part of [Create bridge channel in go-nitro](https://www.notion.so/Create-bridge-channel-in-go-nitro-22ce80a0d8ae4edb80020a8f250ea270)

Co-authored-by: Neeraj <neeraj.rtly@gmail.com>
Reviewed-on: cerc-io/testnet-laconicd-stack#29
2024-10-01 04:30:12 +00:00
prathameshandNeeraj 7041a4ebe8 Add Nitro node config for users and payments instructions (#28)
Part of [Create a public laconicd testnet](https://www.notion.so/Create-a-public-laconicd-testnet-896a11bdd8094eff8f1b49c0be0ca3b8)

Co-authored-by: Neeraj <neeraj.rtly@gmail.com>
Reviewed-on: cerc-io/testnet-laconicd-stack#28
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-09-17 13:55:55 +00:00
prathameshandShreerang Kale 16a164f373 Update L2 Optimism deployment instructions (#27)
Part of [Create a public laconicd testnet](https://www.notion.so/Create-a-public-laconicd-testnet-896a11bdd8094eff8f1b49c0be0ca3b8)

Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
Reviewed-on: cerc-io/testnet-laconicd-stack#27
Co-authored-by: Prathamesh Musale <prathamesh@noreply.git.vdb.to>
Co-committed-by: Prathamesh Musale <prathamesh@noreply.git.vdb.to>
2024-09-13 05:28:55 +00:00
9d92a20ab9 Add instructions to setup and run testnet L2 and Nitro deployments (#26)
Part of [Create a public laconicd testnet](https://www.notion.so/Create-a-public-laconicd-testnet-896a11bdd8094eff8f1b49c0be0ca3b8)

Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
Co-authored-by: Neeraj <neeraj.rtly@gmail.com>
Reviewed-on: cerc-io/testnet-laconicd-stack#26
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-09-12 13:31:17 +00:00
5 changed files with 308 additions and 256 deletions
+1 -1
View File
@@ -16,6 +16,6 @@ Stacks to run a node for laconic testnet
Follow steps in [testnet-onboarding-validator.md](./testnet-onboarding-validator.md) to onboard your participant and join as a validator on the LORO testnet
## Run Testnet Nitro Node
## Run testnet Nitro Node
Follow steps in [testnet-nitro-node.md](./testnet-nitro-node.md) to run you Nitro node for the testnet
+56 -226
View File
@@ -2,7 +2,7 @@
## Login
* Log in as `dev` user on the deployments VM
* Log in as `dev` user on the deployments machine
* All the deployments are placed in the `/srv` directory:
@@ -22,178 +22,14 @@
* Ansible: see [installation](https://git.vdb.to/cerc-io/testnet-ops#installation)
* On deployments VM(s):
* On deployments machine(s):
* laconic-so: see [installation](https://git.vdb.to/cerc-io/testnet-ops/src/branch/main/stack-orchestrator-setup/README.md)
* laconic-so: see [installation](https://git.vdb.to/cerc-io/testnet-ops/src/branch/main/stack-orchestrator-setup/README.md#setup-stack-orchestrator)
<details open>
<summary>L2 Optimism</summary>
<summary>Nitro Contracts Deployment</summary>
## L2 Optimism
* Stack: <https://git.vdb.to/cerc-io/fixturenet-optimism-stack>
* Source repos:
* <github.com/ethereum-optimism/optimism@v1.7.7>
* <github.com/ethereum-optimism/op-geth@v1.101315.2>
* Target dir: `/srv/op-sepolia/optimism-deployment`
* Cleanup an existing deployment on VM if required:
```bash
cd /srv/op-sepolia
# Stop the deployment
laconic-so deployment --dir optimism-deployment stop --delete-volumes
# Remove the deployment dir
sudo rm -rf optimism-deployment
```
### Setup
* Switch to `testnet-ops/l2-setup` directory on your local machine:
```bash
cd testnet-ops/l2-setup
```
* Copy the `l2-vars-example.yml` vars file:
```bash
cp l2-vars-example.yml l2-vars.yml
```
* Edit `l2-vars.yml` with required values:
```bash
# L1 chain ID (Sepolia: 11155111)
l1_chain_id: "11155111"
# L1 RPC endpoint
l1_rpc: "http://host.docker.internal:8545"
# L1 RPC endpoint host or IP address
l1_host: "host.docker.internal"
# L1 RPC endpoint port number
l1_port: "8545"
# L1 Beacon endpoint
l1_beacon: "http://host.docker.internal:8001"
# Account credentials for the Admin account
# Used for Optimism contracts deployment and funding other generated accounts
l1_address: ""
l1_priv_key: ""
```
* Update the target dir in `setup-vars.yml`:
```bash
sed -i 's|^l2_directory:.*|l2_directory: /srv/op-sepolia|' setup-vars.yml
# Will create deployment at /srv/op-sepolia/optimism-deployment
```
### Run
* Set up and run L2 on remote host by executing `run-optimism.yml` Ansible playbook on your local machine:
* Create a new `hosts.ini` file:
```bash
cp ../hosts.example.ini hosts.ini
```
* Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine:
```ini
[l2_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"
# }
```
* Execute the `run-optimism.yml` Ansible playbook for remote deployment:
```bash
LANG=en_US.utf8 ansible-playbook -i hosts.ini run-optimism.yml --extra-vars='{ "target_host": "l2_host"}' --user $USER -kK
```
* Bridge funds on L2:
* On the deployment VM, set the following variables:
```bash
cd /srv/op-sepolia
L1_RPC=http://host.docker.internal:8545
L2_RPC=http://host.docker.internal:9545
NETWORK=$(grep 'cluster-id' optimism-deployment/deployment.yml | sed 's/cluster-id: //')_default
DEPLOYMENT_CONTEXT=11155111
ACCOUNT=<admin-account-address>
```
* Read the bridge contract address from the L1 deployment records in the `op-node` container:
```bash
BRIDGE=$(laconic-so deployment --dir optimism-deployment exec op-node "cat /l1-deployment/$DEPLOYMENT_CONTEXT-deploy.json" | jq -r .L1StandardBridgeProxy)
# Get the funded account's pk
ACCOUNT_PK=$(laconic-so deployment --dir optimism-deployment exec op-node "jq -r '.AdminKey' /l2-accounts/accounts.json")
```
* Check that the starting balance for account on L2 is 0:
```bash
docker run --rm --network $NETWORK cerc/optimism-contracts:local "cast balance $ACCOUNT --rpc-url $L2_RPC"
# 0
```
* Use cast to send ETH to the bridge contract:
```bash
docker run --rm cerc/optimism-contracts:local "cast send --from $ACCOUNT --value 1ether $BRIDGE --rpc-url $L1_RPC --private-key $ACCOUNT_PK"
```
* Allow a couple minutes for the bridge to complete
* Check balance on L2:
```bash
docker run --rm --network $NETWORK cerc/optimism-contracts:local "cast balance $ACCOUNT --rpc-url $L2_RPC"
# 100000000000000000
```
</details>
<details open>
<summary>L1 Nitro Contracts Deployment</summary>
## L1 Nitro Contracts Deployment
## Nitro Contracts Deployment
* Stack: <https://git.vdb.to/cerc-io/nitro-stack/src/branch/main/stack-orchestrator/stacks/nitro-contracts>
@@ -201,7 +37,7 @@
* Target dir: `/srv/bridge/nitro-contracts-deployment`
* Cleanup an existing deployment on VM if required:
* Cleanup an existing deployment if required:
```bash
cd /srv/bridge
@@ -235,7 +71,9 @@
# L1 chain ID (Sepolia: 11155111)
geth_chain_id: "11155111"
# Private key for a funded account on L1 to use for contracts deployment on L1
# Private key for a funded L1 account, to be used for contract deployment on L1
# Must also be funded on L2 for deploying contracts
# Required since this private key will be utilized by both L1 and L2 nodes of the bridge
geth_deployer_pk: ""
# Custom L1 token to be deployed
@@ -265,13 +103,14 @@
* Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine:
```ini
[nitro_host]
[deployment_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)
* 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)
* Verify that you are able to connect to the host using the following command:
@@ -294,12 +133,12 @@
LANG=en_US.utf8 ansible-playbook -i hosts.ini deploy-contracts.yml --extra-vars='{ "target_host": "nitro_host"}' --user $USER -kK
```
* Check logs for deployment on the virtual machine:
* Check logs for deployment on the remote machine:
```bash
cd /srv/bridge
# Check the l1 nitro contract deployments
# Check the nitro contract deployments
laconic-so deployment --dir nitro-contracts-deployment logs nitro-contracts -f
```
@@ -316,7 +155,7 @@
* Target dir: `/srv/bridge/bridge-deployment`
* Cleanup an existing deployment on VM if required:
* Cleanup an existing deployment if required:
```bash
cd /srv/bridge
@@ -330,7 +169,7 @@
### Setup
* Execute the command on the deployment VM to get the deployed L1 Nitro contract addresses along with the L1 asset address:
* Execute the following command on deployment machine to get the deployed Nitro contract addresses along with the asset address:
```bash
cd /srv/bridge
@@ -362,6 +201,15 @@
# }
```
* Get the start block for Nitro Adjudicator events by executing the following command:
```bash
laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq '.receipt.blockNumber' /app/deployment/hardhat-deployments/geth/NitroAdjudicator.json"
# Expected output:
101
```
* Switch to `testnet-ops/nitro-bridge-setup` directory on your local machine:
```bash
@@ -377,41 +225,23 @@
* Edit `bridge-vars.yml` with required values:
```bash
# L1 WS endpoint
nitro_l1_chain_url: "wss://sepolia.laconic.com"
# L2 WS endpoint
nitro_l2_chain_url: "wss://optimism.laconic.com"
# WS endpoint
nitro_chain_url: "wss://sepolia.laconic.com"
# Private key for bridge Nitro address
nitro_sc_pk: ""
# Private key for a funded account on L1
# This account should have L1 tokens for funding Nitro channels
# Private key should correspond to a funded account on L1 and this account must own the Nitro contracts
# It also needs to hold L1 tokens to fund Nitro channels
nitro_chain_pk: ""
# L2 chain ID (Optimism: 42069)
optimism_chain_id: "42069"
# L2 RPC endpoint
optimism_url: "https://optimism.laconic.com"
# Private key for a funded account for L2 contracts deployment
# Use the same account for L1 and L2 deployments
optimism_deployer_pk: ""
# Custom L2 token to be deployed
token_name: ""
token_symbol: ""
intial_token_supply: ""
# Deployed L1 Nitro contract addresses
na_address: ""
vpa_address: ""
ca_address: ""
# Deployed L1 token address
l1_asset_address: ""
# Specifies the block number to start looking for nitro adjudicator events
nitro_chain_start_block: 0
```
* Update the target dir in `setup-vars.yml`:
@@ -424,7 +254,7 @@
### Run
* Deploy L2 contracts and start the bridge on remote host by executing `run-nitro-bridge.yml` Ansible playbook on your local machine:
* Start the bridge on remote host by executing `run-nitro-bridge.yml` Ansible playbook on your local machine:
* Create a new `hosts.ini` file:
@@ -435,13 +265,14 @@
* Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine:
```ini
[nitro_host]
[deployment_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)
* 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)
* Verify that you are able to connect to the host using the following command:
@@ -464,14 +295,11 @@
LANG=en_US.utf8 ansible-playbook -i hosts.ini run-nitro-bridge.yml --extra-vars='{ "target_host": "nitro_host"}' --user $USER -kK
```
* Check logs for deployments on the virtual machine:
* Check logs for deployments on the remote machine:
```bash
cd /srv/bridge
# Check the l2 nitro contract deployments
laconic-so deployment --dir bridge-deployment logs l2-nitro-contracts -f
# Check bridge logs, ensure that the node is running
laconic-so deployment --dir bridge-deployment logs nitro-bridge -f
```
@@ -483,41 +311,45 @@
# Create required variables
GETH_CHAIN_ID="11155111"
OPTIMISM_CHAIN_ID="42069"
export NA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.NitroAdjudicator.address' /app/deployment/nitro-addresses.json")
export CA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.ConsensusApp.address' /app/deployment/nitro-addresses.json")
export VPA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.VirtualPaymentApp.address' /app/deployment/nitro-addresses.json")
export L1_ASSET_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.Token.address' /app/deployment/nitro-addresses.json")
export ASSET_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.Token.address' /app/deployment/nitro-addresses.json")
export BRIDGE_CONTRACT_ADDRESS=$(laconic-so deployment --dir bridge-deployment exec nitro-bridge "jq -r '.\"$OPTIMISM_CHAIN_ID\"[0].contracts.Bridge.address' /app/deployment/nitro-addresses.json")
export BRIDGE_NITRO_ADDRESS=$(laconic-so deployment --dir bridge-deployment exec nitro-rpc-client "nitro-rpc-client get-node-info -p 4005 -h nitro-bridge" | jq -r '.SCAddress')
export BRIDGE_NITRO_ADDRESS=$(laconic-so deployment --dir bridge-deployment exec nitro-rpc-client "nitro-rpc-client get-node-info -p 4006 -h nitro-bridge" | jq -r '.SCAddress')
export BRIDGE_PEER_ID=$(laconic-so deployment --dir bridge-deployment exec nitro-rpc-client "nitro-rpc-client get-node-info -p 4006 -h nitro-bridge" | jq -r '.MessageServicePeerId')
export BRIDGE_PEER_ID=$(laconic-so deployment --dir bridge-deployment exec nitro-rpc-client "nitro-rpc-client get-node-info -p 4005 -h nitro-bridge" | jq -r '.MessageServicePeerId')
export L1_BRIDGE_MULTIADDR="/dns4/bridge.laconic.com/tcp/3005/p2p/$BRIDGE_PEER_ID"
export L2_BRIDGE_MULTIADDR="/dns4/bridge.laconic.com/tcp/3006/p2p/$BRIDGE_PEER_ID"
export NITRO_CHAIN_START_BLOCK=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq '.receipt.blockNumber' /app/deployment/hardhat-deployments/geth/NitroAdjudicator.json")
# Create the required config file
cat <<EOF > nitro-node-config.yml
nitro_l1_chain_url: "wss://sepolia.laconic.com"
nitro_l2_chain_url: "wss://optimism.laconic.com"
nitro_chain_url: "wss://sepolia.laconic.com"
na_address: "$NA_ADDRESS"
ca_address: "$CA_ADDRESS"
vpa_address: "$VPA_ADDRESS"
l1_asset_address: "${L1_ASSET_ADDRESS}"
bridge_contract_address: "$BRIDGE_CONTRACT_ADDRESS"
asset_address: "${ASSET_ADDRESS}"
nitro_chain_start_block: $NITRO_CHAIN_START_BLOCK
bridge_nitro_address: "$BRIDGE_NITRO_ADDRESS"
nitro_l1_bridge_multiaddr: "$L1_BRIDGE_MULTIADDR"
nitro_l2_bridge_multiaddr: "$L2_BRIDGE_MULTIADDR"
EOF
```
The required config file should be generated at `/srv/bridge/nitro-node-config.yml`
* The required config file should be generated at `/srv/bridge/nitro-node-config.yml`
Check in the file at location `ops/stage2/nitro-node-config.yml`
* Check in the generated file at location `ops/stage2/nitro-node-config.yml` within this repository
* List down L2 channels created by the bridge:
```bash
laconic-so deployment --dir bridge-deployment exec nitro-rpc-client "nitro-rpc-client get-all-l2-channels -p 4006 -h nitro-bridge"
```
</details>
@@ -1191,8 +1023,6 @@ https://loro-console.laconic.com -> 4001
# Machine 2
https://sepolia.laconic.com -> 8545
wss://sepolia.laconic.com -> 8546
https://optimism.laconic.com -> 9545
wss://optimism.laconic.com -> 9546
bridge.laconic.com
Open ports:
+8
View File
@@ -0,0 +1,8 @@
nitro_chain_url: "wss://sepolia.laconic.com"
na_address: "0xfD5276DDfE0E7738Af5F3dA0dE58D36560BbE544"
ca_address: "0xC71F47d58d521aE24FDf5e324969aCD6f83b6Ff8"
vpa_address: "0xEA55dEab3718CF4d084a94Fe4C0D750a80Eb1F2C"
asset_address: "0xa4351114dAE1aBEb2d552d441C9733c72682a45D"
bridge_nitro_address: "0xf0E6a85C6D23AcA9ff1b83477D426ed26F218185"
nitro_l1_bridge_multiaddr: "/dns4/bridge.laconic.com/tcp/3005/p2p/16Uiu2HAky2PYTfBNHpytybz4ADY9n7boiLgK5btJpTrGVbWC3diZ"
nitro_l2_bridge_multiaddr: "/dns4/bridge.laconic.com/tcp/3006/p2p/16Uiu2HAky2PYTfBNHpytybz4ADY9n7boiLgK5btJpTrGVbWC3diZ"
+241 -27
View File
@@ -2,30 +2,26 @@
## Prerequisites
* laconic-so: see [installation](https://git.vdb.to/cerc-io/stack-orchestrator#install)
* Local:
* Ansible: see [installation](https://git.vdb.to/cerc-io/testnet-ops#installation)
* Clone the `cerc-io/testnet-ops` repository:
* yq: see [installation](https://github.com/mikefarah/yq#install)
```bash
git clone git@git.vdb.to:cerc-io/testnet-ops.git
```
* Check versions to verify installation:
* Ansible: see [installation](https://git.vdb.to/cerc-io/testnet-ops#installation)
```bash
laconic-so version
* On deployment machine:
ansible --version
yq --version
```
* laconic-so: see [installation](https://git.vdb.to/cerc-io/testnet-ops/src/branch/main/stack-orchestrator-setup/README.md#setup-stack-orchestrator)
## Setup
* Clone the `cerc-io/testnet-ops` repository:
* Move to `nitro-nodes-setup` :
```bash
git clone git@git.vdb.to:cerc-io/testnet-ops.git
cd testnet-ops/nitro-node-setup
cd testnet-ops/nitro-nodes-setup
```
* Fetch the required Nitro node config:
@@ -35,13 +31,12 @@
# Expected variables in the fetched config file:
# nitro_l1_chain_url: ""
# nitro_l2_chain_url: ""
# nitro_chain_url: ""
# na_address: ""
# ca_address: ""
# vpa_address: ""
# l1_asset_address: ""
# bridge_contract_address: ""
# asset_address: ""
# nitro_chain_start_block: 0
# bridge_nitro_address: ""
# nitro_l1_bridge_multiaddr: ""
# nitro_l2_bridge_multiaddr: ""
@@ -76,7 +71,7 @@
* Update the target dir in `setup-vars.yml`:
```bash
# Set path to desired deployments dir
# Set path to desired deployments dir (under your user)
DEPLOYMENTS_DIR=<path-to-deployments-dir>
sed -i "s|^nitro_directory:.*|nitro_directory: $DEPLOYMENTS_DIR/nitro-node|" setup-vars.yml
@@ -84,7 +79,11 @@
# Will create deployments at $DEPLOYMENTS_DIR/nitro-node/l1-nitro-deployment and $DEPLOYMENTS_DIR/nitro-node/l2-nitro-deployment
```
## Run
## 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:
@@ -92,30 +91,101 @@
LANG=en_US.utf8 ansible-playbook -i localhost, --connection=local run-nitro-nodes.yml --extra-vars='{ "target_host": "localhost"}' --user $USER
```
* Check status:
### On Remote Host
* In `testnet-ops/nitro-nodes-setup`, create a new `hosts.ini` file:
```bash
cp ../hosts.example.ini hosts.ini
```
* Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine:
```ini
[<deployment_host>]
<host_name> ansible_host=<target_ip> ansible_user=<ssh_user> ansible_ssh_common_args='-o ForwardAgent=yes'
```
* 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)
* Verify that you are able to connect to the host using the following command
```bash
ansible all -m ping -i hosts.ini -k
# If using password based authentication, enter the ssh password on prompt; otherwise, leave it blank
# Expected output:
# <host_name> | SUCCESS => {
# "ansible_facts": {
# "discovered_interpreter_python": "/usr/bin/python3.10"
# },
# "changed": false,
# "ping": "pong"
# }
```
* Execute the `run-nitro-nodes.yml` Ansible playbook for remote deployment:
```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
```
### Check Deployment Status
* Run the following commands on deployment machine:
```bash
DEPLOYMENTS_DIR=<path-to-deployments-dir>
cd $DEPLOYMENTS_DIR/nitro-node
# Check the logs, ensure that the nodes are running
laconic-so deployment --dir l1-nitro-deployment logs nitro-node -f
laconic-so deployment --dir l2-nitro-deployment logs nitro-node -f
# Let L1 node sync up with the chain
# Expected logs after sync:
# nitro-node-1 | 2:04PM INF Initializing Http RPC transport...
# nitro-node-1 | 2:04PM INF Completed RPC server initialization url=127.0.0.1:4005/api/v1
```
* 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"
# Expected output:
# {
# "SCAddress": "0xd0eA8b27591b1D070cCcD4D30b8D408fe794FDfc",
# "MessageServicePeerId": "16Uiu2HAmSHRjoxveaPmJipzmdq69U8zme8BMnFjSBPferj1E5XAd"
# }
# SCAddress -> nitro address, MessageServicePeerId -> libp2p peer id
```
## Create Channels
* Create a ledger channel with the bridge on L1 that gets mirrored on L2
Create a ledger channel with the bridge on L1 which is mirrored on L2
* Run the following commands on deployment machine
* Set required variables:
```bash
DEPLOYMENTS_DIR=<path-to-deployments-dir>
cd $DEPLOYMENTS_DIR/nitro-node
# Fetch the required Nitro node config
wget https://git.vdb.to/cerc-io/testnet-laconicd-stack/raw/branch/main/ops/stage2/nitro-node-config.yml
export BRIDGE_NITRO_ADDRESS=$(yq eval '.bridge_nitro_address' nitro-node-config.yml)
export L1_ASSET_ADDRESS=$(yq eval '.l1_asset_address' nitro-node-config.yml)
export ASSET_ADDRESS=$(yq eval '.asset_address' nitro-node-config.yml)
```
* Check that check that you have no existing channels on L1 or L2:
@@ -134,7 +204,7 @@
# Set amount to ledger
LEDGER_AMOUNT=1000000
laconic-so deployment --dir l1-nitro-deployment exec nitro-rpc-client "nitro-rpc-client direct-fund $BRIDGE_NITRO_ADDRESS --assetAddress $L1_ASSET_ADDRESS --alphaAmount $LEDGER_AMOUNT --betaAmount $LEDGER_AMOUNT -p 4005 -h nitro-node"
laconic-so deployment --dir l1-nitro-deployment exec nitro-rpc-client "nitro-rpc-client direct-fund $BRIDGE_NITRO_ADDRESS --assetAddress $ASSET_ADDRESS --alphaAmount $LEDGER_AMOUNT --betaAmount $LEDGER_AMOUNT -p 4005 -h nitro-node"
# Follow your L1 Nitro node logs for progress
@@ -202,6 +272,150 @@
# ]
```
## Payments On L2 Channel
Perform payments using a virtual payment channel created with another Nitro node over the mirrored L2 channel with bridge as an intermediary
* Run the following commands on deployment machine
* Switch to the `nitro-node` directory:
```bash
DEPLOYMENTS_DIR=<path-to-deployments-dir>
cd $DEPLOYMENTS_DIR/nitro-node
```
* Check status of the mirrored channel on L2:
```bash
laconic-so deployment --dir l2-nitro-deployment exec nitro-rpc-client "nitro-rpc-client get-all-ledger-channels -p 4005 -h nitro-node"
# Expected output:
# [
# {
# "ID": "0x6a9f5ccf1fa802525d794f4a899897f947615f6acc7141e61e056a8bfca29179",
# "Status": "Open",
# "Balance": {
# "AssetAddress": "<l2-asset-address>",
# "Me": "<your-nitro-address>",
# "Them": "<bridge-nitro-address>",
# "MyBalance": Xn,
# "TheirBalance": Yn
# },
# "ChannelMode": "Open"
# }
# ]
```
* Set required variables:
```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>
# Amount to create the payment channel with
export PAYMENT_CHANNEL_AMOUNT=10000
```
* Check for existing payment channels for the L2 channel:
```bash
laconic-so deployment --dir l2-nitro-deployment exec nitro-rpc-client "nitro-rpc-client get-payment-channels-by-ledger $L2_CHANNEL_ID -p 4005 -h nitro-node"
```
* Create a virtual payment channel:
```bash
laconic-so deployment --dir l2-nitro-deployment exec nitro-rpc-client "nitro-rpc-client virtual-fund $COUNTER_PARTY_ADDRESS $BRIDGE_NITRO_ADDRESS --amount $PAYMENT_CHANNEL_AMOUNT -p 4005 -h nitro-node"
# Follow your L2 Nitro node logs for progress
# Expected Output:
# Objective started VirtualFund-0x43db45a101658387263b36d613322cc952d8ce5b70de51e3a495513c256bef4d
# Channel Open 0x43db45a101658387263b36d613322cc952d8ce5b70de51e3a495513c256bef4d
# Set the resulting payment channel id in a variable
PAYMENT_CHANNEL_ID=<payment-channel-id>
```
Multiple virtual payment channels can be created at once
* Check the payment channel's status:
```bash
laconic-so deployment --dir l2-nitro-deployment exec nitro-rpc-client "nitro-rpc-client get-payment-channel $PAYMENT_CHANNEL_ID -p 4005 -h nitro-node"
# Expected output:
# {
# ID: '0xb29aeb32c9495a793ebf7bd116232075d1e7bfe89fc82281c7d498e3ffd3e3bf',
# Status: 'Open',
# Balance: {
# AssetAddress: '0x0000000000000000000000000000000000000000',
# Payee: '<your-nitro-address>',
# Payer: '<counterparty-nitro-address>',
# PaidSoFar: 0n,
# RemainingFunds: <payment-channel-amount>n
# }
# }
```
* Send payments using the virtual payment channel:
```bash
export PAY_AMOUNT=200
laconic-so deployment --dir l2-nitro-deployment exec nitro-rpc-client "nitro-rpc-client pay $PAYMENT_CHANNEL_ID $PAY_AMOUNT -p 4005 -h nitro-node"
# Expected output
# {
# Amount: <pay-amount>,
# Channel: '<payment-channel-id>'
# }
# This can be done multiple times until the payment channel balance is exhausted
```
* Check payment channel's status again to view updated channel state
* Close the payment channel to settle on the L2 mirrored channel:
```bash
laconic-so deployment --dir l2-nitro-deployment exec nitro-rpc-client "nitro-rpc-client virtual-defund $PAYMENT_CHANNEL_ID -p 4005 -h nitro-node"
# Expected output:
# Objective started VirtualDefund-0x43db45a101658387263b36d613322cc952d8ce5b70de51e3a495513c256bef4d
# Channel complete 0x43db45a101658387263b36d613322cc952d8ce5b70de51e3a495513c256bef4d
```
* Check L2 mirrored channel's status after the virtual payment channel is closed:
```bash
laconic-so deployment --dir l2-nitro-deployment exec nitro-rpc-client "nitro-rpc-client get-all-ledger-channels -p 4005 -h nitro-node"
# Expected output:
# [
# {
# "ID": "0x6a9f5ccf1fa802525d794f4a899897f947615f6acc7141e61e056a8bfca29179",
# "Status": "Open",
# "Balance": {
# "AssetAddress": "<l2-asset-address>",
# "Me": "<your-nitro-address>",
# "Them": "<bridge-nitro-address>",
# "MyBalance": <your-updated-balance>n,
# "TheirBalance": <bridge-updated-balance>n
# },
# "ChannelMode": "Open"
# }
# ]
```
Your balance on the L2 channel should be reduced by total payments done on the virtual payment channel
## Clean up
* Switch to deployments dir:
+2 -2
View File
@@ -879,7 +879,7 @@
- Open new terminal, check that no channels exist on L2
```bash
laconic-so deployment --dir bridge-deployment exec nitro-rpc-client "nitro-rpc-client get-all-l2-channels -p 4006 -h nitro-bridge"
laconic-so deployment --dir bridge-deployment exec nitro-rpc-client "nitro-rpc-client get-all-l2-channels -p 4005 -h nitro-bridge"
```
- Set address of bridge and address of custom token on L1 in the current terminal
@@ -952,7 +952,7 @@
- Check status of all L2 mirrored ledger channels
```bash
laconic-so deployment --dir bridge-deployment exec nitro-rpc-client "nitro-rpc-client get-all-l2-channels -p 4006 -h nitro-bridge"
laconic-so deployment --dir bridge-deployment exec nitro-rpc-client "nitro-rpc-client get-all-l2-channels -p 4005 -h nitro-bridge"
# Expected output:
# {"ID":"0x15dbe6b996e4e46fdd6ea3e2074cbca58014dbb07368e3e7ba286df5c7b9da0d","Status":"Open","Balance":{"AssetAddress":"<Token_address_on_L2>","Me":"0xbbb676f9cff8d242e9eac39d063848807d3d1d94","Them":"0xa8d2d06ace9c7ffc24ee785c2695678aecdfd7a0","MyBalance":1000000,"TheirBalance":1000000},"ChannelMode":"Open"}