From 6dada958f045f6db988570396a97e0f8058d76eb Mon Sep 17 00:00:00 2001 From: Aaron DeRuvo Date: Mon, 14 Oct 2024 12:48:41 +0200 Subject: [PATCH] Fix up configs, --- .changeset/neat-tables-fly.md | 5 +++++ apps/combiner/src/config.ts | 3 ++- apps/monitor/src/index.ts | 9 +++++++-- apps/monitor/src/scripts/run-load-test.ts | 13 ++++++++----- apps/monitor/src/test.ts | 11 ++++++++--- apps/signer/.env | 1 + apps/signer/README.md | 1 + apps/signer/src/config.ts | 3 ++- packages/encrypted-backup/package.json | 1 - packages/encrypted-backup/src/utils.ts | 10 +++++++--- yarn.lock | 3 +-- 11 files changed, 42 insertions(+), 18 deletions(-) create mode 100644 .changeset/neat-tables-fly.md diff --git a/.changeset/neat-tables-fly.md b/.changeset/neat-tables-fly.md new file mode 100644 index 000000000..c067db88a --- /dev/null +++ b/.changeset/neat-tables-fly.md @@ -0,0 +1,5 @@ +--- +"@celo/encrypted-backup": patch +--- + +Remove @celo/connect as a depdendency diff --git a/apps/combiner/src/config.ts b/apps/combiner/src/config.ts index 7421a505d..39a2d3673 100644 --- a/apps/combiner/src/config.ts +++ b/apps/combiner/src/config.ts @@ -168,7 +168,8 @@ if (DEV_MODE) { sslCertPath: env.SERVER_SSL_CERT_PATH, }, blockchain: { - provider: env.BLOCKCHAIN_PROVIDER, + rpcURL: env.BLOCKCHAIN_PROVIDER, + chainID: env.CHAIN_ID, apiKey: env.BLOCKCHAIN_API_KEY, }, phoneNumberPrivacy: { diff --git a/apps/monitor/src/index.ts b/apps/monitor/src/index.ts index b264b1adb..5da5f236c 100644 --- a/apps/monitor/src/index.ts +++ b/apps/monitor/src/index.ts @@ -1,13 +1,18 @@ -import { defineString } from 'firebase-functions/params' +import { defineInt, defineString } from 'firebase-functions/params' import * as functions from 'firebase-functions/v2/scheduler' import { testDomainSignQuery, testPNPSignQuery } from './test' const contextName = defineString('MONITOR_CONTEXT_NAME') const blockchainProvider = defineString('BLOCKCHAIN_PROVIDER') +const chainID = defineInt('CHAIN_ID') export const odisMonitorScheduleFunctionPNPGen2 = functions.onSchedule( 'every 5 minutes', - async () => testPNPSignQuery(blockchainProvider.value(), contextName.value() as any), + async () => + testPNPSignQuery( + { rpcURL: blockchainProvider.value(), chainID: chainID.value() as 44787 }, + contextName.value() as any, + ), ) export const odisMonitorScheduleFunctionDomainsGen2 = functions.onSchedule( diff --git a/apps/monitor/src/scripts/run-load-test.ts b/apps/monitor/src/scripts/run-load-test.ts index d3c2b5552..a135a3854 100644 --- a/apps/monitor/src/scripts/run-load-test.ts +++ b/apps/monitor/src/scripts/run-load-test.ts @@ -2,7 +2,7 @@ import { OdisContextName } from '@celo/identity/lib/odis/query' import { CombinerEndpointPNP, rootLogger } from '@celo/phone-number-privacy-common' import { Hex } from 'viem' import yargs from 'yargs' -import { concurrentRPSLoadTest } from '../test' +import { concurrentRPSLoadTest, type TestChainInfo } from '../test' const logger = rootLogger('odis-monitor') @@ -63,14 +63,17 @@ yargs const rps = args.rps! const contextName = args.contextName! as OdisContextName - let blockchainProvider: string + let blockchainProvider: TestChainInfo switch (contextName) { case 'alfajoresstaging': case 'alfajores': - blockchainProvider = 'https://alfajores-forno.celo-testnet.org' + blockchainProvider = { + rpcURL: 'https://alfajores-forno.celo-testnet.org', + chainID: 44787, + } break case 'mainnet': - blockchainProvider = 'https://forno.celo.org' + blockchainProvider = { rpcURL: 'https://forno.celo.org', chainID: 42220 } break default: logger.error('Invalid contextName') @@ -85,7 +88,7 @@ yargs } concurrentRPSLoadTest( args.rps, - blockchainProvider!, + blockchainProvider, contextName, CombinerEndpointPNP.PNP_SIGN, args.duration, diff --git a/apps/monitor/src/test.ts b/apps/monitor/src/test.ts index 6bbf526be..51a010156 100644 --- a/apps/monitor/src/test.ts +++ b/apps/monitor/src/test.ts @@ -11,8 +11,13 @@ import { queryOdisDomain, queryOdisForQuota, queryOdisForSalt } from './query' const logger = rootLogger('odis-monitor') +export type TestChainInfo = { + rpcURL: string + chainID: 44787 | 42220 +} + export async function testPNPSignQuery( - blockchainProvider: string, + blockchainProvider: TestChainInfo, contextName: OdisContextName, timeoutMs?: number, bypassQuota?: boolean, @@ -46,7 +51,7 @@ export async function testPNPSignQuery( } export async function testPNPQuotaQuery( - blockchainProvider: string, + blockchainProvider: TestChainInfo, contextName: OdisContextName, timeoutMs?: number, privateKey?: Hex, @@ -89,7 +94,7 @@ export async function testDomainSignQuery(contextName: OdisContextName) { export async function concurrentRPSLoadTest( rps: number, - blockchainProvider: string, + blockchainProvider: TestChainInfo, contextName: OdisContextName, endpoint: | CombinerEndpointPNP.PNP_QUOTA diff --git a/apps/signer/.env b/apps/signer/.env index ab86d9eca..5fd50b01e 100644 --- a/apps/signer/.env +++ b/apps/signer/.env @@ -3,6 +3,7 @@ NODE_ENV=development #SERVER_SSL_KEY_PATH=./server.key #SERVER_SSL_CERT_PATH=./server.cert BLOCKCHAIN_PROVIDER=https://alfajores-forno.celo-testnet.org +CHAIN_ID=42220 DB_HOST=http://localhost DB_USERNAME=postgres DB_PASSWORD=mockPass diff --git a/apps/signer/README.md b/apps/signer/README.md index a8a7a5d1d..501ad4b57 100644 --- a/apps/signer/README.md +++ b/apps/signer/README.md @@ -52,6 +52,7 @@ This could be a node with RPC set up. Preferably this would be an node dedicated - `BLOCKCHAIN_PROVIDER` - The blockchain node provider for chain state access. ` - `BLOCKCHAIN_API_KEY` - Optional API key to be added to the authentication header. ` +- `CHAIN_ID` should be 44220 or celo or 44787 on alfajores ### Security diff --git a/apps/signer/src/config.ts b/apps/signer/src/config.ts index 40964944d..7a1f8551b 100644 --- a/apps/signer/src/config.ts +++ b/apps/signer/src/config.ts @@ -125,7 +125,8 @@ export const config: SignerConfig = { }, }, blockchain: { - provider: env.BLOCKCHAIN_PROVIDER, + rpcURL: env.BLOCKCHAIN_PROVIDER, + chainID: env.CHAIN_ID, apiKey: env.BLOCKCHAIN_API_KEY, }, db: { diff --git a/packages/encrypted-backup/package.json b/packages/encrypted-backup/package.json index 516afd937..37e4814a2 100644 --- a/packages/encrypted-backup/package.json +++ b/packages/encrypted-backup/package.json @@ -26,7 +26,6 @@ }, "dependencies": { "@celo/base": "^6.0.0", - "@celo/connect": "^5.1.2", "@celo/identity": "^5.1.2", "@celo/phone-number-privacy-common": "^3.1.2", "@celo/poprf": "^0.1.9", diff --git a/packages/encrypted-backup/src/utils.ts b/packages/encrypted-backup/src/utils.ts index 62383197a..953a04734 100644 --- a/packages/encrypted-backup/src/utils.ts +++ b/packages/encrypted-backup/src/utils.ts @@ -1,5 +1,6 @@ +import { Address } from '@celo/base' import { Err, Ok, Result } from '@celo/base/lib/result' -import { ReadOnlyWallet } from '@celo/connect' +import type { EIP712TypedData } from '@celo/utils/lib/sign-typed-data-utils' import * as crypto from 'crypto' import { ComputationalHardeningConfig, ComputationalHardeningFunction } from './config' import { DecryptionError, EncryptionError, PbkdfError, ScryptError } from './errors' @@ -7,8 +8,11 @@ import { DecryptionError, EncryptionError, PbkdfError, ScryptError } from './err // NOTE: This module is intended for use within the @celo/encrypted-backup package and so is not // exported in the index.ts file. -/** Pared down ReadOnlyWallet type that supports the required functions of EIP-712 signing. */ -export type EIP712Wallet = Pick +/** Pared down ReadOnlyWallet type that supports the required functions of EIP-712 signing. */ export interface EIP712Wallet { + getAccounts: () => Address[] + hasAccount: (address?: Address) => boolean + signTypedData: (address: Address, typedData: EIP712TypedData) => Promise +} /** Info strings to separate distinct usages of the key derivation function */ export enum KDFInfo { diff --git a/yarn.lock b/yarn.lock index 8a2bee80c..31edf36e7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1358,7 +1358,7 @@ __metadata: languageName: node linkType: hard -"@celo/connect@npm:^5.1.1, @celo/connect@npm:^5.1.2, @celo/connect@npm:^5.2.0": +"@celo/connect@npm:^5.1.1, @celo/connect@npm:^5.2.0": version: 5.2.0 resolution: "@celo/connect@npm:5.2.0" dependencies: @@ -1490,7 +1490,6 @@ __metadata: resolution: "@celo/encrypted-backup@workspace:packages/encrypted-backup" dependencies: "@celo/base": "npm:^6.0.0" - "@celo/connect": "npm:^5.1.2" "@celo/dev-utils": "npm:0.0.1-beta.1" "@celo/identity": "npm:^5.1.2" "@celo/phone-number-privacy-common": "npm:^3.1.2"