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

Testnet prod #4258

Merged
merged 56 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
9e9942b
feat: update swapandxcall addresses
liu-zhipeng May 9, 2023
fefb8dd
Add router
rhlsthrm May 10, 2023
af29140
Prep release
rhlsthrm May 10, 2023
b1a4d65
tf configs for prover read replica
carlomazzaferro May 10, 2023
4198fd1
fix typo
carlomazzaferro May 10, 2023
d1abbae
Merge pull request #4186 from connext/feat/use-read-replica-for-prover
carlomazzaferro May 10, 2023
1e08af4
Merge branch 'testnet-prod'
rhlsthrm May 10, 2023
38095f8
feat: create utility to find asset record in chain data
LayneHaber May 10, 2023
dd4e138
refactor: use created utility in all cases to ensure string mismatch …
LayneHaber May 10, 2023
e769259
fix: handle checksum failures
LayneHaber May 10, 2023
feded62
chore: add unit tests for helper
LayneHaber May 10, 2023
0dfcdbf
fix: build
LayneHaber May 10, 2023
a17f241
Install pg_cron
just-a-node May 10, 2023
3be4c2f
Create cron jobs
just-a-node May 10, 2023
4d04fd8
Fix name and tweak apply method
just-a-node May 10, 2023
d5aa3d9
fix: remaining .only
LayneHaber May 10, 2023
466f96b
Merge pull request #4194 from connext/hotfix-decimals
LayneHaber May 10, 2023
424c072
ops: match mainnet prod prover memory
LayneHaber May 10, 2023
10c8b1b
Merge pull request #4197 from connext/main
LayneHaber May 11, 2023
30a0c88
Docker container for postgres with pg_cron
just-a-node May 11, 2023
5ff9ee4
Schema update
just-a-node May 11, 2023
6e7f046
Local DB image with pg_cron
just-a-node May 11, 2023
1059472
Use custom pg image with pg_cron
just-a-node May 11, 2023
616354e
Readme update
just-a-node May 11, 2023
c8a969f
Merge branch 'prod' into testnet-prod
rhlsthrm May 11, 2023
d2736da
Fix query
rhlsthrm May 11, 2023
aff4ff6
Fix query
rhlsthrm May 11, 2023
74dbd1c
Build db
rhlsthrm May 11, 2023
88d29cc
Change postgres image
rhlsthrm May 11, 2023
005ee33
Database image
rhlsthrm May 11, 2023
307d12f
Fix conf
rhlsthrm May 11, 2023
92afc8c
Fix package.json
rhlsthrm May 11, 2023
62648fa
Merge branch 'main' into 4148-deploy-midas-to-other-chains
liu-zhipeng May 11, 2023
31e166b
Merge pull request #4205 from connext/4148-deploy-midas-to-other-chains
liu-zhipeng May 11, 2023
03a61ac
bump chain-abstraction sdk version
liu-zhipeng May 11, 2023
8f31dfc
bump chain-abstraction sdk - 18
liu-zhipeng May 11, 2023
47f99aa
Mirror to mainnet
just-a-node May 11, 2023
fda8371
Use module output for parameter group name
just-a-node May 11, 2023
1fa6b1d
Revert carto image env vars
just-a-node May 11, 2023
dbf4def
Merge pull request #4203 from connext/4147-investigate-cartographer-data
LayneHaber May 11, 2023
16dacf8
Merge branch 'main' of https://github.com/connext/monorepo into 4145-…
just-a-node May 11, 2023
73cff1b
Merge pull request #4199 from connext/4145-pg-cron
just-a-node May 11, 2023
205d319
Merge pull request #4209 from connext/main
just-a-node May 11, 2023
dbeaebd
Use explicit parameter group dependency
just-a-node May 12, 2023
ee34d41
Merge pull request #4211 from connext/rds-param-group
just-a-node May 12, 2023
70da857
Ops readme update
just-a-node May 12, 2023
48c2354
Mirror the param group change to mainnet
just-a-node May 12, 2023
32de5e8
Merge pull request #4213 from connext/main
sanchaymittal May 12, 2023
4787284
Change to pending-reboot
rhlsthrm May 12, 2023
a6eae05
Increase mem
rhlsthrm May 15, 2023
5188bbd
testnet prod sync (#4257)
May 17, 2023
6caafdc
Merge branch 'prod' into testnet-prod
rhlsthrm May 17, 2023
ff25f2b
Merge branch 'testnet-prod' of github.com:connext/monorepo into testn…
rhlsthrm May 17, 2023
2f5b603
Testnet sync (#4259)
May 17, 2023
50d8c24
Fix lambda
rhlsthrm May 17, 2023
cae1aac
Bump DB
rhlsthrm May 17, 2023
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
58 changes: 58 additions & 0 deletions .github/workflows/build-test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,58 @@ jobs:
outputs:
json: ${{ steps.meta.outputs.json }}

build-and-push-sdk-server-image:
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/testnet-prod' || github.ref == 'refs/heads/prod'
env:
REGISTRY: ghcr.io
IMAGE_NAME: connext/sdk-server
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Remove watcher from version tag
run: |
tag=${{ github.ref_name }}
if [[ $tag == *watcher-* ]]; then
new_tag=${tag/watcher-/}
echo "::set-output name=docker_tag::$new_tag"
else
echo "::set-output name=docker_tag::''"
fi

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,format=short
type=raw,value=${{ steps.build-and-push-sdk-server-image.outputs.docker_tag }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: docker/sdk-server/Dockerfile

outputs:
json: ${{ steps.meta.outputs.json }}

smoke-tests:
runs-on: ubuntu-latest
needs:
Expand All @@ -711,6 +763,7 @@ jobs:
build-and-push-lighthouse-image,
build-and-push-relayer-image,
build-and-push-watcher-image,
build-and-push-sdk-server-image,
]
env:
ROUTER_PUBLISHER_IMAGE: ${{ fromJSON(needs.build-and-push-router-publisher-image.outputs.json).tags[0] }}
Expand All @@ -722,6 +775,7 @@ jobs:
LIGHTHOUSE_IMAGE: ghcr.io/connext/lighthouse:${{ github.sha }}
RELAYER_IMAGE: ${{ fromJSON(needs.build-and-push-relayer-image.outputs.json).tags[0] }}
WATCHER_IMAGE: ${{ fromJSON(needs.build-and-push-watcher-image.outputs.json).tags[0] }}
SDK_SERVER_IMAGE: ${{ fromJSON(needs.build-and-push-sdk-server-image.outputs.json).tags[0] }}
WEB3_SIGNER_PRIVATE_KEY_ROUTER: "0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3"
WEB3_SIGNER_PRIVATE_KEY_SEQUENCER: "0xae6ae8e5ccbfb04590405997ee2d52d2b330726137b875053c36d94e974d162f"
WEB3_SIGNER_PRIVATE_KEY_RELAYER: "0x09ac2359ab897a5ffc47d7c67df32abbf9c006e00fa2ba36580e0cecc58834fe"
Expand All @@ -747,6 +801,7 @@ jobs:
sequencer-subscriber-tags: ${{ needs.build-and-push-sequencer-subscriber-image.outputs.json }}
relayer-tags: ${{ needs.build-and-push-relayer-image.outputs.json }}
watcher-tags: ${{ needs.build-and-push-watcher-image.outputs.json }}
sdk-server-tags: ${{ needs.build-and-push-sdk-server-image.outputs.json }}

e2e-tests:
if: github.ref != 'refs/heads/staging'
Expand All @@ -763,6 +818,7 @@ jobs:
build-and-push-lighthouse-image,
build-and-push-relayer-image,
build-and-push-watcher-image,
build-and-push-sdk-server-image,
]
env:
ROUTER_PUBLISHER_IMAGE: ${{ fromJSON(needs.build-and-push-router-publisher-image.outputs.json).tags[0] }}
Expand Down Expand Up @@ -806,6 +862,7 @@ jobs:
sequencer-subscriber-tags: ${{ needs.build-and-push-sequencer-subscriber-image.outputs.json }}
relayer-tags: ${{ needs.build-and-push-relayer-image.outputs.json }}
watcher-tags: ${{ needs.build-and-push-watcher-image.outputs.json }}
sdk-server-tags: ${{ needs.build-and-push-sdk-server-image.outputs.json }}

terraform-infra:
if: github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/testnet-prod' || github.ref == 'refs/heads/prod'
Expand Down Expand Up @@ -850,6 +907,7 @@ jobs:
env:
AWS_PROFILE: aws-deployer-connext
TF_VAR_cartographer_image_tag: ${{ github.sha }}
TF_VAR_sdk_server_image_tag: ${{ github.sha }}

runs-on: ubuntu-latest
permissions:
Expand Down
75 changes: 75 additions & 0 deletions docker/sdk-server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
FROM node:18-alpine as node

# ----------------------------------------
# Builds Docker container for nxtp-watcher package.

# ----------------------------------------

FROM node as build
RUN apk update
RUN apk add git

ENV HOME=/tmp/build \
PATH=/tmp/build/node_modules/.bin:./node_modules/.bin:${PATH}

WORKDIR /tmp/build

ARG TEMP_DEPS_DIR

# ----- Copy only the files that affect yarn install -----
# Allows docker to use cache and skip install if dependencies are unchanged.
# Assumes that ./packages/*/package.json files have been copied to TEMP_DEPS_DIR
# with that same directory structure. build.sh does this.
COPY .yarn /tmp/build/.yarn/
COPY .yarnrc.yml /tmp/build/
COPY package.json /tmp/build/
COPY packages/agents/sdk/package.json /tmp/build/packages/agents/sdk/
COPY packages/adapters/cache/package.json /tmp/build/packages/adapters/cache/
COPY packages/adapters/subgraph/package.json /tmp/build/packages/adapters/subgraph/
COPY packages/adapters/web3signer/package.json /tmp/build/packages/adapters/web3signer/
COPY packages/adapters/txservice/package.json /tmp/build/packages/adapters/txservice/
COPY packages/deployments/contracts/package.json /tmp/build/packages/deployments/contracts/
COPY packages/utils/package.json /tmp/build/packages/utils/
COPY yarn.lock /tmp/build/

# ----- Install dependencies -----
# Install dependencies exactly as in the yarn.lock file - no updates.
RUN yarn install

# ----- Copy source and all other files that affect lint, test, build -----
COPY config config/
COPY packages/agents/sdk /tmp/build/packages/agents/sdk
COPY packages/adapters/cache /tmp/build/packages/adapters/cache
COPY packages/adapters/subgraph /tmp/build/packages/adapters/subgraph
COPY packages/adapters/web3signer /tmp/build/packages/adapters/web3signer
COPY packages/adapters/txservice /tmp/build/packages/adapters/txservice
COPY packages/deployments/contracts /tmp/build/packages/deployments/contracts/
COPY packages/utils /tmp/build/packages/utils
COPY .eslintignore /tmp/build/
COPY .eslintrc.js /tmp/build/

# ----- Lint, test and build -----
RUN yarn build

# ----------------------------------------
# Copy files to the deployment image.
# ----------------------------------------

FROM node as runtime

ENV NODE_ENV=production

ARG COMMIT_HASH
ENV COMMIT_HASH ${COMMIT_HASH:-unknown}

# ----- Copy files required at runtime by the app -----
COPY --from=build --chown=node:node /tmp/build /home/node

# This user is created in the base image with uid and gid = 1000.
USER node

WORKDIR /home/node/packages/agents/sdk

EXPOSE 8080

CMD ["node", "--trace-warnings", "dist/index.js"]
17 changes: 17 additions & 0 deletions docker/sdk-server/conifg.local.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"chains": {
"1735353714": {
"providers": ["https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161"]
},
"1735356532": {
"providers": ["https://goerli.optimism.io/"]
},
"9991": {
"providers": ["https://rpc.ankr.com/polygon_mumbai"]
}
},
"logLevel": "debug",
"mnemonic": "<YOUR MNEMONIC HERE>",
"environment": "production",
"network": "testnet"
}
4 changes: 2 additions & 2 deletions ops/mainnet/prod/backend/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ module "cartographer_db" {
source = "../../../modules/db"
identifier = "rds-postgres-cartographer-${var.environment}"
instance_class = "db.t4g.xlarge"
allocated_storage = 60
max_allocated_storage = 200
allocated_storage = 250
max_allocated_storage = 1000


name = "connext" // db name
Expand Down
4 changes: 2 additions & 2 deletions ops/mainnet/prod/core/config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ locals {
relayerFeeTolerance = 60
environment = var.stage
database = {
url = "postgresql://${var.postgres_user}:${var.postgres_password}@db.mainnet.connext.ninja:5432/connext"
url = local.default_db_url
}
messageQueue = {
connection = {
Expand Down Expand Up @@ -288,7 +288,7 @@ locals {
gelatoApiKey = "${var.gelato_api_key}"
environment = var.stage
database = {
url = "postgresql://${var.postgres_user}:${var.postgres_password}@db.mainnet.connext.ninja:5432/connext"
url = local.default_db_url
}
relayers = [
{
Expand Down
6 changes: 5 additions & 1 deletion ops/mainnet/prod/core/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,13 @@ module "lighthouse_prover_cron" {
container_family = "lighthouse-prover"
environment = var.environment
stage = var.stage
container_env_vars = merge(local.lighthouse_env_vars, { LIGHTHOUSE_SERVICE = "prover" })
container_env_vars = merge(local.lighthouse_env_vars, {
LIGHTHOUSE_SERVICE = "prover"
DATABASE_URL = local.read_replica_db_url
})
schedule_expression = "rate(15 minutes)"
memory_size = 1024
timeout = 900
}

module "lighthouse_process_from_root_cron" {
Expand Down
4 changes: 2 additions & 2 deletions ops/testnet/prod/core/config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ locals {
]
environment = var.stage
database = {
url = "postgresql://${var.postgres_user}:${var.postgres_password}@db.testnet.connext.ninja:5432/connext"
url = local.default_db_url
}
messageQueue = {
connection = {
Expand Down Expand Up @@ -271,7 +271,7 @@ locals {
gelatoApiKey = "${var.gelato_api_key}"
environment = var.stage
database = {
url = "postgresql://${var.postgres_user}:${var.postgres_password}@db.testnet.connext.ninja:5432/connext"
url = local.default_db_url
}
relayers = [
{
Expand Down
11 changes: 8 additions & 3 deletions ops/testnet/prod/core/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ provider "aws" {
region = var.region
}


# Fetch AZs in the current region
data "aws_availability_zones" "available" {}

Expand Down Expand Up @@ -263,9 +264,13 @@ module "lighthouse_prover_cron" {
container_family = "lighthouse-prover"
environment = var.environment
stage = var.stage
container_env_vars = merge(local.lighthouse_env_vars, { LIGHTHOUSE_SERVICE = "prover" })
container_env_vars = merge(local.lighthouse_env_vars, {
LIGHTHOUSE_SERVICE = "prover"
DATABASE_URL = local.read_replica_db_url
})
schedule_expression = "rate(5 minutes)"
memory_size = 512
timeout = 900
memory_size = 2048
}

module "lighthouse_process_from_root_cron" {
Expand All @@ -289,7 +294,7 @@ module "lighthouse_propagate_cron" {
environment = var.environment
stage = var.stage
container_env_vars = merge(local.lighthouse_env_vars, { LIGHTHOUSE_SERVICE = "propagate" })
memory_size = 1024
memory_size = 2048
schedule_expression = "rate(30 minutes)"
}

Expand Down
23 changes: 23 additions & 0 deletions ops/testnet/staging/backend/config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ locals {
DD_LAMBDA_HANDLER = "packages/agents/cartographer/poller/dist/index.handler"
}

sdk_server_env_vars = [
{ name = "NXTP_CONFIG", value = local.local_sdk_server_config },
{ name = "ENVIRONMENT", value = var.environment },
{ name = "STAGE", value = var.stage },
{ name = "DD_PROFILING_ENABLED", value = "true" },
{ name = "DD_ENV", value = "${var.environment}-${var.stage}" },
]
postgrest_env_vars = [
{ name = "PGRST_ADMIN_SERVER_PORT", value = "3001" },
{ name = "PGRST_DB_URI", value = "postgres://${var.postgres_user}:${var.postgres_password}@${module.cartographer_db.db_instance_endpoint}/connext" },
Expand All @@ -20,6 +27,22 @@ locals {
{ name = "STAGE", value = var.stage }
]

local_sdk_server_config = jsonencode({
logLevel = "debug"
chains = {
"1735356532" = {
providers = ["https://goerli.optimism.io/"]
}
"1735353714" = {
providers = ["https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161"]
}
"9991" = {
providers = ["https://rpc.ankr.com/polygon_mumbai"]
}
}
environment = var.stage
})

local_cartographer_config = jsonencode({
logLevel = "debug"
chains = {
Expand Down
32 changes: 31 additions & 1 deletion ops/testnet/staging/backend/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module "postgrest" {
private_subnets = module.network.private_subnets
lb_subnets = module.network.public_subnets
internal_lb = false
docker_image = "679752396206.dkr.ecr.${var.region}.amazonaws.com/postgrest:v9.0.0.20220107"
docker_image = "postgrest/postgrest:v10.0.0.20221011"
container_family = "postgrest"
container_port = 3000
loadbalancer_port = 80
Expand All @@ -84,6 +84,36 @@ module "postgrest" {
domain = var.domain
}

module "sdk-server" {
source = "../../../modules/service"
region = var.region
dd_api_key = var.dd_api_key
zone_id = data.aws_route53_zone.primary.zone_id
execution_role_arn = data.aws_iam_role.ecr_admin_role.arn
cluster_id = module.ecs.ecs_cluster_id
vpc_id = module.network.vpc_id
private_subnets = module.network.private_subnets
lb_subnets = module.network.public_subnets
internal_lb = false
docker_image = var.sdk_server_image_tag
container_family = "sdk-server"
container_port = 8080
loadbalancer_port = 80
cpu = 256
memory = 512
instance_count = 2
timeout = 180
environment = var.environment
stage = var.stage
ingress_cdir_blocks = ["0.0.0.0/0"]
ingress_ipv6_cdir_blocks = []
service_security_groups = flatten([module.network.allow_all_sg, module.network.ecs_task_sg])
cert_arn = var.certificate_arn_testnet
container_env_vars = local.sdk_server_env_vars
domain = var.domain
}


module "cartographer-routers-lambda-cron" {
source = "../../../modules/lambda"
ecr_repository_name = "nxtp-cartographer"
Expand Down
7 changes: 7 additions & 0 deletions ops/testnet/staging/backend/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ variable "cartographer_image_tag" {
default = "latest"
}

variable "sdk_server_image_tag" {
type = string
description = "sdk-server image tag"
default = "latest"
}


variable "certificate_arn_testnet" {
default = "arn:aws:acm:us-east-1:679752396206:certificate/45908dc4-137b-4366-8538-4f59ee6a914e"
}
Expand Down
Loading