Skip to content

Optimization Suggestion: Reduce Redundant Calls to SignedMessage.Validate in QBFT Message Processing #326

@olegshmuelov

Description

@olegshmuelov

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:

  1. Within the Instance.BaseMsgValidation method:
// Instance.BaseMsgValidation method
if err := msg.Validate(); err != nil {
    return errors.Wrap(err, "invalid signed message")
}
  1. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions