Skip to content

Commit

Permalink
refactor(relayer): Reduce inventory log spam in looping mode (#1808)
Browse files Browse the repository at this point in the history
If there are no cross-chain transfers to update then don't bother
logging about it.
  • Loading branch information
pxrl authored Sep 9, 2024
1 parent bd101fc commit 5be2609
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/clients/bridges/CrossChainTransferClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ export class CrossChainTransferClient {
async update(l1Tokens: string[], chainIds = this.getEnabledL2Chains()): Promise<void> {
const enabledChainIds = this.getEnabledL2Chains();
chainIds = chainIds.filter((chainId) => enabledChainIds.includes(chainId));
if (chainIds.length === 0) {
return;
}

this.log("Updating cross chain transfers", { chainIds });

const outstandingTransfersPerChain = await Promise.all(
Expand Down
10 changes: 6 additions & 4 deletions src/relayer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ export async function runRelayer(_logger: winston.Logger, baseSigner: Signer): P
const simulate = !config.sendingRelaysEnabled;
const enableSlowFills = config.sendingSlowRelaysEnabled;

let run = 1;
let txnReceipts: { [chainId: number]: Promise<string[]> };
const { acrossApiClient, inventoryClient, profitClient, spokePoolClients, tokenClient } = relayerClients;
const inventoryChainIds =
config.pollingDelay === 0 ? Object.values(spokePoolClients).map(({ chainId }) => chainId) : [];

let txnReceipts: { [chainId: number]: Promise<string[]> };
let run = 1;

try {
do {
if (loop) {
Expand Down Expand Up @@ -67,8 +71,6 @@ export async function runRelayer(_logger: winston.Logger, baseSigner: Signer): P
// disable inventory management, but does make it ignorant of in-flight cross-chain transfers. The rebalancer is
// assumed to run separately from the relayer and with pollingDelay 0, so it doesn't loop and will track transfers
// correctly to avoid repeat rebalances.
const inventoryChainIds =
config.pollingDelay === 0 ? Object.values(spokePoolClients).map(({ chainId }) => chainId) : [];
await Promise.all([
acrossApiClient.update(config.ignoreLimits),
inventoryClient.update(inventoryChainIds),
Expand Down

0 comments on commit 5be2609

Please sign in to comment.