-
Notifications
You must be signed in to change notification settings - Fork 471
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
Algod: state-proof key deletion safety #4601
Algod: state-proof key deletion safety #4601
Conversation
Codecov Report
@@ Coverage Diff @@
## feature/stateproofs-recoverability #4601 +/- ##
======================================================================
- Coverage 54.53% 54.03% -0.51%
======================================================================
Files 408 408
Lines 52650 52658 +8
======================================================================
- Hits 28714 28453 -261
- Misses 21540 21791 +251
- Partials 2396 2414 +18
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
98719a4
to
3d0b984
Compare
3d0b984
to
3ee4000
Compare
3ee4000
to
0e8a113
Compare
15387cd
to
9e5ec61
Compare
9468178
to
a8b7543
Compare
d99b8e3
to
65d8b21
Compare
stateproof/builder.go
Outdated
return | ||
} | ||
|
||
oldestRoundToRemove := stateProofNextRound.SubSaturate(basics.Round(proto.StateProofInterval)) |
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.
If I understand correctly, for every round (?) we're going to be going over all of the participation records, extracting the state proof keys from them and removing stale keys? It might be worth it to hold the previous state proof next round to decide if we have to do that, even if we put aside the question of changing state proof intervals.
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 have a point. I've addressed that. take a second look
stateproof/builder.go
Outdated
func (spw *Worker) deleteOldBuilders(currentHdr *bookkeeping.BlockHeader) { | ||
oldestRoundToRemove := GetOldestExpectedStateProof(currentHdr) | ||
func (spw *Worker) deleteStaleKeys(latestRoundToKeep basics.Round) { | ||
keys := spw.accts.StateProofKeys(latestRoundToKeep) |
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.
Won't we miss out on purging stale data from accounts that can't sign latestRoundToKeep but still have old keys in their DB?
It seems to me we should simply iterate over all accounts and invoke spw.accts.DeleteStateProofKey(participationID, latestRoundToKeep) for all of them, no?
stateproof/builder.go
Outdated
spw.log.Errorf("deleteOldKeys: could not calculate keylifetime for account %v on round %s: %v", key.ParticipationID, roundToRemove, err) | ||
continue | ||
} | ||
err = spw.accts.DeleteStateProofKey(key.ParticipationID, basics.Round(roundToRemove)) |
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.
Why do we need to use roundToRemove? Why not latestRoundToKeep instead?
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.
if we delete roundToRemove we might delete a key that should be used for a later state proof.
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.
Let's iron out the kinks in the deletion part, otherwise looks good.
16943a3
to
62be9ac
Compare
62be9ac
to
c5f89f1
Compare
Summary
Due to StateProof keys' lifetime, the signer might delete the key while not all signatures are present in the DB.
This critical error might occur when the DB fails to record a signature and a new signature arrives from the same key.