Skip to content

feat(indexer): handle PiecesAddedV2 events - #103

Merged
Kubuxu merged 2 commits into
masterfrom
feat/PiecesAddedV2
Aug 21, 2026
Merged

feat(indexer): handle PiecesAddedV2 events#103
Kubuxu merged 2 commits into
masterfrom
feat/PiecesAddedV2

Conversation

@Kubuxu

@Kubuxu Kubuxu commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Closes #101.

Summary

Add indexer support for the compact PiecesAddedV2 event introduced by FilOzone/pdp#300.

  • update generated contract ABIs from the head commit of chore: update PDP dependency filecoin-services#596
  • register a PDPVerifier:PiecesAddedV2 handler
  • reconstruct PieceCIDv2 bytes from the packed header and root
  • derive consecutive piece IDs from firstPieceId
  • store V2 events in the existing pdp_pieces_added table
  • retain the legacy PiecesAdded ABI and handler for historical indexing

Large additions emitted as multiple PiecesAddedV2 batches produce separate rows, identified by their block hash and log index.

CID reconstruction

PackedCid.header is right-aligned in a bytes32. 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 passed
  • npm run typecheck
  • synthetic PiecesAddedV2 ABI decode and packed-CID smoke test

Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
@FilOzzy FilOzzy added this to FOC Aug 20, 2026
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC Aug 20, 2026
@BigLep
BigLep requested a review from rvagg August 20, 2026 17:25
@BigLep BigLep moved this from 📌 Triage to 🔎 Awaiting review in FOC Aug 20, 2026
@BigLep
BigLep requested a lite review from Copilot August 20, 2026 17:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:PiecesAddedV2 handler and persist decoded pieces into pdp_pieces_added.
  • Implement packed-CID reconstruction (header + root) plus consecutive piece ID derivation helpers.
  • Update generated ABIs to include PiecesAddedV2 and 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 rvagg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@github-project-automation github-project-automation Bot moved this from 🔎 Awaiting review to ✔️ Approved by reviewer in FOC Aug 21, 2026
Signed-off-by: Jakub Sztandera <oss@kubuxu.com>
@Kubuxu

Kubuxu commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator Author

@rvagg feel free to critique in post-review, merging to deploy this.

@Kubuxu
Kubuxu merged commit 238d448 into master Aug 21, 2026
4 checks passed
@Kubuxu
Kubuxu deleted the feat/PiecesAddedV2 branch August 21, 2026 14:30
@github-project-automation github-project-automation Bot moved this from ✔️ Approved by reviewer to 🎉 Done in FOC Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🎉 Done

Development

Successfully merging this pull request may close these issues.

feat: handle PiecesAddedV2 event

5 participants