fix: missing listener address in data set#105
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
listenerAddrfor bothcreateDataSetandaddPieces. - Update
Transaction.methodderivation 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
createDataSetCreatedFromAddPiecesEventsays the calldatasetIdis0when creating a new dataset, but the mock currently ABI-encodes the emittedsetIdvalue into the transaction input. This makes the calldata inconsistent with the scenario being tested and could hide future decoding bugs. Consider encoding0for the calldatasetId(while keepingevent.params.setIdas 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.
kaola526
approved these changes
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #103