Skip to content

fix(fwss): price PDP rails on raw bytes, not Fr32-expanded leaf size#471

Merged
rvagg merged 3 commits into
mainfrom
rvagg/overcharge
May 8, 2026
Merged

fix(fwss): price PDP rails on raw bytes, not Fr32-expanded leaf size#471
rvagg merged 3 commits into
mainfrom
rvagg/overcharge

Conversation

@rvagg
Copy link
Copy Markdown
Collaborator

@rvagg rvagg commented May 7, 2026

updatePaymentRates was multiplying leafCount by 32 to derive total bytes, which is the Fr32-expanded size, not the raw payload size. Switch to the new Cids.leafCountToRawSize to apply the 127/128 ratio, removing the ~0.787% per-byte overcharge.

Also marks getDataSetSizeInBytes deprecated and to-be-removed; it now delegates to the same helper rather than computing Fr32 size. Drops the BYTES_PER_LEAF constant.

Bumps lib/pdp submodule to FilOzone/pdp#266.

Fixes: #451

Pending: we're going to tag + release pdp with that change, but not deploy it, so I'll update here with a new head commit when that's done but it'll be the same code.

`updatePaymentRates` was multiplying leafCount by 32 to derive total bytes,
which is the Fr32-expanded size, not the raw payload size. Switch to the new
`Cids.leafCountToRawSize` to apply the 127/128 ratio, removing the ~0.787%
per-byte overcharge.

Also marks `getDataSetSizeInBytes` deprecated and to-be-removed; it now
delegates to the same helper rather than computing Fr32 size. Drops the
`BYTES_PER_LEAF` constant.

Bumps lib/pdp submodule to FilOzone/pdp#266.

Fixes: #451
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

Adjusts FWSS payment rail pricing to charge based on raw payload bytes derived from PDP leaf counts, instead of the FR32-expanded byte size, eliminating the ~0.787% per-byte overcharge described in #451.

Changes:

  • Update updatePaymentRates to compute total bytes via Cids.leafCountToRawSize(leafCount) (raw-size upper bound).
  • Deprecate getDataSetSizeInBytes and make it delegate to the same raw-size helper.
  • Add regression tests covering rate updates on piece add and on next proving period after removals.

Reviewed changes

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

File Description
service_contracts/src/FilecoinWarmStorageService.sol Switches pricing byte calculation from FR32 leaf bytes to raw-size approximation via Cids.leafCountToRawSize.
service_contracts/src/lib/FilecoinWarmStorageServiceStateLibrary.sol Deprecates getDataSetSizeInBytes and changes it to return raw-size approximation via Cids.leafCountToRawSize.
service_contracts/src/lib/FilecoinWarmStorageServiceStateInternalLibrary.sol Regenerated/internal variant reflecting the same deprecated raw-size delegation.
service_contracts/test/FilecoinWarmStorageService.t.sol Adds tests asserting rails price on raw bytes for piece additions and post-removal recomputation.

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

Comment thread service_contracts/test/FilecoinWarmStorageService.t.sol Outdated
Comment thread service_contracts/test/FilecoinWarmStorageService.t.sol Outdated
@rvagg
Copy link
Copy Markdown
Collaborator Author

rvagg commented May 7, 2026

Submodule updated to https://github.com/FilOzone/pdp/releases/tag/v3.3.0

@BigLep BigLep moved this from 📌 Triage to 🔎 Awaiting review in FOC May 7, 2026
@github-project-automation github-project-automation Bot moved this from 🔎 Awaiting review to ✔️ Approved by reviewer in FOC May 7, 2026
Copy link
Copy Markdown
Collaborator

@ZenGround0 ZenGround0 left a comment

Choose a reason for hiding this comment

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

LGTM

@rvagg rvagg merged commit e63d263 into main May 8, 2026
6 checks passed
@rvagg rvagg deleted the rvagg/overcharge branch May 8, 2026 13:07
@github-project-automation github-project-automation Bot moved this from ✔️ Approved by reviewer to 🎉 Done in FOC May 8, 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.

Fix FWSS per-byte over-charging

6 participants