From 0e86790d7aff85bcf121d3b3786fe929a5ad55ac Mon Sep 17 00:00:00 2001 From: ConjunctiveNormalForm Date: Wed, 5 Jun 2024 13:25:50 -0400 Subject: [PATCH 1/2] (cbv2) checksum addr --- lib/cron/fade-rate-v2.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/cron/fade-rate-v2.ts b/lib/cron/fade-rate-v2.ts index 6aea1e0..07ae7fe 100644 --- a/lib/cron/fade-rate-v2.ts +++ b/lib/cron/fade-rate-v2.ts @@ -5,6 +5,7 @@ import { ScheduledHandler } from 'aws-lambda/trigger/cloudwatch-events'; import { EventBridgeEvent } from 'aws-lambda/trigger/eventbridge'; import Logger from 'bunyan'; +import { ethers } from 'ethers'; import { BETA_S3_KEY, PRODUCTION_S3_KEY, WEBHOOK_CONFIG_BUCKET } from '../constants'; import { CircuitBreakerMetricDimension } from '../entities'; import { checkDefined } from '../preconditions/preconditions'; @@ -67,7 +68,10 @@ async function main(metrics: MetricsLogger) { if (result) { const fillerEndpoints = webhookProvider.fillerEndpoints(); const addressToFillerMap = await fillerAddressRepo.getAddressToFillerMap(fillerEndpoints); - log.info({ addressToFillerMap }, 'address to filler map from dynamo'); + log.info( + { map: addressToFillerMap.forEach((filler, addr) => [addr, filler]) }, + 'address to filler map from dynamo' + ); const fillerTimestamps = await timestampDB.getFillerTimestampsMap(fillerEndpoints); // get fillers new fades from last checked timestamp: @@ -134,7 +138,7 @@ export function getFillersNewFades( ): FillerFades { const newFadesMap: FillerFades = {}; // filler hash -> # of new fades rows.forEach((row) => { - const fillerAddr = row.fillerAddress.toLowerCase(); + const fillerAddr = ethers.utils.getAddress(row.fillerAddress); const fillerHash = addressToFillerMap.get(fillerAddr); if (!fillerHash) { log?.info({ fillerAddr }, 'filler address not found dynamo mapping'); From 6c27d7b51ace33fa3c5a4f09e9807289df554d5b Mon Sep 17 00:00:00 2001 From: ConjunctiveNormalForm Date: Wed, 5 Jun 2024 13:54:21 -0400 Subject: [PATCH 2/2] fix unit tests --- test/crons/fade-rate-v2.test.ts | 34 ++++++++++++++++----------------- test/crons/fade-rate.test.ts | 12 ++++++------ 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/test/crons/fade-rate-v2.test.ts b/test/crons/fade-rate-v2.test.ts index 0bee139..9ba8444 100644 --- a/test/crons/fade-rate-v2.test.ts +++ b/test/crons/fade-rate-v2.test.ts @@ -13,31 +13,31 @@ const now = Math.floor(Date.now() / 1000); const FADES_ROWS: V2FadesRowType[] = [ // filler1 - { fillerAddress: '0x1', faded: 1, postTimestamp: now - 100 }, - { fillerAddress: '0x1', faded: 0, postTimestamp: now - 90 }, - { fillerAddress: '0x1', faded: 1, postTimestamp: now - 80 }, - { fillerAddress: '0x2', faded: 1, postTimestamp: now - 80 }, + { fillerAddress: '0x0000000000000000000000000000000000000001', faded: 1, postTimestamp: now - 100 }, + { fillerAddress: '0x0000000000000000000000000000000000000001', faded: 0, postTimestamp: now - 90 }, + { fillerAddress: '0x0000000000000000000000000000000000000001', faded: 1, postTimestamp: now - 80 }, + { fillerAddress: '0x0000000000000000000000000000000000000002', faded: 1, postTimestamp: now - 80 }, // filler2 - { fillerAddress: '0x3', faded: 1, postTimestamp: now - 70 }, - { fillerAddress: '0x3', faded: 1, postTimestamp: now - 100 }, + { fillerAddress: '0x0000000000000000000000000000000000000003', faded: 1, postTimestamp: now - 70 }, + { fillerAddress: '0x0000000000000000000000000000000000000003', faded: 1, postTimestamp: now - 100 }, // filler3 - { fillerAddress: '0x4', faded: 1, postTimestamp: now - 100 }, + { fillerAddress: '0x0000000000000000000000000000000000000004', faded: 1, postTimestamp: now - 100 }, // filler4 - { fillerAddress: '0x5', faded: 0, postTimestamp: now - 100 }, + { fillerAddress: '0x0000000000000000000000000000000000000005', faded: 0, postTimestamp: now - 100 }, // filler5 - { fillerAddress: '0x6', faded: 0, postTimestamp: now - 100 }, + { fillerAddress: '0x0000000000000000000000000000000000000006', faded: 0, postTimestamp: now - 100 }, // filler6 - { fillerAddress: '0x7', faded: 1, postTimestamp: now - 100 }, + { fillerAddress: '0x0000000000000000000000000000000000000007', faded: 1, postTimestamp: now - 100 }, ]; const ADDRESS_TO_FILLER = new Map([ - ['0x1', 'filler1'], - ['0x2', 'filler1'], - ['0x3', 'filler2'], - ['0x4', 'filler3'], - ['0x5', 'filler4'], - ['0x6', 'filler5'], - ['0x7', 'filler6'], + ['0x0000000000000000000000000000000000000001', 'filler1'], + ['0x0000000000000000000000000000000000000002', 'filler1'], + ['0x0000000000000000000000000000000000000003', 'filler2'], + ['0x0000000000000000000000000000000000000004', 'filler3'], + ['0x0000000000000000000000000000000000000005', 'filler4'], + ['0x0000000000000000000000000000000000000006', 'filler5'], + ['0x0000000000000000000000000000000000000007', 'filler6'], ]); const FILLER_TIMESTAMPS: FillerTimestamps = new Map([ diff --git a/test/crons/fade-rate.test.ts b/test/crons/fade-rate.test.ts index 730fd13..0492784 100644 --- a/test/crons/fade-rate.test.ts +++ b/test/crons/fade-rate.test.ts @@ -4,15 +4,15 @@ import { calculateFillerFadeRates } from '../../lib/cron/fade-rate'; import { FadesRowType } from '../../lib/repositories'; const FADES_ROWS: FadesRowType[] = [ - { fillerAddress: '0x1', totalQuotes: 50, fadedQuotes: 10 }, - { fillerAddress: '0x2', totalQuotes: 50, fadedQuotes: 20 }, - { fillerAddress: '0x3', totalQuotes: 100, fadedQuotes: 5 }, + { fillerAddress: '0x0000000000000000000000000000000000000001', totalQuotes: 50, fadedQuotes: 10 }, + { fillerAddress: '0x0000000000000000000000000000000000000002', totalQuotes: 50, fadedQuotes: 20 }, + { fillerAddress: '0x0000000000000000000000000000000000000003', totalQuotes: 100, fadedQuotes: 5 }, ]; const ADDRESS_TO_FILLER = new Map([ - ['0x1', 'filler1'], - ['0x2', 'filler1'], - ['0x3', 'filler2'], + ['0x0000000000000000000000000000000000000001', 'filler1'], + ['0x0000000000000000000000000000000000000002', 'filler1'], + ['0x0000000000000000000000000000000000000003', 'filler2'], ]); // silent logger in tests