-
Notifications
You must be signed in to change notification settings - Fork 57
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
Prune EthereumSignatures and EthereumEventVoteRecords #517
Conversation
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. @@ Coverage Diff @@
## main #517 +/- ##
==========================================
+ Coverage 29.90% 30.01% +0.10%
==========================================
Files 47 48 +1
Lines 6503 6987 +484
==========================================
+ Hits 1945 2097 +152
- Misses 4402 4708 +306
- Partials 156 182 +26
|
…ubmitter's event nonce
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 comments.
module/x/gravity/abci.go
Outdated
@@ -27,6 +27,8 @@ func BeginBlocker(ctx sdk.Context, k keeper.Keeper) { | |||
// EndBlocker is called at the end of every block | |||
func EndBlocker(ctx sdk.Context, k keeper.Keeper) { | |||
outgoingTxSlashing(ctx, k) | |||
// Do we need to concern ourselves with future slashing windows for this pruning? |
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 you elaborate on this question?
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.
there is a window of blocks for which the chain waits to prune batch votes so that validators have time to sign them before getting slashed. At the time when I commented this I didn't fully understand how vote records work for events as distinct from signatures for outgoing TXs. There's no reason to keep event vote records around after the last observed event nonce has incremented so I'll remove this comment.
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.
Now that you have me thinking about it, I think there's certainly an argument to be made for a slashing window for the oracle function as well. It's as necessary to complete the bridge transaction lifecycle as signatures are. From this perspective, we may want to keep a sliding window's worth of history for both.
module/x/gravity/abci.go
Outdated
panic(err) | ||
} | ||
eventNonce := event.GetEventNonce() | ||
if eventNonce <= lastObservedEventNonce { |
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 this be <
rather than <=
?
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 the nonce has been canonically observed there is no need to keep new votes for it right?
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.
One thing I have noticed while helping validators diagnose issues with their orchestrators is that it's valuable to have evidence they have or have not been submitting things correctly. If we prune everything every time, it's very hard to query for this sort of information. I think leaving some small bit of history before pruning might be worthwhile.
Need to look into replacing the scan iteration when getting the vote attestation map into a lookup |
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.
A small suggestion. Also responded to some of the existing comment threads.
module/x/gravity/keeper/keeper.go
Outdated
@@ -464,6 +464,7 @@ func (k Keeper) SetOutgoingTx(ctx sdk.Context, outgoing types.OutgoingTx) { | |||
// DeleteOutgoingTx deletes a given outgoingtx | |||
func (k Keeper) DeleteOutgoingTx(ctx sdk.Context, storeIndex []byte) { | |||
ctx.KVStore(k.storeKey).Delete(types.MakeOutgoingTxKey(storeIndex)) | |||
k.DeleteEthereumSignatures(ctx, storeIndex) |
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'm not certain if it matters in practice here, but I would suggest cleaning up the "child" records (the signatures) before deleting the "parent" record (the outgoing TX).
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.
LGTM
CompletedOutgoingTxs
store. When anOutgoingTx
is observed or timed out, it is moved to this new store and the original deleted. This new store is used for slashing. A completedOutgoingTx
is pruned after it leaves the slashing window. Signer sets are a special case, theirOutgoingTx
is still used for slashing.EthereumSignature
at the time ofCompletedOutgoingTx
deletion for each type, which occurs after the slashing has passedEthereumEventVoteRecord
s with nonces older than the last observed event nonce.CompletedOutgoingTxs
andEventVoteRecords
queriesOutgoingTxs
in the results returned by theUnsigned*Txs
queries so that new signers can sign completed txs and not get slashed.Closes #431
Closes #349