Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEVOPS-1047: zillion migration to gcp #283

Merged
merged 10 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/cicd-prd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
eth-spout,
neo-savant,
zilliqa-isolated-server,
zillion,
]
include:
- application: bluebell-playground
Expand Down Expand Up @@ -61,6 +62,11 @@ jobs:
path: products/neo-savant
tag_length: 8
tag_latest: false
- application: zillion
image_name: zillion
path: products/zillion
tag_length: 8
tag_latest: false
- application: zilliqa-isolated-server
image_name: zilliqa-isolated-server
path: products/zilliqa-isolated-server
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/cicd-stg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ jobs:
strategy:
fail-fast: false
matrix:
application: [developer-portal, devex, devex-apollo, neo-savant]
application:
[developer-portal, devex, devex-apollo, neo-savant, zillion]
include:
- application: developer-portal
image_name: developer-portal
Expand All @@ -48,6 +49,11 @@ jobs:
path: products/pdt
tag_length: 8
tag_latest: false
- application: zillion
image_name: zillion
path: products/zillion
tag_length: 8
tag_latest: false
env:
DOCKER_DOMAIN: asia-docker.pkg.dev
REGISTRY: asia-docker.pkg.dev/prj-d-devops-services-4dgwlsse/zilliqa-public
Expand Down
5 changes: 3 additions & 2 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ lint:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
# - [email protected] - removed for being over-prissy and wanting tab indents - rrw 2023-04-25
ignore:
- linters: [gitleaks]
Expand All @@ -36,7 +36,8 @@ lint:
- linters: [ALL]
paths:
- needing-organisation/**/*
- products/devex/public/*.js
- products/devex/public/*.js
- products/zillion/**
- .devcontainer/*
- .devcontainer/**
- .trunk/*out/**
Expand Down
105 changes: 105 additions & 0 deletions products/zillion/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
build/

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
15 changes: 15 additions & 0 deletions products/zillion/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:14.20.1 as build-stage


ENV NODE_OPTIONS=--max-old-space-size=4096
WORKDIR /app
COPY ./package.json ./
COPY ./yarn.lock ./
RUN yarn install -E
COPY . ./
RUN yarn build

FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /app/build /usr/share/nginx/html
EXPOSE 80
ENTRYPOINT ["nginx", "-g", "daemon off;"]
20 changes: 20 additions & 0 deletions products/zillion/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.PHONY: all
all: image/build-and-push

.ONESHELL:
SHELL := /bin/bash
.SHELLFLAGS = -ec

ENVIRONMENT ?= dev
VALID_ENVIRONMENTS := dev stg prd
IMAGE_TAG ?= localhost:5001/zillion:latest

# Check if the ENVIRONMENT variable is in the list of valid environments
ifeq ($(filter $(ENVIRONMENT),$(VALID_ENVIRONMENTS)),)
$(error Invalid value for ENVIRONMENT. Valid values are dev, stg, or prd.)
endif

## Build and push the Docker image
image/build-and-push:
docker build --build-arg REACT_APP_DEPLOY_ENV=${ENVIRONMENT} -t "${IMAGE_TAG}" .
docker push "${IMAGE_TAG}"
86 changes: 86 additions & 0 deletions products/zillion/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Zilliqa Staking Wallet App

## Getting Started



### Development
1. `yarn`


2. Tweak the settings in `public/config.js`
```
networks_config: {
testnet: {
proxy: "<proxy_checksum_address>",
impl: "<implementation_contract_checksum_address>",
blockchain: "https://dev-api.zilliqa.com",
node_status: "https://testnet-viewer.zilliqa.com",
api_list : [
"https://dev-api.zilliqa.com",
]
},
mainnet: {
proxy: "<proxy_checksum_address>",
impl: "<implementation_contract_checksum_address>",
blockchain: "https://api.zilliqa.com",
node_status: "https://staking-viewer.zilliqa.com",
api_list : [
"https://api.zilliqa.com",
]
},
isolated_server: {
proxy: "<proxy_checksum_address>",
impl: "<implementation_contract_checksum_address>",
blockchain: "https://zilliqa-isolated-server.zilliqa.com",
node_status: "",
api_list : [
"https://zilliqa-isolated-server.zilliqa.com",
]
}
},
blockchain_explorer_config: "viewblock",
refresh_rate_config: 3000,
api_max_retry_attempt: 10,
environment_config: "dev"
```

3. (Optional) If you are interested in using the isolated server, set `environment_config` to `dev` otherwise, set to `stage` for testnet and `prod` for mainnet respectively.

This enables the "Isolated Server" option in the network selection menu and disables authentications checks in the dashboard.

4. Execute `yarn dev` and browse to `https://localhost:3000/`. HTTPS is required due to hardware ledger support.

5. On the home page, select the network. Next, select _Sign in as Delegators_ or _Sign in as Operators_

6. An operator can see "Staking Performance", "Staked Seed Nodes" whereas delegators can only see "Staked Seed Nodes"

7. Explore and execute any actions

8. If the contract details doesn't get updated, click on the "Dashboard" wordings on the navigation bar to manually refresh


### Production

1. Follow Steps (1) and (2) as stated in **Development** section.

2. Set the `environment_config` flag in `config.js` to `prod`.

3. Assuming the hosted server is running `https`, execute `yarn start`.

4. Done.


### Enable / Disable Stake Operations
Adjust these parameters to disable all stake operations and display a warning banner:

1. At `src/util/enum.ts`, set the `enum ContractState` to **'true'** with the single quotes.
-- This disables all the stake contract calls buttons and replaces the wordings to **"Not Available"**

2. To change the banner display for the main page, edit `src/components/warning-banner.tsx`.

3. To change the banner display for dashboard, edit `src/components/warning-dashboard-banner.tsx`.


## Caveats
The wallet app does not store your private keys or passphrases for privacy and security concerns. The wallet session object is disconnected upon refreshing the browser. We advise you to avoid refreshing the browser; all statistics are retrieved at regular intervals as configured by `config.js`.
46 changes: 46 additions & 0 deletions products/zillion/cd/base/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: zillion-config
data:
config.js: |
window['config'] = {
networks_config: {
testnet: {
proxy: "0x351a37e2841a45c7f2de18ee45f968e106416273",
impl: "0xa2e4657de8108dd3730eb51f05a1d486d77be2df",
blockchain: "https://dev-api.zilliqa.com",
node_status: "https://testnet-viewer.zilliqa.com",
api_list: [
"https://dev-api.zilliqa.com",
]
},
mainnet: {
proxy: "",
impl: "",
blockchain: "https://api.zilliqa.com",
node_status: "https://staking-viewer.zilliqa.com",
api_list : [
"https://api.zilliqa.com",
"https://ssn.zillacracy.com/api",
"https://ssn-zilliqa.cex.io/api",
"https://ssn.zillet.io",
"https://zil-staking.ezil.me/api",
"https://staking-zil.kucoin.com/api",
]
},
isolated_server: {
proxy: "0x0578B8e9D9c2493D4a2E98f364c7ed311F7a0d71",
impl: "",
blockchain: "https://zilliqa-isolated-server.zilliqa.com",
node_status: "",
api_list : [
"https://zilliqa-isolated-server.zilliqa.com"
]
}
},
blockchain_explorer_config: "viewblock",
refresh_rate_config: 10000,
api_max_retry_attempt: 10,
environment_config: "stage"
}
32 changes: 32 additions & 0 deletions products/zillion/cd/base/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: zillion
namespace: zillion
labels:
"app.kubernetes.io/name": "zillion"
spec:
replicas: 1
selector:
matchLabels:
"app.kubernetes.io/name": "zillion"
strategy:
type: RollingUpdate
template:
metadata:
labels:
"app.kubernetes.io/name": "zillion"
spec:
containers:
- image: zillion
name: zillion
ports:
- containerPort: 80
volumeMounts:
- mountPath: /usr/share/nginx/html/config.js
name: zillion-config
subPath: config.js
volumes:
- name: zillion-config
configMap:
name: zillion-config
Loading