Add steps to run nitro nodes

This commit is contained in:
Neeraj 2024-08-22 15:23:31 +05:30
parent dd57b1c5bb
commit a5e4d76e55

View File

@ -124,10 +124,11 @@
```
- Deploy nitro contracts
- Create a deployment spec-file for nitro contract:
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-contracts deploy init --output nitro-contracts-spec.yml --config "GETH_URL=http://host.docker.internal:8545,OPTIMISM_URL=http://host.docker.internal:9545,GETH_DEPLOYER_PK=888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218,TOKEN_NAME=LaconicNetworkToken,TOKEN_SYMBOL=LNT,INITIAL_TOKEN_SUPPLY=129600"
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-contracts deploy init --output nitro-contracts-spec.yml --config "GETH_URL=http://host.docker.internal:8545,GETH_DEPLOYER_PK=888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218,TOKEN_NAME=LaconicNetworkToken,TOKEN_SYMBOL=LNT,INITIAL_TOKEN_SUPPLY=129600"
```
- Create a deployment `nitro-contracts` from the spec file
@ -143,4 +144,150 @@
# Check the logs
laconic-so deployment --dir nitro-contracts-deployment logs nitro-contracts -f
```
- Get the deployed nitro contract addresses
```bash
# Nitro contract addresses
export NA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.NitroAdjudicator.address' /app/deployment/nitro-addresses.json")
export CA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.ConsensusApp.address' /app/deployment/nitro-addresses.json")
export VPA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.VirtualPaymentApp.address' /app/deployment/nitro-addresses.json")
export ASSET_ADDRESS="$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"1212\"[0].contracts.Token.address' /app/deployment/nitro-addresses.json")"
```
- Create deployment for Alice:
- Create a deployment spec-file for Alice node:
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy init --output alice-nitro-spec.yml
```
- Edit `network` in the spec file to map container ports to host ports as required:
```bash
# alice-nitro-spec.yml
...
network:
ports:
nitro-node:
- 3007:3005
- 4007:4005
```
- Create a deployment `alice-nitro-deployment` from the spec file
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy create --spec-file alice-nitro-spec.yml --deployment-dir alice-nitro-deployment
```
- Set the env variables for Alice's nitro-node:
```bash
cat <<EOF > alice-nitro-deployment/config.env
NITRO_CHAIN_URL=ws://host.docker.internal:8546
NITRO_SC_PK=0x9aebbd42f3044295411e3631fcb6aa834ed5373a6d3bf368bfa09e5b74f4f6d1
NITRO_CHAIN_PK=570b909da9669b2f35a0b1ac70b8358516d55ae1b5b3710e95e9a94395090597
NA_ADDRESS=$NA_ADDRESS
VPA_ADDRESS=$VPA_ADDRESS
CA_ADDRESS=$CA_ADDRESS
NITRO_EXT_MULTIADDR=/dns4/host.docker.internal/tcp/3007
EOF
```
- Create deployment for Charlie:
- Create a deployment spec-file for Charlie node:
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy init --output charlie-nitro-spec.yml
```
- Edit `network` in the spec file to map container ports to host ports as required:
```bash
# charlie-nitro-spec.yml
...
network:
ports:
nitro-node:
- 3008:3005
- 4008:4005
```
- Create a deployment `charlie-nitro-deployment` from the spec file
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy create --spec-file charlie-nitro-spec.yml --deployment-dir charlie-nitro-deployment
```
- Set the env variables for Charlie's nitro-node:
```bash
cat <<EOF > charlie-nitro-deployment/config.env
NITRO_CHAIN_URL=ws://host.docker.internal:8546
NITRO_SC_PK=0x19242258fc60ec7488db0163b20ed1c32f2d27dc49e4d427a461e20a6656de20
NITRO_CHAIN_PK=111b7500bdce494d6f4bcfe8c2a0dde2ef92f751d9070fac6475dbd6d8021b3f
NA_ADDRESS=$NA_ADDRESS
VPA_ADDRESS=$VPA_ADDRESS
CA_ADDRESS=$CA_ADDRESS
NITRO_BOOTPEERS=/dns4/host.docker.internal/tcp/3007/p2p/16Uiu2HAmVbAtvDW1xrq4gDwRtdTjT1bqVdFJX6eWZbfn174wEENL
NITRO_EXT_MULTIADDR=/dns4/host.docker.internal/tcp/3008
EOF
```
## Demo
- Start nitro nodes
- Start `alice-nitro-deployment` deployment:
```
laconic-so deployment --dir alice-nitro-deployment start
# Check the logs
laconic-so deployment --dir alice-nitro-deployment logs nitro-node -f
```
- Start `charlie-nitro-deployment` deployment:
```
laconic-so deployment --dir charlie-nitro-deployment start
# Check the logs
laconic-so deployment --dir charlie-nitro-deployment logs nitro-node -f
```
## Cleanup
- Reset nitro-node deployments:
- Stop nitro-node deployments and remove volumes:
```bash
# Run where deployments are created
laconic-so deployment --dir alice-nitro-deployment stop --delete-volumes
laconic-so deployment --dir charlie-nitro-deployment stop --delete-volumes
```
- Clear nitro-node and bridge deployments:
```bash
# Run where deployments are created
sudo rm -rf alice-nitro-deployment
sudo rm -rf charlie-nitro-deployment
```
- Clean up fixturenet-eth deployment:
- Stop deployment and remove volumes:
```bash
# Run where deployments are created
laconic-so deployment --dir fixturenet-eth-deployment stop --delete-volumes
```
- Clear deployments:
```bash
# Run where deployments are created
sudo rm -rf fixturenet-eth-deployment
```