feat(indexer): handle PiecesAddedV2 events - #103
Conversation
Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
There was a problem hiding this comment.
Pull request overview
Adds indexer support for the new compact PDPVerifier.PiecesAddedV2 event by decoding the packed CID representation and persisting it into the existing pdp_pieces_added table, while retaining the legacy PiecesAdded handler for historical indexing.
Changes:
- Register a
PDPVerifier:PiecesAddedV2handler and persist decoded pieces intopdp_pieces_added. - Implement packed-CID reconstruction (
header+root) plus consecutive piece ID derivation helpers. - Update generated ABIs to include
PiecesAddedV2and related upstream contract changes, and add a focused unit test suite for decoding.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| indexer/test/pieces-added-v2.test.ts | Adds tests covering packed CID reconstruction, piece ID derivation, and ABI decoding for PiecesAddedV2. |
| indexer/src/pdp-verifier.ts | Registers and implements the PiecesAddedV2 event handler that stores decoded pieces into pdp_pieces_added. |
| indexer/src/cid-utils.ts | Adds decodePackedPiece and decodePackedPieces utilities used by the new handler. |
| indexer/scripts/generate-abis.sh | Updates the pinned upstream ref used to generate ABIs to a commit containing the updated PDPVerifier ABI. |
| indexer/abis/ServiceProviderRegistry.ts | Regenerated ABI changes from upstream (adds new function entry). |
| indexer/abis/PDPVerifier.ts | Regenerated ABI including the new PiecesAddedV2 event and additional functions/errors. |
| indexer/abis/FilecoinWarmStorageService.ts | Regenerated ABI updates (new functions/events/errors and signature adjustments). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
rvagg
left a comment
There was a problem hiding this comment.
fine .. but you're pulling in duplicate events now that were deduped upstream, CDNPaymentRailsToppedUp, CDNServiceTerminated, DataSetAbandoned, RailRateUpdated are now in there twice. Can you see if you can get AI to script up a dedupe in generate-abis.sh? It should be able to find a union and exclude from each one.
we also have some new things to track in here, deletions and authorizer, but we could do those separately
Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
|
@rvagg feel free to critique in post-review, merging to deploy this. |
Closes #101.
Summary
Add indexer support for the compact
PiecesAddedV2event introduced by FilOzone/pdp#300.PDPVerifier:PiecesAddedV2handlerheaderandrootfirstPieceIdpdp_pieces_addedtablePiecesAddedABI and handler for historical indexingLarge additions emitted as multiple
PiecesAddedV2batches produce separate rows, identified by their block hash and log index.CID reconstruction
PackedCid.headeris right-aligned in abytes32. Reconstruction removes only the leading zero bytes, preserves zero bytes within the header, and appends the complete 32-byte root. The resulting bytes use the existing PieceCIDv2 decoder.Verification
npm test— 13 tests passednpm run typecheckPiecesAddedV2ABI decode and packed-CID smoke test