Skip to content

Commit

Permalink
improve(relayer): Defer deposit version computation (#1847)
Browse files Browse the repository at this point in the history
getUnfilledDeposits() currently unconditionally computes the deposit
version (i.e. the ConfigStore VERSION value applicable at the deposit
quoteTimestamp), and then filters out all the deposits that have been
filled. Determining the relevant version implies a lot of Array.find()
calls, all of which is wasted when the object is subsequently discarded.
  • Loading branch information
pxrl authored Oct 4, 2024
1 parent d3a88d5 commit 47c156f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/utils/FillUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ export function getUnfilledDeposits(

return deposits
.map((deposit) => {
const version = hubPoolClient.configStoreClient.getConfigStoreVersionForTimestamp(deposit.quoteTimestamp);
const { unfilledAmount, invalidFills } = destinationClient.getValidUnfilledAmountForDeposit(deposit);
return { deposit, version, unfilledAmount, invalidFills };
return { deposit, unfilledAmount, invalidFills };
})
.filter(({ unfilledAmount }) => unfilledAmount.gt(bnZero));
.filter(({ unfilledAmount }) => unfilledAmount.gt(bnZero))
.map(({ deposit, ...rest }) => {
const version = hubPoolClient.configStoreClient.getConfigStoreVersionForTimestamp(deposit.quoteTimestamp);
return { deposit, ...rest, version };
});
}

export function getAllUnfilledDeposits(
Expand Down

0 comments on commit 47c156f

Please sign in to comment.