Skip to content

[indexer]: Index BidPlaced events from the intents-coprocessor pallet#1060

Merged
Wizdave97 merged 2 commits into
mainfrom
bidplaced-events-indexing-6fa995
Jul 21, 2026
Merged

[indexer]: Index BidPlaced events from the intents-coprocessor pallet#1060
Wizdave97 merged 2 commits into
mainfrom
bidplaced-events-indexing-6fa995

Conversation

@Wizdave97

Copy link
Copy Markdown
Member

Adds a FillerBid entity recording who bid on which order commitment, along with the raw bid payload.

The payload is read out of the place_bid extrinsic in the same block rather than from intents_getBidsForOrder: that RPC pins the chain head internally and has no at parameter, and the pallet's offchain copy expires, so on any backfill it would answer with today's live bids and silently attribute them to a historical block. The RPC remains as a fallback for when the call cannot be decoded.

place_bid may arrive wrapped in batch/proxy/sudo, so the call tree is walked to find it, matching on commitment — one batch can carry bids for several orders. Handler is registered on hyperbridge chains rather than under enablePriceIndexing, which is mainnet-only, since the pallet runs on gargantua too.

Adds a FillerBid entity recording who bid on which order commitment, along
with the raw bid payload.

The payload is read out of the place_bid extrinsic in the same block rather
than from intents_getBidsForOrder: that RPC pins the chain head internally
and has no `at` parameter, and the pallet's offchain copy expires, so on any
backfill it would answer with today's live bids and silently attribute them
to a historical block. The RPC remains as a fallback for when the call
cannot be decoded.

place_bid may arrive wrapped in batch/proxy/sudo, so the call tree is walked
to find it, matching on commitment — one batch can carry bids for several
orders. Handler is registered on hyperbridge chains rather than under
enablePriceIndexing, which is mainnet-only, since the pallet runs on
gargantua too.
subscribePhantomOrders watched system.events over the WsProvider. When the
socket dropped, polkadot-js reconnected the transport but did not reliably
re-establish the storage subscription, and every event emitted while
disconnected was lost with no error. The only error handling was a catch at
startup, so nothing ever checked liveness again. With a bid window measured
in a handful of blocks, that meant silently missed bids.

pollPhantomOrders reads the head each tick and scans every block between the
last one processed and that head, so the block cursor rather than the
connection determines what has been seen. This is gap-free rather than
merely self-healing: an outage delays orders but cannot drop them, since the
cursor only advances past a block whose events were actually read, and
recovery replays the backlog.

The cursor advances per block rather than per range, so a failure partway
through a catch-up re-scans only the unread blocks. maxBlocksPerPoll bounds
a single scan so a long outage catches up over several ticks, and
lookbackBlocks lets a restarting process pick up orders whose window is
still open.

Note this tracks the best head, not the finalized head: a reorg can drop a
block whose order was already bid on. The deposit is retractable, and
waiting for finality would miss the shorter bid windows entirely.
@Wizdave97
Wizdave97 marked this pull request as ready for review July 21, 2026 09:40
@Wizdave97
Wizdave97 merged commit 5cb0746 into main Jul 21, 2026
4 checks passed
@Wizdave97
Wizdave97 deleted the bidplaced-events-indexing-6fa995 branch July 21, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants