diff --git a/src/clients/BundleDataClient/BundleDataClient.ts b/src/clients/BundleDataClient/BundleDataClient.ts index dc4deac37..1c6dcb9d1 100644 --- a/src/clients/BundleDataClient/BundleDataClient.ts +++ b/src/clients/BundleDataClient/BundleDataClient.ts @@ -32,7 +32,6 @@ import { forEachAsync, getBlockRangeForChain, getImpliedBundleBlockRanges, - getMessageHash, getRelayEventKey, isSlowFill, mapAsync, @@ -45,7 +44,6 @@ import { } from "../../utils"; import winston from "winston"; import { - BundleData, BundleDataSS, getEndBlockBuffers, getRefundInformationFromFill, @@ -57,7 +55,6 @@ import { V3FillWithBlock, verifyFillRepayment, } from "./utils"; -import { UNDEFINED_MESSAGE_HASH } from "../../constants"; import { isEVMSpokePoolClient } from "../SpokePoolClient"; // max(uint256) - 1 @@ -209,37 +206,6 @@ export class BundleDataClient { return `bundles-${BundleDataClient.getArweaveClientKey(blockRangesForChains)}`; } - // Post-populate any missing message hashes. - // @todo This can be removed once the legacy types hurdle is cleared (earliest 7 days post migration). - backfillMessageHashes(data: Pick): void { - Object.values(data.bundleDepositsV3).forEach((x) => - Object.values(x).forEach((deposits) => - deposits.forEach((deposit) => { - if (deposit.messageHash === UNDEFINED_MESSAGE_HASH) { - deposit.messageHash = getMessageHash(deposit.message); - } - }) - ) - ); - - Object.values(data.bundleFillsV3).forEach((x) => - Object.values(x).forEach(({ fills }) => - fills.forEach((fill) => { - if (fill.messageHash === UNDEFINED_MESSAGE_HASH && isDefined(fill.message)) { - // If messageHash is undefined, fill should be of type FilledV3Relay and should have a message. - fill.messageHash = getMessageHash(fill.message); - } - if ( - fill.relayExecutionInfo.updatedMessageHash === UNDEFINED_MESSAGE_HASH && - isDefined(fill.relayExecutionInfo.updatedMessage) - ) { - fill.relayExecutionInfo.updatedMessageHash = getMessageHash(fill.relayExecutionInfo.updatedMessage); - } - }) - ) - ); - } - private async loadPersistedDataFromArweave( blockRangesForChains: number[][] ): Promise { @@ -271,9 +237,6 @@ export class BundleDataClient { ); const data = persistedData[0].data; - - this.backfillMessageHashes(data); - const bundleData = { bundleFillsV3: convertTypedStringRecordIntoNumericRecord(data.bundleFillsV3), expiredDepositsToRefundV3: convertTypedStringRecordIntoNumericRecord(data.expiredDepositsToRefundV3), diff --git a/test/BundleDataClient.ts b/test/BundleDataClient.ts deleted file mode 100644 index 5c4b72879..000000000 --- a/test/BundleDataClient.ts +++ /dev/null @@ -1,122 +0,0 @@ -import { expect } from "chai"; -import { BundleData, BundleDataClient } from "../src/clients/BundleDataClient"; -import { getMessageHash, randomAddress, toBN } from "../src/utils"; -import { UNDEFINED_MESSAGE_HASH } from "../src/constants"; -import { MockSpokePoolClient } from "../src/clients/mocks"; -import { createSpyLogger } from "./utils"; - -const random = () => Math.round(Math.random() * 1e6); - -describe("BundleDataClient", function () { - let chainIds: number[]; - let spokePoolClients: { [chainId: number]: MockSpokePoolClient }; - let bundleDataClient: BundleDataClient; - - const logger = createSpyLogger().spyLogger; - const l1Token = randomAddress(); - const originChainId = 1; - - beforeEach(function () { - spokePoolClients = {}; - bundleDataClient = new BundleDataClient( - logger, - {}, // commonClients - spokePoolClients, - chainIds, - {} // block buffers - ); - }); - - it("Correctly appends message hashes to deposit and fill events", function () { - const eventData = { - depositor: randomAddress(), - recipient: randomAddress(), - originChainId, - destinationChainId: random(), - inputToken: randomAddress(), - outputToken: randomAddress(), - inputAmount: toBN(random()), - outputAmount: toBN(random()), - message: "0x", - messageHash: UNDEFINED_MESSAGE_HASH, - depositId: toBN(random()), - quoteTimestamp: random(), - fillDeadline: random(), - exclusivityDeadline: random(), - exclusiveRelayer: randomAddress(), - fromLiteChain: false, - toLiteChain: false, - quoteBlockNumber: random(), - }; - - const blockFields = { - transactionHash: "", - blockNumber: 0, - transactionIndex: 0, - logIndex: 0, - }; - - const miscFill = { - relayer: randomAddress(), - repaymentChainId: random(), - relayExecutionInfo: { - updatedRecipient: eventData.recipient, - updatedMessage: eventData.message, - updatedOutputAmount: eventData.outputAmount, - fillType: random(), - }, - }; - - const bundleData: Pick = { - bundleDepositsV3: { - [originChainId]: { - [l1Token]: [ - { - ...eventData, - ...blockFields, - message: "0x", - messageHash: UNDEFINED_MESSAGE_HASH, - }, - { - ...eventData, - ...blockFields, - message: "0x1234", - messageHash: UNDEFINED_MESSAGE_HASH, - }, - ], - }, - }, - bundleFillsV3: { - [originChainId]: { - [l1Token]: { - fills: [ - { - ...eventData, - ...blockFields, - ...miscFill, - lpFeePct: toBN(random()), - }, - { - ...eventData, - ...blockFields, - ...miscFill, - lpFeePct: toBN(random()), - }, - ], - totalRefundAmount: toBN(random()), - realizedLpFees: toBN(random()), - refunds: {}, - }, - }, - }, - }; - - bundleDataClient.backfillMessageHashes(bundleData); - - Object.values(bundleData.bundleDepositsV3[originChainId][l1Token]).forEach((deposit) => { - expect(deposit.message).to.exist; - expect(deposit.messageHash).to.not.equal(UNDEFINED_MESSAGE_HASH); - expect(deposit.messageHash).to.equal(getMessageHash(deposit.message)); - }); - }); -});