From 9514bb3b2a22aa118a64841626e88d839067c8d0 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Thu, 17 Oct 2024 16:35:58 +0530 Subject: [PATCH 01/17] Add instructions to setup stage2 laconicd deployment --- ops/deployments-from-scratch.md | 109 ++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/ops/deployments-from-scratch.md b/ops/deployments-from-scratch.md index 96a939a..de33eda 100644 --- a/ops/deployments-from-scratch.md +++ b/ops/deployments-from-scratch.md @@ -1533,6 +1533,115 @@ +
+ stage2 laconicd + +## stage2 laconicd + +* Stack: + +* Source repo: + +* Target dir: `/srv/laconicd/stage2-deployment` + +* Cleanup an existing deployment if required: + + ```bash + cd /srv/laconicd + + # Stop the deployment + laconic-so deployment --dir stage2-deployment stop --delete-volumes + + # Remove the deployment dir + sudo rm -rf stage2-deployment + + # Remove the existing spec file + rm stage2-spec.yml + ``` + +### Setup + +* Clone the stack repo: + + ```bash + laconic-so fetch-stack git.vdb.to/cerc-io/fixturenet-laconicd-stack --pull + + # This should clone the fixturenet-laconicd-stack repo at `/home/dev/cerc/fixturenet-laconicd-stack` + ``` + +* Clone required repositories: + + ```bash + laconic-so --stack ~/cerc/fixturenet-laconicd-stack/stack-orchestrator/stacks/fixturenet-laconicd setup-repositories --pull + + # This should clone the laconicd repo at `/home/dev/cerc/laconicd` + ``` + +* Build the stage1 container image (required for exporting stage1 data): + + ```bash + # Checkout to laconicd tag used for stage1 + cd ~/cerc/laconicd + git checkout v0.1.7 + cd - + + # Build + laconic-so --stack ~/cerc/fixturenet-laconicd-stack/stack-orchestrator/stacks/fixturenet-laconicd build-containers --force-rebuild + + # Create required tag + docker tag cerc/laconicd:local cerc/laconicd-stage1:local + ``` + +* Build the stage2 container image: + + ```bash + # Checkout to latest laconicd + cd ~/cerc/laconicd + git checkout main + cd - + + laconic-so --stack ~/cerc/fixturenet-laconicd-stack/stack-orchestrator/stacks/fixturenet-laconicd build-containers --force-rebuild + + # This should create the "cerc/laconicd" Docker image + ``` + +### Deployment + +* Create a spec file for the deployment: + + ```bash + cd /srv/laconicd + + laconic-so --stack ~/cerc/fixturenet-laconicd-stack/stack-orchestrator/stacks/fixturenet-laconicd deploy init --output stage2-spec.yml + ``` + +* Edit network in the spec file to map container ports to host ports: + + ```bash + # stage2-spec.yml + network: + ports: + laconicd: + - '6060' + - '127.0.0.1:26657:26657' + - '26656:26656' + - '127.0.0.1:9473:9473' + - '127.0.0.1:9090:9090' + - '127.0.0.1:1317:1317' + ``` + +* Create a deployment from the spec file: + + ```bash + laconic-so --stack ~/cerc/fixturenet-laconicd-stack/stack-orchestrator/stacks/fixturenet-laconicd deploy create --spec-file stage2-spec.yml --deployment-dir stage2-deployment + ``` + +### Start + +* Follow [stage1-to-stage2.md](./stage1-to-stage2.md) to halt stage1 deployment, initialize the stage2 chain and start stage2 deployment + +
+ ## Domains / Port Mappings ```bash -- 2.45.2 From 88f4d5b8a534c5e68079b8f09b4131a166c2b813 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Thu, 17 Oct 2024 17:23:08 +0530 Subject: [PATCH 02/17] Add instructions for halting testnet stage1 and starting stage2 --- README.md | 1 + ops/stage1-to-stage2.md | 116 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 ops/stage1-to-stage2.md diff --git a/README.md b/README.md index ea70127..2400fed 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/ops/stage1-to-stage2.md b/ops/stage1-to-stage2.md new file mode 100644 index 0000000..0f64ce5 --- /dev/null +++ b/ops/stage1-to-stage2.md @@ -0,0 +1,116 @@ +# 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 + cd /srv/laconicd + + laconic-so deployment --dir stage1-deployment logs laconicd -f --tail 30 + ``` + +* Stop the stage1 deployment: + + ```bash + laconic-so deployment --dir stage1-deployment stop + + # Stopping this deployment marks the end of testnet stage1 + ``` + +## Initialize stage2 + +* Copy over the `stage1-deployment` dir to stage2 deployment machine + +* Copy over the stage1 node data to stage2 deployment dir: + + ```bash + # On stage2 deployment machine + cd /srv/laconicd + + STAGE1_DEPLOYMENT= + cp -r $STAGE1_DEPLOYMENT/data/laconicd-data stage2-deployment/data + ``` + +* Initialize stage2 chain: + + ```bash + DEPLOYMENT_DIR=$pwd + + cd ~/cerc/fixturenet-laconicd-stack/stack-orchestrator/stacks/fixturenet-laconicd + + STAGE2_CHAIN_ID=laconic_9000-2 + ./scripts/initialize-stage2.sh $DEPLOYMENT_DIR/stage2-deployment $STAGE2_CHAIN_ID 1000000000000000 + + cd $DEPLOYMENT_DIR + ``` + + * Exports the data from stage1 + + * Generates the genesis file for stage2 + + * Initializes the `stage2-deployment` node + +## 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 stage1-deployment exec laconicd "laconicd cometbft show-node-id")@laconicd.laconic.com:26656 + ``` + + * Get the genesis file: + + ```bash + scp dev@:/srv/laconicd/stage2-deployment/data/laconicd-data/config/genesis.json + ``` + +* Now users can follow the steps to [Upgrade to testnet stage2](https://git.vdb.to/cerc-io/testnet-laconicd-stack/src/branch/main/testnet-onboarding-validator.md#upgrade-to-testnet-stage2) + +## 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 1000000alnt" + ``` + +* Check balance: + + ```bash + laconic-so deployment --dir stage2-deployment exec laconicd "laconicd query bank balances ${RECEIVER_ADDRESS}" + ``` -- 2.45.2 From b85227f1aa7114a623caa468998ac04de533c969 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Thu, 17 Oct 2024 18:08:07 +0530 Subject: [PATCH 03/17] Add a script and instructions for users to upgrade to testnet stage2 --- ops/stage0-to-stage1.md | 2 +- ops/stage1-to-stage2.md | 4 +- ops/stage2/upgrade-node-to-stage2.sh | 25 ++++++++ testnet-onboarding-validator.md | 94 ++++++++++++++++++++++++++++ 4 files changed, 122 insertions(+), 3 deletions(-) create mode 100755 ops/stage2/upgrade-node-to-stage2.sh diff --git a/ops/stage0-to-stage1.md b/ops/stage0-to-stage1.md index c76e615..89bf12f 100644 --- a/ops/stage0-to-stage1.md +++ b/ops/stage0-to-stage1.md @@ -93,7 +93,7 @@ Once all the participants have completed their onboarding, stage0 laconicd chain scp dev@:/srv/laconicd/stage1-deployment/data/laconicd-data/config/genesis.json ``` -* 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 diff --git a/ops/stage1-to-stage2.md b/ops/stage1-to-stage2.md index 0f64ce5..b2db30f 100644 --- a/ops/stage1-to-stage2.md +++ b/ops/stage1-to-stage2.md @@ -46,7 +46,7 @@ * Initialize stage2 chain: ```bash - DEPLOYMENT_DIR=$pwd + DEPLOYMENT_DIR=$(pwd) cd ~/cerc/fixturenet-laconicd-stack/stack-orchestrator/stacks/fixturenet-laconicd @@ -94,7 +94,7 @@ scp dev@:/srv/laconicd/stage2-deployment/data/laconicd-data/config/genesis.json ``` -* Now users can follow the steps to [Upgrade to testnet stage2](https://git.vdb.to/cerc-io/testnet-laconicd-stack/src/branch/main/testnet-onboarding-validator.md#upgrade-to-testnet-stage2) +* Now users can follow the steps to [Upgrade to testnet stage2](../testnet-onboarding-validator.md#upgrade-to-testnet-stage2) ## Bank Transfer diff --git a/ops/stage2/upgrade-node-to-stage2.sh b/ops/stage2/upgrade-node-to-stage2.sh new file mode 100755 index 0000000..de334cf --- /dev/null +++ b/ops/stage2/upgrade-node-to-stage2.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Exit on error +set -e +set -u + +NODE_HOME="$HOME/.laconicd" +stage2_genesis="$NODE_HOME/tmp-stage2/genesis.json" + +if [ ! -f ${stage2_genesis} ]; then + echo "stage2 genesis file not found, exiting..." + exit 1 +fi + +# Remove data but keep keys +laconicd cometbft unsafe-reset-all + +# Use provided genesis config +cp $stage2_genesis $NODE_HOME/config/genesis.json + +# Set chain id in config +chain_id=$(jq -r '.chain_id' $stage2_genesis) +laconicd config set client chain-id $chain_id --home $NODE_HOME + +echo "Node data reset and ready for stage2!" diff --git a/testnet-onboarding-validator.md b/testnet-onboarding-validator.md index 6f94e9c..c8b1fcb 100644 --- a/testnet-onboarding-validator.md +++ b/testnet-onboarding-validator.md @@ -280,6 +280,100 @@ laconic-so deployment --dir testnet-laconicd-deployment start sudo rm -r testnet-laconicd-deployment ``` +## Upgrade to testnet stage2 + +### Prerequisites + +* Testnet stage2 genesis file and peer node address + +* Mnemonic from the [wallet](https://wallet.laconic.com) + +* Have a testnet stage1 node running + +### Setup + +* 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 + ``` + +* 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 deployment used for stage1 can be used for stage2 + +* Copy over the published testnet genesis file (`.json`) to data directory in deployment (`testnet-laconicd-deployment/data/laconicd-data/tmp-stage2`): + + ```bash + # In dir where stage1 deployment (`testnet-laconicd-deployment`) exists + TESTNET_DEPLOYMENT=$(pwd)/testnet-laconicd-deployment + + # Example + mkdir -p $TESTNET_DEPLOYMENT/data/laconicd-data/tmp-stage2 + cp genesis.json $TESTNET_DEPLOYMENT/data/laconicd-data/tmp-stage2/genesis.json + ``` + +* Run script to reset node data and upgrade for stage2: + + ```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-stage2.sh" + + cd $TESTNET_DEPLOYMENT + ``` + +### Configuration + +* Inside the `testnet-laconicd-deployment` deployment directory, open `config.env` file and set following env variables: + + ```bash + CERC_CHAIN_ID=laconic_9000-2 + + # Comma separated list of nodes to keep persistent connections to + # Example: "node-1-id@laconicd.laconic.com:26656" + # 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](#join-as-testnet-validator) to join / rejoin as a validator using laconicd CLI + +### 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 -- 2.45.2 From 61a3ead68b32447cf8dad556de8350e2bb4f11fe Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Fri, 18 Oct 2024 10:03:29 +0530 Subject: [PATCH 04/17] Update instructions for stage1 to stage2 migration --- ops/stage1-to-stage2.md | 51 +++++++++++++++++++++++++++------ testnet-onboarding-validator.md | 2 +- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/ops/stage1-to-stage2.md b/ops/stage1-to-stage2.md index b2db30f..a513b21 100644 --- a/ops/stage1-to-stage2.md +++ b/ops/stage1-to-stage2.md @@ -29,18 +29,48 @@ # Stopping this deployment marks the end of testnet stage1 ``` +## Export stage1 state + +* Export the chain state: + + ```bash + STAGE1_DEPLOYMENT=/srv/laconicd/stage1-deployment + + docker run -it \ + -v $STAGE1_DEPLOYMENT/data/laconicd-data:/root/.laconicd \ + cerc/laconicd: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" -C $STAGE1_DEPLOYMENT/data/laconicd-data . + sudo chown dev:dev /srv/laconicd/stage1-laconicd-export.tar.gz + ``` + +* Get the exports locally: + + ```bash + scp dev@:/srv/laconicd/stage1-laconicd-export.tar.gz + + # These files are to be used in the next initialization step, scp them over to the stage2 deploment machine + ``` + ## Initialize stage2 -* Copy over the `stage1-deployment` dir to stage2 deployment machine +* Copy over the stage1 state and node export archive to stage2 deployment machine -* Copy over the stage1 node data to stage2 deployment dir: +* Extract the stage1 state and node config to stage2 deployment dir: ```bash # On stage2 deployment machine cd /srv/laconicd - STAGE1_DEPLOYMENT= - cp -r $STAGE1_DEPLOYMENT/data/laconicd-data stage2-deployment/data + # Unarchive + tar -xzf stage1-laconicd-config.tar.gz -C stage2-deployment/data/laconicd-data + + # Verify contents + ll stage2-deployment/data/laconicd-data ``` * Initialize stage2 chain: @@ -51,17 +81,21 @@ cd ~/cerc/fixturenet-laconicd-stack/stack-orchestrator/stacks/fixturenet-laconicd STAGE2_CHAIN_ID=laconic_9000-2 - ./scripts/initialize-stage2.sh $DEPLOYMENT_DIR/stage2-deployment $STAGE2_CHAIN_ID 1000000000000000 + ./scripts/initialize-stage2.sh $DEPLOYMENT_DIR/stage2-deployment $STAGE2_CHAIN_ID LaconicStage2 os 1000000000000000 cd $DEPLOYMENT_DIR ``` - * Exports the data from stage1 - - * Generates the genesis file for stage2 + * 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 + ## Start stage2 * Start the stage2 deployment: @@ -85,6 +119,7 @@ * Get the node id: ```bash + # TODO: Update echo $(laconic-so deployment --dir stage1-deployment exec laconicd "laconicd cometbft show-node-id")@laconicd.laconic.com:26656 ``` diff --git a/testnet-onboarding-validator.md b/testnet-onboarding-validator.md index c8b1fcb..827678c 100644 --- a/testnet-onboarding-validator.md +++ b/testnet-onboarding-validator.md @@ -368,7 +368,7 @@ 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](#join-as-testnet-validator) to join / rejoin as a validator using laconicd CLI +See [Join as testnet validator](#join-as-testnet-validator) to join as a validator using laconicd CLI ### Clean up -- 2.45.2 From acf318f366b01cf0737c34774e8702893098430a Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Fri, 18 Oct 2024 12:36:39 +0530 Subject: [PATCH 05/17] Update container build --- ops/deployments-from-scratch.md | 22 +--------------------- ops/stage1-to-stage2.md | 4 ++-- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/ops/deployments-from-scratch.md b/ops/deployments-from-scratch.md index de33eda..dcdc651 100644 --- a/ops/deployments-from-scratch.md +++ b/ops/deployments-from-scratch.md @@ -1577,29 +1577,9 @@ # This should clone the laconicd repo at `/home/dev/cerc/laconicd` ``` -* Build the stage1 container image (required for exporting stage1 data): +* Build the container images: ```bash - # Checkout to laconicd tag used for stage1 - cd ~/cerc/laconicd - git checkout v0.1.7 - cd - - - # Build - laconic-so --stack ~/cerc/fixturenet-laconicd-stack/stack-orchestrator/stacks/fixturenet-laconicd build-containers --force-rebuild - - # Create required tag - docker tag cerc/laconicd:local cerc/laconicd-stage1:local - ``` - -* Build the stage2 container image: - - ```bash - # Checkout to latest laconicd - cd ~/cerc/laconicd - git checkout main - cd - - laconic-so --stack ~/cerc/fixturenet-laconicd-stack/stack-orchestrator/stacks/fixturenet-laconicd build-containers --force-rebuild # This should create the "cerc/laconicd" Docker image diff --git a/ops/stage1-to-stage2.md b/ops/stage1-to-stage2.md index a513b21..f0caeeb 100644 --- a/ops/stage1-to-stage2.md +++ b/ops/stage1-to-stage2.md @@ -44,7 +44,7 @@ * Archive the state and node config and keys: ```bash - sudo tar -czf /srv/laconicd/stage1-laconicd-export.tar.gz --exclude="./data" -C $STAGE1_DEPLOYMENT/data/laconicd-data . + 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 ``` @@ -67,7 +67,7 @@ cd /srv/laconicd # Unarchive - tar -xzf stage1-laconicd-config.tar.gz -C stage2-deployment/data/laconicd-data + tar -xzf stage1-laconicd-export.tar.gz -C stage2-deployment/data/laconicd-data # Verify contents ll stage2-deployment/data/laconicd-data -- 2.45.2 From cffe62cb1f201a7b88d2ae78ebbb0f80c95279dd Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Mon, 21 Oct 2024 17:14:16 +0530 Subject: [PATCH 06/17] Fix step to get stage2 deployment node id --- ops/stage1-to-stage2.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ops/stage1-to-stage2.md b/ops/stage1-to-stage2.md index f0caeeb..49896f7 100644 --- a/ops/stage1-to-stage2.md +++ b/ops/stage1-to-stage2.md @@ -83,6 +83,8 @@ STAGE2_CHAIN_ID=laconic_9000-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 ``` @@ -119,8 +121,7 @@ * Get the node id: ```bash - # TODO: Update - echo $(laconic-so deployment --dir stage1-deployment exec laconicd "laconicd cometbft show-node-id")@laconicd.laconic.com:26656 + echo $(laconic-so deployment --dir stage2-deployment exec laconicd "laconicd cometbft show-node-id")@laconicd.laconic.com:26656 ``` * Get the genesis file: -- 2.45.2 From 9495af198a97326b8949b6f98f4853f59e053c46 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 22 Oct 2024 13:31:41 +0530 Subject: [PATCH 07/17] Update stage2 chain id and add domain mappings --- ops/deployments-from-scratch.md | 14 +++++++++----- ops/stage1-to-stage2.md | 4 ++-- testnet-onboarding-validator.md | 4 ++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/ops/deployments-from-scratch.md b/ops/deployments-from-scratch.md index dcdc651..ab5d8c3 100644 --- a/ops/deployments-from-scratch.md +++ b/ops/deployments-from-scratch.md @@ -1603,11 +1603,11 @@ ports: laconicd: - '6060' - - '127.0.0.1:26657:26657' - - '26656:26656' - - '127.0.0.1:9473:9473' - - '127.0.0.1:9090:9090' - - '127.0.0.1:1317:1317' + - '127.0.0.1:36657:26657' + - '36656:26656' + - '127.0.0.1:3473:9473' + - '127.0.0.1:3090:9090' + - '127.0.0.1:3317:1317' ``` * Create a deployment from the spec file: @@ -1633,6 +1633,10 @@ https://loro-signup.laconic.com -> 3000 https://wallet.laconic.com -> 5000 https://loro-console.laconic.com -> 4001 +https://laconicd-testnet2.laconic.com -> 36657 +https://laconicd-testnet2.laconic.com/api -> 3473/api +https://loro-console-testnet2.laconic.com -> 4002 + # Machine 2 https://sepolia.laconic.com -> 8545 wss://sepolia.laconic.com -> 8546 diff --git a/ops/stage1-to-stage2.md b/ops/stage1-to-stage2.md index 49896f7..42d6df5 100644 --- a/ops/stage1-to-stage2.md +++ b/ops/stage1-to-stage2.md @@ -80,7 +80,7 @@ cd ~/cerc/fixturenet-laconicd-stack/stack-orchestrator/stacks/fixturenet-laconicd - STAGE2_CHAIN_ID=laconic_9000-2 + 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 @@ -121,7 +121,7 @@ * Get the node id: ```bash - echo $(laconic-so deployment --dir stage2-deployment exec laconicd "laconicd cometbft show-node-id")@laconicd.laconic.com:26656 + echo $(laconic-so deployment --dir stage2-deployment exec laconicd "laconicd cometbft show-node-id")@laconicd-testnet2.laconic.com:36656 ``` * Get the genesis file: diff --git a/testnet-onboarding-validator.md b/testnet-onboarding-validator.md index 827678c..bb8588f 100644 --- a/testnet-onboarding-validator.md +++ b/testnet-onboarding-validator.md @@ -349,10 +349,10 @@ laconic-so deployment --dir testnet-laconicd-deployment start * Inside the `testnet-laconicd-deployment` deployment directory, open `config.env` file and set following env variables: ```bash - CERC_CHAIN_ID=laconic_9000-2 + CERC_CHAIN_ID=laconic-testnet-2 # Comma separated list of nodes to keep persistent connections to - # Example: "node-1-id@laconicd.laconic.com:26656" + # Example: "node-1-id@laconicd-testnet2.laconic.com:26656" # Use the provided node id CERC_PEERS="" -- 2.45.2 From a82d68be0ed59b641513a6cac4bdb9b372da0f13 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 22 Oct 2024 15:01:13 +0530 Subject: [PATCH 08/17] Add instructions to setup laconic console for stage2 --- README.md | 2 + ops/deployments-from-scratch.md | 996 +++++++++++++------------ ops/stage1-to-stage2.md | 18 +- ops/stage2/upgrade-node-to-stage2.sh | 25 - ops/stage2/upgrade-node-to-testnet2.sh | 25 + testnet-onboarding-validator.md | 33 +- 6 files changed, 592 insertions(+), 507 deletions(-) delete mode 100755 ops/stage2/upgrade-node-to-stage2.sh create mode 100755 ops/stage2/upgrade-node-to-testnet2.sh diff --git a/README.md b/README.md index 2400fed..842ccc7 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ 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 +Follow steps in [Upgrade to testnet2](../testnet-onboarding-validator.md#upgrade-to-testnet2) to upgrade your testnet node for testnet2 + ## Run testnet Nitro Node Follow steps in [testnet-nitro-node.md](./testnet-nitro-node.md) to run you Nitro node for the testnet diff --git a/ops/deployments-from-scratch.md b/ops/deployments-from-scratch.md index ab5d8c3..f612e00 100644 --- a/ops/deployments-from-scratch.md +++ b/ops/deployments-from-scratch.md @@ -26,445 +26,6 @@ * laconic-so: see [installation](https://git.vdb.to/cerc-io/testnet-ops/src/branch/main/stack-orchestrator-setup/README.md#setup-stack-orchestrator) -
- Fixturenet Eth - -## Fixturenet Eth - -* Stack: - -* Target dir: `/srv/fixturenet-eth/fixturenet-eth-deployment` - -* Cleanup an existing deployment if required: - - ```bash - cd /srv/fixturenet-eth - - # Stop the deployment - laconic-so deployment --dir fixturenet-eth-deployment stop --delete-volumes - - # Remove the deployment dir - sudo rm -rf fixturenet-eth-deployment - ``` - -### Setup - -* Create a `fixturenet-eth` dir if not present already and cd into it - - ```bash - mkdir /srv/fixturenet-eth - - cd /srv/fixturenet-eth - ``` - -* Clone the stack repo: - - ```bash - laconic-so fetch-stack git.vdb.to/cerc-io/fixturenet-eth-stacks --pull - ``` - -* Clone required repositories: - - ```bash - laconic-so --stack ~/cerc/fixturenet-eth-stacks/stack-orchestrator/stacks/fixturenet-eth setup-repositories --pull - - # If this throws an error as a result of being already checked out to a branch/tag in a repo, remove all repositories from that stack and re-run the command - # The repositories are located in $HOME/cerc by default - ``` - -* Build the container images: - - ```bash - # Remove any older foundry image with `latest` tag - docker rmi ghcr.io/foundry-rs/foundry:latest - - laconic-so --stack ~/cerc/fixturenet-eth-stacks/stack-orchestrator/stacks/fixturenet-eth build-containers --force-rebuild - - # If errors are thrown during build, old images used by this stack would have to be deleted - ``` - - * NOTE: this will take >10 mins depending on the specs of your machine, and **requires** 16GB of memory or greater. - - * Remove any dangling Docker images (to clear up space): - - ```bash - docker image prune - ``` - -* Create spec files for deployments, which will map the stack's ports and volumes to the host: - - ```bash - laconic-so --stack ~/cerc/fixturenet-eth-stacks/stack-orchestrator/stacks/fixturenet-eth deploy init --output fixturenet-eth-spec.yml - ``` - -* Configure ports: - * `fixturenet-eth-spec.yml` - - ```yml - ... - network: - ports: - fixturenet-eth-bootnode-geth: - - '9898:9898' - - '30303' - fixturenet-eth-geth-1: - - '7545:8545' - - '7546:8546' - - '40000' - - '6060' - fixturenet-eth-lighthouse-1: - - '8001' - ... - ``` - -* Create deployments: - Once you've made any needed changes to the spec files, create deployments from them: - - ```bash - laconic-so --stack ~/cerc/fixturenet-eth-stacks/stack-orchestrator/stacks/fixturenet-eth deploy create --spec-file fixturenet-eth-spec.yml --deployment-dir fixturenet-eth-deployment - ``` - -### Run - -* Start `fixturenet-eth-deployment` deployment: - - ```bash - laconic-so deployment --dir fixturenet-eth-deployment start - ``` - -
- -
- Nitro Contracts Deployment - -## Nitro Contracts Deployment - -* Stack: - -* Source repo: - -* Target dir: `/srv/bridge/nitro-contracts-deployment` - -* Cleanup an existing deployment if required: - - ```bash - cd /srv/bridge - - # Stop the deployment - laconic-so deployment --dir nitro-contracts-deployment stop --delete-volumes - - # Remove the deployment dir - sudo rm -rf nitro-contracts-deployment - ``` - -### Setup - -* Switch to `testnet-ops/nitro-contracts-setup` directory on your local machine: - - ```bash - cd testnet-ops/nitro-contracts-setup - ``` - -* Copy the `contract-vars-example.yml` vars file: - - ```bash - cp contract-vars.example.yml contract-vars.yml - ``` - -* Edit [`contract-vars.yml`](./contract-vars.yml) and fill in the following values: - - ```bash - # RPC endpoint - geth_url: "https://fixturenet-eth.laconic.com" - - # Chain ID (Fixturenet-eth: 1212) - geth_chain_id: "1212" - - # Private key for a funded L1 account, to be used for contract deployment on L1 - # Required since this private key will be utilized by both L1 and L2 nodes of the bridge - - geth_deployer_pk: "888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218" - - # Custom token to be deployed - token_name: "TestToken" - token_symbol: "TST" - initial_token_supply: "129600" - ``` - -* Edit the `setup-vars.yml` to update the target directory: - - ```bash - ... - nitro_directory: /srv/bridge - ... - - # Will create deployment at /srv/bridge/nitro-contracts-deployment - ``` - -### Run - -* Deploy nitro contracts on remote host by executing `deploy-contracts.yml` Ansible playbook on your local machine: - - * Create a new `hosts.ini` file: - - ```bash - cp ../hosts.example.ini hosts.ini - ``` - - * Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine: - - ```ini - [deployment_host] - ansible_host= ansible_user= ansible_ssh_common_args='-o ForwardAgent=yes' - ``` - - * Replace `` with `nitro_host` - * Replace `` with the alias of your choice - * Replace `` with the IP address or hostname of the target machine - * Replace `` with the SSH username (e.g., dev, ubuntu) - - * Verify that you are able to connect to the host using the following command: - - ```bash - ansible all -m ping -i hosts.ini -k - - # Expected output: - # | SUCCESS => { - # "ansible_facts": { - # "discovered_interpreter_python": "/usr/bin/python3.10" - # }, - # "changed": false, - # "ping": "pong" - # } - ``` - - * Execute the `deploy-contracts.yml` Ansible playbook for remote deployment: - - ```bash - LANG=en_US.utf8 ansible-playbook -i hosts.ini deploy-contracts.yml --extra-vars='{ "target_host": "nitro_host"}' --user $USER -kK - ``` - -* Check logs for deployment on the remote machine: - - ```bash - cd /srv/bridge - - # Check the nitro contract deployments - laconic-so deployment --dir nitro-contracts-deployment logs nitro-contracts -f - ``` - -* To deploy a new token and transfer it to another account, refer to this [doc](./nitro-token-ops.md) - -
- -
- Nitro Bridge - -## Nitro Bridge - -* Stack: - -* Source repo: - -* Target dir: `/srv/bridge/bridge-deployment` - -* Cleanup an existing deployment if required: - - ```bash - cd /srv/bridge - - # Stop the deployment - laconic-so deployment --dir bridge-deployment stop --delete-volumes - - # Remove the deployment dir - sudo rm -rf bridge-deployment - ``` - -### Setup - -* Execute the following command on deployment machine to get the deployed Nitro contract addresses along with the asset address: - - ```bash - cd /srv/bridge - - laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "cat /app/deployment/nitro-addresses.json" - - # Expected output: - # { - # "1212": [ - # { - # "name": "geth", - # "chainId": "1212", - # "contracts": { - # "ConsensusApp": { - # "address": "0xC98aD0B41B9224dad0605be32A9241dB9c67E2e8" - # }, - # "NitroAdjudicator": { - # "address": "0x7C22fdA703Cdf09eB8D3B5Adc81F723526713D0e" - # }, - # "VirtualPaymentApp": { - # "address": "0x778e4e6297E8BF04C67a20Ec989618d72eB4a19E" - # }, - # "TestToken": { - # "address": "0x02ebfB2706527C7310F2a7d9098b2BC61014C5F2" - # } - # } - # } - # ] - # } - ``` - -* Switch to `testnet-ops/nitro-bridge-setup` directory on your local machine: - - ```bash - cd testnet-ops/nitro-bridge-setup - ``` - -* Create the required vars file: - - ```bash - cp bridge-vars.example.yml bridge-vars.yml - ``` - -* Edit `bridge-vars.yml` with required values: - - ```bash - # WS endpoint - nitro_chain_url: "wss://fixturenet-eth.laconic.com" - - # Private key for bridge Nitro address - nitro_sc_pk: "" - - # Private key should correspond to a funded account on L1 and this account must own the Nitro contracts - # It also needs to hold L1 tokens to fund Nitro channels - nitro_chain_pk: "888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218" - - # Deployed Nitro contract addresses - na_address: "" - vpa_address: "" - ca_address: "" - ``` - -* Edit the `setup-vars.yml` to update the target directory: - - ```bash - ... - nitro_directory: /srv/bridge - ... - - # Will create deployment at /srv/bridge/nitro-contracts-deployment and /srv/bridge/bridge-deployment - ``` - -### Run - -* Start the bridge on remote host by executing `run-nitro-bridge.yml` Ansible playbook on your local machine: - - * Create a new `hosts.ini` file: - - ```bash - cp ../hosts.example.ini hosts.ini - ``` - - * Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine: - - ```ini - [deployment_host] - ansible_host= ansible_user= ansible_ssh_common_args='-o ForwardAgent=yes' - ``` - - * Replace `` with `nitro_host` - * Replace `` with the alias of your choice - * Replace `` with the IP address or hostname of the target machine - * Replace `` with the SSH username (e.g., dev, ubuntu) - - * Verify that you are able to connect to the host using the following command: - - ```bash - ansible all -m ping -i hosts.ini -k - - # Expected output: - # | SUCCESS => { - # "ansible_facts": { - # "discovered_interpreter_python": "/usr/bin/python3.10" - # }, - # "changed": false, - # "ping": "pong" - # } - ``` - - * Execute the `run-nitro-bridge.yml` Ansible playbook for remote deployment: - - ```bash - LANG=en_US.utf8 ansible-playbook -i hosts.ini run-nitro-bridge.yml --extra-vars='{ "target_host": "nitro_host"}' --user $USER -kK - ``` - -* Check logs for deployments on the remote machine: - - ```bash - cd /srv/bridge - - # Check bridge logs, ensure that the node is running - laconic-so deployment --dir bridge-deployment logs nitro-bridge -f - ``` - -* Create Nitro node config for users: - - ```bash - cd /srv/bridge - - # Create required variables - GETH_CHAIN_ID="1212" - - export NA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.NitroAdjudicator.address' /app/deployment/nitro-addresses.json") - export CA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.ConsensusApp.address' /app/deployment/nitro-addresses.json") - export VPA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.VirtualPaymentApp.address' /app/deployment/nitro-addresses.json") - - export BRIDGE_NITRO_ADDRESS=$(laconic-so deployment --dir bridge-deployment exec nitro-rpc-client "nitro-rpc-client get-node-info -p 4005 -h nitro-bridge" | jq -r '.SCAddress') - - export BRIDGE_PEER_ID=$(laconic-so deployment --dir bridge-deployment exec nitro-rpc-client "nitro-rpc-client get-node-info -p 4005 -h nitro-bridge" | jq -r '.MessageServicePeerId') - - 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 files - cat < nitro-node-config.yml - nitro_chain_url: "wss://fixturenet-eth.laconic.com" - na_address: "$NA_ADDRESS" - ca_address: "$CA_ADDRESS" - vpa_address: "$VPA_ADDRESS" - bridge_nitro_address: "$BRIDGE_NITRO_ADDRESS" - nitro_l1_bridge_multiaddr: "$L1_BRIDGE_MULTIADDR" - nitro_l2_bridge_multiaddr: "$L2_BRIDGE_MULTIADDR" - EOF - - laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq --arg chainId \"$GETH_CHAIN_ID\" '{ - (\$chainId): [ - { - \"name\": .[\$chainId][0].name, - \"chainId\": .[\$chainId][0].chainId, - \"contracts\": ( - .[\$chainId][0].contracts - | to_entries - | map(select(.key | in({\"ConsensusApp\":1, \"NitroAdjudicator\":1, \"VirtualPaymentApp\":1}) | not)) - | from_entries - ) - } - ] - }' /app/deployment/nitro-addresses.json" > assets.json - ``` - - * The required config files should be generated at `/srv/bridge/nitro-node-config.yml` and `/srv/bridge/assets.json` - - * Check in the generated files at locations `ops/stage2/nitro-node-config.yml` and `ops/stage2/assets.json` within this repository respectively - -* List down L2 channels created by the bridge: - - ```bash - laconic-so deployment --dir bridge-deployment exec nitro-rpc-client "nitro-rpc-client get-all-l2-channels -p 4005 -h nitro-bridge" - ``` - -
-
stage0 laconicd @@ -1076,7 +637,7 @@ ### Setup -* Same as that for [stage0 laconicd](#setup), not required if already done for stage0 +* Same as that for [stage0-laconicd](#stage0-laconicd), not required if already done for stage0 ### Deployment @@ -1561,29 +1122,13 @@ ### Setup -* Clone the stack repo: +* Create a tag for existing stage1 laconicd image: ```bash - laconic-so fetch-stack git.vdb.to/cerc-io/fixturenet-laconicd-stack --pull - - # This should clone the fixturenet-laconicd-stack repo at `/home/dev/cerc/fixturenet-laconicd-stack` + docker tag cerc/laconicd:local cerc/laconicd-stage1:local ``` -* Clone required repositories: - - ```bash - laconic-so --stack ~/cerc/fixturenet-laconicd-stack/stack-orchestrator/stacks/fixturenet-laconicd setup-repositories --pull - - # This should clone the laconicd repo at `/home/dev/cerc/laconicd` - ``` - -* Build the container images: - - ```bash - laconic-so --stack ~/cerc/fixturenet-laconicd-stack/stack-orchestrator/stacks/fixturenet-laconicd build-containers --force-rebuild - - # This should create the "cerc/laconicd" Docker image - ``` +* Same as that for [stage0-laconicd](#stage0-laconicd) ### Deployment @@ -1622,6 +1167,539 @@
+
+ laconic-console-testnet2 + +## laconic-console-testnet2 + +* Stack: + +* Source repos: + * + * + +* Target dir: `/srv/console/laconic-console-testnet2-deployment` + +* Cleanup an existing deployment if required: + + ```bash + cd /srv/console + + # Stop the deployment + laconic-so deployment --dir laconic-console-testnet2-deployment stop --delete-volumes + + # Remove the deployment dir + sudo rm -rf laconic-console-testnet2-deployment + + # Remove the existing spec file + rm laconic-console-testnet2-spec.yml + ``` + +### Setup + +* Create tags for existing stage1 images: + + ```bash + docker tag cerc/laconic-console-host:local cerc/laconic-console-host-stage1:local + + docker tag cerc/laconic-registry-cli:local cerc/laconic-registry-cli-stage1:local + ``` + +* Same as that for [laconic-console](#laconic-console) + +### Deployment + +* Create a spec file for the deployment: + + ```bash + cd /srv/console + + laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-console deploy init --output laconic-console-testnet2-spec.yml + ``` + +* Edit network in the spec file to map container ports to host ports: + + ```bash + network: + ports: + console: + - '127.0.0.1:4002:80' + ``` + +* Create a deployment from the spec file: + + ```bash + laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-console deploy create --spec-file laconic-console-testnet2-spec.yml --deployment-dir laconic-console-testnet2-deployment + ``` + +* Update the configuration: + + ```bash + cat < laconic-console-testnet2-deployment/config.env + # Laconicd (hosted) GQL endpoint + LACONIC_HOSTED_ENDPOINT=https://laconicd-testnet2.laconic.com + EOF + ``` + +### Start + +* Start the deployment: + + ```bash + laconic-so deployment --dir laconic-console-testnet2-deployment start + ``` + +* Check status: + + ```bash + # List down the container + docker ps -a | grep console + + # Follow logs for console container + laconic-so deployment --dir laconic-console-testnet2-deployment logs console -f + ``` + +* The laconic console can now be viewed at + +
+ +
+ Fixturenet Eth + +## Fixturenet Eth + +* Stack: + +* Target dir: `/srv/fixturenet-eth/fixturenet-eth-deployment` + +* Cleanup an existing deployment if required: + + ```bash + cd /srv/fixturenet-eth + + # Stop the deployment + laconic-so deployment --dir fixturenet-eth-deployment stop --delete-volumes + + # Remove the deployment dir + sudo rm -rf fixturenet-eth-deployment + ``` + +### Setup + +* Create a `fixturenet-eth` dir if not present already and cd into it + + ```bash + mkdir /srv/fixturenet-eth + + cd /srv/fixturenet-eth + ``` + +* Clone the stack repo: + + ```bash + laconic-so fetch-stack git.vdb.to/cerc-io/fixturenet-eth-stacks --pull + ``` + +* Clone required repositories: + + ```bash + laconic-so --stack ~/cerc/fixturenet-eth-stacks/stack-orchestrator/stacks/fixturenet-eth setup-repositories --pull + + # If this throws an error as a result of being already checked out to a branch/tag in a repo, remove all repositories from that stack and re-run the command + # The repositories are located in $HOME/cerc by default + ``` + +* Build the container images: + + ```bash + # Remove any older foundry image with `latest` tag + docker rmi ghcr.io/foundry-rs/foundry:latest + + laconic-so --stack ~/cerc/fixturenet-eth-stacks/stack-orchestrator/stacks/fixturenet-eth build-containers --force-rebuild + + # If errors are thrown during build, old images used by this stack would have to be deleted + ``` + + * NOTE: this will take >10 mins depending on the specs of your machine, and **requires** 16GB of memory or greater. + + * Remove any dangling Docker images (to clear up space): + + ```bash + docker image prune + ``` + +* Create spec files for deployments, which will map the stack's ports and volumes to the host: + + ```bash + laconic-so --stack ~/cerc/fixturenet-eth-stacks/stack-orchestrator/stacks/fixturenet-eth deploy init --output fixturenet-eth-spec.yml + ``` + +* Configure ports: + * `fixturenet-eth-spec.yml` + + ```yml + ... + network: + ports: + fixturenet-eth-bootnode-geth: + - '9898:9898' + - '30303' + fixturenet-eth-geth-1: + - '7545:8545' + - '7546:8546' + - '40000' + - '6060' + fixturenet-eth-lighthouse-1: + - '8001' + ... + ``` + +* Create deployments: + Once you've made any needed changes to the spec files, create deployments from them: + + ```bash + laconic-so --stack ~/cerc/fixturenet-eth-stacks/stack-orchestrator/stacks/fixturenet-eth deploy create --spec-file fixturenet-eth-spec.yml --deployment-dir fixturenet-eth-deployment + ``` + +### Run + +* Start `fixturenet-eth-deployment` deployment: + + ```bash + laconic-so deployment --dir fixturenet-eth-deployment start + ``` + +
+ +
+ Nitro Contracts Deployment + +## Nitro Contracts Deployment + +* Stack: + +* Source repo: + +* Target dir: `/srv/bridge/nitro-contracts-deployment` + +* Cleanup an existing deployment if required: + + ```bash + cd /srv/bridge + + # Stop the deployment + laconic-so deployment --dir nitro-contracts-deployment stop --delete-volumes + + # Remove the deployment dir + sudo rm -rf nitro-contracts-deployment + ``` + +### Setup + +* Switch to `testnet-ops/nitro-contracts-setup` directory on your local machine: + + ```bash + cd testnet-ops/nitro-contracts-setup + ``` + +* Copy the `contract-vars-example.yml` vars file: + + ```bash + cp contract-vars.example.yml contract-vars.yml + ``` + +* Edit [`contract-vars.yml`](./contract-vars.yml) and fill in the following values: + + ```bash + # RPC endpoint + geth_url: "https://fixturenet-eth.laconic.com" + + # Chain ID (Fixturenet-eth: 1212) + geth_chain_id: "1212" + + # Private key for a funded L1 account, to be used for contract deployment on L1 + # Required since this private key will be utilized by both L1 and L2 nodes of the bridge + + geth_deployer_pk: "888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218" + + # Custom token to be deployed + token_name: "TestToken" + token_symbol: "TST" + initial_token_supply: "129600" + ``` + +* Edit the `setup-vars.yml` to update the target directory: + + ```bash + ... + nitro_directory: /srv/bridge + + # Will create deployment at /srv/bridge/nitro-contracts-deployment + ``` + +### Run + +* Deploy nitro contracts on remote host by executing `deploy-contracts.yml` Ansible playbook on your local machine: + + * Create a new `hosts.ini` file: + + ```bash + cp ../hosts.example.ini hosts.ini + ``` + + * Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine: + + ```ini + [deployment_host] + ansible_host= ansible_user= ansible_ssh_common_args='-o ForwardAgent=yes' + ``` + + * Replace `` with `nitro_host` + * Replace `` with the alias of your choice + * Replace `` with the IP address or hostname of the target machine + * Replace `` with the SSH username (e.g., dev, ubuntu) + + * Verify that you are able to connect to the host using the following command: + + ```bash + ansible all -m ping -i hosts.ini -k + + # Expected output: + # | SUCCESS => { + # "ansible_facts": { + # "discovered_interpreter_python": "/usr/bin/python3.10" + # }, + # "changed": false, + # "ping": "pong" + # } + ``` + + * Execute the `deploy-contracts.yml` Ansible playbook for remote deployment: + + ```bash + LANG=en_US.utf8 ansible-playbook -i hosts.ini deploy-contracts.yml --extra-vars='{ "target_host": "nitro_host"}' --user $USER -kK + ``` + +* Check logs for deployment on the remote machine: + + ```bash + cd /srv/bridge + + # Check the nitro contract deployments + laconic-so deployment --dir nitro-contracts-deployment logs nitro-contracts -f + ``` + +* To deploy a new token and transfer it to another account, refer to this [doc](./nitro-token-ops.md) + +
+ +
+ Nitro Bridge + +## Nitro Bridge + +* Stack: + +* Source repo: + +* Target dir: `/srv/bridge/bridge-deployment` + +* Cleanup an existing deployment if required: + + ```bash + cd /srv/bridge + + # Stop the deployment + laconic-so deployment --dir bridge-deployment stop --delete-volumes + + # Remove the deployment dir + sudo rm -rf bridge-deployment + ``` + +### Setup + +* Execute the following command on deployment machine to get the deployed Nitro contract addresses along with the asset address: + + ```bash + cd /srv/bridge + + laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "cat /app/deployment/nitro-addresses.json" + + # Expected output: + # { + # "1212": [ + # { + # "name": "geth", + # "chainId": "1212", + # "contracts": { + # "ConsensusApp": { + # "address": "0xC98aD0B41B9224dad0605be32A9241dB9c67E2e8" + # }, + # "NitroAdjudicator": { + # "address": "0x7C22fdA703Cdf09eB8D3B5Adc81F723526713D0e" + # }, + # "VirtualPaymentApp": { + # "address": "0x778e4e6297E8BF04C67a20Ec989618d72eB4a19E" + # }, + # "TestToken": { + # "address": "0x02ebfB2706527C7310F2a7d9098b2BC61014C5F2" + # } + # } + # } + # ] + # } + ``` + +* Switch to `testnet-ops/nitro-bridge-setup` directory on your local machine: + + ```bash + cd testnet-ops/nitro-bridge-setup + ``` + +* Create the required vars file: + + ```bash + cp bridge-vars.example.yml bridge-vars.yml + ``` + +* Edit `bridge-vars.yml` with required values: + + ```bash + # WS endpoint + nitro_chain_url: "wss://fixturenet-eth.laconic.com" + + # Private key for bridge Nitro address + nitro_sc_pk: "" + + # Private key should correspond to a funded account on L1 and this account must own the Nitro contracts + # It also needs to hold L1 tokens to fund Nitro channels + nitro_chain_pk: "888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218" + + # Deployed Nitro contract addresses + na_address: "" + vpa_address: "" + ca_address: "" + ``` + +* Edit the `setup-vars.yml` to update the target directory: + + ```bash + ... + nitro_directory: /srv/bridge + + # Will create deployment at /srv/bridge/bridge-deployment + ``` + +### Run + +* Start the bridge on remote host by executing `run-nitro-bridge.yml` Ansible playbook on your local machine: + + * Create a new `hosts.ini` file: + + ```bash + cp ../hosts.example.ini hosts.ini + ``` + + * Edit the [`hosts.ini`](./hosts.ini) file to run the playbook on a remote machine: + + ```ini + [deployment_host] + ansible_host= ansible_user= ansible_ssh_common_args='-o ForwardAgent=yes' + ``` + + * Replace `` with `nitro_host` + * Replace `` with the alias of your choice + * Replace `` with the IP address or hostname of the target machine + * Replace `` with the SSH username (e.g., dev, ubuntu) + + * Verify that you are able to connect to the host using the following command: + + ```bash + ansible all -m ping -i hosts.ini -k + + # Expected output: + # | SUCCESS => { + # "ansible_facts": { + # "discovered_interpreter_python": "/usr/bin/python3.10" + # }, + # "changed": false, + # "ping": "pong" + # } + ``` + + * Execute the `run-nitro-bridge.yml` Ansible playbook for remote deployment: + + ```bash + LANG=en_US.utf8 ansible-playbook -i hosts.ini run-nitro-bridge.yml --extra-vars='{ "target_host": "nitro_host"}' --user $USER -kK + ``` + +* Check logs for deployments on the remote machine: + + ```bash + cd /srv/bridge + + # Check bridge logs, ensure that the node is running + laconic-so deployment --dir bridge-deployment logs nitro-bridge -f + ``` + +* Create Nitro node config for users: + + ```bash + cd /srv/bridge + + # Create required variables + GETH_CHAIN_ID="1212" + + export NA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.NitroAdjudicator.address' /app/deployment/nitro-addresses.json") + export CA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.ConsensusApp.address' /app/deployment/nitro-addresses.json") + export VPA_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.VirtualPaymentApp.address' /app/deployment/nitro-addresses.json") + + export BRIDGE_NITRO_ADDRESS=$(laconic-so deployment --dir bridge-deployment exec nitro-rpc-client "nitro-rpc-client get-node-info -p 4005 -h nitro-bridge" | jq -r '.SCAddress') + + export BRIDGE_PEER_ID=$(laconic-so deployment --dir bridge-deployment exec nitro-rpc-client "nitro-rpc-client get-node-info -p 4005 -h nitro-bridge" | jq -r '.MessageServicePeerId') + + 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 files + cat < nitro-node-config.yml + nitro_chain_url: "wss://fixturenet-eth.laconic.com" + na_address: "$NA_ADDRESS" + ca_address: "$CA_ADDRESS" + vpa_address: "$VPA_ADDRESS" + bridge_nitro_address: "$BRIDGE_NITRO_ADDRESS" + nitro_l1_bridge_multiaddr: "$L1_BRIDGE_MULTIADDR" + nitro_l2_bridge_multiaddr: "$L2_BRIDGE_MULTIADDR" + EOF + + laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq --arg chainId \"$GETH_CHAIN_ID\" '{ + (\$chainId): [ + { + \"name\": .[\$chainId][0].name, + \"chainId\": .[\$chainId][0].chainId, + \"contracts\": ( + .[\$chainId][0].contracts + | to_entries + | map(select(.key | in({\"ConsensusApp\":1, \"NitroAdjudicator\":1, \"VirtualPaymentApp\":1}) | not)) + | from_entries + ) + } + ] + }' /app/deployment/nitro-addresses.json" > assets.json + ``` + + * The required config files should be generated at `/srv/bridge/nitro-node-config.yml` and `/srv/bridge/assets.json` + + * Check in the generated files at locations `ops/stage2/nitro-node-config.yml` and `ops/stage2/assets.json` within this repository respectively + +* List down L2 channels created by the bridge: + + ```bash + laconic-so deployment --dir bridge-deployment exec nitro-rpc-client "nitro-rpc-client get-all-l2-channels -p 4005 -h nitro-bridge" + ``` + +
+ ## Domains / Port Mappings ```bash diff --git a/ops/stage1-to-stage2.md b/ops/stage1-to-stage2.md index 42d6df5..e97a622 100644 --- a/ops/stage1-to-stage2.md +++ b/ops/stage1-to-stage2.md @@ -48,14 +48,6 @@ sudo chown dev:dev /srv/laconicd/stage1-laconicd-export.tar.gz ``` -* Get the exports locally: - - ```bash - scp dev@:/srv/laconicd/stage1-laconicd-export.tar.gz - - # These files are to be used in the next initialization step, scp them over to the stage2 deploment machine - ``` - ## Initialize stage2 * Copy over the stage1 state and node export archive to stage2 deployment machine @@ -98,6 +90,12 @@ * 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: @@ -127,10 +125,10 @@ * Get the genesis file: ```bash - scp dev@:/srv/laconicd/stage2-deployment/data/laconicd-data/config/genesis.json + scp dev@:/srv/laconicd/stage2-deployment/genesis.json ``` -* Now users can follow the steps to [Upgrade to testnet stage2](../testnet-onboarding-validator.md#upgrade-to-testnet-stage2) +* Now users can follow the steps to [Upgrade to testnet2](../testnet-onboarding-validator.md#upgrade-to-testnet2) ## Bank Transfer diff --git a/ops/stage2/upgrade-node-to-stage2.sh b/ops/stage2/upgrade-node-to-stage2.sh deleted file mode 100755 index de334cf..0000000 --- a/ops/stage2/upgrade-node-to-stage2.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash - -# Exit on error -set -e -set -u - -NODE_HOME="$HOME/.laconicd" -stage2_genesis="$NODE_HOME/tmp-stage2/genesis.json" - -if [ ! -f ${stage2_genesis} ]; then - echo "stage2 genesis file not found, exiting..." - exit 1 -fi - -# Remove data but keep keys -laconicd cometbft unsafe-reset-all - -# Use provided genesis config -cp $stage2_genesis $NODE_HOME/config/genesis.json - -# Set chain id in config -chain_id=$(jq -r '.chain_id' $stage2_genesis) -laconicd config set client chain-id $chain_id --home $NODE_HOME - -echo "Node data reset and ready for stage2!" diff --git a/ops/stage2/upgrade-node-to-testnet2.sh b/ops/stage2/upgrade-node-to-testnet2.sh new file mode 100755 index 0000000..2cb41e0 --- /dev/null +++ b/ops/stage2/upgrade-node-to-testnet2.sh @@ -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!" diff --git a/testnet-onboarding-validator.md b/testnet-onboarding-validator.md index bb8588f..e01571c 100644 --- a/testnet-onboarding-validator.md +++ b/testnet-onboarding-validator.md @@ -280,18 +280,28 @@ laconic-so deployment --dir testnet-laconicd-deployment start sudo rm -r testnet-laconicd-deployment ``` -## Upgrade to testnet stage2 +## Upgrade to testnet2 ### Prerequisites -* Testnet stage2 genesis file and peer node address +* testnet2 genesis file and peer node address * Mnemonic from the [wallet](https://wallet.laconic.com) -* Have a testnet stage1 node running +* A testnet stage1 node ### Setup +* Stop the stage1 node: + + ```bash + # In dir where stage1 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 @@ -318,20 +328,17 @@ laconic-so deployment --dir testnet-laconicd-deployment start ### Create a deployment -* The existing deployment used for stage1 can be used for stage2 +* The existing stage1 deployment can be used for testnet2 -* Copy over the published testnet genesis file (`.json`) to data directory in deployment (`testnet-laconicd-deployment/data/laconicd-data/tmp-stage2`): +* Copy over the published testnet2 genesis file (`.json`) to data directory in deployment (`testnet-laconicd-deployment/data/laconicd-data/tmp-testnet2`): ```bash - # In dir where stage1 deployment (`testnet-laconicd-deployment`) exists - TESTNET_DEPLOYMENT=$(pwd)/testnet-laconicd-deployment - # Example - mkdir -p $TESTNET_DEPLOYMENT/data/laconicd-data/tmp-stage2 - cp genesis.json $TESTNET_DEPLOYMENT/data/laconicd-data/tmp-stage2/genesis.json + 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 stage2: +* Run script to reset node data and upgrade for testnet2: ```bash cd ~/cerc/testnet-laconicd-stack @@ -339,7 +346,7 @@ laconic-so deployment --dir testnet-laconicd-deployment start docker run -it \ -v $TESTNET_DEPLOYMENT/data/laconicd-data:/root/.laconicd \ -v ./ops/stage2:/scripts \ - cerc/laconicd:local bash -c "/scripts/upgrade-node-to-stage2.sh" + cerc/laconicd:local bash -c "/scripts/upgrade-node-to-testnet2.sh" cd $TESTNET_DEPLOYMENT ``` @@ -352,7 +359,7 @@ laconic-so deployment --dir testnet-laconicd-deployment start CERC_CHAIN_ID=laconic-testnet-2 # Comma separated list of nodes to keep persistent connections to - # Example: "node-1-id@laconicd-testnet2.laconic.com:26656" + # Example: "node-1-id@laconicd-testnet2.laconic.com:36656" # Use the provided node id CERC_PEERS="" -- 2.45.2 From fe712147c41edffa26dd5506fbb5b5811386016e Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 22 Oct 2024 15:09:07 +0530 Subject: [PATCH 09/17] Remove unnecessary requirement --- ops/deployments-from-scratch.md | 2 ++ testnet-onboarding-validator.md | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ops/deployments-from-scratch.md b/ops/deployments-from-scratch.md index f612e00..2a09cae 100644 --- a/ops/deployments-from-scratch.md +++ b/ops/deployments-from-scratch.md @@ -799,6 +799,8 @@ +--- +
deploy-backend diff --git a/testnet-onboarding-validator.md b/testnet-onboarding-validator.md index e01571c..29021ec 100644 --- a/testnet-onboarding-validator.md +++ b/testnet-onboarding-validator.md @@ -286,8 +286,6 @@ laconic-so deployment --dir testnet-laconicd-deployment start * testnet2 genesis file and peer node address -* Mnemonic from the [wallet](https://wallet.laconic.com) - * A testnet stage1 node ### Setup @@ -295,7 +293,7 @@ laconic-so deployment --dir testnet-laconicd-deployment start * Stop the stage1 node: ```bash - # In dir where stage1 deployment (`testnet-laconicd-deployment`) exists + # In dir where stage1 node deployment (`testnet-laconicd-deployment`) exists TESTNET_DEPLOYMENT=$(pwd)/testnet-laconicd-deployment -- 2.45.2 From 266ce1c63a850005105e7fc7b2fe64731db5b389 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 22 Oct 2024 18:21:32 +0530 Subject: [PATCH 10/17] Update export chain state step to use laconicd stage1 image --- ops/stage1-to-stage2.md | 2 +- testnet-onboarding-validator.md | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ops/stage1-to-stage2.md b/ops/stage1-to-stage2.md index e97a622..30ba94c 100644 --- a/ops/stage1-to-stage2.md +++ b/ops/stage1-to-stage2.md @@ -38,7 +38,7 @@ docker run -it \ -v $STAGE1_DEPLOYMENT/data/laconicd-data:/root/.laconicd \ - cerc/laconicd:local bash -c "laconicd export | jq > /root/.laconicd/stage1-state.json" + cerc/laconicd-stage1:local bash -c "laconicd export | jq > /root/.laconicd/stage1-state.json" ``` * Archive the state and node config and keys: diff --git a/testnet-onboarding-validator.md b/testnet-onboarding-validator.md index 29021ec..88dac3f 100644 --- a/testnet-onboarding-validator.md +++ b/testnet-onboarding-validator.md @@ -314,6 +314,8 @@ laconic-so deployment --dir testnet-laconicd-deployment start # 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 @@ -346,7 +348,7 @@ laconic-so deployment --dir testnet-laconicd-deployment start -v ./ops/stage2:/scripts \ cerc/laconicd:local bash -c "/scripts/upgrade-node-to-testnet2.sh" - cd $TESTNET_DEPLOYMENT + cd - ``` ### Configuration -- 2.45.2 From 6edeb28847917414a98dbbad7825cb93d5d68c17 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Wed, 23 Oct 2024 12:55:32 +0530 Subject: [PATCH 11/17] Update stage2 domain mappings --- ops/deployments-from-scratch.md | 35 ++++++++++++++++++++++----------- ops/stage1-to-stage2.md | 2 +- testnet-onboarding-validator.md | 2 +- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/ops/deployments-from-scratch.md b/ops/deployments-from-scratch.md index 2a09cae..186ea5e 100644 --- a/ops/deployments-from-scratch.md +++ b/ops/deployments-from-scratch.md @@ -1239,7 +1239,7 @@ ```bash cat < laconic-console-testnet2-deployment/config.env # Laconicd (hosted) GQL endpoint - LACONIC_HOSTED_ENDPOINT=https://laconicd-testnet2.laconic.com + LACONIC_HOSTED_ENDPOINT=https://laconicd-sapo.laconic.com EOF ``` @@ -1261,7 +1261,7 @@ laconic-so deployment --dir laconic-console-testnet2-deployment logs console -f ``` -* The laconic console can now be viewed at +* The laconic console can now be viewed at
@@ -1706,16 +1706,29 @@ ```bash # Machine 1 -https://laconicd.laconic.com -> 26657 -https://laconicd.laconic.com/api -> 9473/api -https://faucet.laconic.com -> 4000 -https://loro-signup.laconic.com -> 3000 -https://wallet.laconic.com -> 5000 -https://loro-console.laconic.com -> 4001 -https://laconicd-testnet2.laconic.com -> 36657 -https://laconicd-testnet2.laconic.com/api -> 3473/api -https://loro-console-testnet2.laconic.com -> 4002 +# LORO testnet +https://laconicd.laconic.com -> 26657 +https://laconicd.laconic.com/api -> 9473/api +https://laconicd.laconic.com/console -> 9473/console +https://laconicd.laconic.com/graphql -> 9473/graphql +https://faucet.laconic.com -> 4000 +https://loro-signup.laconic.com -> 3000 +https://wallet.laconic.com -> 5000 +https://loro-console.laconic.com -> 4001 + +Open p2p ports: +26656 + +# SAPO testnet +https://laconicd-sapo.laconic.com -> 36657 +https://laconicd-sapo.laconic.com/api -> 3473/api +https://laconicd-sapo.laconic.com/console -> 3473/console +https://laconicd-sapo.laconic.com/graphql -> 3473/graphql +https://console-sapo.laconic.com -> 4002 + +Open p2p ports: +36656 # Machine 2 https://sepolia.laconic.com -> 8545 diff --git a/ops/stage1-to-stage2.md b/ops/stage1-to-stage2.md index 30ba94c..d3f7688 100644 --- a/ops/stage1-to-stage2.md +++ b/ops/stage1-to-stage2.md @@ -119,7 +119,7 @@ * Get the node id: ```bash - echo $(laconic-so deployment --dir stage2-deployment exec laconicd "laconicd cometbft show-node-id")@laconicd-testnet2.laconic.com:36656 + echo $(laconic-so deployment --dir stage2-deployment exec laconicd "laconicd cometbft show-node-id")@laconicd-sapo.laconic.com:36656 ``` * Get the genesis file: diff --git a/testnet-onboarding-validator.md b/testnet-onboarding-validator.md index 88dac3f..d36706e 100644 --- a/testnet-onboarding-validator.md +++ b/testnet-onboarding-validator.md @@ -359,7 +359,7 @@ laconic-so deployment --dir testnet-laconicd-deployment start CERC_CHAIN_ID=laconic-testnet-2 # Comma separated list of nodes to keep persistent connections to - # Example: "node-1-id@laconicd-testnet2.laconic.com:36656" + # Example: "node-1-id@laconicd-sapo.laconic.com:36656" # Use the provided node id CERC_PEERS="" -- 2.45.2 From 65389f6a3dd4a0eaaad9ce54a8f57d0e50098a09 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Wed, 23 Oct 2024 13:03:44 +0530 Subject: [PATCH 12/17] Update root README --- README.md | 4 +++- testnet-onboarding-validator.md | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 842ccc7..fa22dfb 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,9 @@ 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 -Follow steps in [Upgrade to testnet2](../testnet-onboarding-validator.md#upgrade-to-testnet2) to upgrade your testnet node for testnet2 +## Join SAPO testnet + +Follow steps in [Upgrade to SAPO testnet](./testnet-onboarding-validator.md#upgrade-to-sapo-testnet) to upgrade your LORO testnet node for SAPO testnet ## Run testnet Nitro Node diff --git a/testnet-onboarding-validator.md b/testnet-onboarding-validator.md index d36706e..c8b265f 100644 --- a/testnet-onboarding-validator.md +++ b/testnet-onboarding-validator.md @@ -197,6 +197,8 @@ laconic-so deployment --dir testnet-laconicd-deployment start * From wallet, approve and send transaction to stage1 laconicd chain + + * Alternatively, create a validator using the laconicd CLI: * Import a key pair: @@ -280,11 +282,11 @@ laconic-so deployment --dir testnet-laconicd-deployment start sudo rm -r testnet-laconicd-deployment ``` -## Upgrade to testnet2 +## Upgrade to SAPO testnet ### Prerequisites -* testnet2 genesis file and peer node address +* SAPO testnet (testnet2) genesis file and peer node address * A testnet stage1 node @@ -375,7 +377,7 @@ 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](#join-as-testnet-validator) to join as a validator using laconicd CLI +See [Join as testnet validator](#create-validator-using-cli) to join as a validator using laconicd CLI ### Clean up -- 2.45.2 From fec62c4be9dd224bd667524ef3098a4e806d1742 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Fri, 25 Oct 2024 13:49:08 +0530 Subject: [PATCH 13/17] Configure gas price in console stack --- ops/stage1-to-stage2.md | 2 +- .../compose/docker-compose-laconic-console.yml | 3 ++- .../compose/docker-compose-testnet-laconicd.yml | 1 + stack-orchestrator/config/laconicd/run-laconicd.sh | 2 ++ stack-orchestrator/stacks/laconic-console/README.md | 7 ++++++- stack-orchestrator/stacks/testnet-laconicd/README.md | 10 +++++++++- testnet-onboarding-validator.md | 9 +++++++-- 7 files changed, 28 insertions(+), 6 deletions(-) diff --git a/ops/stage1-to-stage2.md b/ops/stage1-to-stage2.md index d3f7688..eb7925e 100644 --- a/ops/stage1-to-stage2.md +++ b/ops/stage1-to-stage2.md @@ -140,7 +140,7 @@ RECEIVER_ADDRESS= AMOUNT= - laconic-so deployment --dir stage2-deployment exec laconicd "laconicd tx bank send alice ${RECEIVER_ADDRESS} ${AMOUNT}alnt --from alice --fees 1000000alnt" + laconic-so deployment --dir stage2-deployment exec laconicd "laconicd tx bank send alice ${RECEIVER_ADDRESS} ${AMOUNT}alnt --from alice --fees 1000alnt" ``` * Check balance: diff --git a/stack-orchestrator/compose/docker-compose-laconic-console.yml b/stack-orchestrator/compose/docker-compose-laconic-console.yml index 54769d9..30a11e9 100644 --- a/stack-orchestrator/compose/docker-compose-laconic-console.yml +++ b/stack-orchestrator/compose/docker-compose-laconic-console.yml @@ -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 diff --git a/stack-orchestrator/compose/docker-compose-testnet-laconicd.yml b/stack-orchestrator/compose/docker-compose-testnet-laconicd.yml index fc7c70e..5a1a22f 100644 --- a/stack-orchestrator/compose/docker-compose-testnet-laconicd.yml +++ b/stack-orchestrator/compose/docker-compose-testnet-laconicd.yml @@ -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 diff --git a/stack-orchestrator/config/laconicd/run-laconicd.sh b/stack-orchestrator/config/laconicd/run-laconicd.sh index 3ae415f..454828f 100755 --- a/stack-orchestrator/config/laconicd/run-laconicd.sh +++ b/stack-orchestrator/config/laconicd/run-laconicd.sh @@ -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 @@ -46,6 +47,7 @@ sed -i "s/^persistent_peers *=.*/persistent_peers = \"$CERC_PEERS\"/g" $NODE_HOM 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 \ diff --git a/stack-orchestrator/stacks/laconic-console/README.md b/stack-orchestrator/stacks/laconic-console/README.md index 7f7bd64..0a7793f 100644 --- a/stack-orchestrator/stacks/laconic-console/README.md +++ b/stack-orchestrator/stacks/laconic-console/README.md @@ -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) diff --git a/stack-orchestrator/stacks/testnet-laconicd/README.md b/stack-orchestrator/stacks/testnet-laconicd/README.md index 8edc70f..b9ffd90 100644 --- a/stack-orchestrator/stacks/testnet-laconicd/README.md +++ b/stack-orchestrator/stacks/testnet-laconicd/README.md @@ -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) diff --git a/testnet-onboarding-validator.md b/testnet-onboarding-validator.md index c8b265f..74e7dc7 100644 --- a/testnet-onboarding-validator.md +++ b/testnet-onboarding-validator.md @@ -126,6 +126,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 @@ -205,6 +207,7 @@ laconic-so deployment --dir testnet-laconicd-deployment start ```bash KEY_NAME=alice + CHAIN_ID=laconic_9000-1 # Restore existing key with mnemonic seed phrase # You will be prompted to enter mnemonic seed @@ -245,7 +248,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" ``` @@ -290,6 +293,8 @@ laconic-so deployment --dir testnet-laconicd-deployment start * A testnet stage1 node + * For setting up a fresh testnet2 node, follow [Join as a validator](#join-as-a-validator-on-stage1), but use testnet2 chain id (`laconic-testnet-2`) + ### Setup * Stop the stage1 node: @@ -377,7 +382,7 @@ 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 +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 -- 2.45.2 From d87587cc66e87a31b6ced8498fd69ec18abb561c Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Fri, 25 Oct 2024 14:24:35 +0530 Subject: [PATCH 14/17] Set gas price in CLI config --- stack-orchestrator/config/laconic-console/cli/create-config.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/stack-orchestrator/config/laconic-console/cli/create-config.sh b/stack-orchestrator/config/laconic-console/cli/create-config.sh index 1442eff..ea50ec2 100755 --- a/stack-orchestrator/config/laconic-console/cli/create-config.sh +++ b/stack-orchestrator/config/laconic-console/cli/create-config.sh @@ -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" -- 2.45.2 From 660e7152316c4a80a03311ac8695bcd3c0aca535 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Tue, 29 Oct 2024 10:15:39 +0530 Subject: [PATCH 15/17] Update stage1 deployment directory --- ops/deployments-from-scratch.md | 6 ++++++ ops/stage1-to-stage2.md | 10 +++++----- testnet-onboarding-validator.md | 2 ++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ops/deployments-from-scratch.md b/ops/deployments-from-scratch.md index 186ea5e..9483c82 100644 --- a/ops/deployments-from-scratch.md +++ b/ops/deployments-from-scratch.md @@ -1232,6 +1232,9 @@ ```bash laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-console deploy create --spec-file laconic-console-testnet2-spec.yml --deployment-dir laconic-console-testnet2-deployment + + # Place console deployment in the same cluster as stage2 deployment + cp ../stage2-deployment/deployment.yml laconic-console-testnet2-deployment/deployment.yml ``` * Update the configuration: @@ -1240,6 +1243,9 @@ cat < laconic-console-testnet2-deployment/config.env # Laconicd (hosted) GQL endpoint LACONIC_HOSTED_ENDPOINT=https://laconicd-sapo.laconic.com + + # laconicd chain id + CERC_LACONICD_CHAIN_ID=laconic-testnet-2 EOF ``` diff --git a/ops/stage1-to-stage2.md b/ops/stage1-to-stage2.md index eb7925e..3c62451 100644 --- a/ops/stage1-to-stage2.md +++ b/ops/stage1-to-stage2.md @@ -16,15 +16,17 @@ ```bash # On stage1 deployment machine - cd /srv/laconicd + STAGE1_DEPLOYMENT=/srv/laconicd/testnet-laconicd-deployment - laconic-so deployment --dir stage1-deployment logs laconicd -f --tail 30 + 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 + laconic-so deployment --dir $STAGE1_DEPLOYMENT stop # Stopping this deployment marks the end of testnet stage1 ``` @@ -34,8 +36,6 @@ * Export the chain state: ```bash - STAGE1_DEPLOYMENT=/srv/laconicd/stage1-deployment - 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" diff --git a/testnet-onboarding-validator.md b/testnet-onboarding-validator.md index 74e7dc7..4f4ebf7 100644 --- a/testnet-onboarding-validator.md +++ b/testnet-onboarding-validator.md @@ -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: -- 2.45.2 From d83fa024a92440b1c5e743be16890aba8ce470eb Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Wed, 30 Oct 2024 11:27:28 +0530 Subject: [PATCH 16/17] Update stage2 port mapping --- ops/deployments-from-scratch.md | 831 ++++++++++++++++---------------- ops/stage1-to-stage2.md | 2 +- testnet-onboarding-validator.md | 2 +- 3 files changed, 419 insertions(+), 416 deletions(-) diff --git a/ops/deployments-from-scratch.md b/ops/deployments-from-scratch.md index 9483c82..8134120 100644 --- a/ops/deployments-from-scratch.md +++ b/ops/deployments-from-scratch.md @@ -279,123 +279,6 @@ -
- Shopify - -## Shopify - -* Stack: - -* Source repo: - -* Target dir: `/srv/shopify/laconic-shopify-deployment` - -* Cleanup an existing deployment if required: - - ```bash - cd /srv/shopify - - # Stop the deployment - laconic-so deployment --dir laconic-shopify-deployment stop - - # Remove the deployment dir - sudo rm -rf laconic-shopify-deployment - - # Remove the existing spec file - rm laconic-shopify-spec.yml - ``` - -### Setup - -* Clone the stack repo: - - ```bash - laconic-so fetch-stack git.vdb.to/cerc-io/testnet-laconicd-stack --pull - - # This should clone the testnet-laconicd-stack repo at `/home/dev/cerc/testnet-laconicd-stack` - ``` - -* Clone required repositories: - - ```bash - laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-shopify setup-repositories --pull - - # This should clone the laconicd repos at `/home/dev/cerc/shopify` and `/home/dev/cerc/laconic-faucet` - ``` - -* Build the container images: - - ```bash - laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-shopify build-containers --force-rebuild - - # This should create the "cerc/laconic-shopify" and "cerc/laconic-shopify-faucet" Docker images - ``` - -### Deployment - -* Create a spec file for the deployment: - - ```bash - cd /srv/shopify - - laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-shopify deploy init --output laconic-shopify-spec.yml - ``` - -* Create a deployment from the spec file: - - ```bash - laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-shopify deploy create --spec-file laconic-shopify-spec.yml --deployment-dir laconic-shopify-deployment - ``` - -* Inside the `laconic-shopify-deployment` deployment directory, open `config.env` file and set following env variables: - - ```bash - # Shopify GraphQL URL - CERC_SHOPIFY_GRAPHQL_URL='https://6h071x-zw.myshopify.com/admin/api/2024-10/graphql.json' - - # Access token for Shopify API - CERC_SHOPIFY_ACCESS_TOKEN= - - # Delay for fetching orders in milliseconds - CERC_FETCH_ORDER_DELAY=10000 - - # Number of line items per order in Get Orders GraphQL query - CERC_ITEMS_PER_ORDER=10 - - # Private key of a funded faucet account - CERC_FAUCET_KEY= - - # laconicd RPC endpoint - CERC_LACONICD_RPC_ENDPOINT='https://laconicd-sapo.laconic.com' - - # laconicd chain id - CERC_LACONICD_CHAIN_ID=laconic-testnet-2 - - # laconicd address prefix - CERC_LACONICD_PREFIX=laconic - - # laconicd gas price - CERC_LACONICD_GAS_PRICE=0.001 - ``` - -### Start - -* Start the deployment: - - ```bash - laconic-so deployment --dir laconic-shopify-deployment start - ``` - -* Check status: - - ```bash - # Check logs for faucet and shopify containers - laconic-so deployment --dir laconic-shopify-deployment logs shopify -f - laconic-so deployment --dir laconic-shopify-deployment logs faucet -f - ``` - -
-
testnet-onboarding-app @@ -801,301 +684,6 @@ --- -
- deploy-backend - -## Deploy Backend - -* Stack: - -* Source repo: - -* Target dir: `/srv/deploy-backend/backend-deployment` - -* Cleanup an existing deployment if required: - - ```bash - cd /srv/deploy-backend - - # Stop the deployment - laconic-so deployment --dir backend-deployment stop --delete-volumes - - # Remove the deployment dir - sudo rm -rf backend-deployment - - # Remove the existing spec file - rm backend-deployment-spec.yml - ``` - -### Setup - -* Clone the stack repo: - - ```bash - laconic-so fetch-stack git.vdb.to/cerc-io/snowballtools-base-api-stack --pull - - # This should clone the snowballtools-base-api-stack repo at `/home/dev/cerc/snowballtools-base-api-stack` - ``` - -* Clone required repositories: - - ```bash - laconic-so --stack ~/cerc/snowballtools-base-api-stack/stack-orchestrator/stacks/snowballtools-base-backend setup-repositories --git-ssh --pull - - # This should clone the snowballtools-base repo at `/home/dev/cerc/snowballtools-base` - ``` - -* Build the container images: - - ```bash - laconic-so --stack ~/cerc/snowballtools-base-api-stack/stack-orchestrator/stacks/snowballtools-base-backend build-containers --force-rebuild - - # This should create the Docker images: "cerc/snowballtools-base-backend" and "cerc/snowballtools-base-backend-base" - ``` - -* Push the images to the container registry. The container registry will be set up while setting up a service provider - - ```bash - laconic-so deployment --dir backend-deployment push-images - ``` - -### Deployment - -* Create a spec file for the deployment: - - ```bash - cd /srv/backend-deployment - - laconic-so --stack ~/cerc/snowballtools-base-api-stack/stack-orchestrator/stacks/snowballtools-base-backend deploy init --output backend-deployment-spec.yml --config SNOWBALL_BACKEND_CONFIG_FILE_PATH=/config/prod.toml - ``` - -* Edit the spec file to deploy the stack to k8s: - - ```bash - stack: - /home/dev/cerc/snowballtools-base-api-stack/stack-orchestrator/stacks/snowballtools-base-backend - deploy-to: k8s - kube-config: /home/dev/.kube/config-vs-narwhal.yaml - image-registry: container-registry.apps.vaasl.io/laconic-registry - config: - SNOWBALL_BACKEND_CONFIG_FILE_PATH: /config/prod.toml - network: - ports: - deploy-backend: - - '8000' - http-proxy: - - host-name: deploy-backend.apps.vaasl.io - routes: - - path: '/' - proxy-to: deploy-backend:8000 - volumes: - data: - configmaps: - config: ./configmaps/config - ``` - -* Create a deployment from the spec file: - - ```bash - laconic-so --stack ~/cerc/snowballtools-base-api-stack/stack-orchestrator/stacks/snowballtools-base-backend deploy create --deployment-dir backend-deployment --spec-file backend-deployment-spec.yml - # This should create the deployment directory at `/srv/deploy-backend/backend-deployment` - ``` - -* Modify file `backend-deployment/kubeconfig.yml` if required - ``` - apiVersion: v1 - ... - contexts: - - context: - cluster: *** - user: *** - name: default - ... - ``` - NOTE: `context.name` must be default to use with SO - -* Fetch the config template file for the snowball backend: - - ```bash - # Place in snowball deployment directory - wget -O /srv/deploy-backend/backend-deployment/configmaps/config/prod.toml https://git.vdb.to/cerc-io/testnet-laconicd-stack/raw/branch/main/ops/configs/backend-deployment.toml - ``` - -* Setup private key and bond. If not already setup, execute the following commands in the directory containing `stage2-deployment` - - * Create a new account and fetch the private key - - ```bash - laconic-so deployment --dir stage2-deployment exec laconicd "laconicd keys add deploy" - # - address: laconic1yr758d5vkg28text073vlzdjdgd7ud6w729tww - ... - export deployKey=$(laconic-so deployment --dir stage2-deployment exec laconicd "echo y | laconicd keys export deploy --keyring-backend test --unarmored-hex --unsafe") - # ... - # txhash: 262D380259AC06024F87C909EB0BF7814CEC26CDF527B003C4C10631E1DB5893 - ``` - - * Send tokens to this account - - ```bash - laconic-so deployment --dir stage2-deployment exec laconicd "laconicd tx bank send alice laconic1yr758d5vkg28text073vlzdjdgd7ud6w729tww 1000000000000000000alnt --from alice --fees 200000alnt -y" - ``` - - * Create a bond using this account - - ```bash - laconic-so deployment --dir laconic-console-testnet2-deployment exec cli "laconic registry bond create --type alnt --quantity 1000000000000 --user-key $deployKey" | jq -r '.bondId' - # 15e5bc37c40f67adc9ab498fa3fa50b090770f9bb56b27d71714a99138df9a22 - ``` - - * Set bond id - - ```bash - export bondId=15e5bc37c40f67adc9ab498fa3fa50b090770f9bb56b27d71714a99138df9a22 - ``` - -* Register authority. Execute the following commands in the directory containing `laconic-console-testnet2-deployment` - - * Reserve an authority - - ```bash - laconic-so deployment --dir laconic-console-testnet2-deployment exec cli "laconic registry authority reserve deploy-vaasl --txKey $deployKey" - ``` - - * Obtain the auction ID - - ```bash - laconic-so deployment --dir laconic-console-testnet2-deployment exec cli "laconic registry authority whois deploy-vaasl --txKey $deployKey" - # "auction": { - # "id": "73e0b082a198c396009ce748804a9060c674a10045365d262c1584f99d2771c1" - ``` - - * Commit a bid using the auction ID. A reveal file will be generated - - ```bash - laconic-so deployment --dir laconic-console-testnet2-deployment exec cli "laconic registry auction bid commit 73e0b082a198c396009ce748804a9060c674a10045365d262c1584f99d2771c1 5000000 alnt --chain-id laconic-testnet-2 --txKey $deployKey" - - # {"reveal_file":"/app/out/bafyreiewi4osqyvrnljwwcb36fn6sr5iidfpuznqkz52gxc5ztt3jt4zmy.json"} - ``` - - * Reveal a bid using the auction ID and the reveal file generated from the bid commit - - ```bash - laconic-so deployment --dir laconic-console-testnet2-deployment exec cli "laconic registry auction bid reveal 73e0b082a198c396009ce748804a9060c674a10045365d262c1584f99d2771c1 /app/out/bafyreiewi4osqyvrnljwwcb36fn6sr5iidfpuznqkz52gxc5ztt3jt4zmy.json --chain-id laconic-testnet-2 --txKey $deployKey" - # {"success": true} - ``` - - * Verify status after the auction ends. It should list a completed status and a winner - - ``` - laconic-so deployment --dir laconic-console-testnet2-deployment exec cli "laconic registry auction get 73e0b082a198c396009ce748804a9060c674a10045365d262c1584f99d2771c1 -txKey $deployKey" - ``` - - * Set the authority using a bond ID. - - ```bash - laconic-so deployment --dir laconic-console-testnet2-deployment exec cli "laconic registry authority bond set deploy-vaasl $bondId --txKey $deployKey" - # {"success": true} - ``` - - * Verify the authority has been registered. - - ```bash - laconic-so deployment --dir laconic-console-testnet2-deployment exec cli "laconic registry authority whois deploy-vaasl --txKey $deployKey" - ``` - - -* Update `/srv/snowball/snowball-deployment/data/config/prod.toml`. Replace `` with your credentials. Use the `userKey`, `bondId` and `authority` that you set up - -### Start - -* Start the deployment: - - ```bash - laconic-so deployment --dir backend-deployment start - ``` - -* Check status: - - ```bash - # Follow logs for snowball container - laconic-so deployment --dir backend-deployment logs snowballtools-base-backend -f - ``` - -
- -
- deploy-frontend - -## Deploy Frontend - -* Source repo: - -### Prerequisites - -* Node.js - -* Yarn - -### Setup - -* On your local machine, clone the `snowballtools-base` repo: - - ```bash - git clone git@git.vdb.to:cerc-io/snowballtools-base.git - ``` - -* Install dependencies: - - ```bash - cd snowballtools-base - yarn install - ``` - -* In the deployer package, create required env: - - ```bash - cd packages/deployer - cp .env.example .env - ``` - - Set the required variables: - - ```bash - REGISTRY_BOND_ID= - DEPLOYER_LRN=lrn://vaasl-provider/deployers/webapp-deployer-api.apps.vaasl.io - AUTHORITY=vaasl - ``` - Note: The bond id should be set to the `vaasl` authority - -* Update required laconic config. You can use the same `userKey` and `bondId` used for deploying backend: - - ```bash - # Replace and - cat < config.yml - services: - registry: - rpcEndpoint: https://laconicd-sapo.laconic.com - gqlEndpoint: https://laconicd-sapo.laconic.com/api - userKey: - bondId: - chainId: laconic-testnet-2 - gasPrice: 0.001alnt - EOF - ``` - Note: The `userKey` account should own the authority `vaasl` - -### Run - -* Run frontend deployment script: - - ```bash - ./deploy-frontend.sh - ``` - - Follow deployment logs on the deployer UI - -
-
stage2 laconicd @@ -1150,9 +738,9 @@ ports: laconicd: - '6060' - - '127.0.0.1:36657:26657' + - '36657:26657' - '36656:26656' - - '127.0.0.1:3473:9473' + - '3473:9473' - '127.0.0.1:3090:9090' - '127.0.0.1:3317:1317' ``` @@ -1271,6 +859,421 @@
+
+ Shopify + +## Shopify + +* Stack: + +* Source repo: + +* Target dir: `/srv/shopify/laconic-shopify-deployment` + +* Cleanup an existing deployment if required: + + ```bash + cd /srv/shopify + + # Stop the deployment + laconic-so deployment --dir laconic-shopify-deployment stop + + # Remove the deployment dir + sudo rm -rf laconic-shopify-deployment + + # Remove the existing spec file + rm laconic-shopify-spec.yml + ``` + +### Setup + +* Clone the stack repo: + + ```bash + laconic-so fetch-stack git.vdb.to/cerc-io/testnet-laconicd-stack --pull + + # This should clone the testnet-laconicd-stack repo at `/home/dev/cerc/testnet-laconicd-stack` + ``` + +* Clone required repositories: + + ```bash + laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-shopify setup-repositories --pull + + # This should clone the laconicd repos at `/home/dev/cerc/shopify` and `/home/dev/cerc/laconic-faucet` + ``` + +* Build the container images: + + ```bash + laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-shopify build-containers --force-rebuild + + # This should create the "cerc/laconic-shopify" and "cerc/laconic-shopify-faucet" Docker images + ``` + +### Deployment + +* Create a spec file for the deployment: + + ```bash + cd /srv/shopify + + laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-shopify deploy init --output laconic-shopify-spec.yml + ``` + +* Create a deployment from the spec file: + + ```bash + laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-shopify deploy create --spec-file laconic-shopify-spec.yml --deployment-dir laconic-shopify-deployment + ``` + +* Inside the `laconic-shopify-deployment` deployment directory, open `config.env` file and set following env variables: + + ```bash + # Shopify GraphQL URL + CERC_SHOPIFY_GRAPHQL_URL='https://6h071x-zw.myshopify.com/admin/api/2024-10/graphql.json' + + # Access token for Shopify API + CERC_SHOPIFY_ACCESS_TOKEN= + + # Delay for fetching orders in milliseconds + CERC_FETCH_ORDER_DELAY=10000 + + # Number of line items per order in Get Orders GraphQL query + CERC_ITEMS_PER_ORDER=10 + + # Private key of a funded faucet account + CERC_FAUCET_KEY= + + # laconicd RPC endpoint + CERC_LACONICD_RPC_ENDPOINT='https://laconicd-sapo.laconic.com' + + # laconicd chain id + CERC_LACONICD_CHAIN_ID=laconic-testnet-2 + + # laconicd address prefix + CERC_LACONICD_PREFIX=laconic + + # laconicd gas price + CERC_LACONICD_GAS_PRICE=0.001 + ``` + +### Start + +* Start the deployment: + + ```bash + laconic-so deployment --dir laconic-shopify-deployment start + ``` + +* Check status: + + ```bash + # Check logs for faucet and shopify containers + laconic-so deployment --dir laconic-shopify-deployment logs shopify -f + laconic-so deployment --dir laconic-shopify-deployment logs faucet -f + ``` + +
+ +
+ deploy-backend + +## Deploy Backend + +* Stack: + +* Source repo: + +* Target dir: `/srv/deploy-backend/backend-deployment` + +* Cleanup an existing deployment if required: + + ```bash + cd /srv/deploy-backend + + # Stop the deployment + laconic-so deployment --dir backend-deployment stop --delete-volumes + + # Remove the deployment dir + sudo rm -rf backend-deployment + + # Remove the existing spec file + rm backend-deployment-spec.yml + ``` + +### Setup + +* Clone the stack repo: + + ```bash + laconic-so fetch-stack git.vdb.to/cerc-io/snowballtools-base-api-stack --pull + + # This should clone the snowballtools-base-api-stack repo at `/home/dev/cerc/snowballtools-base-api-stack` + ``` + +* Clone required repositories: + + ```bash + laconic-so --stack ~/cerc/snowballtools-base-api-stack/stack-orchestrator/stacks/snowballtools-base-backend setup-repositories --git-ssh --pull + + # This should clone the snowballtools-base repo at `/home/dev/cerc/snowballtools-base` + ``` + +* Build the container images: + + ```bash + laconic-so --stack ~/cerc/snowballtools-base-api-stack/stack-orchestrator/stacks/snowballtools-base-backend build-containers --force-rebuild + + # This should create the Docker images: "cerc/snowballtools-base-backend" and "cerc/snowballtools-base-backend-base" + ``` + +* Push the images to the container registry. The container registry will be set up while setting up a service provider + + ```bash + laconic-so deployment --dir backend-deployment push-images + ``` + +### Deployment + +* Create a spec file for the deployment: + + ```bash + cd /srv/backend-deployment + + laconic-so --stack ~/cerc/snowballtools-base-api-stack/stack-orchestrator/stacks/snowballtools-base-backend deploy init --output backend-deployment-spec.yml --config SNOWBALL_BACKEND_CONFIG_FILE_PATH=/config/prod.toml + ``` + +* Edit the spec file to deploy the stack to k8s: + + ```bash + stack: + /home/dev/cerc/snowballtools-base-api-stack/stack-orchestrator/stacks/snowballtools-base-backend + deploy-to: k8s + kube-config: /home/dev/.kube/config-vs-narwhal.yaml + image-registry: container-registry.apps.vaasl.io/laconic-registry + config: + SNOWBALL_BACKEND_CONFIG_FILE_PATH: /config/prod.toml + network: + ports: + deploy-backend: + - '8000' + http-proxy: + - host-name: deploy-backend.apps.vaasl.io + routes: + - path: '/' + proxy-to: deploy-backend:8000 + volumes: + data: + configmaps: + config: ./configmaps/config + ``` + +* Create a deployment from the spec file: + + ```bash + laconic-so --stack ~/cerc/snowballtools-base-api-stack/stack-orchestrator/stacks/snowballtools-base-backend deploy create --deployment-dir backend-deployment --spec-file backend-deployment-spec.yml + # This should create the deployment directory at `/srv/deploy-backend/backend-deployment` + ``` + +* Modify file `backend-deployment/kubeconfig.yml` if required: + + ```bash + apiVersion: v1 + ... + contexts: + - context: + cluster: *** + user: *** + name: default + ... + ``` + + NOTE: `context.name` must be default to use with SO + +* Fetch the config template file for the snowball backend: + + ```bash + # Place in snowball deployment directory + wget -O /srv/deploy-backend/backend-deployment/configmaps/config/prod.toml https://git.vdb.to/cerc-io/testnet-laconicd-stack/raw/branch/main/ops/configs/backend-deployment.toml + ``` + +* Setup private key and bond. If not already setup, execute the following commands in the directory containing `stage2-deployment` + + * Create a new account and fetch the private key + + ```bash + laconic-so deployment --dir stage2-deployment exec laconicd "laconicd keys add deploy" + # - address: laconic1yr758d5vkg28text073vlzdjdgd7ud6w729tww + ... + export deployKey=$(laconic-so deployment --dir stage2-deployment exec laconicd "echo y | laconicd keys export deploy --keyring-backend test --unarmored-hex --unsafe") + # ... + # txhash: 262D380259AC06024F87C909EB0BF7814CEC26CDF527B003C4C10631E1DB5893 + ``` + + * Send tokens to this account + + ```bash + laconic-so deployment --dir stage2-deployment exec laconicd "laconicd tx bank send alice laconic1yr758d5vkg28text073vlzdjdgd7ud6w729tww 1000000000000000000alnt --from alice --fees 200000alnt -y" + ``` + + * Create a bond using this account + + ```bash + laconic-so deployment --dir laconic-console-testnet2-deployment exec cli "laconic registry bond create --type alnt --quantity 1000000000000 --user-key $deployKey" | jq -r '.bondId' + # 15e5bc37c40f67adc9ab498fa3fa50b090770f9bb56b27d71714a99138df9a22 + ``` + + * Set bond id + + ```bash + export bondId=15e5bc37c40f67adc9ab498fa3fa50b090770f9bb56b27d71714a99138df9a22 + ``` + +* Register authority. Execute the following commands in the directory containing `laconic-console-testnet2-deployment` + + * Reserve an authority + + ```bash + laconic-so deployment --dir laconic-console-testnet2-deployment exec cli "laconic registry authority reserve deploy-vaasl --txKey $deployKey" + ``` + + * Obtain the auction ID + + ```bash + laconic-so deployment --dir laconic-console-testnet2-deployment exec cli "laconic registry authority whois deploy-vaasl --txKey $deployKey" + # "auction": { + # "id": "73e0b082a198c396009ce748804a9060c674a10045365d262c1584f99d2771c1" + ``` + + * Commit a bid using the auction ID. A reveal file will be generated + + ```bash + laconic-so deployment --dir laconic-console-testnet2-deployment exec cli "laconic registry auction bid commit 73e0b082a198c396009ce748804a9060c674a10045365d262c1584f99d2771c1 5000000 alnt --chain-id laconic-testnet-2 --txKey $deployKey" + + # {"reveal_file":"/app/out/bafyreiewi4osqyvrnljwwcb36fn6sr5iidfpuznqkz52gxc5ztt3jt4zmy.json"} + ``` + + * Reveal a bid using the auction ID and the reveal file generated from the bid commit + + ```bash + laconic-so deployment --dir laconic-console-testnet2-deployment exec cli "laconic registry auction bid reveal 73e0b082a198c396009ce748804a9060c674a10045365d262c1584f99d2771c1 /app/out/bafyreiewi4osqyvrnljwwcb36fn6sr5iidfpuznqkz52gxc5ztt3jt4zmy.json --chain-id laconic-testnet-2 --txKey $deployKey" + # {"success": true} + ``` + + * Verify status after the auction ends. It should list a completed status and a winner + + ```bash + laconic-so deployment --dir laconic-console-testnet2-deployment exec cli "laconic registry auction get 73e0b082a198c396009ce748804a9060c674a10045365d262c1584f99d2771c1 -txKey $deployKey" + ``` + + * Set the authority using a bond ID. + + ```bash + laconic-so deployment --dir laconic-console-testnet2-deployment exec cli "laconic registry authority bond set deploy-vaasl $bondId --txKey $deployKey" + # {"success": true} + ``` + + * Verify the authority has been registered. + + ```bash + laconic-so deployment --dir laconic-console-testnet2-deployment exec cli "laconic registry authority whois deploy-vaasl --txKey $deployKey" + ``` + +* Update `/srv/snowball/snowball-deployment/data/config/prod.toml`. Replace `` with your credentials. Use the `userKey`, `bondId` and `authority` that you set up + +### Start + +* Start the deployment: + + ```bash + laconic-so deployment --dir backend-deployment start + ``` + +* Check status: + + ```bash + # Follow logs for snowball container + laconic-so deployment --dir backend-deployment logs snowballtools-base-backend -f + ``` + +
+ +
+ deploy-frontend + +## Deploy Frontend + +* Source repo: + +### Prerequisites + +* Node.js + +* Yarn + +### Setup + +* On your local machine, clone the `snowballtools-base` repo: + + ```bash + git clone git@git.vdb.to:cerc-io/snowballtools-base.git + ``` + +* Install dependencies: + + ```bash + cd snowballtools-base + yarn install + ``` + +* In the deployer package, create required env: + + ```bash + cd packages/deployer + cp .env.example .env + ``` + + Set the required variables: + + ```bash + REGISTRY_BOND_ID= + DEPLOYER_LRN=lrn://vaasl-provider/deployers/webapp-deployer-api.apps.vaasl.io + AUTHORITY=vaasl + ``` + + Note: The bond id should be set to the `vaasl` authority + +* Update required laconic config. You can use the same `userKey` and `bondId` used for deploying backend: + + ```bash + # Replace and + cat < config.yml + services: + registry: + rpcEndpoint: https://laconicd-sapo.laconic.com + gqlEndpoint: https://laconicd-sapo.laconic.com/api + userKey: + bondId: + chainId: laconic-testnet-2 + gasPrice: 0.001alnt + EOF + ``` + + Note: The `userKey` account should own the authority `vaasl` + +### Run + +* Run frontend deployment script: + + ```bash + ./deploy-frontend.sh + ``` + + Follow deployment logs on the deployer UI + +
+
Fixturenet Eth diff --git a/ops/stage1-to-stage2.md b/ops/stage1-to-stage2.md index 3c62451..d3453a7 100644 --- a/ops/stage1-to-stage2.md +++ b/ops/stage1-to-stage2.md @@ -128,7 +128,7 @@ scp dev@:/srv/laconicd/stage2-deployment/genesis.json ``` -* Now users can follow the steps to [Upgrade to testnet2](../testnet-onboarding-validator.md#upgrade-to-testnet2) +* Now users can follow the steps to [Upgrade to SAPO testnet](../testnet-onboarding-validator.md#upgrade-to-sapo-testnet) ## Bank Transfer diff --git a/testnet-onboarding-validator.md b/testnet-onboarding-validator.md index 4f4ebf7..9e2c9e9 100644 --- a/testnet-onboarding-validator.md +++ b/testnet-onboarding-validator.md @@ -295,7 +295,7 @@ laconic-so deployment --dir testnet-laconicd-deployment start * A testnet stage1 node - * For setting up a fresh testnet2 node, follow [Join as a validator](#join-as-a-validator-on-stage1), but use testnet2 chain id (`laconic-testnet-2`) + * 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 -- 2.45.2 From a8094b750102b8944dbbf3f56f25690657d6332e Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Wed, 30 Oct 2024 17:28:29 +0530 Subject: [PATCH 17/17] Remove hardcoded PKs from instructions --- README.md | 4 ++-- ops/deployments-from-scratch.md | 18 ++++++++++++++++-- .../config/laconicd/run-laconicd.sh | 3 +++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fa22dfb..6c1775e 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ 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 -## Join SAPO testnet +## SAPO testnet -Follow steps in [Upgrade to SAPO testnet](./testnet-onboarding-validator.md#upgrade-to-sapo-testnet) to upgrade your LORO testnet node for 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 diff --git a/ops/deployments-from-scratch.md b/ops/deployments-from-scratch.md index 8134120..e4b821d 100644 --- a/ops/deployments-from-scratch.md +++ b/ops/deployments-from-scratch.md @@ -1419,6 +1419,13 @@ cp contract-vars.example.yml contract-vars.yml ``` +* Get a funded account's private key from fixturenet-eth deployment: + + ```bash + FUNDED_ACCOUNT_PK=$(curl --silent localhost:9898/accounts.csv | awk -F',' 'NR==1 {gsub(/^0x/, "", $NF); print $NF}') + echo $FUNDED_ACCOUNT_PK + ``` + * Edit [`contract-vars.yml`](./contract-vars.yml) and fill in the following values: ```bash @@ -1431,7 +1438,7 @@ # Private key for a funded L1 account, to be used for contract deployment on L1 # Required since this private key will be utilized by both L1 and L2 nodes of the bridge - geth_deployer_pk: "888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218" + geth_deployer_pk: "" # Custom token to be deployed token_name: "TestToken" @@ -1561,6 +1568,13 @@ # } ``` +* Get a funded account's private key from fixturenet-eth deployment: + + ```bash + FUNDED_ACCOUNT_PK=$(curl --silent localhost:9898/accounts.csv | awk -F',' 'NR==1 {gsub(/^0x/, "", $NF); print $NF}') + echo $FUNDED_ACCOUNT_PK + ``` + * Switch to `testnet-ops/nitro-bridge-setup` directory on your local machine: ```bash @@ -1584,7 +1598,7 @@ # Private key should correspond to a funded account on L1 and this account must own the Nitro contracts # It also needs to hold L1 tokens to fund Nitro channels - nitro_chain_pk: "888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218" + nitro_chain_pk: "" # Deployed Nitro contract addresses na_address: "" diff --git a/stack-orchestrator/config/laconicd/run-laconicd.sh b/stack-orchestrator/config/laconicd/run-laconicd.sh index 454828f..a5d70c9 100755 --- a/stack-orchestrator/config/laconicd/run-laconicd.sh +++ b/stack-orchestrator/config/laconicd/run-laconicd.sh @@ -41,6 +41,9 @@ 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 -- 2.45.2