-
Notifications
You must be signed in to change notification settings - Fork 215
Equivalent proofs tracker #6456
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
Equivalent proofs tracker #6456
Conversation
| dbb.mutHeadersCache.Unlock() | ||
|
|
||
| aggSig, bitmap := headerHandler.GetPreviousAggregatedSignatureAndBitmap() | ||
| proof := headerHandler.GetPreviousProof() |
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.
note for further PRs(probably for myself): this method should be either called from interceptor, either the logic should be moved on the header interceptor, as the header will be broadcast on a new topic
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.
added TODO for this
consensus/interface.go
Outdated
| type EquivalentProofsPool interface { | ||
| AddNotarizedProof(headerProof data.HeaderProofHandler) error | ||
| GetNotarizedProof(shardID uint32, headerHash []byte) (data.HeaderProofHandler, error) | ||
| GetAllNotarizedProofs(shardID uint32) (map[string]data.HeaderProofHandler, 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.
looks like this is not used.. will it be needed in the future?
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.
it was used at some point, not used anymore, it's deleted now
consensus/spos/bls/subroundBlock.go
Outdated
| } | ||
|
|
||
| prevBlockProof := sr.Blockchain().GetCurrentHeaderProof() | ||
| prevBlockProof, err := sr.worker.GetEquivalentProof(sr.GetData()) |
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 worker will have all the equivalent proofs logic removed(maybe in a different PR). The proof for the prev block should be requested from the newly added equivalentProofsTracker
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.
kept initially the worker functions, deleted them now
consensus/spos/bls/subroundBlock.go
Outdated
| func isProofEmpty(proof data.HeaderProof) bool { | ||
| return len(proof.AggregatedSignature) == 0 || len(proof.PubKeysBitmap) == 0 | ||
| func isProofEmpty(proof data.HeaderProofHandler) bool { | ||
| return len(proof.GetAggregatedSignature()) == 0 || len(proof.GetPubKeysBitmap()) == 0 |
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 also add here a check for len of header hash
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.
added
consensus/spos/bls/subroundBlock.go
Outdated
|
|
||
| proof := sr.Blockchain().GetCurrentHeaderProof() | ||
| if !isProofEmpty(proof) { | ||
| proof, err := sr.worker.GetEquivalentProof(sr.GetData()) |
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 can be removed completely L564-576.. reason: it should be saved into the newly added equivalentProofsTracker and this will be done from the interceptor
will be done in a further PR, maybe just save it into equivalentProofsTracker 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.
done
| // NewProofsPool creates a new proofs pool component | ||
| func NewProofsPool() *proofsPool { | ||
| return &proofsPool{ | ||
| cache: make(map[uint32]*proofsCache), |
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 save them by shard?
a node in shard X should have proofs only for X and Meta
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've added the option to save by shardID in a more general way; indeed, currently i use the proofs only for current shard, i haven't covered the cross shard or meta yet; will analyse this for a next PR
process/block/metablock.go
Outdated
| if mp.enableEpochsHandler.IsFlagEnabledInEpoch(common.EquivalentMessagesFlag, shardHdr.GetEpoch()) { | ||
| _, shardData.PubKeysBitmap = shardHdr.GetPreviousAggregatedSignatureAndBitmap() | ||
| proof := shardHdr.GetPreviousProof() | ||
| shardData.PubKeysBitmap = proof.GetPubKeysBitmap() |
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.
check proof against nil before this?
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.
done
| func (hsv *HeaderSigVerifier) getPrevHeaderInfo(currentHeader data.HeaderHandler) (data.HeaderHandler, []byte, []byte, []byte, error) { | ||
| sig, bitmap := currentHeader.GetPreviousAggregatedSignatureAndBitmap() | ||
| previousProof := currentHeader.GetPreviousProof() | ||
| sig, bitmap := previousProof.GetAggregatedSignature(), previousProof.GetPubKeysBitmap() |
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.
check previousProof against nil before this
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.
done
process/peer/process.go
Outdated
| if vs.enableEpochsHandler.IsFlagEnabledInEpoch(common.EquivalentMessagesFlag, previousHeader.GetEpoch()) { | ||
| _, bitmap = previousHeader.GetPreviousAggregatedSignatureAndBitmap() | ||
| proof := previousHeader.GetPreviousProof() | ||
| bitmap = proof.GetPubKeysBitmap() |
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.
check proof against nil
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.
done
| ) | ||
|
|
||
| // ProofsPoolStub - | ||
| type ProofsPoolStub struct { |
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.
rename to mock.. file as well.. can use scripts/generators/mockGenerator.sh
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.
renamed
Co-authored-by: Sorin Stanculeanu <[email protected]>
Co-authored-by: Sorin Stanculeanu <[email protected]>
| dbb.mutHeadersCache.Unlock() | ||
|
|
||
| aggSig, bitmap := headerHandler.GetPreviousAggregatedSignatureAndBitmap() | ||
| // TODO: should be handled from interceptor |
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 method was previously used by validators in consensus to find out if the leader propagates the block with final data on, and if not to do the propagation themselves in the predefined order.
This won't be needed anymore as the block in its final form is propagated at the beginning of the round, and if not propagated, then there is nothing to do.
So after equivalent proofs activation, this method will not be needed.
|
|
||
| func isProofEmpty(proof data.HeaderProof) bool { | ||
| return len(proof.AggregatedSignature) == 0 || len(proof.PubKeysBitmap) == 0 | ||
| func isProofEmpty(proof data.HeaderProofHandler) bool { |
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 should only be an extra validation right?
I mean we only add proofs to the proof tracker if the proof is valid, so if it is already present, then it should have already been validated.
| } | ||
|
|
||
| proof := sr.Blockchain().GetCurrentHeaderProof() | ||
| proof, err := sr.EquivalentProofsPool().GetProof(sr.ShardCoordinator().SelfId(), sr.GetData()) |
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 don't think this method - saveProofForPreviousHeaderIfNeeded is required here, as it is already saved on the regular interceptor.
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.
indeed, should not be needed anymore
|
|
||
| // TODO: check if this is the best approach. Perhaps we don't want to relay only on the first received message | ||
| if sr.worker.HasEquivalentMessage(sr.GetData()) { | ||
| if sr.EquivalentProofsPool().HasProof(sr.ShardCoordinator().SelfId(), sr.GetData()) { |
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 we need to adapt the usage of shouldSendFinalInfo, as it should not stop the leader to commit the block if the proof is already received from someone else.
Leader should not send the info, true, but should still continue to commit the block. (otherwise he will try to sync it afterwards)
| if sr.EnableEpochsHandler().IsFlagEnabledInEpoch(common.EquivalentMessagesFlag, sr.Header.GetEpoch()) { | ||
| sr.worker.SetValidEquivalentProof(sr.GetData(), proof) | ||
| sr.Blockchain().SetCurrentHeaderProof(proof) | ||
| err = sr.EquivalentProofsPool().AddProof(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.
it seems after equivalent proofs activation doEndRoundJobByLeader will be called by all nodes in consensus group, so if shouldSendFinalInfo fails (they received from someone the proof), all consensus group participants that did not send the proof will no longer finalize the block during consensus, but will try to sync it afterwards.
| AggregatedSignature: cnsDta.AggregateSignature, | ||
| proof := &block.HeaderProof{ | ||
| PubKeysBitmap: cnsDta.PubKeysBitmap, | ||
| AggregatedSignature: cnsDta.AggregateSignature, |
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 saving of the proof here maybe not always required, only if it was created by the participant, otherwise it should already be available in the proofs tracker.
| shardData.PubKeysBitmap = shardHdr.GetPubKeysBitmap() | ||
| if mp.enableEpochsHandler.IsFlagEnabledInEpoch(common.EquivalentMessagesFlag, shardHdr.GetEpoch()) { | ||
| _, shardData.PubKeysBitmap = shardHdr.GetPreviousAggregatedSignatureAndBitmap() | ||
| proof := shardHdr.GetPreviousProof() |
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 data for a notarized shard header should be related to that shard header not the previous.
here the proof for the header should be used not the one included in the header, which is for the previous one.
Also
| hasProof = len(previousAggregatedSignature) > 0 && len(previousBitmap) > 0 | ||
|
|
||
| if len(previousBitmap) > 0 { | ||
| hasLeaderSignature = previousBitmap[0]&1 != 0 |
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 no longer valid
with fixed ordering, the leader can have any index in the bitmap, but at the same time it is no longer needed to have its signature in the proof.
AdoAdoAdo
left a 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.
The changes can be taken on the next PR
Reasoning behind the pull request
Testing procedure
Pre-requisites
Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:
featbranch created?featbranch merging, do all satellite projects have a proper tag insidego.mod?