Skip to content

Commit

Permalink
improve(relayer): Permit per-chain external listener customisation (#…
Browse files Browse the repository at this point in the history
…1843)

This can be used to test a viem-based or non-evm-based external
listener.
  • Loading branch information
pxrl authored Sep 27, 2024
1 parent 247451c commit 201162b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/relayer/RelayerClientHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export async function constructRelayerClients(
const opts = {
lookback: config.maxRelayerLookBack,
blockRange: config.maxBlockLookBack[chainId],
path: config.listenerPath[chainId],
};
return [chainId, await indexedSpokePoolClient(baseSigner, hubPoolClient, chainId, opts)];
})
Expand Down
16 changes: 9 additions & 7 deletions src/relayer/RelayerConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type DepositConfirmationConfig = {

export class RelayerConfig extends CommonConfig {
readonly externalIndexer: boolean;
readonly indexerPath: string;
readonly listenerPath: { [chainId: number]: string } = {};
readonly inventoryConfig: InventoryConfig;
readonly debugProfitability: boolean;
readonly sendingRelaysEnabled: boolean;
Expand Down Expand Up @@ -88,7 +88,6 @@ export class RelayerConfig extends CommonConfig {
MIN_DEPOSIT_CONFIRMATIONS,
RELAYER_IGNORE_LIMITS,
RELAYER_EXTERNAL_INDEXER,
RELAYER_SPOKEPOOL_INDEXER_PATH,
RELAYER_TRY_MULTICALL_CHAINS,
RELAYER_USE_GENERIC_ADAPTER,
RELAYER_LOGGING_INTERVAL = "30",
Expand All @@ -100,7 +99,6 @@ export class RelayerConfig extends CommonConfig {

// External indexing is dependent on looping mode being configured.
this.externalIndexer = this.pollingDelay > 0 && RELAYER_EXTERNAL_INDEXER === "true";
this.indexerPath = RELAYER_SPOKEPOOL_INDEXER_PATH ?? Constants.RELAYER_DEFAULT_SPOKEPOOL_INDEXER;

// Empty means all chains.
this.relayerOriginChains = JSON.parse(RELAYER_ORIGIN_CHAINS ?? "[]");
Expand Down Expand Up @@ -326,7 +324,7 @@ export class RelayerConfig extends CommonConfig {
* @param logger Optional logger object.
*/
override validate(chainIds: number[], logger: winston.Logger): void {
const { relayerOriginChains, relayerDestinationChains } = this;
const { listenerPath, minFillTime, relayerOriginChains, relayerDestinationChains } = this;
const relayerChainIds =
relayerOriginChains.length > 0 && relayerDestinationChains.length > 0
? dedupArray([...relayerOriginChains, ...relayerDestinationChains])
Expand All @@ -343,9 +341,13 @@ export class RelayerConfig extends CommonConfig {
});
}

chainIds.forEach(
(chainId) => (this.minFillTime[chainId] = Number(process.env[`RELAYER_MIN_FILL_TIME_${chainId}`] ?? 0))
);
const { RELAYER_SPOKEPOOL_INDEXER_PATH = Constants.RELAYER_DEFAULT_SPOKEPOOL_INDEXER } = process.env;

chainIds.forEach((chainId) => {
minFillTime[chainId] = Number(process.env[`RELAYER_MIN_FILL_TIME_${chainId}`] ?? 0);
listenerPath[chainId] =
process.env[`RELAYER_SPOKEPOOL_INDEXER_PATH_${chainId}`] ?? RELAYER_SPOKEPOOL_INDEXER_PATH;
});

// Only validate config for chains that the relayer cares about.
super.validate(relayerChainIds, logger);
Expand Down

0 comments on commit 201162b

Please sign in to comment.