diff --git a/packages/phone-number-privacy/signer/.env b/packages/phone-number-privacy/signer/.env index 5a3c7e8065e..8dfa0ea6050 100644 --- a/packages/phone-number-privacy/signer/.env +++ b/packages/phone-number-privacy/signer/.env @@ -32,7 +32,7 @@ ALFAJORES_ODIS_BLOCKCHAIN_PROVIDER=https://alfajores-forno.celo-testnet.org MAINNET_ODIS_BLOCKCHAIN_PROVIDER=https://forno.celo.org ODIS_DOMAINS_TEST_KEY_VERSION=1 ODIS_PNP_TEST_KEY_VERSION=1 -DEPLOYED_SIGNER_SERVICE_VERSION=3.0.0-beta.14 +DEPLOYED_SIGNER_SERVICE_VERSION=3.0.0-beta.16 # PUBKEYS STAGING_DOMAINS_PUBKEY=7FsWGsFnmVvRfMDpzz95Np76wf/1sPaK0Og9yiB+P8QbjiC8FV67NBans9hzZEkBaQMhiapzgMR6CkZIZPvgwQboAxl65JWRZecGe5V3XO4sdKeNemdAZ2TzQuWkuZoA ALFAJORES_DOMAINS_PUBKEY=+ZrxyPvLChWUX/DyPw6TuGwQH0glDJEbSrSxUARyP5PuqYyP/U4WZTV1e0bAUioBZ6QCJMiLpDwTaFvy8VnmM5RBbLQUMrMg5p4+CBCqj6HhsMfcyUj8V0LyuNdStlCB diff --git a/packages/phone-number-privacy/signer/jest.config.js b/packages/phone-number-privacy/signer/jest.config.js index 70a12113839..1312f090e3e 100644 --- a/packages/phone-number-privacy/signer/jest.config.js +++ b/packages/phone-number-privacy/signer/jest.config.js @@ -5,7 +5,7 @@ module.exports = { collectCoverageFrom: ['./src/**'], coverageThreshold: { global: { - lines: 68, + lines: 68, // TODO increase this threshold }, }, } diff --git a/packages/phone-number-privacy/signer/src/common/database/wrappers/domain-request.ts b/packages/phone-number-privacy/signer/src/common/database/wrappers/domain-request.ts index 3671174faf3..ef7506d75f1 100644 --- a/packages/phone-number-privacy/signer/src/common/database/wrappers/domain-request.ts +++ b/packages/phone-number-privacy/signer/src/common/database/wrappers/domain-request.ts @@ -8,7 +8,7 @@ import { DomainRequestRecord, toDomainRequestRecord, } from '../models/domain-request' -import { countAndThrowDBError, doMeteredSql } from '../utils' +import { doMeteredSql } from '../utils' // TODO implement replay handling; this file is currently unused // https://github.com/celo-org/celo-monorepo/issues/9909 @@ -20,13 +20,13 @@ export async function getDomainRequestRecordExists( trx: Knex.Transaction, logger: Logger ): Promise { + const hash = domainHash(domain).toString('hex') + logger.debug({ domain, blindedMessage, hash }, 'Checking if domain request exists') return doMeteredSql( 'getDomainRequestRecordExists', ErrorMessage.DATABASE_GET_FAILURE, logger, async () => { - const hash = domainHash(domain).toString('hex') - logger.debug({ domain, blindedMessage, hash }, 'Checking if domain request exists') const existingRequest = await db(DOMAIN_REQUESTS_TABLE) .transacting(trx) .where({ @@ -47,20 +47,16 @@ export async function storeDomainRequestRecord( trx: Knex.Transaction, logger: Logger ) { + logger.debug({ domain, blindedMessage }, 'Storing domain restricted signature request') return doMeteredSql( 'storeDomainRequestRecord', ErrorMessage.DATABASE_INSERT_FAILURE, logger, async () => { - try { - logger.debug({ domain, blindedMessage }, 'Storing domain restricted signature request') - await db(DOMAIN_REQUESTS_TABLE) - .transacting(trx) - .insert(toDomainRequestRecord(domain, blindedMessage)) - .timeout(config.db.timeout) - } catch (err) { - countAndThrowDBError(err, logger, ErrorMessage.DATABASE_INSERT_FAILURE) - } + await db(DOMAIN_REQUESTS_TABLE) + .transacting(trx) + .insert(toDomainRequestRecord(domain, blindedMessage)) + .timeout(config.db.timeout) } ) } diff --git a/packages/phone-number-privacy/signer/src/common/database/wrappers/domain-state.ts b/packages/phone-number-privacy/signer/src/common/database/wrappers/domain-state.ts index 19f0301705a..8cebb8625ba 100644 --- a/packages/phone-number-privacy/signer/src/common/database/wrappers/domain-state.ts +++ b/packages/phone-number-privacy/signer/src/common/database/wrappers/domain-state.ts @@ -17,9 +17,9 @@ export async function setDomainDisabled( trx: Knex.Transaction, logger: Logger ): Promise { + const hash = domainHash(domain).toString('hex') + logger.debug({ hash, domain }, 'Disabling domain') return doMeteredSql('disableDomain', ErrorMessage.DATABASE_UPDATE_FAILURE, logger, async () => { - const hash = domainHash(domain).toString('hex') - logger.debug({ hash, domain }, 'Disabling domain') await db(DOMAIN_STATE_TABLE) .transacting(trx) .where(DOMAIN_STATE_COLUMNS.domainHash, hash) @@ -54,14 +54,13 @@ export async function getDomainStateRecord( logger: Logger, trx?: Knex.Transaction ): Promise { + const hash = domainHash(domain).toString('hex') + logger.debug({ hash, domain }, 'Getting domain state from db') return doMeteredSql( 'getDomainStateRecord', ErrorMessage.DATABASE_GET_FAILURE, logger, async () => { - const hash = domainHash(domain).toString('hex') - logger.debug({ hash, domain }, 'Getting domain state from db') - const sql = db(DOMAIN_STATE_TABLE) .where(DOMAIN_STATE_COLUMNS.domainHash, hash) .first() @@ -85,13 +84,13 @@ export async function updateDomainStateRecord( trx: Knex.Transaction, logger: Logger ): Promise { + const hash = domainHash(domain).toString('hex') + logger.debug({ hash, domain, domainState }, 'Update domain state') return doMeteredSql( 'updateDomainStateRecord', ErrorMessage.DATABASE_UPDATE_FAILURE, logger, async () => { - const hash = domainHash(domain).toString('hex') - logger.debug({ hash, domain, domainState }, 'Update domain state') // Check whether the domain is already in the database. // The current signature flow results in redundant queries of the domain state. // Consider optimizing in the future: https://github.com/celo-org/celo-monorepo/issues/9855 @@ -117,12 +116,12 @@ export async function insertDomainStateRecord( trx: Knex.Transaction, logger: Logger ): Promise { + logger.debug({ domainState }, 'Insert domain state') return doMeteredSql( 'insertDomainState', ErrorMessage.DATABASE_INSERT_FAILURE, logger, async () => { - logger.debug({ domainState }, 'Insert domain state') await db(DOMAIN_STATE_TABLE) .transacting(trx) .insert(domainState)