From 2039ad645df2df569d396127db6361bd86e6d32d Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Thu, 5 Sep 2024 17:08:25 +0530 Subject: [PATCH] Add instructions for users to create ledger channel --- ops/deployments-from-scratch.md | 8 ++- testnet-nitro-node.md | 117 +++++++++++++++++++++++++++++++- 2 files changed, 120 insertions(+), 5 deletions(-) diff --git a/ops/deployments-from-scratch.md b/ops/deployments-from-scratch.md index d2715aa..96453b5 100644 --- a/ops/deployments-from-scratch.md +++ b/ops/deployments-from-scratch.md @@ -234,10 +234,12 @@ # TODO export BRIDGE_NITRO_ADDRESS= - export L1_BRIDGE_MULTIADDR= - export L2_BRIDGE_MULTIADDR= + export BRIDGE_PEER_ID= - # Create the required config file: + 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" + + # Create the required config file cat < nitro-node-config.yml nitro_l1_chain_url: "wss://sepolia.laconic.com" nitro_l2_chain_url: "wss://optimism.laconic.com" diff --git a/testnet-nitro-node.md b/testnet-nitro-node.md index 3ff45e7..d201370 100644 --- a/testnet-nitro-node.md +++ b/testnet-nitro-node.md @@ -6,12 +6,16 @@ * Ansible: see [installation](https://git.vdb.to/cerc-io/testnet-ops#installation) +* yq: see [installation](https://github.com/mikefarah/yq#install) + * Check versions to verify installation: ```bash laconic-so version ansible --version + + yq --version ``` ## Setup @@ -34,8 +38,9 @@ # nitro_l1_chain_url: "" # nitro_l2_chain_url: "" # na_address: "" - # vpa_address: "" # ca_address: "" + # vpa_address: "" + # l1_asset_address: "" # bridge_contract_address: "" # bridge_nitro_address: "" # nitro_l1_bridge_multiaddr: "" @@ -92,7 +97,115 @@ LANG=en_US.utf8 ansible-playbook -i localhost, --connection=local run-nitro-node.yml --extra-vars='{ "target_host": "localhost", "skip_container_build": true }' --user $USER ``` -### Clean up +* Check status: + + ```bash + cd $DEPLOYMENTS_DIR + + # 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 + ``` + +## Create Channels + +* Create a ledger channel with the bridge on L1 that gets mirrored on L2 + +* Set required variables: + + ```bash + cd $DEPLOYMENTS_DIR + + # 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_contract_address' nitro-node-config.yml) + export L1_ASSET_ADDRESS=$(yq eval '.l1_asset_address' nitro-node-config.yml) + ``` + +* Check that 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" + 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: + # [] + ``` + +* Create a ledger channel between your L1 Nitro node and Bridge with custom asset: + + ```bash + # 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" + + # Follow your L1 Nitro node logs for progress + + # Expected Output: + # Objective started DirectFunding-0x161d289a50222caa781db215bb82a3ede4f557217742245525b8e8cbff04ec21 + # Channel Open 0x161d289a50222caa781db215bb82a3ede4f557217742245525b8e8cbff04ec21 + + # Set the resulting ledger channel id in a variable + export LEDGER_CHANNEL_ID= + ``` + + * Check the [Troubleshooting](#troubleshooting) section if command to create a ledger channel fails or gets stuck + +* Once direct-fund objective is complete, the bridge will create a mirrored channel on L2 + +* Check L2 Nitro node's logs to see that a bridged-fund objective completed: + + ```bash + laconic-so deployment --dir l2-nitro-deployment logs nitro-node -f --tail 30 + + # Expected Output: + # nitro-node-1 | 5:01AM INF INFO Objective cranked address=0xaaa6628ec44a8a742987ef3a114ddfe2d4f7adce objective-id=bridgedfunding-0x6a9f5ccf1fa802525d794f4a899897f947615f6acc7141e61e056a8bfca29179 waiting-for=WaitingForNothing + # nitro-node-1 | 5:01AM INF INFO Objective is complete & returned to API address=0xaaa6628ec44a8a742987ef3a114ddfe2d4f7adce objective-id=bridgedfunding-0x6a9f5ccf1fa802525d794f4a899897f947615f6acc7141e61e056a8bfca29179 + ``` + +* Check status of L1 ledger channel with the bridge using channel id: + + ```bash + laconic-so deployment --dir l1-nitro-deployment exec nitro-rpc-client "nitro-rpc-client get-ledger-channel $LEDGER_CHANNEL_ID -p 4005 -h nitro-node" + + # Expected output: + # { + # ID: '0x161d289a50222caa781db215bb82a3ede4f557217742245525b8e8cbff04ec21', + # Status: 'Open', + # Balance: { + # AssetAddress: '', + # Me: '', + # Them: '', + # MyBalance: 1000000n, + # TheirBalance: 1000000n + # }, + # ChannelMode: 'Open' + # } + ``` + +* 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: '', + # Me: '', + # Them: '', + # MyBalance: 1000000n, + # TheirBalance: 1000000n + # }, + # ChannelMode: 'Open' + # } + ``` + +## Clean up * Switch to deployments dir: