-
Notifications
You must be signed in to change notification settings - Fork 11
Replace oracle-based PDP proof fee with fixed FIL-based fee and updatable mechanism #213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: jennijuju <[email protected]>
…nism Co-authored-by: jennijuju <[email protected]>
|
||
function calculateProofFee(uint256 setId, uint256 estimatedGasFee) public view returns (uint256) { | ||
uint256 rawSize = 32 * challengeRange[setId]; | ||
(uint64 filUsdPrice, int32 filUsdPriceExpo) = getFILUSDPrice(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we now remove the other usd oracling code or is it used elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
afaik, it is not used for anything else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The oracle code (getFILUSDPrice, PYTH constants) is kept for backward compatibility since it's still called in tests and may be used by external contracts. It's no longer used for proof fee calculation but remains available as a public function.
@copilot Please fix the Solidity linting errors so that CI passes. |
Co-authored-by: rjan90 <[email protected]>
Fixed trailing whitespace in commit 9e7c8ba. |
Superseded by: #214 |
Summary
Implemented a fixed FIL-based proof fee mechanism to replace the dynamic oracle-dependent fee calculation.
Changes Completed
FEE_PER_TIB
constant (0.00023 FIL = 230000000000000000 AttoFIL)flatProofFee()
function for simple fee calculationupdateProofFee()
function (owner-only, 7-day delay)getActiveProofFeePerTiB()
to get current feeFeeUpdateProposed
eventcalculateProofFee()
to use flat feecalculateAndBurnProofFee()
to use flat feeProofFeePaid
event signature (removed price/expo)Key Features
Fixed Fee: fee = datasetSize_in_TiB * 0.00023 FIL (based on 1 FIL = 2.88 USD)
Updatable: Owner can update fee with 7-day delay for user preparation
No Oracle for Fees: Proof fees no longer depend on Pyth oracle (oracle code kept for backward compatibility)
Events:
FeeUpdateProposed(currentFee, newFee, effectiveTime)
Note
Oracle-related code (
getFILUSDPrice
, PYTH constants) retained for backward compatibility as it may be used by external contracts or tests.Original prompt
This section details on the original issue you should resolve
<issue_title>Update PDP proof fee</issue_title>
<issue_description>we want to move away from the oracle to make the system more resilient by avoiding 3rd party tooling. instead, a FIL based fee will be introduced.
@irenegia, please specify the details.</issue_description>
<agent_instructions>#209 (comment) This is proposed solution </agent_instructions>
Comments on the Issue (you are @copilot in this section)
@irenegia The current value of the PDP proof fee for a proving system with daily proof is - 0.01 * (2/30) USD = 0.00067 USD per TiBCurrently we convert this in FIL using the oracle price and then burn. To avoid the oracle, we propose to use a fixed conversion rate (1 FIL = 2.88 USD) based on past values (see here). In this way we get that the new (fixed) PDP proof fee is
Consequences of this new approach:
What is the FIL prices crashes in the future?
What if the FIL price goes up in the future?
✅ Is it a problem for the network? No
✅ If SPs are paid in FIL, no problem again, same as above.
🔴 If SPs are paid in stablecoins, then this may be a problem because the fee takes a large cut of their profit, so we propose to add a max to the fee and the ax values is computed using and hard-coded value of high base fee, see the following:
- add a public constant
fee_perTiB
, set it to 0.00023 FIL- compute the fee as
fee = fee_perTiB * dataset_sizeTib
- add a public constant
high_baseFee
, set it to 0.1 nanoFil- get an estimate of
gas_units
(this is already done in the contract)- compute
max_fee = gas_units * highbaseFee
- if
fee > max_fee
, thenfee = max_fee
- burn
fee
Note that moreover :
Example of a realist max value: 200000000*0.1 nanoFil = 0.02 FIL
cc @lucaniz</comment_new>
<comment_new>@momack2
This seems like a reasonable approach! Question on the "what if FIL goes up in the future" issue - at what point would we trigger this fee > max fee issue? FIL at $10? FIL at $100? If not in either of those cases, I might punt the added complexity of the max_fee limit since its a future change that no one would be unhappy about and could be updated in the future.</comment_new>
<comment_new>@irenegia
Not sure I get your question, molly.
But he max is not trigger based on the price, we do not have knowledge of that without the oracle.
The idea here is that, at any FIL price, we will have the max that is triggered likely by having a very large data set (larger than 100TiB). This if the FIL price stays as today means we are burning a bit less, but if the price goes crazy high is a security measure. </comment_new>
<comment_new>@momack2
As per live discussion - we're going with the flat fee without the max. we will make this field updateable in case the price of FIL moons and this becomes unreasonable.</comment_new>
<comment_new>@irenegia
fee_perTiB
, set it to 0.00023 FILfee_perTiB * datasetSize_in_TiB
<comment_new>@jennijuju
On top of #209 (comment)
We should also add a
updateProofFee
function that is only callable by the owner, to update the fee_perTiB. The new fee should be effective in 7 days, this gives pdp verifier users time to react to the new fee and make adjustment as needed. We should emit an eventfeeUpdateProposed
that will emit an event to inc...💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.