Add instructions for testnet2 deployment ops (#31)

Part of [Create a public laconicd testnet](https://www.notion.so/Create-a-public-laconicd-testnet-896a11bdd8094eff8f1b49c0be0ca3b8)

- Add instructions to setup stage2 laconicd deployment
- Add instructions for stage1 to stage2 migration
- Add a script and instructions for users to upgrade their nodes to testnet stage2

Reviewed-on: #31
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
This commit is contained in:
Prathamesh Musale 2024-10-30 12:05:54 +00:00 committed by nabarun
parent a8ffb987b1
commit eef72ec9c3
12 changed files with 1092 additions and 572 deletions

View File

@ -10,6 +10,7 @@ Stacks to run a node for laconic testnet
- [Update deployments after code changes](./ops/update-deployments.md)
- [Halt stage0 and start stage1](./ops/stage0-to-stage1.md)
- [Halt stage1 and start stage2](./ops/stage1-to-stage2.md)
- [Create deployments from scratch (for reference only)](./ops/deployments-from-scratch.md)
- [Deploy and transfer new tokens for nitro operations](./ops/nitro-token-ops.md)
@ -17,6 +18,10 @@ 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
## SAPO testnet
Follow steps in [Upgrade to SAPO testnet](./testnet-onboarding-validator.md#upgrade-to-sapo-testnet) for upgrading your LORO testnet node to SAPO testnet
## Run testnet Nitro Node
Follow steps in [testnet-nitro-node.md](./testnet-nitro-node.md) to run you Nitro node for the testnet

File diff suppressed because it is too large Load Diff

View File

@ -93,7 +93,7 @@ Once all the participants have completed their onboarding, stage0 laconicd chain
scp dev@<deployments-server-hostname>:/srv/laconicd/stage1-deployment/data/laconicd-data/config/genesis.json </path/to/local/directory>
```
* Now users can follow the steps to [Join as a validator on stage1](https://git.vdb.to/cerc-io/testnet-laconicd-stack/src/branch/main/testnet-onboarding-validator.md#join-as-a-validator-on-stage1)
* Now users can follow the steps to [Join as a validator on stage1](../testnet-onboarding-validator.md#join-as-a-validator-on-stage1)
## Bank Transfer

150
ops/stage1-to-stage2.md Normal file
View File

@ -0,0 +1,150 @@
# Halt stage1 and start stage2
## Login
* Log in as `dev` user on the deployments VM
* All the deployments are placed in the `/srv` directory:
```bash
cd /srv
```
## Halt stage1
* Confirm the the currently running node is for stage1 chain:
```bash
# On stage1 deployment machine
STAGE1_DEPLOYMENT=/srv/laconicd/testnet-laconicd-deployment
laconic-so deployment --dir $STAGE1_DEPLOYMENT logs laconicd -f --tail 30
# Note: stage1 node on deployments VM has been changed to run from /srv/laconicd/testnet-laconicd-deployment instead of /srv/laconicd/stage1-deployment
```
* Stop the stage1 deployment:
```bash
laconic-so deployment --dir $STAGE1_DEPLOYMENT stop
# Stopping this deployment marks the end of testnet stage1
```
## Export stage1 state
* Export the chain state:
```bash
docker run -it \
-v $STAGE1_DEPLOYMENT/data/laconicd-data:/root/.laconicd \
cerc/laconicd-stage1:local bash -c "laconicd export | jq > /root/.laconicd/stage1-state.json"
```
* Archive the state and node config and keys:
```bash
sudo tar -czf /srv/laconicd/stage1-laconicd-export.tar.gz --exclude="./data" --exclude="./tmp" -C $STAGE1_DEPLOYMENT/data/laconicd-data .
sudo chown dev:dev /srv/laconicd/stage1-laconicd-export.tar.gz
```
## Initialize stage2
* Copy over the stage1 state and node export archive to stage2 deployment machine
* Extract the stage1 state and node config to stage2 deployment dir:
```bash
# On stage2 deployment machine
cd /srv/laconicd
# Unarchive
tar -xzf stage1-laconicd-export.tar.gz -C stage2-deployment/data/laconicd-data
# Verify contents
ll stage2-deployment/data/laconicd-data
```
* Initialize stage2 chain:
```bash
DEPLOYMENT_DIR=$(pwd)
cd ~/cerc/fixturenet-laconicd-stack/stack-orchestrator/stacks/fixturenet-laconicd
STAGE2_CHAIN_ID=laconic-testnet-2
./scripts/initialize-stage2.sh $DEPLOYMENT_DIR/stage2-deployment $STAGE2_CHAIN_ID LaconicStage2 os 1000000000000000
# Enter the keyring passphrase for account from stage1 when prompted
cd $DEPLOYMENT_DIR
```
* Resets the node data (`unsafe-reset-all`)
* Initializes the `stage2-deployment` node
* Generates the genesis file for stage2 with stage1 state
* Carries over accounts, balances and laconicd modules from stage1
* Skips staking and validator data
* Copy over the genesis file outside data directory:
```bash
cp stage2-deployment/data/laconicd-data/config/genesis.json stage2-deployment
```
## Start stage2
* Start the stage2 deployment:
```bash
laconic-so deployment --dir stage2-deployment start
```
* Check status of stage2 laconicd:
```bash
# List down the container and check health status
docker ps -a | grep laconicd
# Follow logs for laconicd container, check that new blocks are getting created
laconic-so deployment --dir stage2-deployment logs laconicd -f
```
* Get the node's peer adddress and stage2 genesis file to share with the participants:
* Get the node id:
```bash
echo $(laconic-so deployment --dir stage2-deployment exec laconicd "laconicd cometbft show-node-id")@laconicd-sapo.laconic.com:36656
```
* Get the genesis file:
```bash
scp dev@<deployments-server-hostname>:/srv/laconicd/stage2-deployment/genesis.json </path/to/local/directory>
```
* Now users can follow the steps to [Upgrade to SAPO testnet](../testnet-onboarding-validator.md#upgrade-to-sapo-testnet)
## Bank Transfer
* Transfer tokens to an address:
```bash
cd /srv/laconicd
RECEIVER_ADDRESS=
AMOUNT=
laconic-so deployment --dir stage2-deployment exec laconicd "laconicd tx bank send alice ${RECEIVER_ADDRESS} ${AMOUNT}alnt --from alice --fees 1000alnt"
```
* Check balance:
```bash
laconic-so deployment --dir stage2-deployment exec laconicd "laconicd query bank balances ${RECEIVER_ADDRESS}"
```

View File

@ -0,0 +1,25 @@
#!/bin/bash
# Exit on error
set -e
set -u
NODE_HOME="$HOME/.laconicd"
testnet2_genesis="$NODE_HOME/tmp-testnet2/genesis.json"
if [ ! -f ${testnet2_genesis} ]; then
echo "testnet2 genesis file not found, exiting..."
exit 1
fi
# Remove data but keep keys
laconicd cometbft unsafe-reset-all
# Use provided genesis config
cp $testnet2_genesis $NODE_HOME/config/genesis.json
# Set chain id in config
chain_id=$(jq -r '.chain_id' $testnet2_genesis)
laconicd config set client chain-id $chain_id --home $NODE_HOME
echo "Node data reset and ready for testnet2!"

View File

@ -9,7 +9,8 @@ services:
CERC_LACONICD_USER_KEY: ${CERC_LACONICD_USER_KEY}
CERC_LACONICD_BOND_ID: ${CERC_LACONICD_BOND_ID}
CERC_LACONICD_GAS: ${CERC_LACONICD_GAS:-200000}
CERC_LACONICD_FEES: ${CERC_LACONICD_FEES:-200000alnt}
CERC_LACONICD_FEES: ${CERC_LACONICD_FEES:-200alnt}
CERC_LACONICD_GASPRICE: ${CERC_LACONICD_GASPRICE:-0.001alnt}
volumes:
- ../config/laconic-console/cli/create-config.sh:/app/create-config.sh
- laconic-registry-data:/laconic-registry-data

View File

@ -7,6 +7,7 @@ services:
CERC_MONIKER: ${CERC_MONIKER:-TestnetNode}
CERC_CHAIN_ID: ${CERC_CHAIN_ID:-laconic_9000-1}
CERC_PEERS: ${CERC_PEERS}
MIN_GAS_PRICE: ${MIN_GAS_PRICE:-0.001}
CERC_LOGLEVEL: ${CERC_LOGLEVEL:-info}
volumes:
- laconicd-data:/root/.laconicd

View File

@ -18,6 +18,7 @@ services:
chainId: ${CERC_LACONICD_CHAIN_ID}
gas: ${CERC_LACONICD_GAS}
fees: ${CERC_LACONICD_FEES}
gasPrice: ${CERC_LACONICD_GASPRICE}
EOF
echo "Exported config to $config_file"

View File

@ -21,6 +21,7 @@ echo "Env:"
echo "Moniker: $CERC_MONIKER"
echo "Chain Id: $CERC_CHAIN_ID"
echo "Persistent peers: $CERC_PEERS"
echo "Min gas price: $MIN_GAS_PRICE"
echo "Log level: $CERC_LOGLEVEL"
NODE_HOME=/root/.laconicd
@ -40,12 +41,16 @@ else
echo "Node data dir $NODE_HOME/data already exists, skipping initialization..."
fi
# Enable cors
sed -i 's/cors_allowed_origins.*$/cors_allowed_origins = ["*"]/' $HOME/.laconicd/config/config.toml
# Update config with persistent peers
sed -i "s/^persistent_peers *=.*/persistent_peers = \"$CERC_PEERS\"/g" $NODE_HOME/config/config.toml
echo "Starting laconicd node..."
laconicd start \
--api.enable \
--minimum-gas-prices=${MIN_GAS_PRICE}alnt \
--rpc.laddr="tcp://0.0.0.0:26657" \
--gql-playground --gql-server \
--log_level $CERC_LOGLEVEL \

View File

@ -83,9 +83,14 @@ Instructions for running laconic registry CLI and console
# Gas limit for txs (default: 200000)
CERC_LACONICD_GAS=
# Max fees for txs (default: 200000alnt)
# Max fees for txs (default: 200alnt)
CERC_LACONICD_FEES=
# Gas price to use for txs (default: 0.001alnt)
# Use for auto fees calculation, gas and fees not required to be set in that case
# Reference: https://git.vdb.to/cerc-io/laconic-registry-cli#gas-and-fees
CERC_LACONICD_GASPRICE=
# Console configuration
# Laconicd (hosted) GQL endpoint (default: http://localhost:9473)

View File

@ -122,6 +122,9 @@ Instructions for running a laconicd testnet full node and joining as a validator
# Output log level (default: info)
CERC_LOGLEVEL=
# Minimum gas price in alnt to accept for transactions (default: "0.001")
MIN_GAS_PRICE
```
* Inside the `laconic-console-deployment` deployment directory, open `config.env` file and set following env variables:
@ -143,9 +146,14 @@ Instructions for running a laconicd testnet full node and joining as a validator
# Gas limit for txs (default: 200000)
CERC_LACONICD_GAS=
# Max fees for txs (default: 200000alnt)
# Max fees for txs (default: 200alnt)
CERC_LACONICD_FEES=
# Gas price to use for txs (default: 0.001alnt)
# Use for auto fees calculation, gas and fees not required to be set in that case
# Reference: https://git.vdb.to/cerc-io/laconic-registry-cli#gas-and-fees
CERC_LACONICD_GASPRICE=
# Console configuration
# Laconicd (hosted) GQL endpoint (default: http://localhost:9473)

View File

@ -63,6 +63,8 @@
```bash
laconic-so fetch-stack git.vdb.to/cerc-io/testnet-laconicd-stack
# See stack documentation stack-orchestrator/stacks/testnet-laconicd/README.md for more details
```
* Clone required repositories:
@ -126,6 +128,8 @@
* Inside the `testnet-laconicd-deployment` deployment directory, open `config.env` file and set following env variables:
```bash
CERC_CHAIN_ID=laconic_9000-1
# Comma separated list of nodes to keep persistent connections to
# Example: "node-1-id@laconicd.laconic.com:26656"
# Use the provided node id
@ -197,12 +201,15 @@ laconic-so deployment --dir testnet-laconicd-deployment start
* From wallet, approve and send transaction to stage1 laconicd chain
<a name="create-validator-using-cli"></a>
* Alternatively, create a validator using the laconicd CLI:
* Import a key pair:
```bash
KEY_NAME=alice
CHAIN_ID=laconic_9000-1
# Restore existing key with mnemonic seed phrase
# You will be prompted to enter mnemonic seed
@ -243,7 +250,7 @@ laconic-so deployment --dir testnet-laconicd-deployment start
```bash
laconic-so deployment --dir testnet-laconicd-deployment exec laconicd "laconicd tx staking create-validator my-validator.json \
--fees 500000alnt \
--chain-id=laconic_9000-1 \
--chain-id=$CHAIN_ID \
--from $KEY_NAME"
```
@ -280,6 +287,109 @@ laconic-so deployment --dir testnet-laconicd-deployment start
sudo rm -r testnet-laconicd-deployment
```
## Upgrade to SAPO testnet
### Prerequisites
* SAPO testnet (testnet2) genesis file and peer node address
* A testnet stage1 node
* For setting up a fresh testnet2 node, follow [Join as a validator](#join-as-a-validator-on-stage1) instead, but use testnet2 chain id (`laconic-testnet-2`)
### Setup
* Stop the stage1 node:
```bash
# In dir where stage1 node deployment (`testnet-laconicd-deployment`) exists
TESTNET_DEPLOYMENT=$(pwd)/testnet-laconicd-deployment
laconic-so deployment --dir testnet-laconicd-deployment stop --delete-volumes
```
* Clone / pull the stack repo:
```bash
laconic-so fetch-stack git.vdb.to/cerc-io/testnet-laconicd-stack --pull
```
* Clone / pull the required repositories:
```bash
laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/testnet-laconicd setup-repositories --pull
# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories and re-run the command
```
Note: Make sure the latest `cerc-io/laconicd` changes have been pulled
* Build the container images:
```bash
laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/testnet-laconicd build-containers --force-rebuild
```
This should create the following docker images locally with latest changes:
* `cerc/laconicd`
### Create a deployment
* The existing stage1 deployment can be used for testnet2
* Copy over the published testnet2 genesis file (`.json`) to data directory in deployment (`testnet-laconicd-deployment/data/laconicd-data/tmp-testnet2`):
```bash
# Example
mkdir -p $TESTNET_DEPLOYMENT/data/laconicd-data/tmp-testnet2
cp genesis.json $TESTNET_DEPLOYMENT/data/laconicd-data/tmp-testnet2/genesis.json
```
* Run script to reset node data and upgrade for testnet2:
```bash
cd ~/cerc/testnet-laconicd-stack
docker run -it \
-v $TESTNET_DEPLOYMENT/data/laconicd-data:/root/.laconicd \
-v ./ops/stage2:/scripts \
cerc/laconicd:local bash -c "/scripts/upgrade-node-to-testnet2.sh"
cd -
```
### Configuration
* Inside the `testnet-laconicd-deployment` deployment directory, open `config.env` file and set following env variables:
```bash
CERC_CHAIN_ID=laconic-testnet-2
# Comma separated list of nodes to keep persistent connections to
# Example: "node-1-id@laconicd-sapo.laconic.com:36656"
# Use the provided node id
CERC_PEERS=""
# A custom human readable name for this node
CERC_MONIKER=
```
### Start the deployment
```bash
laconic-so deployment --dir testnet-laconicd-deployment start
```
See [Check status](#check-status) to follow sync status of your node
See [Join as testnet validator](#create-validator-using-cli) to join as a validator using laconicd CLI (use chain id `laconic-testnet-2`)
### Clean up
* Same as [Clean up](#clean-up)
## Troubleshooting
* If you face any issues in the onboarding app or the web-wallet, clear your browser cache and reload