From c1af2f6cc7b74b96c89cd5279e887e5a17b7f6d7 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Wed, 30 Oct 2024 13:06:51 +0000 Subject: [PATCH] Add instructions for service providers (#37) Part of [Service Provider Setup](https://www.notion.so/Service-provider-setup-a09e2207e1f34f3a847f7ce9713b7ac5) and Add instructions to: - Setup a new service provider - Update existing service provider setup for testnet2 Co-authored-by: Adw8 Reviewed-on: https://git.vdb.to/cerc-io/testnet-laconicd-stack/pulls/37 Co-authored-by: Prathamesh Musale Co-committed-by: Prathamesh Musale --- README.md | 6 +- service-provider.md | 390 ++++++++++++++++++ .../stacks/laconic-console/README.md | 4 +- 3 files changed, 397 insertions(+), 3 deletions(-) create mode 100644 service-provider.md diff --git a/README.md b/README.md index 6c1775e..e89f7eb 100644 --- a/README.md +++ b/README.md @@ -24,4 +24,8 @@ Follow steps in [Upgrade to SAPO testnet](./testnet-onboarding-validator.md#upgr ## Run testnet Nitro Node -Follow steps in [testnet-nitro-node.md](./testnet-nitro-node.md) to run you Nitro node for the testnet +Follow steps in [testnet-nitro-node.md](./testnet-nitro-node.md) to run your Nitro node for the testnet + +## Setup a Service Provider + +Follow steps in [service-provider.md](./service-provider.md) to setup / update your service provider diff --git a/service-provider.md b/service-provider.md new file mode 100644 index 0000000..b04bbbf --- /dev/null +++ b/service-provider.md @@ -0,0 +1,390 @@ +# Service Provider + +* Follow [Set up a new service provider](#set-up-a-new-service-provider) to setup a new service provider (SP) +* If you already have a SP setup for stage1, follow [Update service provider for SAPO testnet](#update-service-provider-for-sapo-testnet) to update it for testnet2 + +## Set up a new service provider + +Follow steps from [service-provider-setup](). After setup, you will have the following services running (your configuration will look similar to the examples listed below): + +* laconicd chain RPC endpoint: +* laconicd GQL endpoint: +* laconic console: +* webapp deployer API: +* webapp deployer UI: + +Follow the steps below to point your deployer to the SAPO testnet + +## Update service provider for SAPO testnet + +### Prerequisites + +* A SAPO testnet node (see [Join SAPO testnet](./README.md#join-sapo-testnet)) + +### Stop services + +* Stop a laconic-console deployment: + + ```bash + # In directory where laconic-console deployment was created + laconic-so deployment --dir laconic-console-deployment stop --delete-volumes + ``` + +* Stop webapp deployer: + + ```bash + # In directory where webapp-deployer deployment was created + laconic-so deployment --dir webapp-deployer stop + laconic-so deployment --dir webapp-ui stop + ``` + +### Update laconic console + +* Remove an existing console deployment: + + ```bash + # In directory where laconic-console deployment was created + # Backup the config if required + rm -rf laconic-console-deployment + ``` + +* Follow [laconic-console](stack-orchestrator/stacks/laconic-console/README.md) stack instructions to setup a new laconic-console deployment + +* Example configuration: + + ```bash + # CLI configuration + + # laconicd RPC endpoint (can be pointed to your node) + CERC_LACONICD_RPC_ENDPOINT=https://laconicd-sapo.laconic.com + + # laconicd GQL endpoint (can be pointed to your node) + CERC_LACONICD_GQL_ENDPOINT=https://laconicd-sapo.laconic.com/api + + CERC_LACONICD_CHAIN_ID=laconic-testnet-2 + + # your private key + CERC_LACONICD_USER_KEY= + + # your bond id (optional) + CERC_LACONICD_BOND_ID= + + # 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 (can be pointed to your node) + LACONIC_HOSTED_ENDPOINT=https://laconicd-sapo.laconic.com + ``` + +### Check authority and deployer record + +* The stage1 testnet state has been carried over to testnet2, if you had authority and records on stage1, they should be present in testnet2 as well + +* Check authority: + + ```bash + # In directory where laconic-console deployment was created + AUTHORITY= + laconic-so deployment --dir laconic-console-deployment exec cli "laconic registry authority whois $AUTHORITY" + ``` + +* Check deployer record: + + ```bash + PAYMENT_ADDRESS= + laconic-so deployment --dir laconic-console-deployment exec cli "laconic registry record list --all --type WebappDeployer --paymentAddress $PAYMENT_ADDRESS" + ``` + +### (Optional) Reserve a new authority + +* Follow steps if you want to reserve a new authority + +* Create a bond: + + ```bash + # An existing bond can also be used + laconic-so deployment --dir laconic-console-deployment exec cli "laconic registry bond create --type alnt --quantity 100000000000" + # {"bondId":"a742489e5817ef274187611dadb0e4284a49c087608b545ab6bd990905fb61f3"} + + # Set bond id + BOND_ID= + ``` + +* Reserve an authority: + + ```bash + AUTHORITY= + laconic-so deployment --dir laconic-console-deployment exec cli "laconic registry authority reserve $AUTHORITY" + + # Triggers an authority auction + ``` + +* Obtain the authority auction id: + + ```bash + laconic-so deployment --dir laconic-console-deployment exec cli "laconic registry authority whois $AUTHORITY" + # "auction": { + # "id": "73e0b082a198c396009ce748804a9060c674a10045365d262c1584f99d2771c1" + + # Set auction id + AUCTION_ID= + ``` + +* Commit a bid to the auction: + + ```bash + laconic-so deployment --dir laconic-console-deployment exec cli "laconic registry auction bid commit $AUCTION_ID 5000000 alnt --chain-id laconic-testnet-2" + + # {"reveal_file":"/app/out/bafyreiewi4osqyvrnljwwcb36fn6sr5iidfpuznqkz52gxc5ztt3jt4zmy.json"} + + # Set reveal file + REVEAL_FILE= + + # Wait for the auction to move from commit to reveal phase + laconic-so deployment --dir laconic-console-deployment exec cli "laconic registry auction get $AUCTION_ID" + ``` + +* Reveal your bid using reveal file generated while commiting the bid: + + ```bash + laconic-so deployment --dir laconic-console-deployment exec cli "laconic registry auction bid reveal $AUCTION_ID $REVEAL_FILE --chain-id laconic-testnet-2" + # {"success": true} + ``` + +* Verify auction status and winner address after auction completion: + + ```bash + laconic-so deployment --dir laconic-console-deployment exec cli "laconic registry auction get $AUCTION_ID" + ``` + +* Set the authority with a bond: + + ```bash + laconic-so deployment --dir laconic-console-deployment exec cli "laconic registry authority bond set $AUTHORITY $BOND_ID" + # {"success": true} + ``` + +* Verify the authority has been registered: + + ```bash + laconic-so deployment --dir laconic-console-deployment exec cli "laconic registry authority whois $AUTHORITY" + ``` + +* Update laconic-console-deployment config (`laconic-console-deployment/config.env`) with created bond: + + ```bash + ... + CERC_LACONICD_BOND_ID= + ... + ``` + +* Restart the console deployment: + + ```bash + laconic-so deployment --dir laconic-console-deployment stop && laconic-so deployment --dir laconic-console-deployment start + ``` + +### Update webapp deployer + +* Fetch latest stack repos: + + ```bash + # In directory where webapp-deployer deployment was created + laconic-so --stack webapp-deployer-backend setup-repositories --pull + + # Confirm latest commit hash in the ~/cerc/webapp-deployment-status-api repo + ``` + +* Rebuild container images: + + ```bash + laconic-so --stack webapp-deployer-backend build-containers --force-rebuild + ``` + +* Push stack images to the container registry: + + * Login to the container registry: + + ```bash + # Set required variables + # eg: container-registry.pwa.laconic.com + CONTAINER_REGISTRY_URL= + CONTAINER_REGISTRY_USERNAME= + CONTAINER_REGISTRY_PASSWORD= + + # login to container registry + docker login $CONTAINER_REGISTRY_URL --username $CONTAINER_REGISTRY_USERNAME --password $CONTAINER_REGISTRY_PASSWORD + + # WARNING! Using --password via the CLI is insecure. Use --password-stdin. + # WARNING! Your password will be stored unencrypted in /home/dev2/.docker/config.json. + # Configure a credential helper to remove this warning. See + # https://docs.docker.com/engine/reference/commandline/login/#credential-stores + + # Login Succeeded + ``` + + * Push images: + + ```bash + laconic-so deployment --dir webapp-deployer push-images + ``` + +* Update deployer laconic registry config (`webapp-deployer/data/config/laconic.yml`) with new endpoints: + + ```bash + services: + registry: + rpcEndpoint: 'https://laconicd-sapo.laconic.com' + gqlEndpoint: 'https://laconicd-sapo.laconic.com/api' + userKey: "" + bondId: "9555 + + # Set pod id + export POD_ID= + + # Example: + # export POD_ID=laconic-096fed46af974a47-deployment-644db859c7-snbq6 + ``` + +* Copy over GPG keys files to the webapp-deployer container: + + ```bash + kubie ctx default + + # Copy the GPG key files to the pod + kubectl cp $POD_ID:/app + kubectl cp $POD_ID:/app + + # Required everytime you stop and start the deployer + ``` + +* Check logs: + + ```bash + # Deployer + kubectl logs -f $POD_ID + + # Deployer auction handler + kubectl logs -f $POD_ID -c cerc-webapp-auction-handler + ``` + +* Update deployer UI config (`webapp-ui/config.env`): + + ```bash + # URL of the webapp deployer backend API + # eg: https://webapp-deployer-api.pwa.laconic.com + LACONIC_HOSTED_CONFIG_app_api_url= + + # URL of the laconic console + LACONIC_HOSTED_CONFIG_app_console_link=https://console-sapo.laconic.com + ``` + +* Start the webapp UI: + + ```bash + laconic-so deployment --dir webapp-ui start + ``` + +* Check logs + + ```bash + laconic-so deployment --dir webapp-ui logs webapp + ``` diff --git a/stack-orchestrator/stacks/laconic-console/README.md b/stack-orchestrator/stacks/laconic-console/README.md index 0a7793f..5ac5d95 100644 --- a/stack-orchestrator/stacks/laconic-console/README.md +++ b/stack-orchestrator/stacks/laconic-console/README.md @@ -17,13 +17,13 @@ Instructions for running laconic registry CLI and console * Clone required repositories: ```bash - laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-console setup-repositories + laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-console setup-repositories --pull ``` * Build the container images: ```bash - laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-console build-containers + laconic-so --stack ~/cerc/testnet-laconicd-stack/stack-orchestrator/stacks/laconic-console build-containers --force-rebuild ``` This should create the following docker images locally: