-
Notifications
You must be signed in to change notification settings - Fork 24
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
feat: prune used merkle proof #218
Conversation
Hm, it's expected for double sign test to fail now, as the proof is deleted |
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.
Keep thinking about this. I feel safer if we make it a CLI: fpd unsafe-prune-merkle-proof [eots-pk] --chain-id --up-to-height
where --chain-id
is required. If the user does not specify --up-to-height
, the pruning is up to the fp's last voted height.
This would require db schema change as follows:
- the current key is the randomness number itself, which does not support range query by height. Therefore we need to add height to the key
- given that the fpd might store different fps with different chain id, we need also add chainid and fp public key in the key like we did for signing record
func getSignRecordKey(chainID, pk []byte, height uint64) []byte {
wdyt?
i am not familiar with this db schema but the first point makes sense. for 2), I don't know if it's necessary to change db because a FP can only register for one consumer chain. So we can simply query the FP's consumer chain id to see if it matches with what's passed in to the CLI meta-thought: you guys might need to think about data migration for backward compatibility issue. |
We need to change db to add
my understanding for this is that after we launch phase-2, for any db schema change later on we need to consider backward compatibility. Do you think we need to do anything before the launch? |
yeah i think it makes sense to only consider it after mainnet launch. |
@@ -488,6 +488,63 @@ func runCommandEditFinalityDescription(cmd *cobra.Command, args []string) error | |||
return nil | |||
} | |||
|
|||
// CommandUnsafeDeleteMerkleProof removes merkle proof | |||
func CommandUnsafeDeleteMerkleProof() *cobra.Command { | |||
var cmd = &cobra.Command{ |
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.
should we have a command to delete this? kkk seems a bit scary
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.
Yeah, maybe more docs about the consequences?
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 would use prune
other than remove
which seems less scary. Let's add a long description of the consequences. The user should ensure that up to the pruning height, the fp has already voted or it does not have voting power for those blocks
@@ -133,4 +171,37 @@ func (s *PubRandProofStore) GetPubRandProofList(pubRandList []*btcec.FieldVal) ( | |||
return proofBytesList, nil | |||
} | |||
|
|||
// TODO: delete function? | |||
// RemovePubRandProofList removes all proofs up to the target height | |||
func (s *PubRandProofStore) RemovePubRandProofList(chainID []byte, pk []byte, targetHeight uint64) error { |
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.
lets add a specific unit test for this one?
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, added in 514b202
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.
utACK, suggestion to add a specific unit test for RemovePubRandProofList
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.
Great work!
@@ -488,6 +488,63 @@ func runCommandEditFinalityDescription(cmd *cobra.Command, args []string) error | |||
return nil | |||
} | |||
|
|||
// CommandUnsafeDeleteMerkleProof removes merkle proof | |||
func CommandUnsafeDeleteMerkleProof() *cobra.Command { | |||
var cmd = &cobra.Command{ |
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 would use prune
other than remove
which seems less scary. Let's add a long description of the consequences. The user should ensure that up to the pruning height, the fp has already voted or it does not have voting power for those blocks
@@ -1020,3 +1026,8 @@ func (fp *FinalityProviderInstance) GetFinalityProviderSlashedOrJailedWithRetry( | |||
|
|||
return slashed, jailed, nil | |||
} | |||
|
|||
// TestGetPubProof only used for tests to get access to the store | |||
func (fp *FinalityProviderInstance) TestGetPubProof(height uint64) ([]byte, error) { |
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 is probably not needed as we can access the store by app.GetPubRandProofStore()
* Init * Update babylon-private reference * Revert "CI: Remove redundant SSH key logic (#218)"
Closes