Skip to content

fix: missing listener address in data set#105

Merged
kaola526 merged 2 commits into
mainfrom
fix/data-set-listner-addr
May 28, 2026
Merged

fix: missing listener address in data set#105
kaola526 merged 2 commits into
mainfrom
fix/data-set-listner-addr

Conversation

@silent-cipher
Copy link
Copy Markdown
Collaborator

Closes #103

Copilot AI review requested due to automatic review settings May 26, 2026 18:34
@silent-cipher silent-cipher self-assigned this May 26, 2026
@FilOzzy FilOzzy added this to FOC May 26, 2026
@github-project-automation github-project-automation Bot moved this to 📌 Triage in FOC May 26, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes incorrect listener address extraction when DataSetCreated is emitted from different contract entry points by decoding the listener address from transaction calldata based on the function selector. This ensures datasets created via addPieces(setId=0, ...) correctly persist the listener address (and record the correct transaction method).

Changes:

  • Add selector-based calldata decoding to extract listenerAddr for both createDataSet and addPieces.
  • Update Transaction.method derivation to reflect the decoded calling function.
  • Extend Matchstick test utilities and add tests covering addPieces-created datasets and the unknown-selector fallback path.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
subgraph/src/pdp-verifier.ts Adds selector-based decoding for listener address and derives transaction method from calldata.
subgraph/tests/pdp-verifier-utils.ts Enhances mock event builders to construct realistic calldata for createDataSet and addPieces.
subgraph/tests/pdp-verifier.test.ts Adds test cases asserting correct listener decoding for addPieces and exercising the unknown-selector path.
Comments suppressed due to low confidence (1)

subgraph/tests/pdp-verifier-utils.ts:134

  • createDataSetCreatedFromAddPiecesEvent says the calldata setId is 0 when creating a new dataset, but the mock currently ABI-encodes the emitted setId value into the transaction input. This makes the calldata inconsistent with the scenario being tested and could hide future decoding bugs. Consider encoding 0 for the calldata setId (while keeping event.params.setId as the newly assigned ID).
  // Build addPieces(uint256,address,Cids.Cid[],bytes) calldata:
  //   [0..3]    selector  0x9afd37f2
  //   [4..35]   setId (uint256) — 0 means "create new dataset"
  //   [36..67]  listenerAddr (address, left-padded to 32 bytes)
  //   [68..99]  offset to pieceData = 0x80 (128)
  //   [100..131] offset to extraData = 0xa0 (160)
  //   [132..163] pieceData length = 0
  //   [164..195] extraData length = 0
  const setIdHex = setId.toHexString().slice(2).padStart(64, "0");
  const listenerHex = listenerAddr.toHexString().slice(2); // 40 hex chars
  DataSetCreatedEvent.transaction.input = Bytes.fromHexString(
    "0x9afd37f2" +
      setIdHex +
      "000000000000000000000000" +

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread subgraph/src/pdp-verifier.ts
Comment thread subgraph/tests/pdp-verifier-utils.ts
Comment thread subgraph/tests/pdp-verifier.test.ts Outdated
@BigLep BigLep moved this from 📌 Triage to ⌨️ In Progress in FOC May 27, 2026
@BigLep BigLep requested review from a team and juliangruber May 27, 2026 14:18
@github-project-automation github-project-automation Bot moved this from ⌨️ In Progress to ✔️ Approved by reviewer in FOC May 28, 2026
@kaola526 kaola526 merged commit 4a09992 into main May 28, 2026
5 checks passed
@github-project-automation github-project-automation Bot moved this from ✔️ Approved by reviewer to 🎉 Done in FOC May 28, 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.

Bug: missing listener in data set

5 participants