Skip to content

Commit

Permalink
Revert "Revert "TrustWallet <-> Shared Production merge""
Browse files Browse the repository at this point in the history
  • Loading branch information
arcticfloyd1984 authored Apr 4, 2024
1 parent 0b56fa6 commit aa8e32e
Show file tree
Hide file tree
Showing 468 changed files with 48,928 additions and 1,602 deletions.
17 changes: 16 additions & 1 deletion .env-example
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
CONFIG_PASSPHRASE=
BUNDLER_CONFIG_PASSPHRASE=
BUNDLER_NODE_PATH_INDEX=0
BUNDLER_CHAIN_ID=80001
BUNDLER_MIN_RELAYER_COUNT=5
BUNDLER_MAX_RELAYER_COUNT=10
BUNDLER_FUNDING_BALANCE_THRESHOLD=0.1
BUNDLER_FUNDING_RELAYER_AMOUNT=0.2
BUNDLER_SIMULATION_DATA_JSON='{"tenderlyData": {}}'
BUNDLER_TOKEN_PRICE_JSON='{"coinMarketCapApi": ""}'
BUNDLER_SLACK_JSON='{"token": "","channel": ""}'
BUNDLER_PROVIDER_JSON='{"137": "", "42161": "", "56": "", "10": "", "43114": "", "8453": "", "80001": ""}'
BUNDLER_DATASOURCES_JSON= '{"mongoUrl": "", "redisUrl": ""}'
BUNDLER_SOCKET_SERVICE_JSON='{"wssUrl": "","httpUrl": "","token": "","apiKey": ""}'
BUNDLER_QUEUE_URL=""
BUNDLER_IS_TRUSTWALLET_SETUP=true
BUNDLER_FALLBACK_PROVIDER_JSON='{"137": ["", ""], "42161": ["", ""], "56": ["", ""], "10": ["", ""], "43114": ["", ""], "8453": ["", ""], "80001": ["", ""]}'
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

steps:
- name: Checkout Repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Check if Master is Ahead of Staging
run: |
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/merge_on_master_tw.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# This workflow will do a clean installation of node dependencies, build the
# source code and run tests across different versions of node
# For more information see:
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Main_or_Master
on:
# The trigger event is for every pull request. If we would trigger when we push
# to any branch and on pull request we would have double workflow runs and will
# consume more minutes. I chose to trigger the workflow run on pull requests only.
push:
branches:
- 'dedicated-bundler-setup_new'

jobs:
js_build_test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [21.x]
# node-version: [14.x, 16.x, 18.x, 20.x]
# See supported Node.js release schedule at
# https://nodejs.org/en/about/releases/
steps:
- name: checkout repo
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Yarn install, build and test
run: echo "In the steps below we will build and run first set of tests for all components"
- run: echo yarn install
- run: echo yarn lint
- run: echo yarn build
- run: echo yarn test

container_img_build_push_gar:
needs: [js_build_test]
# Allow the job to fetch a GitHub ID token
permissions:
id-token: write
contents: read
# The plan is to build and push each docker image in parallel.
strategy:
matrix:
image:
- us-docker.pkg.dev/biconomy-prod/bundler/trustwallet
- us-docker.pkg.dev/prj-biconomy-prod-001/bundler/bundler
# LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY/IMAGE
# {owner}/{repo}/.github/workflows/{filename}@{ref}
uses: bcnmy/devops/.github/workflows/container_img_build_push_gar.yaml@master
with:
image: ${{ matrix.image }}
dockerfile: Dockerfile.helm
# GCP project where the identity provider is
# gcloud projects describe prj-workload-identity-001
gcp_project_number: '766873424314'
gcp_pool_id: 'pool-id-github-actions'
# gcp_provider_id: 'ga-GITHUB_REPO_NAME'
gcp_provider_id: 'ga-bundler'
# LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY/IMAGE
gcp_registry: 'us-docker.pkg.dev/biconomy-prod/bundler/trustwallet'
gcp_service_account: '[email protected]'

# TODO: Add integrations tests here
64 changes: 64 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
# This workflow will do a clean installation of node dependencies, build the
# source code and run tests across different versions of node
# For more information see:
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

# yamllint disable rule:line-length
name: PR
on:
pull_request:
branches:
- '*'

jobs:
js_build_test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [21.x]
# node-version: [14.x, 16.x, 18.x, 20.x]
# See supported Node.js release schedule at
# https://nodejs.org/en/about/releases/
steps:
- name: checkout repo
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Yarn install, build and test
run: echo "In the steps below we will build and run first set of tests for all components"
- run: echo yarn install
- run: echo yarn lint
- run: echo yarn build
- run: echo yarn test

container_img_build_push_gar:
needs: [js_build_test]
# Allow the job to fetch a GitHub ID token
permissions:
id-token: write
contents: read
# The plan is to build and push each docker image in parallel.
strategy:
matrix:
image:
- us-docker.pkg.dev/biconomy-prod/bundler/trustwallet
- us-docker.pkg.dev/prj-biconomy-prod-001/bundler/bundler
# LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY/IMAGE
# {owner}/{repo}/.github/workflows/{filename}@{ref}
uses: bcnmy/devops/.github/workflows/container_img_build_push_gar.yaml@master
with:
image: ${{ matrix.image }}
dockerfile: Dockerfile.helm
# GCP project where the identity provider is
# gcloud projects describe prj-workload-identity-001
gcp_project_number: '766873424314'
gcp_pool_id: 'pool-id-github-actions'
# gcp_provider_id: 'ga-GITHUB_REPO_NAME'
gcp_provider_id: 'ga-bundler'
# LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY/IMAGE
gcp_registry: 'us-docker.pkg.dev/biconomy-prod/bundler/trustwallet'
gcp_service_account: '[email protected]'
#
125 changes: 125 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
---
# This workflow will build a docker image and deploy it to trustwallet stating \
# and production environments

# yamllint disable rule:line-length
name: Version_Release
on:
push:
tags:
- v0.**
jobs:
js_build_test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [21.x]
# node-version: [14.x, 16.x, 18.x, 20.x]
# See supported Node.js release schedule at
# https://nodejs.org/en/about/releases/
steps:
- name: checkout repo
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Yarn install, build and test
run: echo "In the steps below we will build and run first set of tests for all components"
- run: echo yarn install
- run: echo yarn lint
- run: echo yarn build
- run: echo yarn test
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Dump GITHUB_REF
run: echo "${GITHUB_REF}"

container_img_build_push_gar:
needs: [js_build_test]
# Allow the job to fetch a GitHub ID token
permissions:
id-token: write
contents: read
# The plan is to build and push each docker image in parallel.
strategy:
matrix:
image:
- us-docker.pkg.dev/biconomy-prod/bundler/trustwallet
- us-docker.pkg.dev/prj-biconomy-prod-001/bundler/bundler
# LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY/IMAGE
# {owner}/{repo}/.github/workflows/{filename}@{ref}
uses: bcnmy/devops/.github/workflows/container_img_build_push_gar.yaml@master
with:
image: ${{ matrix.image }}
dockerfile: Dockerfile.helm
# GCP project where the identity provider is
# gcloud projects describe prj-workload-identity-001
gcp_project_number: '766873424314'
gcp_pool_id: 'pool-id-github-actions'
# gcp_provider_id: 'ga-GITHUB_REPO_NAME'
gcp_provider_id: 'ga-bundler'
# LOCATION-docker.pkg.dev/PROJECT-ID/REPOSITORY/IMAGE
gcp_registry: 'us-docker.pkg.dev/biconomy-prod/bundler/trustwallet'
gcp_service_account: '[email protected]'

deploy_tw_staging:
needs: [container_img_build_push_gar]
# Allow the job to fetch a GitHub ID token
# runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
uses: bcnmy/devops/.github/workflows/deploy_to_gke.yaml@master
with:
# GCP project where the identity provider is
# gcloud projects describe prj-workload-identity-001
gcp_project_number: '766873424314'
gcp_project_id: 'biconomy-prod'
gcp_bastion: 'bastion02'
gcp_bastion_zone: 'us-east1-b'
gcp_pool_id: 'pool-id-github-actions'
# created by devops/gcp/github-actions/configure_workload_identity_federation_with_github_actions_pipelines.sh
# gcp_provider_id: 'ga-GITHUB_REPO_NAME'
gcp_provider_id: 'ga-bundler'
# SERVICE_ACCOUNT_EMAIL="${SERVICE_ACCOUNT}@${PROJECT}.iam.gserviceaccount.com"
gcp_service_account: '[email protected]'
gcp_cluster_name: 'dedicated-bundler'
gcp_cluster_location: 'us-east1'
use_internal_ip: true
# https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
# deploy_command: 'helm ls --all-namespaces'
# deploy_command: 'echo IMG_VERSION is ${GITHUB_REF:10}' # for example extracts v0.0.5 from "refs/tags/v0.0.5"
deploy_command: './install-bundler/bundler-update-release.sh bundler-tw-staging.cfg ${GITHUB_REF:10}'

deploy_tw_prod:
needs: [deploy_tw_staging]
# environment: tw-prod
# Allow the job to fetch a GitHub ID token
# runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
uses: bcnmy/devops/.github/workflows/deploy_to_gke.yaml@master
with:
environment: 'tw-prod'
# GCP project where the identity provider is
# gcloud projects describe prj-workload-identity-001
gcp_project_number: '766873424314'
# GCP project ID where the workload will be deployed
gcp_project_id: 'prj-biconomy-prod-001'
gcp_bastion: 'bastion02'
gcp_bastion_zone: 'us-central1-a'
gcp_pool_id: 'pool-id-github-actions'
# created by devops/gcp/github-actions/configure_workload_identity_federation_with_github_actions_pipelines.sh
# gcp_provider_id: 'ga-GITHUB_REPO_NAME'
gcp_provider_id: 'ga-bundler'
# SERVICE_ACCOUNT_EMAIL="${SERVICE_ACCOUNT}@${PROJECT}.iam.gserviceaccount.com"
gcp_service_account: '[email protected]'
gcp_cluster_name: 'trustwallet'
gcp_cluster_location: 'us-central1'
use_internal_ip: true
deploy_command: './install-bundler/bundler-update-release.sh bundler-tw-production.cfg ${GITHUB_REF:10}'
# deploy_command: 'helm ls --all-namespaces'
19 changes: 16 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
node_modules
.env
yarn-error.log
centrifugo_config.json
relayer/dist
server/dist
coverage
config.json
config.json.enc
*heapsnapshot
.vscode
refundAddresses.ts
*.enc
# Ignore all JSON files
*.json
*json.enc
# But not these specific files
!static-config.json
!config-example.json
!centrifugo_config.json

# If index.ts is not a .json file, you don't need to explicitly exclude it.
# However, if it's actually index.json, include it like so:
#!index.json

!example.cfg
dist/
*.code-workspace
config/development.json
config/production.json
37 changes: 26 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
FROM node:18.17.1-bookworm
FROM node:21.6-bookworm as builder

# install dependencies
RUN apt update

# Tini allows us to avoid several Docker edge cases, see https://github.com/krallin/tini.
# NOTE: See https://github.com/hexops/dockerfile#is-tini-still-required-in-2020-i-thought-docker-added-it-natively
RUN apt-get install tini
# Install dependencies

# arguments
ARG PORT=3000

RUN mkdir -p /relayer-node
WORKDIR /relayer-node
# Set up the directory
WORKDIR /bundler

# Copy package files
COPY package.json yarn.lock ./

# install packages
RUN yarn install
COPY . /relayer-node

# Copy the rest of the files
COPY . /bundler

# Build the application
RUN yarn run build

# Second stage
FROM node:21.6-bookworm

# Tini allows us to avoid several Docker edge cases, see https://github.com/krallin/tini.
# NOTE: See https://github.com/hexops/dockerfile#is-tini-still-required-in-2020-i-thought-docker-added-it-natively

RUN apt-get update && apt-get install -y \
tini \
&& rm -rf /var/lib/apt/lists/*

# Expose the port
EXPOSE 3000

# Non-root user for security purposes.
Expand All @@ -32,11 +43,15 @@ EXPOSE 3000
# such a user does not exist.
RUN addgroup --gid 10001 --system nonroot \
&& adduser --uid 10000 --system --ingroup nonroot --home /home/nonroot nonroot
EXPOSE 3000

WORKDIR /home/nonroot/bundler
COPY --from=builder --chown=10000:10001 /bundler /home/nonroot/bundler


# Use the non-root user to run our application
USER nonroot

ENTRYPOINT ["/usr/bin/tini", "--", "yarn"]

# Default arguments for your app (remove if you have none):
CMD ["run", "start"]
Loading

0 comments on commit aa8e32e

Please sign in to comment.