Skip to content

Tier-3 block-scan height guard added to an unused class; live PocketBlockchain path still unbounded #302

@jorgecuesta

Description

@jorgecuesta

Summary

The Tier-3 block-scan height guard added in PR #278 was applied to a class that is never instantiated, so it has no effect at runtime, and the live code path still has the unbounded scan it was meant to fix.

Detail

PR #278 added a comet.status() + Math.min(height + maxBlocks, latestHeight) guard to Blockchain.getTransaction in apps/middleman-workflows/src/lib/blockchain/index.ts so the Tier-3 scan stops at the chain tip instead of walking future (non-existent) heights.

But that Blockchain class is imported only for the SendTransactionResult type (ExecuteTransaction.ts) — it is never constructed. The activity's blockchain client is PocketBlockchain from @igniter/pocket (wired in apps/middleman-workflows/src/worker.ts via PocketBlockchain.setup(...)).

The live Tier-3 scan lives in PocketBlockchain.getTransactionFromBlock (packages/pocket/src/index.ts:359) and still loops:

for (let h = startHeight; h < startHeight + maxBlocks; h++) {
  // comet.block(h) throws for future heights -> caught -> continue
}

with no latest-height bound.

Impact

For a not-yet-indexed tx, every Tier-3 scan still attempts up to maxBlocks future heights, each comet.block(h) throwing and being swallowed — exactly the wasted scan budget PR #278 intended to remove. The Tier-3 portion of that PR is effectively dead code.

Fix

Port the latest-height guard into PocketBlockchain.getTransactionFromBlock (packages/pocket/src/index.ts), and either remove the unused Blockchain class or reduce it to the exported type. Consider whether the duplicate Blockchain implementation should exist at all.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions