Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/interfaces/SpokePool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface RelayData {
fillDeadline: number;
exclusiveRelayer: string;
exclusivityDeadline: number;
_hash?: Record<number, string>;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be a fair bit more efficient for this to be a simple string, but the RelayData type doesn't include the destinationChainId, so the same RelayData object can map to multiple hashes depending on the value of destinationChainId. In the interests of safety it seems best to use a record, but I'd love to find a way to use a string instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that mean the hash really should be one level higher where the destination chain is present (i.e. the hash should be in fill and deposit)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a good option. It introduces a little bit of duplication but it's nothing major. I'll think about another way of passing in the hash if it's not defined in RelayData.

}

export interface Deposit extends RelayData {
Expand Down
4 changes: 3 additions & 1 deletion src/utils/SpokeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(" +
Expand Down