Optimization Suggestion: Reduce Redundant Calls to SignedMessage.Validate in QBFT Message Processing
Opened this issue · 0 comments
olegshmuelov commented
Details
The method SignedMessage.Validate is being called multiple times across different functions, which may lead to inefficiencies in processing.
The method SignedMessage.Validate
is redundantly invoked in several places:
- Within the
Instance.BaseMsgValidation
method:
// Instance.BaseMsgValidation method
if err := msg.Validate(); err != nil {
return errors.Wrap(err, "invalid signed message")
}
- Also in other functions such as
isValidProposal
,validSignedPrepareForHeightRoundAndRoot
,validateCommit
, andvalidRoundChangeForData
. For example, inisValidProposal
:
// isValidProposal function
if err := signedProposal.Validate(); err != nil {
return errors.Wrap(err, "proposal invalid")
}
Proposed Solution
We can call SignedMessage.Validate
only once at the beginning to avoid repeating it.