Skip to content

Commit

Permalink
Fix up configs,
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronmgdr committed Oct 14, 2024
1 parent cc5df33 commit 6dada95
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 18 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-tables-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@celo/encrypted-backup": patch
---

Remove @celo/connect as a depdendency
3 changes: 2 additions & 1 deletion apps/combiner/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
9 changes: 7 additions & 2 deletions apps/monitor/src/index.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
13 changes: 8 additions & 5 deletions apps/monitor/src/scripts/run-load-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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')
Expand All @@ -85,7 +88,7 @@ yargs
}
concurrentRPSLoadTest(
args.rps,
blockchainProvider!,
blockchainProvider,
contextName,
CombinerEndpointPNP.PNP_SIGN,
args.duration,
Expand Down
11 changes: 8 additions & 3 deletions apps/monitor/src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -46,7 +51,7 @@ export async function testPNPSignQuery(
}

export async function testPNPQuotaQuery(
blockchainProvider: string,
blockchainProvider: TestChainInfo,
contextName: OdisContextName,
timeoutMs?: number,
privateKey?: Hex,
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions apps/signer/.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions apps/signer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion apps/signer/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
1 change: 0 additions & 1 deletion packages/encrypted-backup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 7 additions & 3 deletions packages/encrypted-backup/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
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'

// 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<ReadOnlyWallet, 'getAccounts' | 'hasAccount' | 'signTypedData'>
/** 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<string>
}

/** Info strings to separate distinct usages of the key derivation function */
export enum KDFInfo {
Expand Down
3 changes: 1 addition & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 6dada95

Please sign in to comment.