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

ci: testnet #4594

Merged
merged 13 commits into from
Jun 27, 2023
2 changes: 1 addition & 1 deletion .github/workflows/build-test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
"packages/adapters/txservice:@connext/nxtp-txservice"
"packages/adapters/subgraph:@connext/nxtp-adapters-subgraph"
"packages/adapters/cache:@connext/nxtp-adapters-cache"
"packages/agents/sdk:@connext/sdk"
"packages/agents/sdk-wrapper:@connext/sdk"
)

for entry in "${workspaces[@]}"; do
Expand Down
7 changes: 7 additions & 0 deletions ops/mainnet/prod/core/config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ locals {
DD_LAMBDA_HANDLER = "packages/agents/lighthouse/dist/index.handler"
GRAPH_API_KEY = var.graph_api_key
}
lighthouse_prover_subscriber_env_vars = [
{ name = "NXTP_CONFIG", value = local.local_lighthouse_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}" },
]
router_web3signer_env_vars = [
{ name = "WEB3_SIGNER_PRIVATE_KEY", value = var.router_web3_signer_private_key },
{ name = "WEB3SIGNER_HTTP_HOST_ALLOWLIST", value = "*" },
Expand Down
5 changes: 5 additions & 0 deletions ops/mainnet/prod/core/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ variable "full_image_name_sequencer_subscriber" {
default = "ghcr.io/connext/sequencer-subscriber:0.2.1-beta.8"
}

variable "full_image_name_lighthouse_prover_subscriber" {
type = string
description = "lighthouse subscriber image name"
}

variable "lighthouse_image_tag" {
type = string
description = "lighthouse image tag"
Expand Down
7 changes: 7 additions & 0 deletions ops/testnet/staging/core/config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ locals {
DD_API_KEY = var.dd_api_key,
DD_LAMBDA_HANDLER = "packages/agents/lighthouse/dist/index.handler"
}
lighthouse_prover_subscriber_env_vars = [
{ name = "NXTP_CONFIG", value = local.local_lighthouse_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}" },
]
router_web3signer_env_vars = [
{ name = "WEB3_SIGNER_PRIVATE_KEY", value = var.router_web3_signer_private_key },
{ name = "WEB3SIGNER_HTTP_HOST_ALLOWLIST", value = "*" },
Expand Down
8 changes: 4 additions & 4 deletions ops/testnet/staging/core/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ module "sequencer_publisher_auto_scaling" {
ecs_service_name = module.sequencer_publisher.service_name
ecs_cluster_name = module.ecs.ecs_cluster_name
min_capacity = 10
max_capacity = 300
max_capacity = 300
}

module "sequencer_subscriber" {
Expand Down Expand Up @@ -263,7 +263,7 @@ module "sequencer_subscriber_auto_scaling" {
ecs_service_name = module.sequencer_subscriber.service_name
ecs_cluster_name = module.ecs.ecs_cluster_name
min_capacity = 10
max_capacity = 300
max_capacity = 300
}

module "sequencer_web3signer" {
Expand Down Expand Up @@ -333,7 +333,7 @@ module "lighthouse_prover_subscriber_auto_scaling" {
ecs_service_name = module.lighthouse_prover_subscriber.service_name
ecs_cluster_name = module.ecs.ecs_cluster_name
min_capacity = 10
max_capacity = 300
max_capacity = 300
}

module "lighthouse_prover_cron" {
Expand Down Expand Up @@ -553,7 +553,7 @@ module "router_cache" {
family = "router"
sg_id = module.network.ecs_task_sg
vpc_id = module.network.vpc_id
cache_subnet_group_subnet_ids = module.network.public_sub
cache_subnet_group_subnet_ids = module.network.public_subnets
public_redis = true
}

Expand Down
8 changes: 7 additions & 1 deletion ops/testnet/staging/core/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ variable "full_image_name_router_subscriber" {
default = "ghcr.io/connext/router-subscriber:sha-b5bb49a"
}

variable "full_image_name_router_executor" {
variable "full_image_name_lighthouse_prover_subscriber" {
type = string
description = "router image name"
default = "ghcr.io/connext/lighthouse-subscriber:sha-b5bb49a"
}

variable "full_image_name_router_publisher" {
type = string
description = "router image name"
default = "ghcr.io/connext/router-executor:sha-b5bb49a"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"lint:all": "yarn workspaces foreach --parallel --exclude @connext/nxtp-subgraph --exclude @connext/bridge-reference --exclude @connext/nxtp-integration --exclude @connext/smart-contracts run lint",
"test:all": "yarn workspaces foreach --parallel --exclude @connext/nxtp-relayer --exclude @connext/nxtp-subgraph --exclude @connext/nxtp-integration --exclude @connext/sdk run test",
"clean:all": "yarn workspaces foreach --parallel --exclude @connext/nxtp-integration --exclude @connext/nxtp-subgraph run clean",
"build:all": "yarn workspaces foreach --parallel -pt --exclude @connext/nxtp-subgraph --exclude @connext/bridge-reference run build",
"build:all": "yarn workspaces foreach --parallel -p --topological-dev --exclude @connext/nxtp-subgraph --exclude @connext/bridge-reference run build",
"verify:all": "yarn test:all && yarn clean:all && yarn build:all && yarn lint:all --max-warnings 0",
"version:all": "yarn workspaces foreach run version $0 && yarn run version $0",
"purge:all": "yarn workspaces foreach --parallel run purge && rimraf './node_modules'",
Expand Down
2 changes: 1 addition & 1 deletion packages/agents/sdk-wrapper/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@connext/sdk",
"version": "2.1.0-alpha.0",
"version": "2.1.0-alpha.2",
"description": "Client-side package for interacting with the Connext protocol",
"author": "Connext",
"license": "MIT",
Expand Down
6 changes: 3 additions & 3 deletions packages/agents/sdk-wrapper/src/sdkUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ export class SdkUtils extends SdkShared {
async getRoutersData(params?: {
order?: { orderBy?: string; ascOrDesc?: "asc" | "desc" };
}): Promise<RouterBalance[]> {
const response = await axiosPost(`${this.baseUri}/getRoutersData`, params);
const response = await axiosPost(`${this.baseUri}/getRoutersData`, params ?? {});
return response.data;
}

async getRouterLiquidity(params?: { order?: { orderBy?: string; ascOrDesc?: "asc" | "desc" } }): Promise<any> {
const response = await axiosPost(`${this.baseUri}/getRouterLiquidity`, params);
const response = await axiosPost(`${this.baseUri}/getRouterLiquidity`, params ?? {});
return response.data;
}

Expand All @@ -44,7 +44,7 @@ export class SdkUtils extends SdkShared {
xcallCaller?: string;
range?: { limit?: number; offset?: number };
}): Promise<Transfer[]> {
const response = await axiosPost(`${this.baseUri}/getTransfers`, params);
const response = await axiosPost(`${this.baseUri}/getTransfers`, params ?? {});
return response.data;
}

Expand Down
47 changes: 46 additions & 1 deletion packages/agents/sdk-wrapper/test/sdkUtils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
const mockConfig = mock.config();
const mockChainData = mock.chainData();

describe.only("#SDKUtils", () => {
describe("#SDKUtils", () => {
let sdkUtils: SdkUtils;
let axiosPostStub: SinonStub;
let expectedBaseUri: string;
Expand Down Expand Up @@ -65,6 +65,21 @@ describe.only("#SDKUtils", () => {
expect(axiosPostStub).to.have.been.calledWithExactly(expectedBaseUri + expectedEndpoint, expectedArgs);
expect(res).to.be.deep.eq(expectedRes);
});

it("happy: should send request with default body if params are empty", async () => {
const expectedEndpoint = "/getRoutersData";
const expectedRes = [];

axiosPostStub.resolves({
data: expectedRes,
status: 200,
});

const res = await sdkUtils.getRoutersData();

expect(axiosPostStub).to.have.been.calledWithExactly(expectedBaseUri + expectedEndpoint, {});
expect(res).to.be.deep.eq(expectedRes);
});
});

describe("#getRouterLiquidity", async () => {
Expand All @@ -88,6 +103,21 @@ describe.only("#SDKUtils", () => {
expect(axiosPostStub).to.have.been.calledWithExactly(expectedBaseUri + expectedEndpoint, expectedArgs);
expect(res).to.be.deep.eq(expectedRes);
});

it("happy: should send request with default body if params are empty", async () => {
const expectedEndpoint = "/getRouterLiquidity";
const expectedRes = [];

axiosPostStub.resolves({
data: expectedRes,
status: 200,
});

const res = await sdkUtils.getRouterLiquidity();

expect(axiosPostStub).to.have.been.calledWithExactly(expectedBaseUri + expectedEndpoint, {});
expect(res).to.be.deep.eq(expectedRes);
});
});

describe("#getTransfers", async () => {
Expand All @@ -111,6 +141,21 @@ describe.only("#SDKUtils", () => {
expect(axiosPostStub).to.have.been.calledWithExactly(expectedBaseUri + expectedEndpoint, expectedArgs);
expect(res).to.be.deep.eq(expectedRes);
});

it("happy: should send request with default body if params are empty", async () => {
const expectedEndpoint = "/getTransfers";
const expectedRes = [];

axiosPostStub.resolves({
data: expectedRes,
status: 200,
});

const res = await sdkUtils.getTransfers();

expect(axiosPostStub).to.have.been.calledWithExactly(expectedBaseUri + expectedEndpoint, {});
expect(res).to.be.deep.eq(expectedRes);
});
});

describe("#checkRouterLiquidity", async () => {
Expand Down
6 changes: 5 additions & 1 deletion packages/agents/sdk-wrapper/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
"types": ["node", "mocha", "chai"]
},
"exclude": [],
"references": []
"references": [
{ "path": "../sdk/tsconfig.build.json" },
{ "path": "../../adapters/txservice/tsconfig.build.json" },
{ "path": "../../deployments/contracts/tsconfig.build.json" }
]
}
1 change: 1 addition & 0 deletions packages/examples/sdk-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@connext/nxtp-txservice": "workspace:*",
"@connext/nxtp-utils": "workspace:*",
"@connext/sdk-core": "workspace:*",
"@fastify/cors": "8.3.0",
"@fastify/redis": "6.1.1",
"@fastify/type-provider-typebox": "2.4.0",
"dotenv": "16.0.3",
Expand Down
16 changes: 10 additions & 6 deletions packages/examples/sdk-server/src/routes/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,25 @@ import {
SdkUpdateSlippageParams,
SdkCalculateAmountReceivedParamsSchema,
} from "@connext/sdk-core";
import { createLoggingContext, jsonifyError } from "@connext/nxtp-utils";
import { RoutesOptions } from "../server";

interface BaseRoutesOptions {
interface BaseRoutesOptions extends RoutesOptions {
sdkBaseInstance: SdkBase;
cacheConfig?: {
enabled?: boolean;
expirationTime?: number;
};
}

export const baseRoutes = async (server: FastifyInstance, options: BaseRoutesOptions): Promise<void> => {
const s = server.withTypeProvider<TypeBoxTypeProvider>();
const { sdkBaseInstance, cacheConfig } = options;
const { sdkBaseInstance, logger, cacheConfig } = options;
const { requestContext, methodContext } = createLoggingContext(baseRoutes.name);

const CACHE_EXPIRATION_SECS = cacheConfig?.expirationTime || 300;

server.setErrorHandler(function (error, request, reply) {
logger?.error(`Error: ${error.message} ${request.body}`, requestContext, methodContext);
reply.status(500).send(jsonifyError(error as Error));
});

s.post<{ Body: SdkXCallParams }>(
"/xcall",
{
Expand Down
15 changes: 14 additions & 1 deletion packages/examples/sdk-server/src/routes/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,23 @@ import {
SdkGetDailySwapVolumeParams,
Options,
} from "@connext/sdk-core";
import { createLoggingContext, jsonifyError } from "@connext/nxtp-utils";
import { BigNumber } from "ethers";
import { RoutesOptions } from "../server";

export const poolRoutes = async (server: FastifyInstance, sdkPoolInstance: SdkPool): Promise<any> => {
interface PoolRoutesOptions extends RoutesOptions {
sdkPoolInstance: SdkPool;
}

export const poolRoutes = async (server: FastifyInstance, options: PoolRoutesOptions): Promise<any> => {
const s = server.withTypeProvider<TypeBoxTypeProvider>();
const { sdkPoolInstance, logger } = options;
const { requestContext, methodContext } = createLoggingContext(poolRoutes.name);

server.setErrorHandler(function (error, request, reply) {
logger?.error(`Error: ${error.message} ${request.body}`, requestContext, methodContext);
reply.status(500).send(jsonifyError(error as Error));
});

s.post<{ Body: SdkCalculateSwapParams }>(
"/calculateSwap",
Expand Down
15 changes: 14 additions & 1 deletion packages/examples/sdk-server/src/routes/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,24 @@ import {
SdkRemoveRouterLiquidityForParamsSchema,
SdkRemoveRouterLiquidityForParams,
} from "@connext/sdk-core";
import { createLoggingContext, jsonifyError } from "@connext/nxtp-utils";
import { FastifyInstance } from "fastify";
import { TypeBoxTypeProvider } from "@fastify/type-provider-typebox";
import { RoutesOptions } from "../server";

export const routerRoutes = async (server: FastifyInstance, sdkRouterInstance: SdkRouter): Promise<any> => {
interface RouterRoutesOptions extends RoutesOptions {
sdkRouterInstance: SdkRouter;
}

export const routerRoutes = async (server: FastifyInstance, options: RouterRoutesOptions): Promise<any> => {
const s = server.withTypeProvider<TypeBoxTypeProvider>();
const { sdkRouterInstance, logger } = options;
const { requestContext, methodContext } = createLoggingContext(routerRoutes.name);

server.setErrorHandler(function (error, request, reply) {
logger?.error(`Error: ${error.message} ${request.body}`, requestContext, methodContext);
reply.status(500).send(jsonifyError(error as Error));
});

s.post<{ Body: SdkAddLiquidityForRouterParams }>(
"/addLiquidityForRouter",
Expand Down
15 changes: 14 additions & 1 deletion packages/examples/sdk-server/src/routes/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,23 @@ import {
SdkGetCanonicalTokenIdParams,
Options,
} from "@connext/sdk-core";
import { createLoggingContext, jsonifyError } from "@connext/nxtp-utils";
import { BigNumber, providers } from "ethers";
import { RoutesOptions } from "../server";

export const sharedRoutes = async (server: FastifyInstance, sdkSharedInstance: SdkShared): Promise<any> => {
interface SharedRoutesOptions extends RoutesOptions {
sdkSharedInstance: SdkShared;
}

export const sharedRoutes = async (server: FastifyInstance, options: SharedRoutesOptions): Promise<any> => {
const s = server.withTypeProvider<TypeBoxTypeProvider>();
const { sdkSharedInstance, logger } = options;
const { requestContext, methodContext } = createLoggingContext(sharedRoutes.name);

server.setErrorHandler(function (error, request, reply) {
logger?.error(`Error: ${error.message} ${request.body}`, requestContext, methodContext);
reply.status(500).send(jsonifyError(error as Error));
});

s.get<{ Params: SdkGetConversionRateParams }>(
"/getConversionRate/:chainId",
Expand Down
Loading