mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-18 14:05:41 +00:00
committed by
GitHub
parent
14a4eed2aa
commit
b9854171c0
@@ -28,7 +28,7 @@ use log::{debug, trace};
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use wasm_timer::Instant;
|
||||
|
||||
use crate::{communication::peers::KnownPeers, keystore::BeefyKeystore};
|
||||
use crate::{communication::peers::KnownPeers, keystore::BeefyKeystore, LOG_TARGET};
|
||||
use beefy_primitives::{
|
||||
crypto::{Public, Signature},
|
||||
VoteMessage,
|
||||
@@ -122,7 +122,7 @@ where
|
||||
///
|
||||
/// Noting round will start a live `round`.
|
||||
pub(crate) fn note_round(&self, round: NumberFor<B>) {
|
||||
debug!(target: "beefy", "🥩 About to note gossip round #{}", round);
|
||||
debug!(target: LOG_TARGET, "🥩 About to note gossip round #{}", round);
|
||||
self.known_votes.write().insert(round);
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ where
|
||||
///
|
||||
/// This can be called once round is complete so we stop gossiping for it.
|
||||
pub(crate) fn conclude_round(&self, round: NumberFor<B>) {
|
||||
debug!(target: "beefy", "🥩 About to drop gossip round #{}", round);
|
||||
debug!(target: LOG_TARGET, "🥩 About to drop gossip round #{}", round);
|
||||
self.known_votes.write().conclude(round);
|
||||
}
|
||||
}
|
||||
@@ -174,7 +174,10 @@ where
|
||||
return ValidationResult::ProcessAndKeep(self.topic)
|
||||
} else {
|
||||
// TODO: report peer
|
||||
debug!(target: "beefy", "🥩 Bad signature on message: {:?}, from: {:?}", msg, sender);
|
||||
debug!(
|
||||
target: LOG_TARGET,
|
||||
"🥩 Bad signature on message: {:?}, from: {:?}", msg, sender
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +195,7 @@ where
|
||||
let round = msg.commitment.block_number;
|
||||
let expired = !known_votes.is_live(&round);
|
||||
|
||||
trace!(target: "beefy", "🥩 Message for round #{} expired: {}", round, expired);
|
||||
trace!(target: LOG_TARGET, "🥩 Message for round #{} expired: {}", round, expired);
|
||||
|
||||
expired
|
||||
})
|
||||
@@ -226,7 +229,7 @@ where
|
||||
let round = msg.commitment.block_number;
|
||||
let allowed = known_votes.is_live(&round);
|
||||
|
||||
trace!(target: "beefy", "🥩 Message for round #{} allowed: {}", round, allowed);
|
||||
trace!(target: LOG_TARGET, "🥩 Message for round #{} allowed: {}", round, allowed);
|
||||
|
||||
allowed
|
||||
})
|
||||
|
||||
+4
-4
@@ -30,7 +30,7 @@ use sp_runtime::traits::Block;
|
||||
use std::{marker::PhantomData, sync::Arc};
|
||||
|
||||
use crate::communication::request_response::{
|
||||
on_demand_justifications_protocol_config, Error, JustificationRequest,
|
||||
on_demand_justifications_protocol_config, Error, JustificationRequest, BEEFY_SYNC_LOG_TARGET,
|
||||
};
|
||||
|
||||
/// A request coming in, including a sender for sending responses.
|
||||
@@ -174,21 +174,21 @@ where
|
||||
|
||||
/// Run [`BeefyJustifsRequestHandler`].
|
||||
pub async fn run(mut self) {
|
||||
trace!(target: "beefy::sync", "🥩 Running BeefyJustifsRequestHandler");
|
||||
trace!(target: BEEFY_SYNC_LOG_TARGET, "🥩 Running BeefyJustifsRequestHandler");
|
||||
|
||||
while let Ok(request) = self.request_receiver.recv(|| vec![]).await {
|
||||
let peer = request.peer;
|
||||
match self.handle_request(request) {
|
||||
Ok(()) => {
|
||||
debug!(
|
||||
target: "beefy::sync",
|
||||
target: BEEFY_SYNC_LOG_TARGET,
|
||||
"🥩 Handled BEEFY justification request from {:?}.", peer
|
||||
)
|
||||
},
|
||||
Err(e) => {
|
||||
// TODO (issue #12293): apply reputation changes here based on error type.
|
||||
debug!(
|
||||
target: "beefy::sync",
|
||||
target: BEEFY_SYNC_LOG_TARGET,
|
||||
"🥩 Failed to handle BEEFY justification request from {:?}: {}", peer, e,
|
||||
)
|
||||
},
|
||||
|
||||
@@ -40,6 +40,8 @@ const JUSTIF_CHANNEL_SIZE: usize = 10;
|
||||
const MAX_RESPONSE_SIZE: u64 = 1024 * 1024;
|
||||
const JUSTIF_REQUEST_TIMEOUT: Duration = Duration::from_secs(3);
|
||||
|
||||
const BEEFY_SYNC_LOG_TARGET: &str = "beefy::sync";
|
||||
|
||||
/// Get the configuration for the BEEFY justifications Request/response protocol.
|
||||
///
|
||||
/// Returns a receiver for messages received on this protocol and the requested
|
||||
|
||||
+24
-17
@@ -32,7 +32,7 @@ use sp_runtime::traits::{Block, NumberFor};
|
||||
use std::{collections::VecDeque, result::Result, sync::Arc};
|
||||
|
||||
use crate::{
|
||||
communication::request_response::{Error, JustificationRequest},
|
||||
communication::request_response::{Error, JustificationRequest, BEEFY_SYNC_LOG_TARGET},
|
||||
justification::{decode_and_verify_finality_proof, BeefyVersionedFinalityProof},
|
||||
KnownPeers,
|
||||
};
|
||||
@@ -96,10 +96,8 @@ impl<B: Block> OnDemandJustificationsEngine<B> {
|
||||
|
||||
fn request_from_peer(&mut self, peer: PeerId, req_info: RequestInfo<B>) {
|
||||
debug!(
|
||||
target: "beefy::sync",
|
||||
"🥩 requesting justif #{:?} from peer {:?}",
|
||||
req_info.block,
|
||||
peer,
|
||||
target: BEEFY_SYNC_LOG_TARGET,
|
||||
"🥩 requesting justif #{:?} from peer {:?}", req_info.block, peer,
|
||||
);
|
||||
|
||||
let payload = JustificationRequest::<B> { begin: req_info.block }.encode();
|
||||
@@ -132,7 +130,10 @@ impl<B: Block> OnDemandJustificationsEngine<B> {
|
||||
if let Some(peer) = self.try_next_peer() {
|
||||
self.request_from_peer(peer, RequestInfo { block, active_set });
|
||||
} else {
|
||||
debug!(target: "beefy::sync", "🥩 no good peers to request justif #{:?} from", block);
|
||||
debug!(
|
||||
target: BEEFY_SYNC_LOG_TARGET,
|
||||
"🥩 no good peers to request justif #{:?} from", block
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,8 +142,8 @@ impl<B: Block> OnDemandJustificationsEngine<B> {
|
||||
match &self.state {
|
||||
State::AwaitingResponse(_, req_info, _) if req_info.block <= block => {
|
||||
debug!(
|
||||
target: "beefy::sync", "🥩 cancel pending request for justification #{:?}",
|
||||
req_info.block
|
||||
target: BEEFY_SYNC_LOG_TARGET,
|
||||
"🥩 cancel pending request for justification #{:?}", req_info.block
|
||||
);
|
||||
self.state = State::Idle;
|
||||
},
|
||||
@@ -159,17 +160,21 @@ impl<B: Block> OnDemandJustificationsEngine<B> {
|
||||
response
|
||||
.map_err(|e| {
|
||||
debug!(
|
||||
target: "beefy::sync",
|
||||
target: BEEFY_SYNC_LOG_TARGET,
|
||||
"🥩 for on demand justification #{:?}, peer {:?} hung up: {:?}",
|
||||
req_info.block, peer, e
|
||||
req_info.block,
|
||||
peer,
|
||||
e
|
||||
);
|
||||
Error::InvalidResponse
|
||||
})?
|
||||
.map_err(|e| {
|
||||
debug!(
|
||||
target: "beefy::sync",
|
||||
target: BEEFY_SYNC_LOG_TARGET,
|
||||
"🥩 for on demand justification #{:?}, peer {:?} error: {:?}",
|
||||
req_info.block, peer, e
|
||||
req_info.block,
|
||||
peer,
|
||||
e
|
||||
);
|
||||
Error::InvalidResponse
|
||||
})
|
||||
@@ -181,7 +186,7 @@ impl<B: Block> OnDemandJustificationsEngine<B> {
|
||||
)
|
||||
.map_err(|e| {
|
||||
debug!(
|
||||
target: "beefy::sync",
|
||||
target: BEEFY_SYNC_LOG_TARGET,
|
||||
"🥩 for on demand justification #{:?}, peer {:?} responded with invalid proof: {:?}",
|
||||
req_info.block, peer, e
|
||||
);
|
||||
@@ -213,14 +218,16 @@ impl<B: Block> OnDemandJustificationsEngine<B> {
|
||||
if let Some(peer) = self.try_next_peer() {
|
||||
self.request_from_peer(peer, req_info);
|
||||
} else {
|
||||
warn!(target: "beefy::sync", "🥩 ran out of peers to request justif #{:?} from", block);
|
||||
warn!(
|
||||
target: BEEFY_SYNC_LOG_TARGET,
|
||||
"🥩 ran out of peers to request justif #{:?} from", block
|
||||
);
|
||||
}
|
||||
})
|
||||
.map(|proof| {
|
||||
debug!(
|
||||
target: "beefy::sync",
|
||||
"🥩 received valid on-demand justif #{:?} from {:?}",
|
||||
block, peer
|
||||
target: BEEFY_SYNC_LOG_TARGET,
|
||||
"🥩 received valid on-demand justif #{:?} from {:?}", block, peer
|
||||
);
|
||||
proof
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user