Populate bridge and nitro node config values during deployment creation

This commit is contained in:
IshaVenikar 2024-07-19 14:58:15 +05:30
parent 9e178ab728
commit 4939be4368

View File

@ -315,7 +315,7 @@
1. Clone the stack repos:
```bash
laconic-so fetch-stack git.vdb.to/cerc-io/bridge --git-ssh --pull
laconic-so fetch-stack git.vdb.to/cerc-io/nitro-stack --git-ssh --pull
```
2. Clone required repositories:
@ -339,29 +339,16 @@
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge deploy init --output bridge-nitro-spec.yml
```
- Edit `network` in the spec file to map container ports to host ports as required:
- For port calibration to map container ports to host ports:
```bash
# bridge-nitro-spec.yml
...
network:
ports:
go-nitro:
- 3005:3005
- 3006:3006
- 4006:4006
```
- For port calibration
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy init --map-ports-to-host any-same --output bridge-nitro-spec.yml
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge deploy init --map-ports-to-host any-same --output bridge-nitro-spec.yml
```
- Create a deployment from the spec file:
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy create --spec-file bridge-nitro-spec.yml --deployment-dir bridge-nitro-deployment
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/bridge deploy create --spec-file bridge-nitro-spec.yml --deployment-dir bridge-nitro-deployment
```
#### Nitro-node Stack
@ -405,12 +392,6 @@
- 4007:4005
```
- Create a deployment from the spec file:
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy create --spec-file l1alice-nitro-spec.yml --deployment-dir l1alice-nitro-deployment
```
5. Create a deployment for Charlie's L1 nitro-node:
- Create spec file for the deployment:
@ -430,12 +411,6 @@
- 4008:4005
```
- Create deployment from the spec files:
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy create --spec-file l1charlie-nitro-spec.yml --deployment-dir l1charlie-nitro-deployment
```
6. Create a deployment for Alice's L2 nitro-node:
- Create spec files for the deployment:
@ -455,12 +430,6 @@
- 4009:4005
```
- Create a deployment from the spec file:
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy create --spec-file l2alice-nitro-spec.yml --deployment-dir l2alice-nitro-deployment
```
7. Create a deployment for Charlie's L2 nitro-node:
- Create spec file for the deployment:
@ -480,12 +449,6 @@
- 4010:4005
```
- Create deployment from the spec files:
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy create --spec-file l2charlie-nitro-spec.yml --deployment-dir l2charlie-nitro-deployment
```
## Run
- Start L1, L2 stacks:
@ -683,6 +646,14 @@
CERC_NITRO_CHAIN_PK=888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218
CERC_NITRO_SC_PK=0279651921cd800ac560c21ceea27aab0107b67daf436cdd25ce84cad30159b4
CERC_GETH_URL=http://host.docker.internal:8545
CERC_OPTIMISM_URL=http://host.docker.internal:9545
CERC_GETH_DEPLOYER_PK=888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218
CERC_OPTIMISM_DEPLOYER_PK=888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218
CERC_TOKEN_NAME=LaconicNetworkToken
CERC_TOKEN_SYMBOL=LNT
CERC_INITIAL_TOKEN_SUPPLY=10000000
```
- Start testnet-onboarding-app (run command in testnet-onboarding-app repo)
@ -766,178 +737,129 @@
- In the wallet, add 2 accounts (Alice and Charlie) for both the networks (ethereum and laconicd) by selecting the network and clicking on `Add account`
- Go to go-nitro repo root and start the nitro bridge using CLI:
- Start the nitro bridge
```bash
# Export contract addresses stored in output files
source ./packages/nitro-protocol/hardhat-deployments/geth/.contracts.env
source ./packages/nitro-protocol/hardhat-deployments/optimism/.contracts.env
laconic-so deployment --dir bridge-nitro-deployment start
# Start bridge CLI
./nitro-bridge -config cmd/test-configs/bridge.toml
```
# Check the logs, ensure that the node is running
laconic-so deployment --dir bridge-nitro-deployment logs laconicd -f
```
- Get Ethereum private keys for accounts Alice and Charlie from `laconic-wallet` (to be used as statechannel PKs)
- Prepare deployments for the nodes
- **Note**: Enter PKs without the leading `0x`
- Set the env variables for L1 Alice's nitro-node:
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy \
--config CERC_NITRO_CHAIN_URL=ws://host.docker.internal:8546, \
CERC_NITRO_SC_PK=<Private key of Alice>, \
CERC_NITRO_CHAIN_PK=570b909da9669b2f35a0b1ac70b8358516d55ae1b5b3710e95e9a94395090597, \
CERC_NA_ADDRESS=0xb2592723B09F42937543f199A305ea6576dCb506, \
CERC_VPA_ADDRESS=0x198c6643f7750c2569C3468E16750a8E8504E2c7, \
CERC_CA_ADDRESS=0x198A8F1F14ACe1662fB2E5BE63A1de2308DE4CC7, \
CERC_BRIDGE_ADDRESS=, \
CERC_NITRO_BOOTPEERS=/ip4/127.0.0.1/tcp/3005/p2p/16Uiu2HAmJDxLM8rSybX78FH51iZq9PdrwCoCyyHRBCndNzcAYMes
```
- Create a deployment from the spec file
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy create --spec-file l1alice-nitro-spec.yml --deployment-dir l1alice-nitro-deployment
```
- Set the env variables for L1 Charlie's nitro-node:
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy \
--config CERC_NITRO_CHAIN_URL=ws://host.docker.internal:8546, \
CERC_NITRO_SC_PK=<Private key of Charlie>, \
CERC_NITRO_CHAIN_PK=570b909da9669b2f35a0b1ac70b8358516d55ae1b5b3710e95e9a94395090597, \
CERC_NA_ADDRESS=0xb2592723B09F42937543f199A305ea6576dCb506, \
CERC_VPA_ADDRESS=0x198c6643f7750c2569C3468E16750a8E8504E2c7, \
CERC_CA_ADDRESS=0x198A8F1F14ACe1662fB2E5BE63A1de2308DE4CC7, \
CERC_BRIDGE_ADDRESS=, \
CERC_NITRO_BOOTPEERS=/ip4/127.0.0.1/tcp/3005/p2p/16Uiu2HAmJDxLM8rSybX78FH51iZq9PdrwCoCyyHRBCndNzcAYMes
```
- Create a deployment `l1charlie-nitro-deployment` from the spec file
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy create --spec-file l1charlie-nitro-spec.yml --deployment-dir l1charlie-nitro-deployment
```
- Set the env variables for L2 Alice's nitro-node:
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy \
--config CERC_NITRO_CHAIN_URL=ws://host.docker.internal:9546, \
CERC_NITRO_SC_PK=<Private key of Alice>, \
CERC_NITRO_CHAIN_PK=111b7500bdce494d6f4bcfe8c2a0dde2ef92f751d9070fac6475dbd6d8021b3f, \
CERC_NITRO_MSG_PORT=3008, \
CERC_NITRO_RPC_PORT=4008, \
CERC_NA_ADDRESS=0xb2592723B09F42937543f199A305ea6576dCb506, \
CERC_VPA_ADDRESS=0x198c6643f7750c2569C3468E16750a8E8504E2c7, \
CERC_CA_ADDRESS=0x198A8F1F14ACe1662fB2E5BE63A1de2308DE4CC7, \
CERC_BRIDGE_ADDRESS=, \
CERC_NITRO_BOOTPEERS=/ip4/127.0.0.1/tcp/3006/p2p/16Uiu2HAmJDxLM8rSybX78FH51iZq9PdrwCoCyyHRBCndNzcAYMes, \
CERC_NITRO_L2=true
```
- Create a deployment from the spec file:
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy create --spec-file l2alice-nitro-spec.yml --deployment-dir l2alice-nitro-deployment
```
- Set the env variables for L2 Charlie's nitro-node:
<!-- TO -->
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy \
--config CERC_NITRO_CHAIN_URL=ws://host.docker.internal:9546, \
CERC_NITRO_SC_PK=<Private key of Charlie>, \
CERC_NITRO_CHAIN_PK=111b7500bdce494d6f4bcfe8c2a0dde2ef92f751d9070fac6475dbd6d8021b3f, \
CERC_NITRO_MSG_PORT=3010, \
CERC_NITRO_RPC_PORT=4010, \
CERC_NA_ADDRESS=0xb2592723B09F42937543f199A305ea6576dCb506, \
CERC_VPA_ADDRESS=0x198c6643f7750c2569C3468E16750a8E8504E2c7, \
CERC_CA_ADDRESS=0x198A8F1F14ACe1662fB2E5BE63A1de2308DE4CC7, \
CERC_BRIDGE_ADDRESS=, \
CERC_NITRO_BOOTPEERS=/ip4/127.0.0.1/tcp/3006/p2p/16Uiu2HAmJDxLM8rSybX78FH51iZq9PdrwCoCyyHRBCndNzcAYMes, \
CERC_NITRO_L2=true
```
- Create deployment from the spec files:
```bash
laconic-so --stack ~/cerc/nitro-stack/stack-orchestrator/stacks/nitro-node deploy create --spec-file l2charlie-nitro-spec.yml --deployment-dir l2charlie-nitro-deployment
```
- Start nitro nodes for Alice and Charlie on L1 and L2:
- Prepare config files for the nodes
- **Note**: Enter PKs without the leading `0x`
- In `l1alice-nitro-deployment/config.env` file, set the following env variable:
```bash
# URL endpoint of the chain
CERC_NITRO_CHAIN_URL=ws://host.docker.internal:8546
# Private key of account to be used by Nitro node (derived address is used as Nitro address)
# Note: Enter PKs without the leading `0x`
CERC_NITRO_SC_PK="<Private key of Alice>"
# Private key of the account on chain that is used for funding channels in Nitro node
CERC_NITRO_CHAIN_PK=570b909da9669b2f35a0b1ac70b8358516d55ae1b5b3710e95e9a94395090597
# Optional
# Contract addresses of NitroAdjudicator, VirtualPaymentApp and ConsensusApp
# TODO: Contracts are deployed if addresses are not set
# TODO: Fetch contract address from bridge stack
CERC_NA_ADDRESS=0xb2592723B09F42937543f199A305ea6576dCb506
CERC_VPA_ADDRESS=0x198c6643f7750c2569C3468E16750a8E8504E2c7
CERC_CA_ADDRESS=0x198A8F1F14ACe1662fB2E5BE63A1de2308DE4CC7
# Public IP of the nitro-node
CERC_NITRO_BOOTPEERS=/ip4/127.0.0.1/tcp/3005/p2p/16Uiu2HAmJDxLM8rSybX78FH51iZq9PdrwCoCyyHRBCndNzcAYMes
```
- In `l2alice-nitro-deployment/config.env` file, set the following env variable:
```bash
# URL endpoint of the chain
CERC_NITRO_CHAIN_URL=ws://host.docker.internal:9546
# Private key of account to be used by Nitro node (derived address is used as Nitro address)
# Note: Enter PKs without the leading `0x`
CERC_NITRO_SC_PK="<Private key of Alice>"
# Private key of the account on chain that is used for funding channels in Nitro node
CERC_NITRO_CHAIN_PK=570b909da9669b2f35a0b1ac70b8358516d55ae1b5b3710e95e9a94395090597
# Port to be used by P2P message service
CERC_NITRO_MSG_PORT=3008
# Port to be used by RPC server
CERC_NITRO_RPC_PORT=4008
# Optional
# Contract addresses of NitroAdjudicator, VirtualPaymentApp and ConsensusApp
# TODO: Contracts are deployed if addresses are not set
# TODO: Fetch contract address from bridge stack
CERC_NA_ADDRESS=0xb2592723B09F42937543f199A305ea6576dCb506
CERC_VPA_ADDRESS=0x198c6643f7750c2569C3468E16750a8E8504E2c7
CERC_CA_ADDRESS=0x198A8F1F14ACe1662fB2E5BE63A1de2308DE4CC7
# Public IP of the nitro-node
CERC_NITRO_BOOTPEERS=/ip4/127.0.0.1/tcp/3006/p2p/16Uiu2HAmJDxLM8rSybX78FH51iZq9PdrwCoCyyHRBCndNzcAYMes
CERC_NITRO_L2=true
```
- In `l1charlie-nitro-deployment/config.env` file, set the following env variable:
```bash
# URL endpoint of the chain
CERC_NITRO_CHAIN_URL=ws://host.docker.internal:8546
# Private key of account to be used by Nitro node (derived address is used as Nitro address)
# Note: Enter PKs without the leading `0x`
CERC_NITRO_SC_PK="<Private key of Charlie>"
# Private key of the account on chain that is used for funding channels in Nitro node
CERC_NITRO_CHAIN_PK=111b7500bdce494d6f4bcfe8c2a0dde2ef92f751d9070fac6475dbd6d8021b3f
# Port to be used by P2P message service
CERC_NITRO_MSG_PORT=3009
# Port to be used by RPC server
CERC_NITRO_RPC_PORT=4009
# Optional
# Contract addresses of NitroAdjudicator, VirtualPaymentApp and ConsensusApp
# TODO: Fetch contract address from bridge stack
# TODO: Contracts are deployed if addresses are not set
CERC_NA_ADDRESS=0xb2592723B09F42937543f199A305ea6576dCb506
CERC_VPA_ADDRESS=0x198c6643f7750c2569C3468E16750a8E8504E2c7
CERC_CA_ADDRESS=0x198A8F1F14ACe1662fB2E5BE63A1de2308DE4CC7
# Public IP of the nitro-node
CERC_NITRO_BOOTPEERS=/ip4/127.0.0.1/tcp/3005/p2p/16Uiu2HAmJDxLM8rSybX78FH51iZq9PdrwCoCyyHRBCndNzcAYMes
```
- In `l2charlie-nitro-deployment/config.env` file, set the following env variable:
```bash
# URL endpoint of the chain
CERC_NITRO_CHAIN_URL=ws://host.docker.internal:9546
# Private key of account to be used by Nitro node (derived address is used as Nitro address)
# Note: Enter PKs without the leading `0x`
CERC_NITRO_SC_PK="<Private key of Charlie>"
# Private key of the account on chain that is used for funding channels in Nitro node
CERC_NITRO_CHAIN_PK=111b7500bdce494d6f4bcfe8c2a0dde2ef92f751d9070fac6475dbd6d8021b3f
# Port to be used by P2P message service
CERC_NITRO_MSG_PORT=3010
# Port to be used by RPC server
CERC_NITRO_RPC_PORT=4010
# Optional
# Contract addresses of NitroAdjudicator, VirtualPaymentApp and ConsensusApp
# TODO: Fetch contract address from bridge stack
# TODO: Contracts are deployed if addresses are not set
CERC_NA_ADDRESS=0xb2592723B09F42937543f199A305ea6576dCb506
CERC_VPA_ADDRESS=0x198c6643f7750c2569C3468E16750a8E8504E2c7
CERC_CA_ADDRESS=0x198A8F1F14ACe1662fB2E5BE63A1de2308DE4CC7
# Public IP of the nitro-node
CERC_NITRO_BOOTPEERS=/ip4/127.0.0.1/tcp/3006/p2p/16Uiu2HAmJDxLM8rSybX78FH51iZq9PdrwCoCyyHRBCndNzcAYMes
CERC_NITRO_L2=true
```
- In a new terminal, go to go-nitro repo root and initialize node A on L1
- Start the deployements for L1 Alice's node
```bash
# Export L1 contract addresses
source ./packages/nitro-protocol/hardhat-deployments/geth/.contracts.env
./go-nitro -config cmd/test-configs/l1alice.toml -naaddress $NA_ADDRESS -vpaaddress $VPA_ADDRESS -caaddress $CA_ADDRESS
laconic-so deployment --dir l1alice-nitro-deployment start
```
- In another terminal, initialize node A' on L2
- Start the deployements for L1 Charlie's node
```bash
# Export contract addresses stored in output files
source ./packages/nitro-protocol/hardhat-deployments/geth/.contracts.env
source ./packages/nitro-protocol/hardhat-deployments/optimism/.contracts.env
./go-nitro -config cmd/test-configs/l2alice.toml -bridgeaddress $BRIDGE_ADDRESS -vpaaddress $VPA_ADDRESS -caaddress $CA_ADDRESS
laconic-so deployment --dir l1charlie-nitro-deployment start
```
- In another terminal, initialize node C on L1:
- Start the deployements for L2 Alice's node
```bash
# Export L1 contract addresses
source ./packages/nitro-protocol/hardhat-deployments/geth/.contracts.env
./go-nitro -config cmd/test-configs/l1charlie.toml -naaddress $NA_ADDRESS -vpaaddress $VPA_ADDRESS -caaddress $CA_ADDRESS
laconic-so deployment --dir l2alice-nitro-deployment start
```
- In another terminal, initialize node C' on L2
- Start the deployements for L2 Charlie's node
```bash
# Export contract addresses stored in output files
source ./packages/nitro-protocol/hardhat-deployments/geth/.contracts.env
source ./packages/nitro-protocol/hardhat-deployments/optimism/.contracts.env
./go-nitro -config cmd/test-configs/l2charlie.toml -bridgeaddress $BRIDGE_ADDRESS -vpaaddress $VPA_ADDRESS -caaddress $CA_ADDRESS
laconic-so deployment --dir l2charlie-nitro-deployment start
```
- Create ledger channels on L1 and mirrored channel on L2s