From bb243ee4c17240bda3ecc15551acf44014e940ad Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Thu, 18 Dec 2025 13:21:15 +0000 Subject: [PATCH 1/2] improve(SpokeUtils): Reorder getRelayDataHash() svm implementation For SVM deposits & fills, there's no need to create the _relayData object. --- src/utils/SpokeUtils.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/utils/SpokeUtils.ts b/src/utils/SpokeUtils.ts index 04a9b032a..b4f7affec 100644 --- a/src/utils/SpokeUtils.ts +++ b/src/utils/SpokeUtils.ts @@ -141,6 +141,11 @@ export function getRelayDataHash(relayData: RelayData, destinationChainId: numbe { type: "uint256", name: "destinationChainId" }, ]; + if (chainIsSvm(destinationChainId)) { + const messageHash = getMessageHash(relayData.message); + return svm.getRelayDataHash({ ...relayData, messageHash }, destinationChainId); + } + const _relayData = { ...relayData, depositor: relayData.depositor.toBytes32(), @@ -149,10 +154,6 @@ export function getRelayDataHash(relayData: RelayData, destinationChainId: numbe outputToken: relayData.outputToken.toBytes32(), exclusiveRelayer: relayData.exclusiveRelayer.toBytes32(), }; - if (chainIsSvm(destinationChainId)) { - const messageHash = getMessageHash(relayData.message); - return svm.getRelayDataHash({ ...relayData, messageHash }, destinationChainId); - } return keccak256(encodeAbiParameters(abi, [_relayData, destinationChainId])); } From d31444bda08f9d5dbe78d767e33093a7c77b409d Mon Sep 17 00:00:00 2001 From: Paul <108695806+pxrl@users.noreply.github.com> Date: Thu, 18 Dec 2025 13:24:48 +0000 Subject: [PATCH 2/2] More tune --- src/utils/SpokeUtils.ts | 43 +++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/utils/SpokeUtils.ts b/src/utils/SpokeUtils.ts index b4f7affec..d8caa0629 100644 --- a/src/utils/SpokeUtils.ts +++ b/src/utils/SpokeUtils.ts @@ -113,6 +113,27 @@ export function unpackFillEvent(rawEvent: SortableEvent, destinationChainId: num } satisfies FillWithBlock; } +const RELAYDATA_ABI = [ + { + type: "tuple", + components: [ + { type: "bytes32", name: "depositor" }, + { type: "bytes32", name: "recipient" }, + { type: "bytes32", name: "exclusiveRelayer" }, + { type: "bytes32", name: "inputToken" }, + { type: "bytes32", name: "outputToken" }, + { type: "uint256", name: "inputAmount" }, + { type: "uint256", name: "outputAmount" }, + { type: "uint256", name: "originChainId" }, + { type: "uint256", name: "depositId" }, + { type: "uint32", name: "fillDeadline" }, + { type: "uint32", name: "exclusivityDeadline" }, + { type: "bytes", name: "message" }, + ], + }, + { type: "uint256", name: "destinationChainId" }, +]; + /** * Compute the RelayData hash for a fill. This can be used to determine the fill status. * @param relayData RelayData information that is used to complete a fill. @@ -120,26 +141,6 @@ export function unpackFillEvent(rawEvent: SortableEvent, destinationChainId: num * @returns The corresponding RelayData hash. */ export function getRelayDataHash(relayData: RelayData, destinationChainId: number): string { - const abi = [ - { - type: "tuple", - components: [ - { type: "bytes32", name: "depositor" }, - { type: "bytes32", name: "recipient" }, - { type: "bytes32", name: "exclusiveRelayer" }, - { type: "bytes32", name: "inputToken" }, - { type: "bytes32", name: "outputToken" }, - { type: "uint256", name: "inputAmount" }, - { type: "uint256", name: "outputAmount" }, - { type: "uint256", name: "originChainId" }, - { type: "uint256", name: "depositId" }, - { type: "uint32", name: "fillDeadline" }, - { type: "uint32", name: "exclusivityDeadline" }, - { type: "bytes", name: "message" }, - ], - }, - { type: "uint256", name: "destinationChainId" }, - ]; if (chainIsSvm(destinationChainId)) { const messageHash = getMessageHash(relayData.message); @@ -154,7 +155,7 @@ export function getRelayDataHash(relayData: RelayData, destinationChainId: numbe outputToken: relayData.outputToken.toBytes32(), exclusiveRelayer: relayData.exclusiveRelayer.toBytes32(), }; - return keccak256(encodeAbiParameters(abi, [_relayData, destinationChainId])); + return keccak256(encodeAbiParameters(RELAYDATA_ABI, [_relayData, destinationChainId])); } export function getRelayHashFromEvent(e: RelayData & { destinationChainId: number }): string {