-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds timeouts to ODIS signer (#7597)
* adds timeouts to signer * moves timeout function to base package, adds signer timeout metric * udpates dependency graph * fixes typo * fixes error * adds backup timeout at express level * addresses feedback * import timeout through common package * moves backup timeout to better spot * removes commented out code * parallelizes db ops * adds TODOS * adds timeout helper to sdk/base * adds retryAsyncWithTimeout helper to sdk/base * refactors retryAsyncWithBackOffAndTimeout() to use timeout() * bumps package version and updates changelog * adds docs * Revert "bumps package version and updates changelog" This reverts commit ed9040e. * Adds timeout functions to sdk/base package (#7617) ### Description In our efforts to improve ODIS scalability, the CAP team came across the need for these timeout async functions and they seemed like something that should be added to the base package. We've added retryAsyncWithBackOffWithTimeout() and timeout(). The former retries an async function up to a given number of times with a backoff between each retry and caps the attempt to call the function with a timeout. The timeout() function simply calls an async function and wraps the promise in a timeout. Authorship credit goes to @codyborn who wrote the timeout logic in a separate PR ### Tested Unit tests added to async.test.ts ### Related issues None ### Backwards compatibility Yes ### Documentation None * add full node timeouts to signer * adds db timeouts to signer * adds dependency graph * ODIS Combiner Reliability (#7594) ### Description - Adding timeouts to full-node requests - “Failing open” when timeouts are hit - Forcing outstanding request termination when k of m signatures have been collected - Forcing outstanding request termination and returning early when k of m signatures are not possible ### Tested - Test cases for new async method wrapper - TODO: Deploy to alfajores and perform load tests to measure impact ### Backwards compatibility Yes ### Documentation N/A * ODIS load test (#7602) Integrates load test logic into monitor * update dependency graph * adds sdk/base to signer dockerfile (temporary) Co-authored-by: Cody Born <codyborn@outlook.com>
- Loading branch information
Showing
15 changed files
with
138 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,13 @@ | ||
import { PhoneNumberHashDetails } from '@celo/identity/lib/odis/phone-number-identifier' | ||
import { ErrorMessages } from '@celo/identity/lib/odis/query' | ||
import { rootLogger as logger } from '@celo/phone-number-privacy-common' | ||
import * as functions from 'firebase-functions' | ||
import { queryOdisForSalt } from './query' | ||
import { testQuery } from './test' | ||
|
||
const haveConfig = !!functions.config().blockchain | ||
export const network = haveConfig ? functions.config().blockchain.network : process.env.NETWORK | ||
export const blockchainProvider: string = haveConfig | ||
? functions.config().blockchain.provider | ||
: process.env.BLOCKCHAIN_PROVIDER | ||
|
||
export const odisMonitorScheduleFunction = functions | ||
.region('us-central1', 'europe-west3') | ||
.pubsub.schedule('every 5 minutes') | ||
.onRun(async () => { | ||
logger.info('Performing test query') | ||
try { | ||
const odisResponse: PhoneNumberHashDetails = await queryOdisForSalt() | ||
logger.info({ odisResponse }, 'ODIS salt request successful. System is healthy.') | ||
} catch (err) { | ||
if ((err as Error).message === ErrorMessages.ODIS_QUOTA_ERROR) { | ||
logger.info( | ||
{ error: err }, | ||
'ODIS salt request out of quota. This is expected. System is healthy.' | ||
) | ||
} else { | ||
logger.error('ODIS salt request failed.') | ||
logger.error({ err }) | ||
throw err | ||
} | ||
} | ||
}) | ||
.onRun(testQuery) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/phone-number-privacy/monitor/src/scripts/runLoadTest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { concurrentLoadTest } from '../test' | ||
|
||
/* tslint:disable:no-console */ | ||
|
||
const args = process.argv.slice(2) | ||
|
||
const printHelpAndExit = () => { | ||
console.log('Usage: yarn loadTest <network> <numWorkers>') | ||
process.exit(1) | ||
} | ||
|
||
if (args[0] === '--help' || args.length !== 2) { | ||
printHelpAndExit() | ||
} | ||
|
||
switch (args[0]) { | ||
case 'alfajores': | ||
process.env.BLOCKCHAIN_PROVIDER = 'https://alfajores-forno.celo-testnet.org' | ||
break | ||
case 'mainnet': | ||
process.env.BLOCKCHAIN_PROVIDER = 'https://forno.celo.org' | ||
break | ||
default: | ||
printHelpAndExit() | ||
break | ||
} | ||
process.env.NETWORK = args[0] | ||
|
||
concurrentLoadTest(Number(args[1])) // tslint:disable-line:no-floating-promises |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.