Skip to content

Commit

Permalink
Relocate filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
pxrl committed Sep 1, 2023
1 parent 7357d18 commit 1d2c4a7
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions src/relayer/Relayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,17 @@ export class Relayer {
const maxVersion = configStoreClient.configStoreVersion;

const unfilledDeposits = await getUnfilledDeposits(spokePoolClients, hubPoolClient, this.config.maxRelayerLookBack);
const { supportedDeposits = [], unsupportedDeposits = [] } = groupBy(unfilledDeposits, ({ version }) => {
return version <= maxVersion ? "supportedDeposits" : "unsupportedDeposits";
const {
supportedDeposits = [],
unsupportedDeposits = [],
ignoredDeposits = []
} = groupBy(unfilledDeposits, ({ deposit, version }) => {
const { originChainId, destinationChainId } = deposit;
if (version > maxVersion) {
return "unsupportedDeposits";
}

return this.routeEnabled(originChainId, destinationChainId) ? "supportedDeposits" : "ignoredDeposits";
});

if (unsupportedDeposits.length > 0) {
Expand All @@ -56,14 +65,27 @@ export class Relayer {
return { originChainId, depositId, version, transactionHash };
});
this.logger.warn({
at: "Relayer::checkForUnfilledDepositsAndFill",
at: "Relayer::getUnfilledDeposits",
message: "Skipping deposits that are not supported by this relayer version.",
latestVersionSupported: maxVersion,
latestInConfigStore: configStoreClient.getConfigStoreVersionForTimestamp(),
deposits,
});
}

if (ignoredDeposits.length > 0) {
const deposits = ignoredDeposits
.map(({ deposit }) => {
const { originChainId, destinationChainId, depositId, originToken, amount, transactionHash } = deposit;
return { originChainId, destinationChainId, depositId, originToken, amount, transactionHash };
});
this.logger.debug({
at: "Relayer::getUnfilledDeposits",
message: `Skipping ${deposits.length} deposits from or to disabled chains.`,
deposits,
});
}

return supportedDeposits;
}

Expand Down Expand Up @@ -157,15 +179,6 @@ export class Relayer {
const { originChainId, destinationChainId, originToken } = deposit;
const destinationChain = getNetworkName(destinationChainId);

if (!this.routeEnabled(originChainId, destinationChainId)) {
this.logger.debug({
at: "Relayer",
message: "Skipping deposit for unsupported origin or destination chain",
deposit,
});
continue;
}

// Skip any L1 tokens that are not specified in the config.
// If relayerTokens is an empty list, we'll assume that all tokens are supported.
const l1Token = hubPoolClient.getL1TokenInfoForL2Token(originToken, originChainId);
Expand Down

0 comments on commit 1d2c4a7

Please sign in to comment.