Skip to content

Conversation

@rjan90
Copy link
Collaborator

@rjan90 rjan90 commented Oct 23, 2025

Makes the three pricing rate constants mutable storage variables instead of immutable, enabling future price adjustments without requiring contract upgrades.

Changes

  • Pricing Variables: Converted STORAGE_PRICE_PER_TIB_PER_MONTH, CACHE_MISS_PRICE_PER_TIB_PER_MONTH, and CDN_PRICE_PER_TIB_PER_MONTH from immutable constants to mutable storage variables
  • New Function: Added updatePricing() - owner-only function that allows selective updates to pricing rates (pass 0 to keep existing value)
  • New Getter: Added getCurrentPricingRates() - public view function to query current pricing values
  • New Event: Added PricingUpdated event to track pricing changes
  • Lockup Amounts: DEFAULT_CDN_LOCKUP_AMOUNT and DEFAULT_CACHE_MISS_LOCKUP_AMOUNT remain immutable as they are not expected to change

Impact

  • New price rates will apply to all active data sets on their next proving period update (via nextProvingPeriod())

@FilOzzy FilOzzy added this to FS Oct 23, 2025
@github-project-automation github-project-automation bot moved this to 📌 Triage in FS Oct 23, 2025
@rjan90 rjan90 moved this from 📌 Triage to ⌨️ In Progress in FS Oct 23, 2025
@rjan90 rjan90 self-assigned this Oct 23, 2025
@rjan90 rjan90 linked an issue Oct 23, 2025 that may be closed by this pull request
@rjan90
Copy link
Collaborator Author

rjan90 commented Oct 23, 2025

I had to make the pricing variables use camelCase (storagePricePerTibPerMonth, cacheMissPricePerTibPerMonth, cdnPricePerTibPerMonth) to match the existing storage variable convention in the contract (e.g., maxProvingPeriod, serviceCommissionBps): c7aa970.

Because without it the generated files check was failing.

@rjan90 rjan90 marked this pull request as ready for review October 23, 2025 12:54
@rjan90 rjan90 moved this from ⌨️ In Progress to 🔎 Awaiting review in FS Oct 23, 2025
@rjan90 rjan90 requested a review from wjmelements October 23, 2025 15:29
view
returns (uint256 storagePrice, uint256 cacheMissPrice, uint256 cdnPrice)
{
return (storagePricePerTibPerMonth, cacheMissPricePerTibPerMonth, cdnPricePerTibPerMonth);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these cdn rates should be zero after #237. Might be an oversight in that PR. I have raised this question on slack.

Copy link
Contributor

Choose a reason for hiding this comment

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

looks like they noticed before I did #324

Copy link
Contributor

@wjmelements wjmelements left a comment

Choose a reason for hiding this comment

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

I think we should have a reasonable upper bound (eg 4x the initial value) on these numbers enforced by the contract. Increasing the rates above that boundary should require a contract upgrade via announcePlannedUpgrade.

@rjan90
Copy link
Collaborator Author

rjan90 commented Oct 23, 2025

I think we should have a reasonable upper bound (eg 4x the initial value) on these numbers enforced by the contract. Increasing the rates above that boundary should require a contract upgrade via announcePlannedUpgrade.

I think that makes sense. Will implement

@rvagg
Copy link
Collaborator

rvagg commented Oct 24, 2025

Will have to be reconciled with #320 depending on which is merged first. We'll want to be able to add MINIMUM_STORAGE_RATE_PER_MONTH to the update function.

@rjan90
Copy link
Collaborator Author

rjan90 commented Oct 24, 2025

Happy to let #320 to get merged first, and then followup here.

@rjan90 rjan90 force-pushed the phi/price-variable branch from 1a61736 to ba45531 Compare October 24, 2025 06:29
…pdates

- Convert STORAGE_PRICE_PER_TIB_PER_MONTH, CACHE_MISS_PRICE_PER_TIB_PER_MONTH,
  and CDN_PRICE_PER_TIB_PER_MONTH from immutable to storage variables
- Add updatePricing() owner-only function to update pricing rates
- Add getCurrentPricingRates() getter function
- Add PricingUpdated event to track pricing changes
fix: make update-abi
chore: make abi-gen
Rebased on main to incorporate floor pricing changes (commit 6cb08ce) and
made MINIMUM_STORAGE_RATE_PER_MONTH mutable to enable runtime updates.

Changes:
- Converted minimumStorageRatePerMonth from immutable to storage variable
- Added MAX_MINIMUM_STORAGE_RATE_PER_MONTH (0.24 USDFC, 4x initial 0.06)
- Updated updatePricing() to accept newMinimumRate parameter
- Updated PricingUpdated event to include minimumRate
- Updated getCurrentPricingRates() to return both storage price and minimum rate
- Added AtLeastOnePriceMustBeNonZero and PriceExceedsMaximum errors
- Updated all references throughout contract to use camelCase variable names
@rjan90 rjan90 force-pushed the phi/price-variable branch from ba45531 to 79ada50 Compare October 24, 2025 21:10
@rjan90 rjan90 requested a review from wjmelements October 24, 2025 21:11
@rjan90
Copy link
Collaborator Author

rjan90 commented Oct 24, 2025

I have reconciled this PR with the changes coming from #320 now, and added MINIMUM_STORAGE_RATE_PER_MONTH to the update function.

/// @param priceType The type of price being updated (e.g., "storage", "minimumRate")
/// @param maxAllowed The maximum allowed value for this price type
/// @param actual The attempted value that exceeds the maximum
error PriceExceedsMaximum(string priceType, uint256 maxAllowed, uint256 actual);
Copy link
Contributor

Choose a reason for hiding this comment

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

we want to avoid strings in the code because solidity strings are a lot of codesize. They are actually the reason we are using these ABI errors.

Copy link
Contributor

Choose a reason for hiding this comment

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

There is a comparable situation where we are working around this with enum AddressField and another with enum CommissionType.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively you can use two different errors.

Copy link
Contributor

@wjmelements wjmelements left a comment

Choose a reason for hiding this comment

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

  1. Prefer require() to if (){ revert() }
  2. Avoid string constants.

@github-project-automation github-project-automation bot moved this from 🔎 Awaiting review to ⌨️ In Progress in FS Oct 25, 2025
rjan90 and others added 4 commits October 26, 2025 20:15
Address PR feedback to reduce code size by using enum instead of string
literals in error definitions.

Changes:
- Add PriceType enum (Storage, MinimumRate) to Errors.sol
- Update PriceExceedsMaximum error to use PriceType enum instead of string
- Update error calls in updatePricing() to use Errors.PriceType.Storage/MinimumRate
- Fix formatting issues in updatePricing() function
@rjan90 rjan90 requested a review from wjmelements October 26, 2025 20:04
* @return minimumRate Current minimum monthly storage rate
*/
function getCurrentPricingRates() external view returns (uint256 storagePrice, uint256 minimumRate) {
return (storagePricePerTibPerMonth, minimumStorageRatePerMonth);
Copy link
Contributor

Choose a reason for hiding this comment

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

rm or move to WarmStorageView lib

Copy link
Contributor

Choose a reason for hiding this comment

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

@github-project-automation github-project-automation bot moved this from ⌨️ In Progress to ✔️ Approved by reviewer in FS Oct 26, 2025
Reviewer @rjan90
We want view methods to use `extsload` because this reduces codesize.
Codesize is a minor component of gas costs in the Filecoin EVM.
#### Changes
* mv getCurrentPricingRates to the View contract
Comment on lines +496 to +513
if (newStoragePrice > 0) {
require(
newStoragePrice <= MAX_STORAGE_PRICE_PER_TIB_PER_MONTH,
Errors.PriceExceedsMaximum(
Errors.PriceType.Storage, MAX_STORAGE_PRICE_PER_TIB_PER_MONTH, newStoragePrice
)
);
storagePricePerTibPerMonth = newStoragePrice;
}
if (newMinimumRate > 0) {
require(
newMinimumRate <= MAX_MINIMUM_STORAGE_RATE_PER_MONTH,
Errors.PriceExceedsMaximum(
Errors.PriceType.MinimumRate, MAX_MINIMUM_STORAGE_RATE_PER_MONTH, newMinimumRate
)
);
minimumStorageRatePerMonth = newMinimumRate;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't love having ifs here and am not sure "Pass 0 to keep existing value unchanged." is all that helpful. It might help with footguns, perhaps, but now there's no way to set a floor of 0, we'd have to use 1 to be our floor if we decided to undo that.
But, not a big deal if we're just trying to get this over the line at this point.

@rjan90
Copy link
Collaborator Author

rjan90 commented Oct 27, 2025

Will go ahead and merge as-is, since we are trying to get this over the line at this point, to unblock the release of FWSS contracts for GA

@rjan90 rjan90 merged commit 6801108 into main Oct 27, 2025
6 checks passed
@rjan90 rjan90 deleted the phi/price-variable branch October 27, 2025 09:29
@github-project-automation github-project-automation bot moved this from ✔️ Approved by reviewer to 🎉 Done in FS Oct 27, 2025
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.

Make pricing constants variable

4 participants