From b909179bd3335826ab816d241b08e4ae7bbb7d91 Mon Sep 17 00:00:00 2001 From: soloseng <102702451+soloseng@users.noreply.github.com> Date: Sat, 3 Jun 2023 16:44:14 -0400 Subject: [PATCH 1/7] change default timeout to a variable set by env --- .../combiner/src/common/io.ts | 6 +++++- .../phone-number-privacy/combiner/src/config.ts | 15 +++++++++++++-- .../combiner/src/pnp/endpoints/quota/io.ts | 8 +++++++- .../combiner/src/pnp/endpoints/sign/io.legacy.ts | 8 +++++++- .../combiner/src/pnp/endpoints/sign/io.ts | 8 +++++++- .../common/src/utils/authentication.ts | 8 +++++--- .../phone-number-privacy/signer/src/common/io.ts | 3 ++- .../signer/src/pnp/endpoints/quota/io.legacy.ts | 12 ++++++++++-- .../signer/src/pnp/endpoints/quota/io.ts | 12 ++++++++++-- .../signer/src/pnp/endpoints/sign/io.legacy.ts | 12 ++++++++++-- .../signer/src/pnp/endpoints/sign/io.ts | 12 ++++++++++-- .../phone-number-privacy/signer/src/server.ts | 12 ++++++++---- 12 files changed, 94 insertions(+), 22 deletions(-) diff --git a/packages/phone-number-privacy/combiner/src/common/io.ts b/packages/phone-number-privacy/combiner/src/common/io.ts index db175e48a84..d7ba08e81d0 100644 --- a/packages/phone-number-privacy/combiner/src/common/io.ts +++ b/packages/phone-number-privacy/combiner/src/common/io.ts @@ -42,7 +42,11 @@ export abstract class IO { response: Response> ): Promise | null> - abstract authenticate(request: Request<{}, {}, R>, logger?: Logger): Promise + abstract authenticate( + request: Request<{}, {}, R>, + logger?: Logger, + timeoutMs?: number + ): Promise abstract sendFailure( error: ErrorType, diff --git a/packages/phone-number-privacy/combiner/src/config.ts b/packages/phone-number-privacy/combiner/src/config.ts index da962d4ca15..ae64f7ce25c 100644 --- a/packages/phone-number-privacy/combiner/src/config.ts +++ b/packages/phone-number-privacy/combiner/src/config.ts @@ -1,4 +1,10 @@ -import { BlockchainConfig, rootLogger, TestUtils, toBool } from '@celo/phone-number-privacy-common' +import { + BlockchainConfig, + FULL_NODE_TIMEOUT_IN_MS, + rootLogger, + TestUtils, + toBool, +} from '@celo/phone-number-privacy-common' import * as functions from 'firebase-functions' export function getCombinerVersion(): string { return process.env.npm_package_version ?? require('../package.json').version ?? '0.0.0' @@ -23,12 +29,13 @@ export interface OdisConfig { shouldFailOpen: boolean // TODO (https://github.com/celo-org/celo-monorepo/issues/9862) consider refactoring config, this isn't relevant to domains endpoints odisServices: { signers: string - timeoutMilliSeconds: number + timeoutMilliSeconds: number // XXX (soloseng): what is this timeout used for? could it also be used to replace FULL_NODE_TIMEOUT_IN_MS? } keys: { currentVersion: number versions: string // parse as KeyVersionInfo[] } + timeoutMs: number } export interface CombinerConfig { @@ -94,6 +101,7 @@ if (DEV_MODE) { }, ]), }, + timeoutMs: Number(process.env.TIMEOUT_MS ?? FULL_NODE_TIMEOUT_IN_MS), }, domains: { serviceName: defaultServiceName, @@ -126,6 +134,7 @@ if (DEV_MODE) { }, ]), }, + timeoutMs: Number(process.env.TIMEOUT_MS ?? FULL_NODE_TIMEOUT_IN_MS), }, } } else { @@ -150,6 +159,7 @@ if (DEV_MODE) { currentVersion: Number(functionConfig.pnp_keys.current_version), versions: functionConfig.pnp_keys.versions, }, + timeoutMs: Number(process.env.TIMEOUT_MS ?? FULL_NODE_TIMEOUT_IN_MS), }, domains: { serviceName: functionConfig.domains.service_name ?? defaultServiceName, @@ -165,6 +175,7 @@ if (DEV_MODE) { currentVersion: Number(functionConfig.domains_keys.current_version), versions: functionConfig.domains_keys.versions, }, + timeoutMs: Number(process.env.TIMEOUT_MS ?? FULL_NODE_TIMEOUT_IN_MS), }, } } diff --git a/packages/phone-number-privacy/combiner/src/pnp/endpoints/quota/io.ts b/packages/phone-number-privacy/combiner/src/pnp/endpoints/quota/io.ts index 2680a560f29..efc023dcdf5 100644 --- a/packages/phone-number-privacy/combiner/src/pnp/endpoints/quota/io.ts +++ b/packages/phone-number-privacy/combiner/src/pnp/endpoints/quota/io.ts @@ -66,7 +66,13 @@ export class PnpQuotaIO extends IO { } async authenticate(request: Request<{}, {}, PnpQuotaRequest>, logger: Logger): Promise { - return authenticateUser(request, this.kit, logger, this.config.shouldFailOpen) + return authenticateUser( + request, + this.kit, + logger, + this.config.timeoutMs, + this.config.shouldFailOpen + ) } sendSuccess( diff --git a/packages/phone-number-privacy/combiner/src/pnp/endpoints/sign/io.legacy.ts b/packages/phone-number-privacy/combiner/src/pnp/endpoints/sign/io.legacy.ts index f2926aed541..409de8f7a5e 100644 --- a/packages/phone-number-privacy/combiner/src/pnp/endpoints/sign/io.legacy.ts +++ b/packages/phone-number-privacy/combiner/src/pnp/endpoints/sign/io.legacy.ts @@ -85,7 +85,13 @@ export class LegacyPnpSignIO extends IO { request: Request<{}, {}, LegacySignMessageRequest>, logger: Logger ): Promise { - return authenticateUser(request, this.kit, logger, this.config.shouldFailOpen) + return authenticateUser( + request, + this.kit, + logger, + this.config.timeoutMs, + this.config.shouldFailOpen + ) } sendSuccess( diff --git a/packages/phone-number-privacy/combiner/src/pnp/endpoints/sign/io.ts b/packages/phone-number-privacy/combiner/src/pnp/endpoints/sign/io.ts index f008597067b..1e1f5ef1f56 100644 --- a/packages/phone-number-privacy/combiner/src/pnp/endpoints/sign/io.ts +++ b/packages/phone-number-privacy/combiner/src/pnp/endpoints/sign/io.ts @@ -84,7 +84,13 @@ export class PnpSignIO extends IO { request: Request<{}, {}, SignMessageRequest>, logger: Logger ): Promise { - return authenticateUser(request, this.kit, logger, this.config.shouldFailOpen) + return authenticateUser( + request, + this.kit, + logger, + this.config.timeoutMs, + this.config.shouldFailOpen + ) } sendSuccess( diff --git a/packages/phone-number-privacy/common/src/utils/authentication.ts b/packages/phone-number-privacy/common/src/utils/authentication.ts index cc30def42d9..0169983159f 100644 --- a/packages/phone-number-privacy/common/src/utils/authentication.ts +++ b/packages/phone-number-privacy/common/src/utils/authentication.ts @@ -24,6 +24,7 @@ export async function authenticateUser( request: Request<{}, {}, R>, contractKit: ContractKit, logger: Logger, + timeoutMs: number, shouldFailOpen: boolean = false, warnings: ErrorType[] = [] ): Promise { @@ -42,7 +43,7 @@ export async function authenticateUser( if (authMethod && authMethod === AuthenticationMethod.ENCRYPTION_KEY) { let registeredEncryptionKey try { - registeredEncryptionKey = await getDataEncryptionKey(signer, contractKit, logger) + registeredEncryptionKey = await getDataEncryptionKey(signer, contractKit, logger, timeoutMs) } catch (err) { // getDataEncryptionKey should only throw if there is a full-node connection issue. // That is, it does not throw if the DEK is undefined or invalid @@ -127,7 +128,8 @@ export function verifyDEKSignature( export async function getDataEncryptionKey( address: string, contractKit: ContractKit, - logger: Logger + logger: Logger, + timeoutMs: number ): Promise { try { const res = await retryAsyncWithBackOffAndTimeout( @@ -139,7 +141,7 @@ export async function getDataEncryptionKey( [], RETRY_DELAY_IN_MS, 1.5, - FULL_NODE_TIMEOUT_IN_MS + timeoutMs ) return res } catch (error) { diff --git a/packages/phone-number-privacy/signer/src/common/io.ts b/packages/phone-number-privacy/signer/src/common/io.ts index 96df9e8115b..1bfe7b4a655 100644 --- a/packages/phone-number-privacy/signer/src/common/io.ts +++ b/packages/phone-number-privacy/signer/src/common/io.ts @@ -26,7 +26,8 @@ export abstract class IO { abstract authenticate( request: Request<{}, {}, R>, warnings?: string[], - logger?: Logger + logger?: Logger, + timeoutMs?: number ): Promise abstract sendFailure( diff --git a/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.legacy.ts b/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.legacy.ts index b9cb4e9e7fc..193c9a8dd09 100644 --- a/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.legacy.ts +++ b/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.legacy.ts @@ -28,7 +28,8 @@ export class LegacyPnpQuotaIO extends IO { constructor( readonly enabled: boolean, readonly shouldFailOpen: boolean, - readonly kit: ContractKit + readonly kit: ContractKit, + readonly timeoutMs: number ) { super(enabled) } @@ -64,7 +65,14 @@ export class LegacyPnpQuotaIO extends IO { warnings: ErrorType[], logger: Logger ): Promise { - return authenticateUser(request, this.kit, logger, this.shouldFailOpen, warnings) + return authenticateUser( + request, + this.kit, + logger, + this.timeoutMs, + this.shouldFailOpen, + warnings + ) } sendSuccess( diff --git a/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.ts b/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.ts index 3a367fae728..5525f194686 100644 --- a/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.ts +++ b/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.ts @@ -27,7 +27,8 @@ export class PnpQuotaIO extends IO { constructor( readonly enabled: boolean, readonly shouldFailOpen: boolean, - readonly kit: ContractKit + readonly kit: ContractKit, + readonly timeoutMs: number ) { super(enabled) } @@ -62,7 +63,14 @@ export class PnpQuotaIO extends IO { warnings: ErrorType[], logger: Logger ): Promise { - return authenticateUser(request, this.kit, logger, this.shouldFailOpen, warnings) + return authenticateUser( + request, + this.kit, + logger, + this.timeoutMs, + this.shouldFailOpen, + warnings + ) } sendSuccess( diff --git a/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.legacy.ts b/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.legacy.ts index 70d8068aa07..be26a2931a7 100644 --- a/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.legacy.ts +++ b/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.legacy.ts @@ -32,7 +32,8 @@ export class LegacyPnpSignIO extends IO { constructor( readonly enabled: boolean, readonly shouldFailOpen: boolean, - readonly kit: ContractKit + readonly kit: ContractKit, + readonly timeoutMs: number ) { super(enabled) } @@ -76,7 +77,14 @@ export class LegacyPnpSignIO extends IO { warnings: ErrorType[], logger: Logger ): Promise { - return authenticateUser(request, this.kit, logger, this.shouldFailOpen, warnings) + return authenticateUser( + request, + this.kit, + logger, + this.timeoutMs, + this.shouldFailOpen, + warnings + ) } sendSuccess( diff --git a/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.ts b/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.ts index 7e522defd0a..1fb0c810ea9 100644 --- a/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.ts +++ b/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.ts @@ -31,7 +31,8 @@ export class PnpSignIO extends IO { constructor( readonly enabled: boolean, readonly shouldFailOpen: boolean, - readonly kit: ContractKit + readonly kit: ContractKit, + readonly timeoutMs: number ) { super(enabled) } @@ -72,7 +73,14 @@ export class PnpSignIO extends IO { warnings: ErrorType[], logger: Logger ): Promise { - return authenticateUser(request, this.kit, logger, this.shouldFailOpen, warnings) + return authenticateUser( + request, + this.kit, + logger, + this.timeoutMs, + this.shouldFailOpen, + warnings + ) } sendSuccess( diff --git a/packages/phone-number-privacy/signer/src/server.ts b/packages/phone-number-privacy/signer/src/server.ts index 7b0ba8d472b..b9de5f79709 100644 --- a/packages/phone-number-privacy/signer/src/server.ts +++ b/packages/phone-number-privacy/signer/src/server.ts @@ -98,7 +98,8 @@ export function startSigner( new PnpQuotaIO( config.api.phoneNumberPrivacy.enabled, config.api.phoneNumberPrivacy.shouldFailOpen, // TODO (https://github.com/celo-org/celo-monorepo/issues/9862) consider refactoring config to make the code cleaner - kit + kit, + config.timeout ) ) ) @@ -111,7 +112,8 @@ export function startSigner( new PnpSignIO( config.api.phoneNumberPrivacy.enabled, config.api.phoneNumberPrivacy.shouldFailOpen, - kit + kit, + config.timeout ) ) ) @@ -124,7 +126,8 @@ export function startSigner( new LegacyPnpSignIO( config.api.legacyPhoneNumberPrivacy.enabled, config.api.legacyPhoneNumberPrivacy.shouldFailOpen, - kit + kit, + config.timeout ) ) ) @@ -135,7 +138,8 @@ export function startSigner( new LegacyPnpQuotaIO( config.api.legacyPhoneNumberPrivacy.enabled, config.api.legacyPhoneNumberPrivacy.shouldFailOpen, - kit + kit, + config.timeout ) ) ) From 186123f75013d5d0c6b3e784cc5551062d55b21b Mon Sep 17 00:00:00 2001 From: soloseng <102702451+soloseng@users.noreply.github.com> Date: Sat, 3 Jun 2023 17:03:51 -0400 Subject: [PATCH 2/7] updated authentication test --- .../common/test/utils/authentication.test.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/phone-number-privacy/common/test/utils/authentication.test.ts b/packages/phone-number-privacy/common/test/utils/authentication.test.ts index 4e129b6fbd5..739d38efd01 100644 --- a/packages/phone-number-privacy/common/test/utils/authentication.test.ts +++ b/packages/phone-number-privacy/common/test/utils/authentication.test.ts @@ -2,7 +2,7 @@ import { hexToBuffer } from '@celo/base' import { ContractKit } from '@celo/contractkit' import Logger from 'bunyan' import { Request } from 'express' -import { ErrorMessage, ErrorType } from '../../lib' +import { ErrorMessage, ErrorType, FULL_NODE_TIMEOUT_IN_MS } from '../../lib' import { AuthenticationMethod } from '../../src/interfaces/requests' import * as auth from '../../src/utils/authentication' @@ -28,6 +28,7 @@ describe('Authentication test suite', () => { sampleRequest, mockContractKit, logger, + FULL_NODE_TIMEOUT_IN_MS, true, warnings ) @@ -49,6 +50,7 @@ describe('Authentication test suite', () => { sampleRequest, mockContractKit, logger, + FULL_NODE_TIMEOUT_IN_MS, true, warnings ) @@ -73,6 +75,7 @@ describe('Authentication test suite', () => { sampleRequest, mockContractKit, logger, + FULL_NODE_TIMEOUT_IN_MS, true, warnings ) @@ -97,6 +100,7 @@ describe('Authentication test suite', () => { sampleRequest, mockContractKit, logger, + FULL_NODE_TIMEOUT_IN_MS, false, warnings ) @@ -131,6 +135,7 @@ describe('Authentication test suite', () => { sampleRequest, mockContractKit, logger, + FULL_NODE_TIMEOUT_IN_MS, true, warnings ) @@ -161,7 +166,12 @@ describe('Authentication test suite', () => { const warnings: ErrorType[] = [] - const success = await auth.authenticateUser(sampleRequest, mockContractKit, logger) + const success = await auth.authenticateUser( + sampleRequest, + mockContractKit, + logger, + FULL_NODE_TIMEOUT_IN_MS + ) expect(success).toBe(false) expect(warnings).toEqual([]) @@ -202,6 +212,7 @@ describe('Authentication test suite', () => { sampleRequest, mockContractKit, logger, + FULL_NODE_TIMEOUT_IN_MS, true, warnings ) @@ -253,6 +264,7 @@ describe('Authentication test suite', () => { sampleRequest, mockContractKit, logger, + FULL_NODE_TIMEOUT_IN_MS, true, warnings ) @@ -299,6 +311,7 @@ describe('Authentication test suite', () => { sampleRequest, mockContractKit, logger, + FULL_NODE_TIMEOUT_IN_MS, true, warnings ) @@ -346,6 +359,7 @@ describe('Authentication test suite', () => { sampleRequest, mockContractKit, logger, + FULL_NODE_TIMEOUT_IN_MS, true, warnings ) @@ -390,6 +404,7 @@ describe('Authentication test suite', () => { sampleRequest, mockContractKit, logger, + FULL_NODE_TIMEOUT_IN_MS, true, warnings ) From c6aeb11670e30d14d6be4cd9c30d49d7920c7987 Mon Sep 17 00:00:00 2001 From: soloseng <102702451+soloseng@users.noreply.github.com> Date: Tue, 13 Jun 2023 20:37:09 -0400 Subject: [PATCH 3/7] PR feedback --- .../combiner/src/common/io.ts | 6 +-- .../combiner/src/config.ts | 13 ++--- .../combiner/src/pnp/endpoints/quota/io.ts | 5 +- .../src/pnp/endpoints/sign/io.legacy.ts | 5 +- .../combiner/src/pnp/endpoints/sign/io.ts | 5 +- .../common/src/utils/authentication.ts | 4 +- .../common/src/utils/contracts.ts | 1 + .../common/test/utils/authentication.test.ts | 47 +++++++++---------- .../signer/src/common/io.ts | 3 +- .../phone-number-privacy/signer/src/config.ts | 7 ++- .../src/pnp/endpoints/quota/io.legacy.ts | 4 +- .../signer/src/pnp/endpoints/quota/io.ts | 4 +- .../src/pnp/endpoints/sign/io.legacy.ts | 4 +- .../signer/src/pnp/endpoints/sign/io.ts | 4 +- .../phone-number-privacy/signer/src/server.ts | 8 ++-- 15 files changed, 60 insertions(+), 60 deletions(-) diff --git a/packages/phone-number-privacy/combiner/src/common/io.ts b/packages/phone-number-privacy/combiner/src/common/io.ts index d7ba08e81d0..db175e48a84 100644 --- a/packages/phone-number-privacy/combiner/src/common/io.ts +++ b/packages/phone-number-privacy/combiner/src/common/io.ts @@ -42,11 +42,7 @@ export abstract class IO { response: Response> ): Promise | null> - abstract authenticate( - request: Request<{}, {}, R>, - logger?: Logger, - timeoutMs?: number - ): Promise + abstract authenticate(request: Request<{}, {}, R>, logger?: Logger): Promise abstract sendFailure( error: ErrorType, diff --git a/packages/phone-number-privacy/combiner/src/config.ts b/packages/phone-number-privacy/combiner/src/config.ts index ae64f7ce25c..9bfff36f24c 100644 --- a/packages/phone-number-privacy/combiner/src/config.ts +++ b/packages/phone-number-privacy/combiner/src/config.ts @@ -29,13 +29,13 @@ export interface OdisConfig { shouldFailOpen: boolean // TODO (https://github.com/celo-org/celo-monorepo/issues/9862) consider refactoring config, this isn't relevant to domains endpoints odisServices: { signers: string - timeoutMilliSeconds: number // XXX (soloseng): what is this timeout used for? could it also be used to replace FULL_NODE_TIMEOUT_IN_MS? + timeoutMilliSeconds: number } keys: { currentVersion: number versions: string // parse as KeyVersionInfo[] } - timeoutMs: number + fullNodeTimeoutMs: number } export interface CombinerConfig { @@ -101,7 +101,7 @@ if (DEV_MODE) { }, ]), }, - timeoutMs: Number(process.env.TIMEOUT_MS ?? FULL_NODE_TIMEOUT_IN_MS), + fullNodeTimeoutMs: FULL_NODE_TIMEOUT_IN_MS, }, domains: { serviceName: defaultServiceName, @@ -134,7 +134,7 @@ if (DEV_MODE) { }, ]), }, - timeoutMs: Number(process.env.TIMEOUT_MS ?? FULL_NODE_TIMEOUT_IN_MS), + fullNodeTimeoutMs: FULL_NODE_TIMEOUT_IN_MS, }, } } else { @@ -144,6 +144,7 @@ if (DEV_MODE) { blockchain: { provider: functionConfig.blockchain.provider, apiKey: functionConfig.blockchain.api_key, + timeout_ms: Number(functionConfig.blockchain.timeout_ms ?? FULL_NODE_TIMEOUT_IN_MS), }, phoneNumberPrivacy: { serviceName: functionConfig.pnp.service_name ?? defaultServiceName, @@ -159,7 +160,7 @@ if (DEV_MODE) { currentVersion: Number(functionConfig.pnp_keys.current_version), versions: functionConfig.pnp_keys.versions, }, - timeoutMs: Number(process.env.TIMEOUT_MS ?? FULL_NODE_TIMEOUT_IN_MS), + fullNodeTimeoutMs: Number(functionConfig.blockchain.timeout_ms ?? FULL_NODE_TIMEOUT_IN_MS), }, domains: { serviceName: functionConfig.domains.service_name ?? defaultServiceName, @@ -175,7 +176,7 @@ if (DEV_MODE) { currentVersion: Number(functionConfig.domains_keys.current_version), versions: functionConfig.domains_keys.versions, }, - timeoutMs: Number(process.env.TIMEOUT_MS ?? FULL_NODE_TIMEOUT_IN_MS), + fullNodeTimeoutMs: Number(functionConfig.blockchain.timeout_ms ?? FULL_NODE_TIMEOUT_IN_MS), }, } } diff --git a/packages/phone-number-privacy/combiner/src/pnp/endpoints/quota/io.ts b/packages/phone-number-privacy/combiner/src/pnp/endpoints/quota/io.ts index efc023dcdf5..64c402b7ebc 100644 --- a/packages/phone-number-privacy/combiner/src/pnp/endpoints/quota/io.ts +++ b/packages/phone-number-privacy/combiner/src/pnp/endpoints/quota/io.ts @@ -70,8 +70,9 @@ export class PnpQuotaIO extends IO { request, this.kit, logger, - this.config.timeoutMs, - this.config.shouldFailOpen + this.config.shouldFailOpen, + [], + this.config.fullNodeTimeoutMs ) } diff --git a/packages/phone-number-privacy/combiner/src/pnp/endpoints/sign/io.legacy.ts b/packages/phone-number-privacy/combiner/src/pnp/endpoints/sign/io.legacy.ts index 409de8f7a5e..bfd15656083 100644 --- a/packages/phone-number-privacy/combiner/src/pnp/endpoints/sign/io.legacy.ts +++ b/packages/phone-number-privacy/combiner/src/pnp/endpoints/sign/io.legacy.ts @@ -89,8 +89,9 @@ export class LegacyPnpSignIO extends IO { request, this.kit, logger, - this.config.timeoutMs, - this.config.shouldFailOpen + this.config.shouldFailOpen, + [], + this.config.fullNodeTimeoutMs ) } diff --git a/packages/phone-number-privacy/combiner/src/pnp/endpoints/sign/io.ts b/packages/phone-number-privacy/combiner/src/pnp/endpoints/sign/io.ts index 1e1f5ef1f56..ce02dc0321b 100644 --- a/packages/phone-number-privacy/combiner/src/pnp/endpoints/sign/io.ts +++ b/packages/phone-number-privacy/combiner/src/pnp/endpoints/sign/io.ts @@ -88,8 +88,9 @@ export class PnpSignIO extends IO { request, this.kit, logger, - this.config.timeoutMs, - this.config.shouldFailOpen + this.config.shouldFailOpen, + [], + this.config.fullNodeTimeoutMs ) } diff --git a/packages/phone-number-privacy/common/src/utils/authentication.ts b/packages/phone-number-privacy/common/src/utils/authentication.ts index 0169983159f..79c70acca0a 100644 --- a/packages/phone-number-privacy/common/src/utils/authentication.ts +++ b/packages/phone-number-privacy/common/src/utils/authentication.ts @@ -24,9 +24,9 @@ export async function authenticateUser( request: Request<{}, {}, R>, contractKit: ContractKit, logger: Logger, - timeoutMs: number, shouldFailOpen: boolean = false, - warnings: ErrorType[] = [] + warnings: ErrorType[] = [], + timeoutMs: number = FULL_NODE_TIMEOUT_IN_MS ): Promise { logger.debug('Authenticating user') diff --git a/packages/phone-number-privacy/common/src/utils/contracts.ts b/packages/phone-number-privacy/common/src/utils/contracts.ts index f4952231f1f..80c18464059 100644 --- a/packages/phone-number-privacy/common/src/utils/contracts.ts +++ b/packages/phone-number-privacy/common/src/utils/contracts.ts @@ -3,6 +3,7 @@ import { ContractKit, newKit, newKitWithApiKey } from '@celo/contractkit' export interface BlockchainConfig { provider: string apiKey?: string + timeout_ms?: number } export function getContractKit(config: BlockchainConfig): ContractKit { diff --git a/packages/phone-number-privacy/common/test/utils/authentication.test.ts b/packages/phone-number-privacy/common/test/utils/authentication.test.ts index 739d38efd01..c08a87c16bf 100644 --- a/packages/phone-number-privacy/common/test/utils/authentication.test.ts +++ b/packages/phone-number-privacy/common/test/utils/authentication.test.ts @@ -28,9 +28,9 @@ describe('Authentication test suite', () => { sampleRequest, mockContractKit, logger, - FULL_NODE_TIMEOUT_IN_MS, true, - warnings + warnings, + FULL_NODE_TIMEOUT_IN_MS ) expect(success).toBe(false) @@ -50,9 +50,9 @@ describe('Authentication test suite', () => { sampleRequest, mockContractKit, logger, - FULL_NODE_TIMEOUT_IN_MS, true, - warnings + warnings, + FULL_NODE_TIMEOUT_IN_MS ) expect(success).toBe(false) @@ -75,9 +75,9 @@ describe('Authentication test suite', () => { sampleRequest, mockContractKit, logger, - FULL_NODE_TIMEOUT_IN_MS, true, - warnings + warnings, + FULL_NODE_TIMEOUT_IN_MS ) expect(success).toBe(true) @@ -100,9 +100,9 @@ describe('Authentication test suite', () => { sampleRequest, mockContractKit, logger, - FULL_NODE_TIMEOUT_IN_MS, false, - warnings + warnings, + FULL_NODE_TIMEOUT_IN_MS ) expect(success).toBe(false) @@ -135,9 +135,9 @@ describe('Authentication test suite', () => { sampleRequest, mockContractKit, logger, - FULL_NODE_TIMEOUT_IN_MS, true, - warnings + warnings, + FULL_NODE_TIMEOUT_IN_MS ) expect(success).toBe(false) @@ -166,12 +166,7 @@ describe('Authentication test suite', () => { const warnings: ErrorType[] = [] - const success = await auth.authenticateUser( - sampleRequest, - mockContractKit, - logger, - FULL_NODE_TIMEOUT_IN_MS - ) + const success = await auth.authenticateUser(sampleRequest, mockContractKit, logger) expect(success).toBe(false) expect(warnings).toEqual([]) @@ -212,9 +207,9 @@ describe('Authentication test suite', () => { sampleRequest, mockContractKit, logger, - FULL_NODE_TIMEOUT_IN_MS, true, - warnings + warnings, + FULL_NODE_TIMEOUT_IN_MS ) expect(success).toBe(true) @@ -264,9 +259,9 @@ describe('Authentication test suite', () => { sampleRequest, mockContractKit, logger, - FULL_NODE_TIMEOUT_IN_MS, true, - warnings + warnings, + FULL_NODE_TIMEOUT_IN_MS ) expect(success).toBe(false) @@ -311,9 +306,9 @@ describe('Authentication test suite', () => { sampleRequest, mockContractKit, logger, - FULL_NODE_TIMEOUT_IN_MS, true, - warnings + warnings, + FULL_NODE_TIMEOUT_IN_MS ) expect(success).toBe(false) @@ -359,9 +354,9 @@ describe('Authentication test suite', () => { sampleRequest, mockContractKit, logger, - FULL_NODE_TIMEOUT_IN_MS, true, - warnings + warnings, + FULL_NODE_TIMEOUT_IN_MS ) expect(success).toBe(false) @@ -404,9 +399,9 @@ describe('Authentication test suite', () => { sampleRequest, mockContractKit, logger, - FULL_NODE_TIMEOUT_IN_MS, true, - warnings + warnings, + FULL_NODE_TIMEOUT_IN_MS ) expect(success).toBe(false) diff --git a/packages/phone-number-privacy/signer/src/common/io.ts b/packages/phone-number-privacy/signer/src/common/io.ts index 1bfe7b4a655..96df9e8115b 100644 --- a/packages/phone-number-privacy/signer/src/common/io.ts +++ b/packages/phone-number-privacy/signer/src/common/io.ts @@ -26,8 +26,7 @@ export abstract class IO { abstract authenticate( request: Request<{}, {}, R>, warnings?: string[], - logger?: Logger, - timeoutMs?: number + logger?: Logger ): Promise abstract sendFailure( diff --git a/packages/phone-number-privacy/signer/src/config.ts b/packages/phone-number-privacy/signer/src/config.ts index cfa3881b91f..b9fe93a7759 100644 --- a/packages/phone-number-privacy/signer/src/config.ts +++ b/packages/phone-number-privacy/signer/src/config.ts @@ -1,4 +1,8 @@ -import { BlockchainConfig, toBool } from '@celo/phone-number-privacy-common' +import { + BlockchainConfig, + FULL_NODE_TIMEOUT_IN_MS, + toBool, +} from '@celo/phone-number-privacy-common' import BigNumber from 'bignumber.js' require('dotenv').config() @@ -136,6 +140,7 @@ export const config: SignerConfig = { blockchain: { provider: env.BLOCKCHAIN_PROVIDER, apiKey: env.BLOCKCHAIN_API_KEY, + timeout_ms: Number(env.TIMEOUT_MS ?? FULL_NODE_TIMEOUT_IN_MS), }, db: { type: env.DB_TYPE ? env.DB_TYPE.toLowerCase() : SupportedDatabase.Postgres, diff --git a/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.legacy.ts b/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.legacy.ts index 193c9a8dd09..6bfc6b38240 100644 --- a/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.legacy.ts +++ b/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.legacy.ts @@ -69,9 +69,9 @@ export class LegacyPnpQuotaIO extends IO { request, this.kit, logger, - this.timeoutMs, this.shouldFailOpen, - warnings + warnings, + this.timeoutMs ) } diff --git a/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.ts b/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.ts index 5525f194686..94cfcfd9336 100644 --- a/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.ts +++ b/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.ts @@ -67,9 +67,9 @@ export class PnpQuotaIO extends IO { request, this.kit, logger, - this.timeoutMs, this.shouldFailOpen, - warnings + warnings, + this.timeoutMs ) } diff --git a/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.legacy.ts b/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.legacy.ts index be26a2931a7..200ce365101 100644 --- a/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.legacy.ts +++ b/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.legacy.ts @@ -81,9 +81,9 @@ export class LegacyPnpSignIO extends IO { request, this.kit, logger, - this.timeoutMs, this.shouldFailOpen, - warnings + warnings, + this.timeoutMs ) } diff --git a/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.ts b/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.ts index 1fb0c810ea9..7a38a034b72 100644 --- a/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.ts +++ b/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.ts @@ -77,9 +77,9 @@ export class PnpSignIO extends IO { request, this.kit, logger, - this.timeoutMs, this.shouldFailOpen, - warnings + warnings, + this.timeoutMs ) } diff --git a/packages/phone-number-privacy/signer/src/server.ts b/packages/phone-number-privacy/signer/src/server.ts index b9de5f79709..dc057526c0b 100644 --- a/packages/phone-number-privacy/signer/src/server.ts +++ b/packages/phone-number-privacy/signer/src/server.ts @@ -99,7 +99,7 @@ export function startSigner( config.api.phoneNumberPrivacy.enabled, config.api.phoneNumberPrivacy.shouldFailOpen, // TODO (https://github.com/celo-org/celo-monorepo/issues/9862) consider refactoring config to make the code cleaner kit, - config.timeout + config.blockchain.timeout_ms ) ) ) @@ -113,7 +113,7 @@ export function startSigner( config.api.phoneNumberPrivacy.enabled, config.api.phoneNumberPrivacy.shouldFailOpen, kit, - config.timeout + config.blockchain.timeout_ms ) ) ) @@ -127,7 +127,7 @@ export function startSigner( config.api.legacyPhoneNumberPrivacy.enabled, config.api.legacyPhoneNumberPrivacy.shouldFailOpen, kit, - config.timeout + config.blockchain.timeout_ms ) ) ) @@ -139,7 +139,7 @@ export function startSigner( config.api.legacyPhoneNumberPrivacy.enabled, config.api.legacyPhoneNumberPrivacy.shouldFailOpen, kit, - config.timeout + config.blockchain.timeout_ms ) ) ) From 2a8901db0c0502340d4f0c6b9392c9e8bc71745b Mon Sep 17 00:00:00 2001 From: soloseng <102702451+soloseng@users.noreply.github.com> Date: Tue, 13 Jun 2023 20:53:56 -0400 Subject: [PATCH 4/7] fix optinal timout --- packages/phone-number-privacy/signer/src/server.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/phone-number-privacy/signer/src/server.ts b/packages/phone-number-privacy/signer/src/server.ts index dc057526c0b..3f7c03d7375 100644 --- a/packages/phone-number-privacy/signer/src/server.ts +++ b/packages/phone-number-privacy/signer/src/server.ts @@ -1,6 +1,7 @@ import { ContractKit } from '@celo/contractkit' import { ErrorMessage, + FULL_NODE_TIMEOUT_IN_MS, getContractKit, loggerMiddleware, rootLogger, @@ -99,7 +100,7 @@ export function startSigner( config.api.phoneNumberPrivacy.enabled, config.api.phoneNumberPrivacy.shouldFailOpen, // TODO (https://github.com/celo-org/celo-monorepo/issues/9862) consider refactoring config to make the code cleaner kit, - config.blockchain.timeout_ms + Number(config.blockchain.timeout_ms ?? FULL_NODE_TIMEOUT_IN_MS) ) ) ) @@ -113,7 +114,7 @@ export function startSigner( config.api.phoneNumberPrivacy.enabled, config.api.phoneNumberPrivacy.shouldFailOpen, kit, - config.blockchain.timeout_ms + Number(config.blockchain.timeout_ms ?? FULL_NODE_TIMEOUT_IN_MS) ) ) ) @@ -127,7 +128,7 @@ export function startSigner( config.api.legacyPhoneNumberPrivacy.enabled, config.api.legacyPhoneNumberPrivacy.shouldFailOpen, kit, - config.blockchain.timeout_ms + Number(config.blockchain.timeout_ms ?? FULL_NODE_TIMEOUT_IN_MS) ) ) ) @@ -139,7 +140,7 @@ export function startSigner( config.api.legacyPhoneNumberPrivacy.enabled, config.api.legacyPhoneNumberPrivacy.shouldFailOpen, kit, - config.blockchain.timeout_ms + Number(config.blockchain.timeout_ms ?? FULL_NODE_TIMEOUT_IN_MS) ) ) ) From f39f6b9c21c524288d24de08b09202d8d1b461e2 Mon Sep 17 00:00:00 2001 From: soloseng <102702451+soloseng@users.noreply.github.com> Date: Thu, 15 Jun 2023 14:31:28 -0400 Subject: [PATCH 5/7] PR feedback --- .../common/test/utils/authentication.test.ts | 32 +++++++------------ .../src/pnp/endpoints/quota/io.legacy.ts | 4 +-- .../signer/src/pnp/endpoints/quota/io.ts | 4 +-- .../src/pnp/endpoints/sign/io.legacy.ts | 4 +-- .../signer/src/pnp/endpoints/sign/io.ts | 4 +-- 5 files changed, 19 insertions(+), 29 deletions(-) diff --git a/packages/phone-number-privacy/common/test/utils/authentication.test.ts b/packages/phone-number-privacy/common/test/utils/authentication.test.ts index c08a87c16bf..4e129b6fbd5 100644 --- a/packages/phone-number-privacy/common/test/utils/authentication.test.ts +++ b/packages/phone-number-privacy/common/test/utils/authentication.test.ts @@ -2,7 +2,7 @@ import { hexToBuffer } from '@celo/base' import { ContractKit } from '@celo/contractkit' import Logger from 'bunyan' import { Request } from 'express' -import { ErrorMessage, ErrorType, FULL_NODE_TIMEOUT_IN_MS } from '../../lib' +import { ErrorMessage, ErrorType } from '../../lib' import { AuthenticationMethod } from '../../src/interfaces/requests' import * as auth from '../../src/utils/authentication' @@ -29,8 +29,7 @@ describe('Authentication test suite', () => { mockContractKit, logger, true, - warnings, - FULL_NODE_TIMEOUT_IN_MS + warnings ) expect(success).toBe(false) @@ -51,8 +50,7 @@ describe('Authentication test suite', () => { mockContractKit, logger, true, - warnings, - FULL_NODE_TIMEOUT_IN_MS + warnings ) expect(success).toBe(false) @@ -76,8 +74,7 @@ describe('Authentication test suite', () => { mockContractKit, logger, true, - warnings, - FULL_NODE_TIMEOUT_IN_MS + warnings ) expect(success).toBe(true) @@ -101,8 +98,7 @@ describe('Authentication test suite', () => { mockContractKit, logger, false, - warnings, - FULL_NODE_TIMEOUT_IN_MS + warnings ) expect(success).toBe(false) @@ -136,8 +132,7 @@ describe('Authentication test suite', () => { mockContractKit, logger, true, - warnings, - FULL_NODE_TIMEOUT_IN_MS + warnings ) expect(success).toBe(false) @@ -208,8 +203,7 @@ describe('Authentication test suite', () => { mockContractKit, logger, true, - warnings, - FULL_NODE_TIMEOUT_IN_MS + warnings ) expect(success).toBe(true) @@ -260,8 +254,7 @@ describe('Authentication test suite', () => { mockContractKit, logger, true, - warnings, - FULL_NODE_TIMEOUT_IN_MS + warnings ) expect(success).toBe(false) @@ -307,8 +300,7 @@ describe('Authentication test suite', () => { mockContractKit, logger, true, - warnings, - FULL_NODE_TIMEOUT_IN_MS + warnings ) expect(success).toBe(false) @@ -355,8 +347,7 @@ describe('Authentication test suite', () => { mockContractKit, logger, true, - warnings, - FULL_NODE_TIMEOUT_IN_MS + warnings ) expect(success).toBe(false) @@ -400,8 +391,7 @@ describe('Authentication test suite', () => { mockContractKit, logger, true, - warnings, - FULL_NODE_TIMEOUT_IN_MS + warnings ) expect(success).toBe(false) diff --git a/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.legacy.ts b/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.legacy.ts index 6bfc6b38240..7fd5ed0bb3d 100644 --- a/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.legacy.ts +++ b/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.legacy.ts @@ -28,8 +28,8 @@ export class LegacyPnpQuotaIO extends IO { constructor( readonly enabled: boolean, readonly shouldFailOpen: boolean, - readonly kit: ContractKit, - readonly timeoutMs: number + readonly timeoutMs: number, + readonly kit: ContractKit ) { super(enabled) } diff --git a/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.ts b/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.ts index 94cfcfd9336..727ac3cdceb 100644 --- a/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.ts +++ b/packages/phone-number-privacy/signer/src/pnp/endpoints/quota/io.ts @@ -27,8 +27,8 @@ export class PnpQuotaIO extends IO { constructor( readonly enabled: boolean, readonly shouldFailOpen: boolean, - readonly kit: ContractKit, - readonly timeoutMs: number + readonly timeoutMs: number, + readonly kit: ContractKit ) { super(enabled) } diff --git a/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.legacy.ts b/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.legacy.ts index 200ce365101..f4617119f74 100644 --- a/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.legacy.ts +++ b/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.legacy.ts @@ -32,8 +32,8 @@ export class LegacyPnpSignIO extends IO { constructor( readonly enabled: boolean, readonly shouldFailOpen: boolean, - readonly kit: ContractKit, - readonly timeoutMs: number + readonly timeoutMs: number, + readonly kit: ContractKit ) { super(enabled) } diff --git a/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.ts b/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.ts index 7a38a034b72..6761fd797d2 100644 --- a/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.ts +++ b/packages/phone-number-privacy/signer/src/pnp/endpoints/sign/io.ts @@ -31,8 +31,8 @@ export class PnpSignIO extends IO { constructor( readonly enabled: boolean, readonly shouldFailOpen: boolean, - readonly kit: ContractKit, - readonly timeoutMs: number + readonly timeoutMs: number, + readonly kit: ContractKit ) { super(enabled) } From 12471db959d1625f52bd420af91f29fa569a28a7 Mon Sep 17 00:00:00 2001 From: soloseng <102702451+soloseng@users.noreply.github.com> Date: Thu, 15 Jun 2023 14:59:35 -0400 Subject: [PATCH 6/7] refactor configs --- .../phone-number-privacy/combiner/src/config.ts | 5 ++--- .../common/src/utils/contracts.ts | 1 - .../phone-number-privacy/signer/src/config.ts | 3 ++- .../phone-number-privacy/signer/src/server.ts | 17 ++++++++--------- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/packages/phone-number-privacy/combiner/src/config.ts b/packages/phone-number-privacy/combiner/src/config.ts index 9bfff36f24c..f9cc2ecda24 100644 --- a/packages/phone-number-privacy/combiner/src/config.ts +++ b/packages/phone-number-privacy/combiner/src/config.ts @@ -144,7 +144,6 @@ if (DEV_MODE) { blockchain: { provider: functionConfig.blockchain.provider, apiKey: functionConfig.blockchain.api_key, - timeout_ms: Number(functionConfig.blockchain.timeout_ms ?? FULL_NODE_TIMEOUT_IN_MS), }, phoneNumberPrivacy: { serviceName: functionConfig.pnp.service_name ?? defaultServiceName, @@ -160,7 +159,7 @@ if (DEV_MODE) { currentVersion: Number(functionConfig.pnp_keys.current_version), versions: functionConfig.pnp_keys.versions, }, - fullNodeTimeoutMs: Number(functionConfig.blockchain.timeout_ms ?? FULL_NODE_TIMEOUT_IN_MS), + fullNodeTimeoutMs: Number(functionConfig.pnp.full_node_timeout_ms ?? FULL_NODE_TIMEOUT_IN_MS), }, domains: { serviceName: functionConfig.domains.service_name ?? defaultServiceName, @@ -176,7 +175,7 @@ if (DEV_MODE) { currentVersion: Number(functionConfig.domains_keys.current_version), versions: functionConfig.domains_keys.versions, }, - fullNodeTimeoutMs: Number(functionConfig.blockchain.timeout_ms ?? FULL_NODE_TIMEOUT_IN_MS), + fullNodeTimeoutMs: Number(functionConfig.pnp.full_node_timeout_ms ?? FULL_NODE_TIMEOUT_IN_MS), }, } } diff --git a/packages/phone-number-privacy/common/src/utils/contracts.ts b/packages/phone-number-privacy/common/src/utils/contracts.ts index 80c18464059..f4952231f1f 100644 --- a/packages/phone-number-privacy/common/src/utils/contracts.ts +++ b/packages/phone-number-privacy/common/src/utils/contracts.ts @@ -3,7 +3,6 @@ import { ContractKit, newKit, newKitWithApiKey } from '@celo/contractkit' export interface BlockchainConfig { provider: string apiKey?: string - timeout_ms?: number } export function getContractKit(config: BlockchainConfig): ContractKit { diff --git a/packages/phone-number-privacy/signer/src/config.ts b/packages/phone-number-privacy/signer/src/config.ts index b9fe93a7759..588a95dd3ee 100644 --- a/packages/phone-number-privacy/signer/src/config.ts +++ b/packages/phone-number-privacy/signer/src/config.ts @@ -98,6 +98,7 @@ export interface SignerConfig { } timeout: number test_quota_bypass_percentage: number + fullNodeTimeoutMs: number } const env = process.env as any @@ -140,7 +141,6 @@ export const config: SignerConfig = { blockchain: { provider: env.BLOCKCHAIN_PROVIDER, apiKey: env.BLOCKCHAIN_API_KEY, - timeout_ms: Number(env.TIMEOUT_MS ?? FULL_NODE_TIMEOUT_IN_MS), }, db: { type: env.DB_TYPE ? env.DB_TYPE.toLowerCase() : SupportedDatabase.Postgres, @@ -180,4 +180,5 @@ export const config: SignerConfig = { }, timeout: Number(env.ODIS_SIGNER_TIMEOUT ?? 5000), test_quota_bypass_percentage: Number(env.TEST_QUOTA_BYPASS_PERCENTAGE ?? 0), + fullNodeTimeoutMs: Number(env.TIMEOUT_MS ?? FULL_NODE_TIMEOUT_IN_MS), } diff --git a/packages/phone-number-privacy/signer/src/server.ts b/packages/phone-number-privacy/signer/src/server.ts index 3f7c03d7375..19558bfc396 100644 --- a/packages/phone-number-privacy/signer/src/server.ts +++ b/packages/phone-number-privacy/signer/src/server.ts @@ -1,7 +1,6 @@ import { ContractKit } from '@celo/contractkit' import { ErrorMessage, - FULL_NODE_TIMEOUT_IN_MS, getContractKit, loggerMiddleware, rootLogger, @@ -99,8 +98,8 @@ export function startSigner( new PnpQuotaIO( config.api.phoneNumberPrivacy.enabled, config.api.phoneNumberPrivacy.shouldFailOpen, // TODO (https://github.com/celo-org/celo-monorepo/issues/9862) consider refactoring config to make the code cleaner - kit, - Number(config.blockchain.timeout_ms ?? FULL_NODE_TIMEOUT_IN_MS) + config.fullNodeTimeoutMs, + kit ) ) ) @@ -113,8 +112,8 @@ export function startSigner( new PnpSignIO( config.api.phoneNumberPrivacy.enabled, config.api.phoneNumberPrivacy.shouldFailOpen, - kit, - Number(config.blockchain.timeout_ms ?? FULL_NODE_TIMEOUT_IN_MS) + config.fullNodeTimeoutMs, + kit ) ) ) @@ -127,8 +126,8 @@ export function startSigner( new LegacyPnpSignIO( config.api.legacyPhoneNumberPrivacy.enabled, config.api.legacyPhoneNumberPrivacy.shouldFailOpen, - kit, - Number(config.blockchain.timeout_ms ?? FULL_NODE_TIMEOUT_IN_MS) + config.fullNodeTimeoutMs, + kit ) ) ) @@ -139,8 +138,8 @@ export function startSigner( new LegacyPnpQuotaIO( config.api.legacyPhoneNumberPrivacy.enabled, config.api.legacyPhoneNumberPrivacy.shouldFailOpen, - kit, - Number(config.blockchain.timeout_ms ?? FULL_NODE_TIMEOUT_IN_MS) + config.fullNodeTimeoutMs, + kit ) ) ) From 981c7dd05fc1f1ab3194974141dd0a722da720e3 Mon Sep 17 00:00:00 2001 From: soloseng <102702451+soloseng@users.noreply.github.com> Date: Thu, 15 Jun 2023 15:51:42 -0400 Subject: [PATCH 7/7] updated tests --- .../combiner/test/integration/domain.test.ts | 2 ++ .../combiner/test/integration/legacypnp.test.ts | 2 ++ .../phone-number-privacy/combiner/test/integration/pnp.test.ts | 2 ++ 3 files changed, 6 insertions(+) diff --git a/packages/phone-number-privacy/combiner/test/integration/domain.test.ts b/packages/phone-number-privacy/combiner/test/integration/domain.test.ts index 5641c2fcdde..5f7f1f1fe50 100644 --- a/packages/phone-number-privacy/combiner/test/integration/domain.test.ts +++ b/packages/phone-number-privacy/combiner/test/integration/domain.test.ts @@ -13,6 +13,7 @@ import { domainRestrictedSignatureRequestEIP712, DomainRestrictedSignatureResponse, ErrorMessage, + FULL_NODE_TIMEOUT_IN_MS, genSessionID, getContractKit, KEY_VERSION_HEADER, @@ -138,6 +139,7 @@ const signerConfig: SignerConfig = { }, timeout: 5000, test_quota_bypass_percentage: 0, + fullNodeTimeoutMs: FULL_NODE_TIMEOUT_IN_MS, } describe('domainService', () => { diff --git a/packages/phone-number-privacy/combiner/test/integration/legacypnp.test.ts b/packages/phone-number-privacy/combiner/test/integration/legacypnp.test.ts index 630959579ef..1506015c289 100644 --- a/packages/phone-number-privacy/combiner/test/integration/legacypnp.test.ts +++ b/packages/phone-number-privacy/combiner/test/integration/legacypnp.test.ts @@ -3,6 +3,7 @@ import { AuthenticationMethod, CombinerEndpoint, ErrorMessage, + FULL_NODE_TIMEOUT_IN_MS, genSessionID, KEY_VERSION_HEADER, LegacySignMessageRequest, @@ -142,6 +143,7 @@ const signerConfig: SignerConfig = { }, timeout: 5000, test_quota_bypass_percentage: 0, + fullNodeTimeoutMs: FULL_NODE_TIMEOUT_IN_MS, } const testBlockNumber = 1000000 diff --git a/packages/phone-number-privacy/combiner/test/integration/pnp.test.ts b/packages/phone-number-privacy/combiner/test/integration/pnp.test.ts index 54fd0884dd5..f74d4432bf5 100644 --- a/packages/phone-number-privacy/combiner/test/integration/pnp.test.ts +++ b/packages/phone-number-privacy/combiner/test/integration/pnp.test.ts @@ -3,6 +3,7 @@ import { AuthenticationMethod, CombinerEndpoint, ErrorMessage, + FULL_NODE_TIMEOUT_IN_MS, genSessionID, KEY_VERSION_HEADER, PnpQuotaRequest, @@ -146,6 +147,7 @@ const signerConfig: SignerConfig = { }, timeout: 5000, test_quota_bypass_percentage: 0, + fullNodeTimeoutMs: FULL_NODE_TIMEOUT_IN_MS, } const testBlockNumber = 1000000