Add demo to run bridge with nitro nodes on L1 and L2 #4

Merged
nabarun merged 4 commits from iv-update-stack-steps into main 2024-08-22 10:51:43 +00:00
Showing only changes of commit 694dec8b4f - Show all commits

View File

@ -577,16 +577,200 @@
- Charlie is participant since `Them` address is `0xaaa6628ec44a8a742987ef3a114ddfe2d4f7adce`
- Charlie amount is `1000000` since `TheirBalance` corresponds to his amount
## Exit to L1 from mirrored channel
### Payments Demo in L2
- Close Alice's Bridge channel
- Create virtual channel on L2 from A' to C' via Bridge' as intermediary
- Get Nitro (Ethereum) addresses for Alice and Charlie from the wallet:
```bash
laconic-so deployment --dir l2alice-nitro-deployment exec nitro-rpc-client "nitro-rpc-client bridged-defund <Alice L2 ledger channel Id> -p 4009"
export A_ADDRESS=<Alice Nitro address>
export C_ADDRESS=<Charlie Nitro address>
# Bridge's Nitro address
export BRIDGE_NITRO_ADDRESS=0xBBB676f9cFF8D242e9eaC39D063848807d3D1D94
```
- Close Charlie's Bridge channel
- Create a virtual channel:
```bash
laconic-so deployment --dir l2charlie-nitro-deployment exec nitro-rpc-client "nitro-rpc-client bridged-defund <Charlie L2 ledger channel Id> -p 4010"
# Starts virtual fund objective on L2 to create virtual channel from A' to C'
laconic-so deployment --dir l2alice-nitro-deployment exec nitro-rpc-client "nitro-rpc-client virtual-fund $C_ADDRESS $BRIDGE_NITRO_ADDRESS --amount 1000 -p 4005 -h nitro-node"
# Set the payment channel id in a variable
PAYMENT_CHANNEL_ID=<payment channel id>
```
- Check payment channel between A' and C'
```bash
laconic-so deployment --dir l2alice-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: '0xa8d2d06ace9c7ffc24ee785c2695678aecdfd7a0',
# Payer: '0xaaa6628ec44a8a742987ef3a114ddfe2d4f7adce',
# PaidSoFar: 0n,
# RemainingFunds: 1000n
# }
# }
```
- After virtual fund objective is complete, make payments
```bash
laconic-so deployment --dir l2alice-nitro-deployment exec nitro-rpc-client "nitro-rpc-client pay $PAYMENT_CHANNEL_ID 200 -p 4005 -h nitro-node"
# Expected output:
# {
# Amount: 200,
# Channel: '0xb29aeb32c9495a793ebf7bd116232075d1e7bfe89fc82281c7d498e3ffd3e3bf'
# }
```
- Check payment channel status again to view updated channel state
- Close payment channel after payments
```bash
laconic-so deployment --dir l2alice-nitro-deployment exec nitro-rpc-client "nitro-rpc-client virtual-defund $PAYMENT_CHANNEL_ID -p 4005 -h nitro-node"
```
- Check L2 mirrored channels status after virtual-defund is complete:
- Note balance change in A' node:
```bash
laconic-so deployment --dir l2alice-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":"<Token_address_on_L2>","Me":"0xaaa6628ec44a8a742987ef3a114ddfe2d4f7adce","Them":"0xbbb676f9cff8d242e9eac39d063848807d3d1d94","MyBalance":999800,"TheirBalance":1000200},"ChannelMode":"Open"}
```
- Note balance change in C' node:
```bash
laconic-so deployment --dir l2charlie-nitro-deployment exec nitro-rpc-client "nitro-rpc-client get-all-ledger-channels -p 4005 -h nitro-node"
# Expected output:
# {"ID":"0x15dbe6b996e4e46fdd6ea3e2074cbca58014dbb07368e3e7ba286df5c7b9da0d","Status":"Open","Balance":{"AssetAddress":"<Token_address_on_L2>","Me":"0xa8d2d06ace9c7ffc24ee785c2695678aecdfd7a0","Them":"0xbbb676f9cff8d242e9eac39d063848807d3d1d94","MyBalance":1000200,"TheirBalance":999800},"ChannelMode":"Open"}
```
## Demo cleanup
- Reset nitro-node deployments:
- Stop nitro-node deployments and remove volumes:
```bash
# Run where deployments are created
laconic-so deployment --dir l1alice-nitro-deployment stop --delete-volumes
laconic-so deployment --dir l1charlie-nitro-deployment stop --delete-volumes
laconic-so deployment --dir l2alice-nitro-deployment stop --delete-volumes
laconic-so deployment --dir l2charlie-nitro-deployment stop --delete-volumes
```
- Clear nitro-node deployments:
```bash
# Run where deployments are created
sudo rm -rf l1alice-nitro-deployment
sudo rm -rf l1charlie-nitro-deployment
sudo rm -rf l2alice-nitro-deployment
sudo rm -rf l2charlie-nitro-deployment
```
## Re-run
- After running demo cleanup, follow the steps from [Demo](#demo) to re-run the demo
## Cleanup
- Reset nitro-node deployments:
- Stop nitro-node deployments and remove volumes:
```bash
# Run where deployments are created
laconic-so deployment --dir l1alice-nitro-deployment stop --delete-volumes
laconic-so deployment --dir l1charlie-nitro-deployment stop --delete-volumes
laconic-so deployment --dir l2alice-nitro-deployment stop --delete-volumes
laconic-so deployment --dir l2charlie-nitro-deployment stop --delete-volumes
laconic-so deployment --dir bridge-deployment stop --delete-volumes
```
- Clear nitro-node and bridge deployments:
```bash
# Run where deployments are created
sudo rm -rf l1alice-nitro-deployment
sudo rm -rf l1charlie-nitro-deployment
sudo rm -rf l2alice-nitro-deployment
sudo rm -rf l2charlie-nitro-deployment
sudo rm -rf bridge-deployment
```
- Clean up L1 and L2 deployments:
- Stop deployment and remove volumes:
```bash
# Run where deployments are created
laconic-so deployment --dir fixturenet-optimism-deployment stop --delete-volumes
laconic-so deployment --dir fixturenet-eth-deployment stop --delete-volumes
```
- Clear deployments:
```bash
# Run where deployments are created
sudo rm -rf fixturenet-optimism-deployment
sudo rm -rf fixturenet-eth-deployment
```
## Troubleshooting
- If the ledger channel creation fails, follow these steps:
- Check whether the status of `cerc/fixturenet-eth-geth` is `unhealthy`.
```bash
docker ps
```
- If the chain is not producing new blocks, restart the chain.
```bash
laconic-so deployment --dir fixturenet-eth-deployment stop
laconic-so deployment --dir fixturenet-eth-deployment start
```
- Stop the nitro-rpc-client direct-fund command if it is stuck
- Restart the failed node (for example: to restart Charlie's node)
- Stop the failed nitro node
```bash
laconic-so deployment --dir l1charlie-nitro-deployment stop
```
- Remove the node's durable store and create it again
```bash
sudo rm -rf l1charlie-nitro-deployment/data/nitro_node_data
mkdir l1charlie-nitro-deployment/data/nitro_node_data
```
- Restart the node and create ledger channel again
```bash
laconic-so deployment --dir l1charlie-nitro-deployment start
```
- Retry the ledger channel creation command