in platform/consensus/ordering/pbft/viewchange_manager.cpp [165:206]
bool ViewChangeManager::IsValidViewChangeMsg(
const ViewChangeMessage& view_change_message) {
if (view_change_message.view_number() <= system_info_->GetCurrentView()) {
LOG(ERROR) << "View number is not greater than current view:"
<< view_change_message.view_number() << "("
<< system_info_->GetCurrentView() << ")";
return false;
}
if (!checkpoint_manager_->IsValidCheckpointProof(
view_change_message.stable_ckpt())) {
LOG(ERROR) << "stable checkpoint invalid";
return false;
}
uint64_t stable_seq = view_change_message.stable_ckpt().seq();
for (const auto& prepared_msg : view_change_message.prepared_msg()) {
if (prepared_msg.seq() <= stable_seq) {
continue;
}
// If there is less than 2f+1 proof, reject.
if (prepared_msg.proof_size() < config_.GetMinDataReceiveNum()) {
LOG(ERROR) << "proof[" << prepared_msg.proof_size()
<< "] not enough:" << config_.GetMinDataReceiveNum();
return false;
}
for (const auto& proof : prepared_msg.proof()) {
if (proof.request().seq() != prepared_msg.seq()) {
LOG(ERROR) << "proof seq not match";
return false;
}
std::string data;
proof.request().SerializeToString(&data);
if (!verifier_->VerifyMessage(data, proof.signature())) {
LOG(ERROR) << "proof signature not valid";
return false;
}
}
}
return true;
}