-
Notifications
You must be signed in to change notification settings - Fork 2
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
Simplify fault design #67
Conversation
contracts/src/SimplePDPService.sol
Outdated
@@ -170,9 +164,14 @@ contract SimplePDPService is PDPListener, PDPRecordKeeper, Initializable, UUPSUp | |||
uint256 periodsSkipped = 1; | |||
if (provingDeadlines[proofSetId] < block.number) { | |||
periodsSkipped = 1 + ((block.number - provingDeadlines[proofSetId]) / getMaxProvingPeriod()); | |||
provingDeadlines[proofSetId] = block.number + getMaxProvingPeriod(); // reset deadline |
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.
Shouldn't that also be provingDeadlines[proofSetId] = provingDeadlines[proofSetId] + getMaxProvingPeriod();
to keep the deadline in a fixed window?
The current way the proving window will keep sliding backwards as I have to compute and submit the proof some time before the deadline
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.
SGTM but we need to catch up multiple windows if we missed multiple otherwise you need to call this a bunch. So you'll need to add periodsSkipped I think
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't PR now but fee lfree to push
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.
Some discussion about policy options here, it wants a bit of thought.
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 current way the proving window will keep sliding backwards as I have to compute and submit the proof some time before the deadline
Note the line you commented on is only the unproven case, so it only slides until a valid proof is submitted. But note also there's no window or equivalent here that makes the deadline really matter: the proof can be submitted any time in the 24hr window (after the short challenge delay). So I don't think the scheduling matters as much as it does for Window PoST.
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.
This would benefit from some tests demonstrating the behaviour, especially around when the proving deadline moves.
contracts/src/SimplePDPService.sol
Outdated
@@ -170,9 +164,14 @@ contract SimplePDPService is PDPListener, PDPRecordKeeper, Initializable, UUPSUp | |||
uint256 periodsSkipped = 1; | |||
if (provingDeadlines[proofSetId] < block.number) { | |||
periodsSkipped = 1 + ((block.number - provingDeadlines[proofSetId]) / getMaxProvingPeriod()); | |||
provingDeadlines[proofSetId] = block.number + getMaxProvingPeriod(); // reset deadline |
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 current way the proving window will keep sliding backwards as I have to compute and submit the proof some time before the deadline
Note the line you commented on is only the unproven case, so it only slides until a valid proof is submitted. But note also there's no window or equivalent here that makes the deadline really matter: the proof can be submitted any time in the 24hr window (after the short challenge delay). So I don't think the scheduling matters as much as it does for Window PoST.
contracts/src/SimplePDPService.sol
Outdated
} | ||
emit FaultRecord(FaultType.SKIPPED, periodsSkipped); | ||
} | ||
|
||
} |
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.
Need to update provingDeadlines[proofSetId]
if there was a successful proof, too.
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 think this is very close.
The grinding that I see remaining could only be exercised with integration tests, which we lack. I suggest following up to add some integration tests, with some of them explicitly constructed from an "SP trying to cheat" frame.
contracts/src/SimplePDPService.sol
Outdated
uint256 periodsSkipped = (block.number - provingDeadlines[proofSetId]) / getMaxProvingPeriod(); | ||
uint256 faultPeriods = periodsSkipped; | ||
if (!provenThisPeriod[proofSetId]) { | ||
// include previous unproven period | ||
faultPeriods += 1; | ||
} | ||
if (faultPeriods > 0) { | ||
emit FaultRecord(faultPeriods); | ||
} | ||
provingDeadlines[proofSetId] = provingDeadlines[proofSetId] + getMaxProvingPeriod()*periodsSkipped; |
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.
Nit: I think this code could also handle the on-time case, with something like periodsSkipped = max(0, (block.number - provingDeadlines[proofSetId])) / getMaxProvingPeriod()
. The rest is basically duplicate.
contracts/src/SimplePDPService.sol
Outdated
// Can only get here if calling nextProvingPeriod multiple times within the same proving period | ||
uint256 prevDeadline = provingDeadlines[proofSetId] - getMaxProvingPeriod(); | ||
if (block.number <= prevDeadline) { | ||
return; |
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 think this needs to revert. As is, a provider could grind challenges by calling verifier.nextProvingPeriod
once each epoch after a successful proof until the deadline is reached.
In general, I think any call to this method must either (1) advance the proving period (possibly with fault), or (2) revert.
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.
This makes me think that, in the PDP Verifier contract, the method name nextProvingPeriod
is not quite right. That contract doesn't know anything about proving periods. It could instead be newChallenge
or something. However since that's the method actually invoked by SPs, I can see the motivation for a name that represents their expected workflow.
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.
Thanks for the catch on the revert.
Yeah I'm still not happy with the name but there is some sort of proving period thing that the pdp verifier knows about. Namely when batched adds and removes get added into the proofset. I think this name is probably ok for now even though pdp service has a modified idea of proving period
9605d2a
to
f3e854f
Compare
initializeData = abi.encodeWithSelector(SimplePDPService.initialize.selector, address(pdpVerifier)); | ||
MyERC1967Proxy listenerProxy = new MyERC1967Proxy(address(listenerImpl), initializeData); | ||
listener = SimplePDPService(address(listenerProxy)); | ||
listener = new TestingRecordKeeperService(); |
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.
❤️
No description provided.