-
Notifications
You must be signed in to change notification settings - Fork 20
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
Changes from 11 commits
6181eae
6cb8ce1
d667c30
ca06140
999104b
36ceef5
542ba04
406c507
5d323c0
db58714
514b202
66af147
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -527,7 +527,7 @@ func (fp *FinalityProviderInstance) commitPubRandPairs(startHeight uint64) (*typ | |
commitment, proofList := types.GetPubRandCommitAndProofs(pubRandList) | ||
|
||
// store them to database | ||
if err := fp.pubRandState.addPubRandProofList(pubRandList, proofList); err != nil { | ||
if err := fp.pubRandState.addPubRandProofList(fp.btcPk.MustMarshal(), fp.GetChainID(), startHeight, uint64(fp.cfg.NumPubRand), proofList); err != nil { | ||
return nil, fmt.Errorf("failed to save public randomness to DB: %w", err) | ||
} | ||
|
||
|
@@ -641,14 +641,20 @@ func (fp *FinalityProviderInstance) SubmitBatchFinalitySignatures(blocks []*type | |
} | ||
|
||
// get public randomness list | ||
numPubRand := len(blocks) | ||
// #nosec G115 -- performed the conversion check above | ||
prList, err := fp.getPubRandList(blocks[0].Height, uint32(len(blocks))) | ||
prList, err := fp.getPubRandList(blocks[0].Height, uint32(numPubRand)) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to get public randomness list: %w", err) | ||
} | ||
// get proof list | ||
// TODO: how to recover upon having an error in getPubRandProofList? | ||
proofBytesList, err := fp.pubRandState.getPubRandProofList(prList) | ||
proofBytesList, err := fp.pubRandState.getPubRandProofList( | ||
fp.btcPk.MustMarshal(), | ||
fp.GetChainID(), | ||
blocks[0].Height, | ||
uint64(numPubRand), | ||
) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to get public randomness inclusion proof list: %w", err) | ||
} | ||
|
@@ -696,7 +702,7 @@ func (fp *FinalityProviderInstance) TestSubmitFinalitySignatureAndExtractPrivKey | |
pubRand := prList[0] | ||
|
||
// get proof | ||
proofBytes, err := fp.pubRandState.getPubRandProof(pubRand) | ||
proofBytes, err := fp.pubRandState.getPubRandProof(fp.btcPk.MustMarshal(), fp.GetChainID(), b.Height) | ||
if err != nil { | ||
return nil, nil, fmt.Errorf("failed to get public randomness inclusion proof: %w", err) | ||
} | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. This is probably not needed as we can access the store by |
||
return fp.pubRandState.getPubRandProof(fp.btcPk.MustMarshal(), fp.GetChainID(), height) | ||
} |
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 thanremove
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