Skip to content

Commit

Permalink
improve(Monitor): Ignore chains without pool rebalance leaves when lo…
Browse files Browse the repository at this point in the history
…gging about "stuck" rebalances (#1725)

* improve(Monitor): Ignore chains without pool rebalance leaves when logging about "stuck" rebalances

Fixes ACX-2433

* Update Monitor.ts
  • Loading branch information
nicholaspai authored Aug 1, 2024
1 parent f6b739e commit 499c760
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/monitor/Monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ export class Monitor {
// should stay unstuck for longer than one bundle.
async checkStuckRebalances(): Promise<void> {
const hubPoolClient = this.clients.hubPoolClient;
const { currentTime } = hubPoolClient;
const { currentTime, latestBlockSearched } = hubPoolClient;
const lastFullyExecutedBundle = hubPoolClient.getLatestFullyExecutedRootBundle(hubPoolClient.latestBlockSearched);
// This case shouldn't happen outside of tests as Across V2 has already launched.
if (lastFullyExecutedBundle === undefined) {
Expand All @@ -573,7 +573,16 @@ export class Monitor {
const lastFullyExecutedBundleTime = lastFullyExecutedBundle.challengePeriodEndTimestamp;

const allL1Tokens = this.clients.hubPoolClient.getL1Tokens();
const poolRebalanceLeaves = this.clients.hubPoolClient.getExecutedLeavesForRootBundle(
lastFullyExecutedBundle,
latestBlockSearched
);
for (const chainId of this.crossChainAdapterSupportedChains) {
// Exit early if there were no pool rebalance leaves for this chain executed in the last bundle.
const poolRebalanceLeaf = poolRebalanceLeaves.find((leaf) => leaf.chainId === chainId);
if (!poolRebalanceLeaf) {
continue;
}
const gracePeriod = EXPECTED_L1_TO_L2_MESSAGE_TIME[chainId] ?? REBALANCE_FINALIZE_GRACE_PERIOD;
// If we're still within the grace period, skip looking for any stuck rebalances.
// Again, this would give false negatives for transfers that have been stuck for longer than one bundle if the
Expand All @@ -585,7 +594,7 @@ export class Monitor {
lastFullyExecutedBundleTime,
currentTime,
});
return;
continue;
}

// If chain wasn't active in latest bundle, then skip it.
Expand Down

0 comments on commit 499c760

Please sign in to comment.