Skip to content

Commit 2ecfd5d

Browse files
committed
cap search to 5k blocks
1 parent 330e51d commit 2ecfd5d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

platforms/evm/protocols/portico/src/bridge.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -385,17 +385,18 @@ export class EvmPorticoBridge<
385385

386386
// Check if the swap succeeded or failed
387387
// NOTE: If we can't find the event, assume the swap succeeded
388-
const tokenBridge = this.tokenBridge.tokenBridge;
388+
const { tokenBridge } = this.tokenBridge;
389389
const filter = tokenBridge.filters.TransferRedeemed(
390390
toChainId(vaa.emitterChain),
391391
vaa.emitterAddress.toString(),
392392
vaa.sequence,
393393
);
394394

395-
// Search for the event in the last 15 minutes
395+
// Search for the event in the last 15 minutes or 5000 blocks (whichever is smaller)
396396
const latestBlock = await EvmPlatform.getLatestBlock(this.provider);
397397
const blockTime = finality.blockTime.get(this.chain)!;
398-
const fromBlock = latestBlock - Math.floor((15 * 60 * 1000) / blockTime);
398+
const fromBlock =
399+
latestBlock - Math.min(5000, Math.floor((15 * 60 * 1000) / blockTime));
399400

400401
const logs = await tokenBridge
401402
.queryFilter(filter, fromBlock, latestBlock)

0 commit comments

Comments
 (0)