Skip to content

fix: normalize empty outputs for pdp-verifier#723

Merged
hugomrdias merged 4 commits intomasterfrom
hugomrdias/574-pdp-verifier
Apr 16, 2026
Merged

fix: normalize empty outputs for pdp-verifier#723
hugomrdias merged 4 commits intomasterfrom
hugomrdias/574-pdp-verifier

Conversation

@hugomrdias
Copy link
Copy Markdown
Member

@hugomrdias hugomrdias commented Apr 8, 2026

Handling these portions of #574

  • add error handling for non-live data sets and implement LimitMustBeGreaterThanZeroError
  • updates in the sdk
  • better multicall errors mocking

…imitMustBeGreaterThanZeroError

- Introduced LimitMustBeGreaterThanZeroError for pagination limits.
- Updated various PDP verifier functions to return 0 or null when the data set is not live.
- Enhanced error handling in getActivePieces, getActivePieceCount, getDataSetLeafCount, getDataSetListener, getDataSetStorageProvider, getNextChallengeEpoch, and getNextPieceId functions.
- Added utility functions for error string comparison and parsing.
- Updated tests to cover new error handling scenarios.
- Changed the condition for nextChallengeEpoch to check for null instead of 0.
- Added comments to clarify the implications of nextChallengeEpoch being null, indicating potential states of the data set.
- Removed redundant debug logging for when nextChallengeEpoch is 0, streamlining the logic.
@hugomrdias hugomrdias requested a review from rvagg as a code owner April 8, 2026 14:20
@github-project-automation github-project-automation bot moved this to 📌 Triage in FOC Apr 8, 2026
@hugomrdias hugomrdias requested a review from juliangruber April 8, 2026 14:20
@rjan90 rjan90 moved this from 📌 Triage to 🔎 Awaiting review in FOC Apr 8, 2026
@rjan90 rjan90 added this to the M4.2: mainnet GA milestone Apr 8, 2026
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 8, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
synapse-dev 2c6009e Commit Preview URL

Branch Preview URL
Apr 15 2026, 03:03 PM

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

Normalizes PDP Verifier contract “not live” / empty-ish states across synapse-core (and adjusts synapse-sdk usage) by converting specific revert reasons into consistent null/0/[] outputs, plus adds better multicall error mocking and a new limit-validation error.

Changes:

  • Add STRING_ERRORS + helpers to detect/normalize “Data set not live” errors across PDP Verifier reads/multicalls.
  • Update PDP Verifier query helpers to return normalized outputs (e.g., 0n, null, []) and add LimitMustBeGreaterThanZeroError.
  • Expand/adjust tests and JSON-RPC mocks to preserve revert details in multicall results.

Reviewed changes

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

Show a summary per file
File Description
packages/synapse-sdk/src/storage/context.ts Adjust piece timing logic to handle getNextChallengeEpoch returning null.
packages/synapse-core/test/jsonrpc-multicall.test.ts Adds coverage ensuring aggregate3 multicall preserves mixed success/failure.
packages/synapse-core/test/get-scheduled-removals.test.ts Adds tests for deduplication + not-live normalization to [].
packages/synapse-core/test/get-pieces.test.ts Adds tests for scheduled-removal dedupe, not-live normalization, and negative limit validation.
packages/synapse-core/test/get-next-piece-id.test.ts Adds test for not-live normalization to 0n.
packages/synapse-core/test/get-next-challenge-epoch.test.ts Adds tests for null normalization (non-positive epoch + not-live).
packages/synapse-core/test/get-dataset-size.test.ts Adds test ensuring not-live datasets contribute 0n size.
packages/synapse-core/test/get-data-set-storage-provider.test.ts Updates expectations to allow null proposed provider + not-live normalization.
packages/synapse-core/test/get-data-set-listener.test.ts Adds tests for zero-address → null and not-live → null.
packages/synapse-core/test/get-data-set-leaf-count.test.ts Adds test for not-live normalization to 0n.
packages/synapse-core/test/get-active-pieces.test.ts Adds tests for negative limit validation and not-live normalization.
packages/synapse-core/test/get-active-piece-count.test.ts Adds test for not-live normalization to 0n.
packages/synapse-core/src/utils/contract-errors.ts Introduces shared helpers/constants for matching known revert-string errors.
packages/synapse-core/src/pdp-verifier/get-scheduled-removals.ts Adds not-live handling and factors dedupe into parseScheduledRemovals.
packages/synapse-core/src/pdp-verifier/get-pieces.ts Adds limit validation, not-live handling, and avoids metadata requests when empty.
packages/synapse-core/src/pdp-verifier/get-next-piece-id.ts Normalizes not-live to 0n.
packages/synapse-core/src/pdp-verifier/get-next-challenge-epoch.ts Normalizes non-positive epochs and not-live to null via parseNextChallengeEpoch.
packages/synapse-core/src/pdp-verifier/get-dataset-size.ts Uses allowFailure: true multicall to map not-live → 0n per dataset.
packages/synapse-core/src/pdp-verifier/get-data-set-storage-provider.ts Normalizes not-live to null and converts zero proposed provider to null.
packages/synapse-core/src/pdp-verifier/get-data-set-listener.ts Normalizes not-live to null and converts zero listener address to null.
packages/synapse-core/src/pdp-verifier/get-data-set-leaf-count.ts Normalizes not-live to 0n.
packages/synapse-core/src/pdp-verifier/get-active-pieces.ts Adds limit validation and normalizes not-live to an empty page.
packages/synapse-core/src/pdp-verifier/get-active-piece-count.ts Normalizes not-live to 0n.
packages/synapse-core/src/mocks/jsonrpc/index.ts Improves mock revert encoding and aggregate3 failure returnData handling.
packages/synapse-core/src/errors/pdp-verifier.ts Adds LimitMustBeGreaterThanZeroError.

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

Comment thread packages/synapse-core/src/pdp-verifier/get-pieces.ts Outdated
Comment thread packages/synapse-core/src/pdp-verifier/get-pieces.ts Outdated
Comment thread packages/synapse-core/src/pdp-verifier/get-pieces.ts Outdated
Comment thread packages/synapse-core/src/pdp-verifier/get-active-pieces.ts Outdated
Comment thread packages/synapse-sdk/src/storage/context.ts Outdated
Comment thread packages/synapse-core/src/errors/pdp-verifier.ts
@juliangruber juliangruber removed their request for review April 10, 2026 14:17
@juliangruber
Copy link
Copy Markdown
Member

Removed review request as I need to focus on pay explorer for now

- Updated limit checks in getActivePieces and getPieces functions to ensure options.limit is not null before comparison.
- Modified getPiecesWithMetadata to correctly return the hasMore property from pieces instead of a hardcoded false value.
- Added export for pdp-verifier module to enhance functionality.
Comment thread packages/synapse-core/src/utils/contract-errors.ts
Comment thread packages/synapse-sdk/src/storage/context.ts Outdated
Comment on lines +136 to +138
if (data <= 0n) {
return null
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I htink this can be === 0n but also we're now returning null for two cases so we're limiting the amount of information we can present here; maybe we should just pass through 0n in this case because it does say something, we'd just need to document what that means (no challenge epoch set, as opposed to not live)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

is that information we need to exposes in this action?
my feeling is here we just say no challenge set in both cases, user can check if dataset is live with the specific action for that.

Copy link
Copy Markdown
Collaborator

@rvagg rvagg left a comment

Choose a reason for hiding this comment

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

sgtm; I'll leave the comments up to your judgement though I reckon you could do better on the error matching in here

@github-project-automation github-project-automation bot moved this from 🔎 Awaiting review to ✔️ Approved by reviewer in FOC Apr 15, 2026
- Improved the stringErrorEquals function to better handle nested error causes and extract the reason from them.
- Added a new test suite for error handling, including tests for detecting viem errors and matching revert reasons from nested causes.
- Ensured comprehensive coverage for various error scenarios in contract error handling.
@hugomrdias hugomrdias changed the title Partial fix for #574 focused on pdp-verifier fix: normalize empty outputs for pdp-verifier Apr 16, 2026
@hugomrdias hugomrdias merged commit 187e8a4 into master Apr 16, 2026
13 checks passed
@hugomrdias hugomrdias deleted the hugomrdias/574-pdp-verifier branch April 16, 2026 10:59
@github-project-automation github-project-automation bot moved this from ✔️ Approved by reviewer to 🎉 Done in FOC Apr 16, 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.

5 participants