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, and validRoundChangeForData. For example, in isValidProposal:
// 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.