mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 18:01:03 +00:00
Use LOG_TARGET in consensus related crates (#12875)
* Use shared LOG_TARGET in consensus related crates * Rename target from "afg" to "grandpa"
This commit is contained in:
@@ -29,7 +29,7 @@ use sc_consensus::shared_data::{SharedData, SharedDataLocked};
|
||||
use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_INFO};
|
||||
use sp_finality_grandpa::{AuthorityId, AuthorityList};
|
||||
|
||||
use crate::SetId;
|
||||
use crate::{SetId, LOG_TARGET};
|
||||
|
||||
/// Error type returned on operations on the `AuthoritySet`.
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
@@ -314,7 +314,7 @@ where
|
||||
let number = pending.canon_height.clone();
|
||||
|
||||
debug!(
|
||||
target: "afg",
|
||||
target: LOG_TARGET,
|
||||
"Inserting potential standard set change signaled at block {:?} (delayed by {:?} blocks).",
|
||||
(&number, &hash),
|
||||
pending.delay,
|
||||
@@ -323,7 +323,7 @@ where
|
||||
self.pending_standard_changes.import(hash, number, pending, is_descendent_of)?;
|
||||
|
||||
debug!(
|
||||
target: "afg",
|
||||
target: LOG_TARGET,
|
||||
"There are now {} alternatives for the next pending standard change (roots), and a \
|
||||
total of {} pending standard changes (across all forks).",
|
||||
self.pending_standard_changes.roots().count(),
|
||||
@@ -362,7 +362,7 @@ where
|
||||
.unwrap_or_else(|i| i);
|
||||
|
||||
debug!(
|
||||
target: "afg",
|
||||
target: LOG_TARGET,
|
||||
"Inserting potential forced set change at block {:?} (delayed by {:?} blocks).",
|
||||
(&pending.canon_height, &pending.canon_hash),
|
||||
pending.delay,
|
||||
@@ -370,7 +370,11 @@ where
|
||||
|
||||
self.pending_forced_changes.insert(idx, pending);
|
||||
|
||||
debug!(target: "afg", "There are now {} pending forced changes.", self.pending_forced_changes.len());
|
||||
debug!(
|
||||
target: LOG_TARGET,
|
||||
"There are now {} pending forced changes.",
|
||||
self.pending_forced_changes.len()
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -475,7 +479,7 @@ where
|
||||
if standard_change.effective_number() <= median_last_finalized &&
|
||||
is_descendent_of(&standard_change.canon_hash, &change.canon_hash)?
|
||||
{
|
||||
log::info!(target: "afg",
|
||||
log::info!(target: LOG_TARGET,
|
||||
"Not applying authority set change forced at block #{:?}, due to pending standard change at block #{:?}",
|
||||
change.canon_height,
|
||||
standard_change.effective_number(),
|
||||
@@ -488,7 +492,7 @@ where
|
||||
}
|
||||
|
||||
// apply this change: make the set canonical
|
||||
afg_log!(
|
||||
grandpa_log!(
|
||||
initial_sync,
|
||||
"👴 Applying authority set change forced at block #{:?}",
|
||||
change.canon_height,
|
||||
@@ -570,7 +574,7 @@ where
|
||||
}
|
||||
|
||||
if let Some(change) = change {
|
||||
afg_log!(
|
||||
grandpa_log!(
|
||||
initial_sync,
|
||||
"👴 Applying authority set change scheduled at block #{:?}",
|
||||
change.canon_height,
|
||||
|
||||
@@ -38,7 +38,7 @@ use crate::{
|
||||
CompletedRound, CompletedRounds, CurrentRounds, HasVoted, SharedVoterSetState,
|
||||
VoterSetState,
|
||||
},
|
||||
GrandpaJustification, NewAuthoritySet,
|
||||
GrandpaJustification, NewAuthoritySet, LOG_TARGET,
|
||||
};
|
||||
|
||||
const VERSION_KEY: &[u8] = b"grandpa_schema_version";
|
||||
@@ -100,8 +100,8 @@ where
|
||||
// previously we only supported at most one pending change per fork
|
||||
&|_, _| Ok(false),
|
||||
) {
|
||||
warn!(target: "afg", "Error migrating pending authority set change: {}", err);
|
||||
warn!(target: "afg", "Node is in a potentially inconsistent state.");
|
||||
warn!(target: LOG_TARGET, "Error migrating pending authority set change: {}", err);
|
||||
warn!(target: LOG_TARGET, "Node is in a potentially inconsistent state.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,8 +384,11 @@ where
|
||||
}
|
||||
|
||||
// genesis.
|
||||
info!(target: "afg", "👴 Loading GRANDPA authority set \
|
||||
from genesis on what appears to be first startup.");
|
||||
info!(
|
||||
target: LOG_TARGET,
|
||||
"👴 Loading GRANDPA authority set \
|
||||
from genesis on what appears to be first startup."
|
||||
);
|
||||
|
||||
let genesis_authorities = genesis_authorities()?;
|
||||
let genesis_set = AuthoritySet::genesis(genesis_authorities)
|
||||
|
||||
@@ -99,7 +99,7 @@ use sp_finality_grandpa::AuthorityId;
|
||||
use sp_runtime::traits::{Block as BlockT, NumberFor, Zero};
|
||||
|
||||
use super::{benefit, cost, Round, SetId, NEIGHBOR_REBROADCAST_PERIOD};
|
||||
use crate::{environment, CatchUp, CompactCommit, SignedMessage};
|
||||
use crate::{environment, CatchUp, CompactCommit, SignedMessage, LOG_TARGET};
|
||||
|
||||
use std::{
|
||||
collections::{HashSet, VecDeque},
|
||||
@@ -578,8 +578,13 @@ impl<N: Ord> Peers<N> {
|
||||
last_update: Some(now),
|
||||
};
|
||||
|
||||
trace!(target: "afg", "Peer {} updated view. Now at {:?}, {:?}",
|
||||
who, peer.view.round, peer.view.set_id);
|
||||
trace!(
|
||||
target: LOG_TARGET,
|
||||
"Peer {} updated view. Now at {:?}, {:?}",
|
||||
who,
|
||||
peer.view.round,
|
||||
peer.view.set_id
|
||||
);
|
||||
|
||||
Ok(Some(&peer.view))
|
||||
}
|
||||
@@ -801,8 +806,12 @@ impl<Block: BlockT> Inner<Block> {
|
||||
|
||||
let set_id = local_view.set_id;
|
||||
|
||||
debug!(target: "afg", "Voter {} noting beginning of round {:?} to network.",
|
||||
self.config.name(), (round, set_id));
|
||||
debug!(
|
||||
target: LOG_TARGET,
|
||||
"Voter {} noting beginning of round {:?} to network.",
|
||||
self.config.name(),
|
||||
(round, set_id)
|
||||
);
|
||||
|
||||
local_view.update_round(round);
|
||||
|
||||
@@ -824,7 +833,7 @@ impl<Block: BlockT> Inner<Block> {
|
||||
authorities.iter().collect::<HashSet<_>>();
|
||||
|
||||
if diff_authorities {
|
||||
debug!(target: "afg",
|
||||
debug!(target: LOG_TARGET,
|
||||
"Gossip validator noted set {:?} twice with different authorities. \
|
||||
Was the authority set hard forked?",
|
||||
set_id,
|
||||
@@ -912,7 +921,7 @@ impl<Block: BlockT> Inner<Block> {
|
||||
|
||||
// ensure authority is part of the set.
|
||||
if !self.authorities.contains(&full.message.id) {
|
||||
debug!(target: "afg", "Message from unknown voter: {}", full.message.id);
|
||||
debug!(target: LOG_TARGET, "Message from unknown voter: {}", full.message.id);
|
||||
telemetry!(
|
||||
self.config.telemetry;
|
||||
CONSENSUS_DEBUG;
|
||||
@@ -929,7 +938,7 @@ impl<Block: BlockT> Inner<Block> {
|
||||
full.round.0,
|
||||
full.set_id.0,
|
||||
) {
|
||||
debug!(target: "afg", "Bad message signature {}", full.message.id);
|
||||
debug!(target: LOG_TARGET, "Bad message signature {}", full.message.id);
|
||||
telemetry!(
|
||||
self.config.telemetry;
|
||||
CONSENSUS_DEBUG;
|
||||
@@ -964,7 +973,7 @@ impl<Block: BlockT> Inner<Block> {
|
||||
if full.message.precommits.len() != full.message.auth_data.len() ||
|
||||
full.message.precommits.is_empty()
|
||||
{
|
||||
debug!(target: "afg", "Malformed compact commit");
|
||||
debug!(target: LOG_TARGET, "Malformed compact commit");
|
||||
telemetry!(
|
||||
self.config.telemetry;
|
||||
CONSENSUS_DEBUG;
|
||||
@@ -1023,9 +1032,9 @@ impl<Block: BlockT> Inner<Block> {
|
||||
PendingCatchUp::Processing { .. } => {
|
||||
self.pending_catch_up = PendingCatchUp::None;
|
||||
},
|
||||
state => debug!(target: "afg",
|
||||
"Noted processed catch up message when state was: {:?}",
|
||||
state,
|
||||
state => debug!(
|
||||
target: LOG_TARGET,
|
||||
"Noted processed catch up message when state was: {:?}", state,
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -1067,7 +1076,9 @@ impl<Block: BlockT> Inner<Block> {
|
||||
return (None, Action::Discard(Misbehavior::OutOfScopeMessage.cost()))
|
||||
}
|
||||
|
||||
trace!(target: "afg", "Replying to catch-up request for round {} from {} with round {}",
|
||||
trace!(
|
||||
target: LOG_TARGET,
|
||||
"Replying to catch-up request for round {} from {} with round {}",
|
||||
request.round.0,
|
||||
who,
|
||||
last_completed_round.number,
|
||||
@@ -1141,9 +1152,9 @@ impl<Block: BlockT> Inner<Block> {
|
||||
let (catch_up_allowed, catch_up_report) = self.note_catch_up_request(who, &request);
|
||||
|
||||
if catch_up_allowed {
|
||||
debug!(target: "afg", "Sending catch-up request for round {} to {}",
|
||||
round,
|
||||
who,
|
||||
debug!(
|
||||
target: LOG_TARGET,
|
||||
"Sending catch-up request for round {} to {}", round, who,
|
||||
);
|
||||
|
||||
catch_up = Some(GossipMessage::<Block>::CatchUpRequest(request));
|
||||
@@ -1347,7 +1358,7 @@ impl<Block: BlockT> GossipValidator<Block> {
|
||||
let metrics = match prometheus_registry.map(Metrics::register) {
|
||||
Some(Ok(metrics)) => Some(metrics),
|
||||
Some(Err(e)) => {
|
||||
debug!(target: "afg", "Failed to register metrics: {:?}", e);
|
||||
debug!(target: LOG_TARGET, "Failed to register metrics: {:?}", e);
|
||||
None
|
||||
},
|
||||
None => None,
|
||||
@@ -1466,7 +1477,7 @@ impl<Block: BlockT> GossipValidator<Block> {
|
||||
},
|
||||
Err(e) => {
|
||||
message_name = None;
|
||||
debug!(target: "afg", "Error decoding message: {}", e);
|
||||
debug!(target: LOG_TARGET, "Error decoding message: {}", e);
|
||||
telemetry!(
|
||||
self.telemetry;
|
||||
CONSENSUS_DEBUG;
|
||||
|
||||
@@ -54,7 +54,7 @@ use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT, Numb
|
||||
|
||||
use crate::{
|
||||
environment::HasVoted, CatchUp, Commit, CommunicationIn, CommunicationOutH, CompactCommit,
|
||||
Error, Message, SignedMessage,
|
||||
Error, Message, SignedMessage, LOG_TARGET,
|
||||
};
|
||||
use gossip::{
|
||||
FullCatchUpMessage, FullCommitMessage, GossipMessage, GossipValidator, PeerReport, VoteMessage,
|
||||
@@ -274,7 +274,8 @@ impl<B: BlockT, N: Network<B>> NetworkBridge<B, N> {
|
||||
gossip_engine.lock().register_gossip_message(topic, message.encode());
|
||||
}
|
||||
|
||||
trace!(target: "afg",
|
||||
trace!(
|
||||
target: LOG_TARGET,
|
||||
"Registered {} messages for topic {:?} (round: {}, set_id: {})",
|
||||
round.votes.len(),
|
||||
topic,
|
||||
@@ -340,13 +341,19 @@ impl<B: BlockT, N: Network<B>> NetworkBridge<B, N> {
|
||||
|
||||
match decoded {
|
||||
Err(ref e) => {
|
||||
debug!(target: "afg", "Skipping malformed message {:?}: {}", notification, e);
|
||||
debug!(
|
||||
target: LOG_TARGET,
|
||||
"Skipping malformed message {:?}: {}", notification, e
|
||||
);
|
||||
future::ready(None)
|
||||
},
|
||||
Ok(GossipMessage::Vote(msg)) => {
|
||||
// check signature.
|
||||
if !voters.contains(&msg.message.id) {
|
||||
debug!(target: "afg", "Skipping message from unknown voter {}", msg.message.id);
|
||||
debug!(
|
||||
target: LOG_TARGET,
|
||||
"Skipping message from unknown voter {}", msg.message.id
|
||||
);
|
||||
return future::ready(None)
|
||||
}
|
||||
|
||||
@@ -388,7 +395,7 @@ impl<B: BlockT, N: Network<B>> NetworkBridge<B, N> {
|
||||
future::ready(Some(msg.message))
|
||||
},
|
||||
_ => {
|
||||
debug!(target: "afg", "Skipping unknown message type");
|
||||
debug!(target: LOG_TARGET, "Skipping unknown message type");
|
||||
future::ready(None)
|
||||
},
|
||||
}
|
||||
@@ -631,7 +638,12 @@ fn incoming_global<B: BlockT>(
|
||||
// this could be optimized by decoding piecewise.
|
||||
let decoded = GossipMessage::<B>::decode(&mut ¬ification.message[..]);
|
||||
if let Err(ref e) = decoded {
|
||||
trace!(target: "afg", "Skipping malformed commit message {:?}: {}", notification, e);
|
||||
trace!(
|
||||
target: LOG_TARGET,
|
||||
"Skipping malformed commit message {:?}: {}",
|
||||
notification,
|
||||
e
|
||||
);
|
||||
}
|
||||
future::ready(decoded.map(move |d| (notification, d)).ok())
|
||||
})
|
||||
@@ -642,7 +654,7 @@ fn incoming_global<B: BlockT>(
|
||||
GossipMessage::CatchUp(msg) =>
|
||||
process_catch_up(msg, notification, &gossip_engine, &gossip_validator, &voters),
|
||||
_ => {
|
||||
debug!(target: "afg", "Skipping unknown message type");
|
||||
debug!(target: LOG_TARGET, "Skipping unknown message type");
|
||||
None
|
||||
},
|
||||
})
|
||||
@@ -748,7 +760,7 @@ impl<Block: BlockT> Sink<Message<Block::Header>> for OutgoingMessages<Block> {
|
||||
});
|
||||
|
||||
debug!(
|
||||
target: "afg",
|
||||
target: LOG_TARGET,
|
||||
"Announcing block {} to peers which we voted on in round {} in set {}",
|
||||
target_hash,
|
||||
self.round,
|
||||
@@ -813,7 +825,7 @@ fn check_compact_commit<Block: BlockT>(
|
||||
return Err(cost::MALFORMED_COMMIT)
|
||||
}
|
||||
} else {
|
||||
debug!(target: "afg", "Skipping commit containing unknown voter {}", id);
|
||||
debug!(target: LOG_TARGET, "Skipping commit containing unknown voter {}", id);
|
||||
return Err(cost::MALFORMED_COMMIT)
|
||||
}
|
||||
}
|
||||
@@ -838,7 +850,7 @@ fn check_compact_commit<Block: BlockT>(
|
||||
set_id.0,
|
||||
&mut buf,
|
||||
) {
|
||||
debug!(target: "afg", "Bad commit message signature {}", id);
|
||||
debug!(target: LOG_TARGET, "Bad commit message signature {}", id);
|
||||
telemetry!(
|
||||
telemetry;
|
||||
CONSENSUS_DEBUG;
|
||||
@@ -886,7 +898,10 @@ fn check_catch_up<Block: BlockT>(
|
||||
return Err(cost::MALFORMED_CATCH_UP)
|
||||
}
|
||||
} else {
|
||||
debug!(target: "afg", "Skipping catch up message containing unknown voter {}", id);
|
||||
debug!(
|
||||
target: LOG_TARGET,
|
||||
"Skipping catch up message containing unknown voter {}", id
|
||||
);
|
||||
return Err(cost::MALFORMED_CATCH_UP)
|
||||
}
|
||||
}
|
||||
@@ -922,7 +937,7 @@ fn check_catch_up<Block: BlockT>(
|
||||
if !sp_finality_grandpa::check_message_signature_with_buffer(
|
||||
&msg, id, sig, round, set_id, buf,
|
||||
) {
|
||||
debug!(target: "afg", "Bad catch up message signature {}", id);
|
||||
debug!(target: LOG_TARGET, "Bad catch up message signature {}", id);
|
||||
telemetry!(
|
||||
telemetry;
|
||||
CONSENSUS_DEBUG;
|
||||
|
||||
@@ -21,17 +21,19 @@
|
||||
use futures::{future::FutureExt as _, prelude::*, ready, stream::Stream};
|
||||
use futures_timer::Delay;
|
||||
use log::debug;
|
||||
use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender};
|
||||
use std::{
|
||||
pin::Pin,
|
||||
task::{Context, Poll},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use super::gossip::{GossipMessage, NeighborPacket};
|
||||
use sc_network::PeerId;
|
||||
use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender};
|
||||
use sp_runtime::traits::{Block as BlockT, NumberFor};
|
||||
|
||||
use super::gossip::{GossipMessage, NeighborPacket};
|
||||
use crate::LOG_TARGET;
|
||||
|
||||
/// A sender used to send neighbor packets to a background job.
|
||||
#[derive(Clone)]
|
||||
pub(super) struct NeighborPacketSender<B: BlockT>(
|
||||
@@ -46,7 +48,7 @@ impl<B: BlockT> NeighborPacketSender<B> {
|
||||
neighbor_packet: NeighborPacket<NumberFor<B>>,
|
||||
) {
|
||||
if let Err(err) = self.0.unbounded_send((who, neighbor_packet)) {
|
||||
debug!(target: "afg", "Failed to send neighbor packet: {:?}", err);
|
||||
debug!(target: LOG_TARGET, "Failed to send neighbor packet: {:?}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ use crate::{
|
||||
until_imported::UntilVoteTargetImported,
|
||||
voting_rule::VotingRule as VotingRuleT,
|
||||
ClientForGrandpa, CommandOrError, Commit, Config, Error, NewAuthoritySet, Precommit, Prevote,
|
||||
PrimaryPropose, SignedMessage, VoterCommand,
|
||||
PrimaryPropose, SignedMessage, VoterCommand, LOG_TARGET,
|
||||
};
|
||||
|
||||
type HistoricalVotes<Block> = finality_grandpa::HistoricalVotes<
|
||||
@@ -551,7 +551,10 @@ where
|
||||
{
|
||||
Some(proof) => proof,
|
||||
None => {
|
||||
debug!(target: "afg", "Equivocation offender is not part of the authority set.");
|
||||
debug!(
|
||||
target: LOG_TARGET,
|
||||
"Equivocation offender is not part of the authority set."
|
||||
);
|
||||
return Ok(())
|
||||
},
|
||||
};
|
||||
@@ -609,8 +612,13 @@ where
|
||||
let tree_route = match tree_route_res {
|
||||
Ok(tree_route) => tree_route,
|
||||
Err(e) => {
|
||||
debug!(target: "afg", "Encountered error computing ancestry between block {:?} and base {:?}: {}",
|
||||
block, base, e);
|
||||
debug!(
|
||||
target: LOG_TARGET,
|
||||
"Encountered error computing ancestry between block {:?} and base {:?}: {}",
|
||||
block,
|
||||
base,
|
||||
e
|
||||
);
|
||||
|
||||
return Err(GrandpaError::NotDescendent)
|
||||
},
|
||||
@@ -955,7 +963,8 @@ where
|
||||
historical_votes: &HistoricalVotes<Block>,
|
||||
) -> Result<(), Self::Error> {
|
||||
debug!(
|
||||
target: "afg", "Voter {} completed round {} in set {}. Estimate = {:?}, Finalized in round = {:?}",
|
||||
target: LOG_TARGET,
|
||||
"Voter {} completed round {} in set {}. Estimate = {:?}, Finalized in round = {:?}",
|
||||
self.config.name(),
|
||||
round,
|
||||
self.set_id,
|
||||
@@ -1016,7 +1025,8 @@ where
|
||||
historical_votes: &HistoricalVotes<Block>,
|
||||
) -> Result<(), Self::Error> {
|
||||
debug!(
|
||||
target: "afg", "Voter {} concluded round {} in set {}. Estimate = {:?}, Finalized in round = {:?}",
|
||||
target: LOG_TARGET,
|
||||
"Voter {} concluded round {} in set {}. Estimate = {:?}, Finalized in round = {:?}",
|
||||
self.config.name(),
|
||||
round,
|
||||
self.set_id,
|
||||
@@ -1102,9 +1112,12 @@ where
|
||||
Self::Signature,
|
||||
>,
|
||||
) {
|
||||
warn!(target: "afg", "Detected prevote equivocation in the finality worker: {:?}", equivocation);
|
||||
warn!(
|
||||
target: LOG_TARGET,
|
||||
"Detected prevote equivocation in the finality worker: {:?}", equivocation
|
||||
);
|
||||
if let Err(err) = self.report_equivocation(equivocation.into()) {
|
||||
warn!(target: "afg", "Error reporting prevote equivocation: {}", err);
|
||||
warn!(target: LOG_TARGET, "Error reporting prevote equivocation: {}", err);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1117,9 +1130,12 @@ where
|
||||
Self::Signature,
|
||||
>,
|
||||
) {
|
||||
warn!(target: "afg", "Detected precommit equivocation in the finality worker: {:?}", equivocation);
|
||||
warn!(
|
||||
target: LOG_TARGET,
|
||||
"Detected precommit equivocation in the finality worker: {:?}", equivocation
|
||||
);
|
||||
if let Err(err) = self.report_equivocation(equivocation.into()) {
|
||||
warn!(target: "afg", "Error reporting precommit equivocation: {}", err);
|
||||
warn!(target: LOG_TARGET, "Error reporting precommit equivocation: {}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1158,7 +1174,8 @@ where
|
||||
let base_header = match client.header(BlockId::Hash(block))? {
|
||||
Some(h) => h,
|
||||
None => {
|
||||
debug!(target: "afg",
|
||||
debug!(
|
||||
target: LOG_TARGET,
|
||||
"Encountered error finding best chain containing {:?}: couldn't find base block",
|
||||
block,
|
||||
);
|
||||
@@ -1172,7 +1189,10 @@ where
|
||||
// proceed onwards. most of the time there will be no pending transition. the limit, if any, is
|
||||
// guaranteed to be higher than or equal to the given base number.
|
||||
let limit = authority_set.current_limit(*base_header.number());
|
||||
debug!(target: "afg", "Finding best chain containing block {:?} with number limit {:?}", block, limit);
|
||||
debug!(
|
||||
target: LOG_TARGET,
|
||||
"Finding best chain containing block {:?} with number limit {:?}", block, limit
|
||||
);
|
||||
|
||||
let result = match select_chain.finality_target(block, None).await {
|
||||
Ok(best_hash) => {
|
||||
@@ -1234,7 +1254,10 @@ where
|
||||
.or_else(|| Some((target_header.hash(), *target_header.number())))
|
||||
},
|
||||
Err(e) => {
|
||||
warn!(target: "afg", "Encountered error finding best chain containing {:?}: {}", block, e);
|
||||
warn!(
|
||||
target: LOG_TARGET,
|
||||
"Encountered error finding best chain containing {:?}: {}", block, e
|
||||
);
|
||||
None
|
||||
},
|
||||
};
|
||||
@@ -1273,7 +1296,7 @@ where
|
||||
// This can happen after a forced change (triggered manually from the runtime when
|
||||
// finality is stalled), since the voter will be restarted at the median last finalized
|
||||
// block, which can be lower than the local best finalized block.
|
||||
warn!(target: "afg", "Re-finalized block #{:?} ({:?}) in the canonical chain, current best finalized is #{:?}",
|
||||
warn!(target: LOG_TARGET, "Re-finalized block #{:?} ({:?}) in the canonical chain, current best finalized is #{:?}",
|
||||
hash,
|
||||
number,
|
||||
status.finalized_number,
|
||||
@@ -1303,7 +1326,10 @@ where
|
||||
) {
|
||||
if let Some(sender) = justification_sender {
|
||||
if let Err(err) = sender.notify(justification) {
|
||||
warn!(target: "afg", "Error creating justification for subscriber: {}", err);
|
||||
warn!(
|
||||
target: LOG_TARGET,
|
||||
"Error creating justification for subscriber: {}", err
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1354,11 +1380,16 @@ where
|
||||
client
|
||||
.apply_finality(import_op, hash, persisted_justification, true)
|
||||
.map_err(|e| {
|
||||
warn!(target: "afg", "Error applying finality to block {:?}: {}", (hash, number), e);
|
||||
warn!(
|
||||
target: LOG_TARGET,
|
||||
"Error applying finality to block {:?}: {}",
|
||||
(hash, number),
|
||||
e
|
||||
);
|
||||
e
|
||||
})?;
|
||||
|
||||
debug!(target: "afg", "Finalizing blocks up to ({:?}, {})", number, hash);
|
||||
debug!(target: LOG_TARGET, "Finalizing blocks up to ({:?}, {})", number, hash);
|
||||
|
||||
telemetry!(
|
||||
telemetry;
|
||||
@@ -1376,13 +1407,17 @@ where
|
||||
let (new_id, set_ref) = authority_set.current();
|
||||
|
||||
if set_ref.len() > 16 {
|
||||
afg_log!(
|
||||
grandpa_log!(
|
||||
initial_sync,
|
||||
"👴 Applying GRANDPA set change to new set with {} authorities",
|
||||
set_ref.len(),
|
||||
);
|
||||
} else {
|
||||
afg_log!(initial_sync, "👴 Applying GRANDPA set change to new set {:?}", set_ref);
|
||||
grandpa_log!(
|
||||
initial_sync,
|
||||
"👴 Applying GRANDPA set change to new set {:?}",
|
||||
set_ref
|
||||
);
|
||||
}
|
||||
|
||||
telemetry!(
|
||||
@@ -1411,8 +1446,11 @@ where
|
||||
);
|
||||
|
||||
if let Err(e) = write_result {
|
||||
warn!(target: "afg", "Failed to write updated authority set to disk. Bailing.");
|
||||
warn!(target: "afg", "Node is in a potentially inconsistent state.");
|
||||
warn!(
|
||||
target: LOG_TARGET,
|
||||
"Failed to write updated authority set to disk. Bailing."
|
||||
);
|
||||
warn!(target: LOG_TARGET, "Node is in a potentially inconsistent state.");
|
||||
|
||||
return Err(e.into())
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ use crate::{
|
||||
authorities::{AuthoritySetChangeId, AuthoritySetChanges},
|
||||
best_justification,
|
||||
justification::GrandpaJustification,
|
||||
SharedAuthoritySet,
|
||||
SharedAuthoritySet, LOG_TARGET,
|
||||
};
|
||||
|
||||
const MAX_UNKNOWN_HEADERS: usize = 100_000;
|
||||
@@ -163,7 +163,7 @@ where
|
||||
"Requested finality proof for descendant of #{} while we only have finalized #{}.",
|
||||
block, info.finalized_number,
|
||||
);
|
||||
trace!(target: "afg", "{}", &err);
|
||||
trace!(target: LOG_TARGET, "{}", &err);
|
||||
return Err(FinalityProofError::BlockNotYetFinalized)
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ where
|
||||
justification
|
||||
} else {
|
||||
trace!(
|
||||
target: "afg",
|
||||
target: LOG_TARGET,
|
||||
"No justification found for the latest finalized block. \
|
||||
Returning empty proof.",
|
||||
);
|
||||
@@ -194,7 +194,7 @@ where
|
||||
grandpa_justification
|
||||
} else {
|
||||
trace!(
|
||||
target: "afg",
|
||||
target: LOG_TARGET,
|
||||
"No justification found when making finality proof for {}. \
|
||||
Returning empty proof.",
|
||||
block,
|
||||
@@ -205,7 +205,7 @@ where
|
||||
},
|
||||
AuthoritySetChangeId::Unknown => {
|
||||
warn!(
|
||||
target: "afg",
|
||||
target: LOG_TARGET,
|
||||
"AuthoritySetChanges does not cover the requested block #{} due to missing data. \
|
||||
You need to resync to populate AuthoritySetChanges properly.",
|
||||
block,
|
||||
|
||||
@@ -45,6 +45,7 @@ use crate::{
|
||||
justification::GrandpaJustification,
|
||||
notification::GrandpaJustificationSender,
|
||||
AuthoritySetChanges, ClientForGrandpa, CommandOrError, Error, NewAuthoritySet, VoterCommand,
|
||||
LOG_TARGET,
|
||||
};
|
||||
|
||||
/// A block-import handler for GRANDPA.
|
||||
@@ -589,18 +590,16 @@ where
|
||||
Ok(ImportResult::Imported(aux)) => aux,
|
||||
Ok(r) => {
|
||||
debug!(
|
||||
target: "afg",
|
||||
"Restoring old authority set after block import result: {:?}",
|
||||
r,
|
||||
target: LOG_TARGET,
|
||||
"Restoring old authority set after block import result: {:?}", r,
|
||||
);
|
||||
pending_changes.revert();
|
||||
return Ok(r)
|
||||
},
|
||||
Err(e) => {
|
||||
debug!(
|
||||
target: "afg",
|
||||
"Restoring old authority set after block import error: {}",
|
||||
e,
|
||||
target: LOG_TARGET,
|
||||
"Restoring old authority set after block import error: {}", e,
|
||||
);
|
||||
pending_changes.revert();
|
||||
return Err(ConsensusError::ClientImport(e.to_string()))
|
||||
@@ -665,7 +664,7 @@ where
|
||||
import_res.unwrap_or_else(|err| {
|
||||
if needs_justification {
|
||||
debug!(
|
||||
target: "afg",
|
||||
target: LOG_TARGET,
|
||||
"Requesting justification from peers due to imported block #{} that enacts authority set change with invalid justification: {}",
|
||||
number,
|
||||
err
|
||||
@@ -678,7 +677,7 @@ where
|
||||
None =>
|
||||
if needs_justification {
|
||||
debug!(
|
||||
target: "afg",
|
||||
target: LOG_TARGET,
|
||||
"Imported unjustified block #{} that enacts authority set change, waiting for finality for enactment.",
|
||||
number,
|
||||
);
|
||||
@@ -803,7 +802,7 @@ where
|
||||
|
||||
match result {
|
||||
Err(CommandOrError::VoterCommand(command)) => {
|
||||
afg_log!(
|
||||
grandpa_log!(
|
||||
initial_sync,
|
||||
"👴 Imported justification for block #{} that triggers \
|
||||
command {}, signaling voter.",
|
||||
|
||||
@@ -93,10 +93,12 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
const LOG_TARGET: &str = "grandpa";
|
||||
|
||||
// utility logging macro that takes as first argument a conditional to
|
||||
// decide whether to log under debug or info level (useful to restrict
|
||||
// logging under initial sync).
|
||||
macro_rules! afg_log {
|
||||
macro_rules! grandpa_log {
|
||||
($condition:expr, $($msg: expr),+ $(,)?) => {
|
||||
{
|
||||
let log_level = if $condition {
|
||||
@@ -105,7 +107,7 @@ macro_rules! afg_log {
|
||||
log::Level::Info
|
||||
};
|
||||
|
||||
log::log!(target: "afg", log_level, $($msg),+);
|
||||
log::log!(target: LOG_TARGET, log_level, $($msg),+);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -803,10 +805,11 @@ where
|
||||
);
|
||||
|
||||
let voter_work = voter_work.map(|res| match res {
|
||||
Ok(()) => error!(target: "afg",
|
||||
Ok(()) => error!(
|
||||
target: LOG_TARGET,
|
||||
"GRANDPA voter future has concluded naturally, this should be unreachable."
|
||||
),
|
||||
Err(e) => error!(target: "afg", "GRANDPA voter error: {}", e),
|
||||
Err(e) => error!(target: LOG_TARGET, "GRANDPA voter error: {}", e),
|
||||
});
|
||||
|
||||
// Make sure that `telemetry_task` doesn't accidentally finish and kill grandpa.
|
||||
@@ -871,7 +874,7 @@ where
|
||||
let metrics = match prometheus_registry.as_ref().map(Metrics::register) {
|
||||
Some(Ok(metrics)) => Some(metrics),
|
||||
Some(Err(e)) => {
|
||||
debug!(target: "afg", "Failed to register metrics: {:?}", e);
|
||||
debug!(target: LOG_TARGET, "Failed to register metrics: {:?}", e);
|
||||
None
|
||||
},
|
||||
None => None,
|
||||
@@ -913,7 +916,12 @@ where
|
||||
/// state. This method should be called when we know that the authority set
|
||||
/// has changed (e.g. as signalled by a voter command).
|
||||
fn rebuild_voter(&mut self) {
|
||||
debug!(target: "afg", "{}: Starting new voter with set ID {}", self.env.config.name(), self.env.set_id);
|
||||
debug!(
|
||||
target: LOG_TARGET,
|
||||
"{}: Starting new voter with set ID {}",
|
||||
self.env.config.name(),
|
||||
self.env.set_id
|
||||
);
|
||||
|
||||
let maybe_authority_id =
|
||||
local_authority_id(&self.env.voters, self.env.config.keystore.as_ref());
|
||||
@@ -974,7 +982,8 @@ where
|
||||
|
||||
// Repoint shared_voter_state so that the RPC endpoint can query the state
|
||||
if self.shared_voter_state.reset(voter.voter_state()).is_none() {
|
||||
info!(target: "afg",
|
||||
info!(
|
||||
target: LOG_TARGET,
|
||||
"Timed out trying to update shared GRANDPA voter state. \
|
||||
RPC endpoints may return stale data."
|
||||
);
|
||||
@@ -1043,7 +1052,7 @@ where
|
||||
Ok(())
|
||||
},
|
||||
VoterCommand::Pause(reason) => {
|
||||
info!(target: "afg", "Pausing old validator set: {}", reason);
|
||||
info!(target: LOG_TARGET, "Pausing old validator set: {}", reason);
|
||||
|
||||
// not racing because old voter is shut down.
|
||||
self.env.update_voter_set_state(|voter_set_state| {
|
||||
|
||||
@@ -43,7 +43,7 @@ use crate::{
|
||||
environment, global_communication,
|
||||
notification::GrandpaJustificationSender,
|
||||
ClientForGrandpa, CommandOrError, CommunicationIn, Config, Error, LinkHalf, VoterCommand,
|
||||
VoterSetState,
|
||||
VoterSetState, LOG_TARGET,
|
||||
};
|
||||
|
||||
struct ObserverChain<'a, Block: BlockT, Client> {
|
||||
@@ -145,7 +145,7 @@ where
|
||||
// proceed processing with new finalized block number
|
||||
future::ok(finalized_number)
|
||||
} else {
|
||||
debug!(target: "afg", "Received invalid commit: ({:?}, {:?})", round, commit);
|
||||
debug!(target: LOG_TARGET, "Received invalid commit: ({:?}, {:?})", round, commit);
|
||||
|
||||
finality_grandpa::process_commit_validation_result(validation_result, callback);
|
||||
|
||||
@@ -317,7 +317,7 @@ where
|
||||
// update it on-disk in case we restart as validator in the future.
|
||||
self.persistent_data.set_state = match command {
|
||||
VoterCommand::Pause(reason) => {
|
||||
info!(target: "afg", "Pausing old validator set: {}", reason);
|
||||
info!(target: LOG_TARGET, "Pausing old validator set: {}", reason);
|
||||
|
||||
let completed_rounds = self.persistent_data.set_state.read().completed_rounds();
|
||||
let set_state = VoterSetState::Paused { completed_rounds };
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
use super::{
|
||||
BlockStatus as BlockStatusT, BlockSyncRequester as BlockSyncRequesterT, CommunicationIn, Error,
|
||||
SignedMessage,
|
||||
SignedMessage, LOG_TARGET,
|
||||
};
|
||||
|
||||
use finality_grandpa::voter;
|
||||
@@ -296,7 +296,7 @@ where
|
||||
let next_log = *last_log + LOG_PENDING_INTERVAL;
|
||||
if Instant::now() >= next_log {
|
||||
debug!(
|
||||
target: "afg",
|
||||
target: LOG_TARGET,
|
||||
"Waiting to import block {} before {} {} messages can be imported. \
|
||||
Requesting network sync service to retrieve block from. \
|
||||
Possible fork?",
|
||||
@@ -346,7 +346,7 @@ where
|
||||
|
||||
fn warn_authority_wrong_target<H: ::std::fmt::Display>(hash: H, id: AuthorityId) {
|
||||
warn!(
|
||||
target: "afg",
|
||||
target: LOG_TARGET,
|
||||
"Authority {:?} signed GRANDPA message with \
|
||||
wrong block number for hash {}",
|
||||
id,
|
||||
|
||||
Reference in New Issue
Block a user