[BEEFY] Avoid missing voting sessions during node restart (#3074)

Related to https://github.com/paritytech/polkadot-sdk/issues/3003 and
https://github.com/paritytech/polkadot-sdk/issues/2842

---------

Co-authored-by: Adrian Catangiu <adrian@parity.io>
This commit is contained in:
Serban Iorga
2024-02-01 12:24:16 +01:00
committed by GitHub
parent 8a8f6f9877
commit b177c2860e
8 changed files with 456 additions and 278 deletions
@@ -201,7 +201,7 @@ where
let peer = request.peer;
match self.handle_request(request) {
Ok(()) => {
metric_inc!(self, beefy_successful_justification_responses);
metric_inc!(self.metrics, beefy_successful_justification_responses);
debug!(
target: BEEFY_SYNC_LOG_TARGET,
"🥩 Handled BEEFY justification request from {:?}.", peer
@@ -209,7 +209,7 @@ where
},
Err(e) => {
// peer reputation changes already applied in `self.handle_request()`
metric_inc!(self, beefy_failed_justification_responses);
metric_inc!(self.metrics, beefy_failed_justification_responses);
debug!(
target: BEEFY_SYNC_LOG_TARGET,
"🥩 Failed to handle BEEFY justification request from {:?}: {}", peer, e,
@@ -148,7 +148,7 @@ impl<B: Block> OnDemandJustificationsEngine<B> {
if let Some(peer) = self.try_next_peer() {
self.request_from_peer(peer, RequestInfo { block, active_set });
} else {
metric_inc!(self, beefy_on_demand_justification_no_peer_to_request_from);
metric_inc!(self.metrics, beefy_on_demand_justification_no_peer_to_request_from);
debug!(
target: BEEFY_SYNC_LOG_TARGET,
"🥩 no good peers to request justif #{:?} from", block
@@ -194,13 +194,13 @@ impl<B: Block> OnDemandJustificationsEngine<B> {
);
match e {
RequestFailure::Refused => {
metric_inc!(self, beefy_on_demand_justification_peer_refused);
metric_inc!(self.metrics, beefy_on_demand_justification_peer_refused);
let peer_report =
PeerReport { who: *peer, cost_benefit: cost::REFUSAL_RESPONSE };
Error::InvalidResponse(peer_report)
},
_ => {
metric_inc!(self, beefy_on_demand_justification_peer_error);
metric_inc!(self.metrics, beefy_on_demand_justification_peer_error);
Error::ResponseError
},
}
@@ -212,7 +212,7 @@ impl<B: Block> OnDemandJustificationsEngine<B> {
&req_info.active_set,
)
.map_err(|(err, signatures_checked)| {
metric_inc!(self, beefy_on_demand_justification_invalid_proof);
metric_inc!(self.metrics, beefy_on_demand_justification_invalid_proof);
debug!(
target: BEEFY_SYNC_LOG_TARGET,
"🥩 for on demand justification #{:?}, peer {:?} responded with invalid proof: {:?}",
@@ -261,7 +261,7 @@ impl<B: Block> OnDemandJustificationsEngine<B> {
}
},
Ok(proof) => {
metric_inc!(self, beefy_on_demand_justification_good_proof);
metric_inc!(self.metrics, beefy_on_demand_justification_good_proof);
debug!(
target: BEEFY_SYNC_LOG_TARGET,
"🥩 received valid on-demand justif #{:?} from {:?}", block, peer