diff --git a/src/interfaces/SpokePool.ts b/src/interfaces/SpokePool.ts index 37b228452..7d2f41037 100644 --- a/src/interfaces/SpokePool.ts +++ b/src/interfaces/SpokePool.ts @@ -19,6 +19,7 @@ export interface RelayData { fillDeadline: number; exclusiveRelayer: string; exclusivityDeadline: number; + _hash?: Record; } export interface Deposit extends RelayData { diff --git a/src/utils/SpokeUtils.ts b/src/utils/SpokeUtils.ts index 554b777f0..863eb0c02 100644 --- a/src/utils/SpokeUtils.ts +++ b/src/utils/SpokeUtils.ts @@ -216,7 +216,9 @@ export async function getDepositIdAtBlock(contract: Contract, blockTag: number): * @returns The corresponding RelayData hash. */ export function getRelayDataHash(relayData: RelayData, destinationChainId: number): string { - return ethersUtils.keccak256( + relayData._hash ??= {}; + + return (relayData._hash[destinationChainId] ??= ethersUtils.keccak256( ethersUtils.defaultAbiCoder.encode( [ "tuple(" + @@ -237,7 +239,7 @@ export function getRelayDataHash(relayData: RelayData, destinationChainId: numbe ], [relayData, destinationChainId] ) - ); + )); } export function getRelayHashFromEvent(e: Deposit | Fill | SlowFillRequest): string { diff --git a/test/SpokePoolClient.ValidateFill.ts b/test/SpokePoolClient.ValidateFill.ts index fc5e6fb35..5026c7a6c 100644 --- a/test/SpokePoolClient.ValidateFill.ts +++ b/test/SpokePoolClient.ValidateFill.ts @@ -216,7 +216,7 @@ describe("SpokePoolClient: Fill Validation", function () { await spokePoolClient1.update(); expect(spokePoolClient1.getDepositForFill(fill)) - .excludingEvery(["realizedLpFeePct", "quoteBlockNumber"]) + .excludingEvery(["realizedLpFeePct", "quoteBlockNumber", "_hash"]) .to.deep.equal(deposit); }); @@ -631,7 +631,7 @@ describe("SpokePoolClient: Fill Validation", function () { expect(fill_2.relayExecutionInfo.fillType === FillType.FastFill).to.be.true; expect(spokePoolClient1.getDepositForFill(fill_1)) - .excludingEvery(["quoteBlockNumber", "realizedLpFeePct"]) + .excludingEvery(["quoteBlockNumber", "realizedLpFeePct", "_hash"]) .to.deep.equal(deposit_1); expect(spokePoolClient1.getDepositForFill(fill_2)).to.equal(undefined); @@ -652,22 +652,24 @@ describe("SpokePoolClient: Fill Validation", function () { expect(validateFillForDeposit(validFill, deposit_2)).to.be.true; + const _hash = undefined; + // Invalid input amount. - expect(validateFillForDeposit({ ...validFill, inputAmount: toBNWei(1337) }, deposit_2)).to.be.false; + expect(validateFillForDeposit({ ...validFill, inputAmount: toBNWei(1337), _hash }, deposit_2)).to.be.false; // Changed the output token. - expect(validateFillForDeposit(validFill, { ...deposit_2, outputToken: owner.address })).to.be.false; + expect(validateFillForDeposit(validFill, { ...deposit_2, outputToken: owner.address, _hash })).to.be.false; // Changed the output amount. - expect(validateFillForDeposit({ ...validFill, outputAmount: toBNWei(1337) }, deposit_2)).to.be.false; + expect(validateFillForDeposit({ ...validFill, outputAmount: toBNWei(1337), _hash }, deposit_2)).to.be.false; // Invalid depositId. - expect(validateFillForDeposit({ ...validFill, depositId: 1337 }, deposit_2)).to.be.false; + expect(validateFillForDeposit({ ...validFill, depositId: 1337, _hash }, deposit_2)).to.be.false; // Changed the depositor. - expect(validateFillForDeposit({ ...validFill, depositor: relayer.address }, deposit_2)).to.be.false; + expect(validateFillForDeposit({ ...validFill, depositor: relayer.address, _hash }, deposit_2)).to.be.false; // Changed the recipient. - expect(validateFillForDeposit({ ...validFill, recipient: relayer.address }, deposit_2)).to.be.false; + expect(validateFillForDeposit({ ...validFill, recipient: relayer.address, _hash }, deposit_2)).to.be.false; }); }); diff --git a/test/SpokePoolClient.v3Events.ts b/test/SpokePoolClient.v3Events.ts index 17c5edb79..3ea796b5e 100644 --- a/test/SpokePoolClient.v3Events.ts +++ b/test/SpokePoolClient.v3Events.ts @@ -209,9 +209,9 @@ describe("SpokePoolClient: Event Filtering", function () { // The SpokePoolClient appends destinationChainId, so check for it specifically. expect(slowFillRequest?.destinationChainId).to.not.be.undefined; expect(slowFillRequest?.destinationChainId).to.equal(destinationChainId); - Object.entries(relayData).forEach( - ([k, v]) => expect(isDefined(v)).to.equal(true) && expect(slowFillRequest?.[k]).to.equal(v) - ); + Object.entries(relayData) + .filter(([k]) => k !== "_hash") + .forEach(([k, v]) => expect(isDefined(v)).to.equal(true) && expect(slowFillRequest?.[k]).to.equal(v)); }); });