Description
There appears to be a redundancy in the validation of consensus data, resulting in the same checks being conducted twice. This redundancy could be unnecessarily extending the time taken for consensus.
Details
The validation check for the input data (byts) is performed twice:
- In the
BaseRunner.decide method:
// BaseRunner.decide method
if err := runner.GetValCheckF()(byts); err != nil {
return errors.Wrap(err, "input data invalid")
}
- In the
Controller.StartNewInstance method:
// Controller.StartNewInstance method
if err := c.GetConfig().GetValueCheckF()(value); err != nil {
return errors.Wrap(err, "value invalid")
}
Given that BaseRunner.decide calls Controller.StartNewInstance, this results in the same validation check being performed twice on the same data.
Suggestion
To optimize the consensus time, I propose removing one of these duplicate checks. My recommendation would be to keep the validation in the Controller.StartNewInstance method, as it seems more contextually appropriate for the responsibility of starting a new QBFT instance.