-
Notifications
You must be signed in to change notification settings - Fork 17
perf(validatePayment): loop over proving periods #267
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
perf(validatePayment): loop over proving periods #267
Conversation
|
@wjmelements @rjan90 Would love to get your thoughts on this draft PR |
|
Some workflow checks are failing, sorry about that, let me just fix them real quick |
bf33be6 to
54d5f4d
Compare
|
Please add some tests to check the edge cases, verifying that the |
|
I am fixing some issues, will soon start writing the tests. Will push my commits soon |
|
Are you able to finish this week? We are planning to code freeze this repo |
|
@wjmelements I am actively working on this issue and will try my best to finish it this week |
|
Looks like you did a bad merge and reverted a bunch of our recent changes by mistake. |
|
Yes I think something went wrong with the rebasing, I am trying to fix that |
ec22cb9 to
ab96798
Compare
|
@parzival1821 Some smaller Lint Check failures to fix up here |
|
Working on the tests now, will push soon |
|
Great! Let us know when it is ready for another round of review - we will try to get these changes across the line today |
|
Hi @rjan90 @wjmelements I have added the tests and made a few changes to the algorithm. One thing which is kind of unusual is that in the tests, is that I am using Please review my changes and lmk is any changes/improvement is required! |
In forge tests, use |
17eee48 to
01555fe
Compare
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.
you still haven't reverted your changes to the submodules
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.
My bad, fixed it now
| } | ||
|
|
||
| uint256 startingPeriod = getProvingPeriodForEpoch(dataSetId, fromEpoch + 1); | ||
| uint256 endingPeriod = getProvingPeriodForEpoch(dataSetId, toEpoch); |
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.
I changed it so we only calculate endingPeriod if we will use it
| } | ||
|
|
||
| function _calcPeriodDeadline(uint256 dataSetId, uint256 periodId) private view returns (uint256) { | ||
| return provingActivationEpoch[dataSetId] + (periodId + 1) * maxProvingPeriod; |
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.
I pass the activationEpoch from the parent function instead of looking it up again with the dataSetId
| for (uint256 period = startingPeriod + 1; period < endingPeriod; period++) { | ||
| if (_isPeriodProven(dataSetId, period, currentPeriod)) { | ||
| provenEpochCount += maxProvingPeriod; | ||
| lastProvenEpoch = _calcPeriodDeadline(dataSetId, period); |
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.
Instead I calculate this once, from the ending period deadline
| uint256 provenEpochCount, | ||
| uint256 lastProvenEpoch, |
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.
I remove these parameters since they are the outvars
In the case where lastProvenEpoch is unchanged, we revert so it is unimportant to initialize it
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.
In the case where lastProvenEpoch is unchanged, we revert so it is unimportant to initialize it
This isn't quite true because we don't revert. But the uninitialized outvar is unused in that case.
Still I think we should be able to settle the rail over periods of inactivity.
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.
|
Thank you very much @wjmelements @rjan90 for guiding me through this PR. Would love to keep contributing to FilOzone and the Filecoin ecosystem as a whole! |
Reviewer @rvagg It is only important to block forward progress through the current proving period. Currently we don't allow forward progress through unsettled periods without proofs. This could be a problem if there was a rail unproven for a long time but proofs were later resumed. Though much less likely after #258 and #267, we would not want it to be possible for the gap to exceed the block gas limit. Also important to recall that the `fromEpoch` is an exclusive index while `toEpoch` is an inclusive index. #### Changes * allow to settleUpTo previous period when unproven * define settledUpTo in previously irrelevant case
Related Issue
Closes 252 ( Once completed)
Current Progress
I've implemented the updated looping algorithm in validatePayment as described in the issue
What I Need Feedback On
Before I continue with the rest of the issue, I'd like to get feedback on my implementation of the looping algorithm.
Since there were no existing tests for this specific part of the code, I want to make sure my approach is correct before implementing the remaining parts of the issue. Also I would love to help you guys write some tests for the same if required
Questions for Maintainers
Changes Made
FilecoinWarmStorageService.solto implement the new loop structureNext Steps (after approval)
Once you confirm this approach is correct, I'll:
Note: This is a WIP/Draft PR specifically for early feedback on the algorithm implementation.
(Also, just a heads-up, I changed my username from
dev-n-doughtoparzival1821