Add ops instructions to setup snowball frontend and backend (#32)

Part of [Service provider auctions for web deployments](https://www.notion.so/Service-provider-auctions-for-web-deployments-104a6b22d47280dbad51d28aa3a91d75)

- Update instructions for nitro node deployments

Co-authored-by: Adw8 <adwaitgharpure@gmail.com>
Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
Co-authored-by: Neeraj <neeraj.rtly@gmail.com>
Reviewed-on: cerc-io/testnet-laconicd-stack#32
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
This commit is contained in:
2024-10-30 10:16:28 +00:00
committed by nabarun
co-authored by Adw8 Shreerang Kale Neeraj
parent 9f86b2f2b5
commit a8ffb987b1
4 changed files with 572 additions and 90 deletions
+40
View File
@@ -0,0 +1,40 @@
[server]
host = "0.0.0.0"
port = 8000
gqlPath = "/graphql"
[server.session]
secret = "<redacted>"
# Frontend webapp URL origin
appOriginUrl = "https://deploy.apps.vaasl.io"
# Set to true if server running behind proxy
trustProxy = true
# Backend URL hostname
domain = "deploy-backend.apps.vaasl.io"
[database]
dbPath = "/data/db/deploy-backend"
[gitHub]
webhookUrl = "https://deploy-backend.apps.vaasl.io"
[gitHub.oAuth]
clientId = "<redacted>"
clientSecret = "<redacted>"
[registryConfig]
fetchDeploymentRecordDelay = 5000
checkAuctionStatusDelay = 5000
restEndpoint = "https://laconicd-sapo.laconic.com"
gqlEndpoint = "https://laconicd-sapo.laconic.com/api"
chainId = "laconic-testnet-2"
privateKey = "<redacted>"
bondId = "<redacted>"
authority = "vaasl"
[registryConfig.fee]
gasPrice = "0.001alnt"
[auction]
commitFee = "1000"
commitsDuration = "60s"
revealFee = "1000"
revealsDuration = "60s"
denom = "alnt"
+303 -4
View File
@@ -191,10 +191,12 @@
initial_token_supply: "129600"
```
* Update the target dir in `setup-vars.yml`:
* Edit the `setup-vars.yml` to update the target directory:
```bash
sed -i 's|^nitro_directory:.*|nitro_directory: /srv/bridge|' setup-vars.yml
...
nitro_directory: /srv/bridge
...
# Will create deployment at /srv/bridge/nitro-contracts-deployment
```
@@ -343,10 +345,12 @@
ca_address: ""
```
* Update the target dir in `setup-vars.yml`:
* Edit the `setup-vars.yml` to update the target directory:
```bash
sed -i 's|^nitro_directory:.*|nitro_directory: /srv/bridge|' setup-vars.yml
...
nitro_directory: /srv/bridge
...
# Will create deployment at /srv/bridge/nitro-contracts-deployment and /srv/bridge/bridge-deployment
```
@@ -1234,6 +1238,301 @@
</details>
<details open>
<summary>deploy-backend</summary>
## Deploy Backend
* Stack: <https://git.vdb.to/cerc-io/snowballtools-base-api-stack/src/branch/main/stack-orchestrator/stacks/snowballtools-base-backend>
* Source repo: <https://git.vdb.to/cerc-io/snowballtools-base>
* 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 `<redacted>` 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
```
</details>
<details open>
<summary>deploy-frontend</summary>
## Deploy Frontend
* Source repo: <https://git.vdb.to/cerc-io/snowballtools-base>
### 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=<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 <user-pk> and <bond-id>
cat <<EOF > config.yml
services:
registry:
rpcEndpoint: https://laconicd-sapo.laconic.com
gqlEndpoint: https://laconicd-sapo.laconic.com/api
userKey: <user-pk>
bondId: <bond-id>
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
</details>
## Domains / Port Mappings
```bash
+25 -5
View File
@@ -1,6 +1,8 @@
# Nitro Token Ops
## Setup
## Deploy and transfer custom tokens
### Setup
* Go to the directory where `nitro-contracts-deployment` is present:
@@ -8,7 +10,7 @@
cd /srv/bridge
```
## Deploy new token
### Deploy new token
* To deploy another token:
@@ -48,7 +50,7 @@
* Check in the generated file at location `ops/stage2/assets.json` within this repository
## Transfer deployed tokens to given address
### Transfer deployed tokens to given address
* To transfer a token to an account:
@@ -57,7 +59,25 @@
export TOKEN_NAME="<name-of-token-to-be-transferred>"
export ASSET_ADDRESS=$(laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "jq -r '.\"$GETH_CHAIN_ID\"[0].contracts.$TOKEN_NAME.address' /app/deployment/nitro-addresses.json")
export ACCOUNT="<target-account-address>"
export AMOUNT="<transfer-amount>"
laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "cd packages/nitro-protocol && yarn hardhat transfer --contract $ASSET_ADDRESS --to $ACCOUNT --amount 1000 --network geth"
laconic-so deployment --dir nitro-contracts-deployment exec nitro-contracts "cd packages/nitro-protocol && yarn hardhat transfer --contract $ASSET_ADDRESS --to $ACCOUNT --amount 100 --network geth"
```
## Transfer ETH
* Go to the directory where `fixturenet-eth-deployment` is present:
```bash
cd /srv/fixturenet-eth
```
* To transfer ETH to an account:
```bash
export FUNDED_ADDRESS="0xe6CE22afe802CAf5fF7d3845cec8c736ecc8d61F"
export FUNDED_PK="888814df89c4358d7ddb3fa4b0213e7331239a80e1f013eaa7b2deca2a41a218"
export TO_ADDRESS="<target-account-address>"
laconic-so deployment --dir fixturenet-eth-deployment exec foundry "cast send $TO_ADDRESS --value 1ether --from $FUNDED_ADDRESS --private-key $FUNDED_PK"
```