mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-21 23:45:40 +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:
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
aura_err, authorities, find_pre_digest, slot_author, AuthorityId, CompatibilityMode, Error,
|
aura_err, authorities, find_pre_digest, slot_author, AuthorityId, CompatibilityMode, Error,
|
||||||
|
LOG_TARGET,
|
||||||
};
|
};
|
||||||
use codec::{Codec, Decode, Encode};
|
use codec::{Codec, Decode, Encode};
|
||||||
use log::{debug, info, trace};
|
use log::{debug, info, trace};
|
||||||
@@ -88,7 +89,7 @@ where
|
|||||||
.map_err(Error::Client)?
|
.map_err(Error::Client)?
|
||||||
{
|
{
|
||||||
info!(
|
info!(
|
||||||
target: "aura",
|
target: LOG_TARGET,
|
||||||
"Slot author is equivocating at slot {} with headers {:?} and {:?}",
|
"Slot author is equivocating at slot {} with headers {:?} and {:?}",
|
||||||
slot,
|
slot,
|
||||||
equivocation_proof.first_header.hash(),
|
equivocation_proof.first_header.hash(),
|
||||||
@@ -256,7 +257,7 @@ where
|
|||||||
block.body = Some(inner_body);
|
block.body = Some(inner_body);
|
||||||
}
|
}
|
||||||
|
|
||||||
trace!(target: "aura", "Checked {:?}; importing.", pre_header);
|
trace!(target: LOG_TARGET, "Checked {:?}; importing.", pre_header);
|
||||||
telemetry!(
|
telemetry!(
|
||||||
self.telemetry;
|
self.telemetry;
|
||||||
CONSENSUS_TRACE;
|
CONSENSUS_TRACE;
|
||||||
@@ -272,7 +273,7 @@ where
|
|||||||
Ok((block, None))
|
Ok((block, None))
|
||||||
},
|
},
|
||||||
CheckedHeader::Deferred(a, b) => {
|
CheckedHeader::Deferred(a, b) => {
|
||||||
debug!(target: "aura", "Checking {:?} failed; {:?}, {:?}.", hash, a, b);
|
debug!(target: LOG_TARGET, "Checking {:?} failed; {:?}, {:?}.", hash, a, b);
|
||||||
telemetry!(
|
telemetry!(
|
||||||
self.telemetry;
|
self.telemetry;
|
||||||
CONSENSUS_DEBUG;
|
CONSENSUS_DEBUG;
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ pub use sp_consensus_aura::{
|
|||||||
AuraApi, ConsensusLog, SlotDuration, AURA_ENGINE_ID,
|
AuraApi, ConsensusLog, SlotDuration, AURA_ENGINE_ID,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const LOG_TARGET: &str = "aura";
|
||||||
|
|
||||||
type AuthorityId<P> = <P as Pair>::Public;
|
type AuthorityId<P> = <P as Pair>::Public;
|
||||||
|
|
||||||
/// Run `AURA` in a compatibility mode.
|
/// Run `AURA` in a compatibility mode.
|
||||||
@@ -530,7 +532,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn aura_err<B: BlockT>(error: Error<B>) -> Error<B> {
|
fn aura_err<B: BlockT>(error: Error<B>) -> Error<B> {
|
||||||
debug!(target: "aura", "{}", error);
|
debug!(target: LOG_TARGET, "{}", error);
|
||||||
error
|
error
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -580,10 +582,10 @@ pub fn find_pre_digest<B: BlockT, Signature: Codec>(header: &B::Header) -> Resul
|
|||||||
|
|
||||||
let mut pre_digest: Option<Slot> = None;
|
let mut pre_digest: Option<Slot> = None;
|
||||||
for log in header.digest().logs() {
|
for log in header.digest().logs() {
|
||||||
trace!(target: "aura", "Checking log {:?}", log);
|
trace!(target: LOG_TARGET, "Checking log {:?}", log);
|
||||||
match (CompatibleDigestItem::<Signature>::as_aura_pre_digest(log), pre_digest.is_some()) {
|
match (CompatibleDigestItem::<Signature>::as_aura_pre_digest(log), pre_digest.is_some()) {
|
||||||
(Some(_), true) => return Err(aura_err(Error::MultipleHeaders)),
|
(Some(_), true) => return Err(aura_err(Error::MultipleHeaders)),
|
||||||
(None, _) => trace!(target: "aura", "Ignoring digest not meant for us"),
|
(None, _) => trace!(target: LOG_TARGET, "Ignoring digest not meant for us"),
|
||||||
(s, false) => pre_digest = s,
|
(s, false) => pre_digest = s,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use log::info;
|
use log::info;
|
||||||
|
|
||||||
use crate::{migration::EpochV0, Epoch};
|
use crate::{migration::EpochV0, Epoch, LOG_TARGET};
|
||||||
use sc_client_api::backend::AuxStore;
|
use sc_client_api::backend::AuxStore;
|
||||||
use sc_consensus_epochs::{
|
use sc_consensus_epochs::{
|
||||||
migration::{EpochChangesV0For, EpochChangesV1For},
|
migration::{EpochChangesV0For, EpochChangesV1For},
|
||||||
@@ -82,7 +82,7 @@ pub fn load_epoch_changes<Block: BlockT, B: AuxStore>(
|
|||||||
let epoch_changes =
|
let epoch_changes =
|
||||||
SharedEpochChanges::<Block, Epoch>::new(maybe_epoch_changes.unwrap_or_else(|| {
|
SharedEpochChanges::<Block, Epoch>::new(maybe_epoch_changes.unwrap_or_else(|| {
|
||||||
info!(
|
info!(
|
||||||
target: "babe",
|
target: LOG_TARGET,
|
||||||
"👶 Creating empty BABE epoch changes on what appears to be first startup.",
|
"👶 Creating empty BABE epoch changes on what appears to be first startup.",
|
||||||
);
|
);
|
||||||
EpochChangesFor::<Block, Epoch>::default()
|
EpochChangesFor::<Block, Epoch>::default()
|
||||||
|
|||||||
@@ -149,6 +149,8 @@ pub mod aux_schema;
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
|
const LOG_TARGET: &str = "babe";
|
||||||
|
|
||||||
/// BABE epoch information
|
/// BABE epoch information
|
||||||
#[derive(Decode, Encode, PartialEq, Eq, Clone, Debug)]
|
#[derive(Decode, Encode, PartialEq, Eq, Clone, Debug)]
|
||||||
pub struct Epoch {
|
pub struct Epoch {
|
||||||
@@ -323,7 +325,7 @@ impl<B: BlockT> From<Error<B>> for String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn babe_err<B: BlockT>(error: Error<B>) -> Error<B> {
|
fn babe_err<B: BlockT>(error: Error<B>) -> Error<B> {
|
||||||
debug!(target: "babe", "{}", error);
|
debug!(target: LOG_TARGET, "{}", error);
|
||||||
error
|
error
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,7 +347,7 @@ where
|
|||||||
let block_id = if client.usage_info().chain.finalized_state.is_some() {
|
let block_id = if client.usage_info().chain.finalized_state.is_some() {
|
||||||
BlockId::Hash(client.usage_info().chain.best_hash)
|
BlockId::Hash(client.usage_info().chain.best_hash)
|
||||||
} else {
|
} else {
|
||||||
debug!(target: "babe", "No finalized state is available. Reading config from genesis");
|
debug!(target: LOG_TARGET, "No finalized state is available. Reading config from genesis");
|
||||||
BlockId::Hash(client.usage_info().chain.genesis_hash)
|
BlockId::Hash(client.usage_info().chain.genesis_hash)
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -486,7 +488,7 @@ where
|
|||||||
telemetry,
|
telemetry,
|
||||||
};
|
};
|
||||||
|
|
||||||
info!(target: "babe", "👶 Starting BABE Authorship worker");
|
info!(target: LOG_TARGET, "👶 Starting BABE Authorship worker");
|
||||||
|
|
||||||
let slot_worker = sc_consensus_slots::start_slot_worker(
|
let slot_worker = sc_consensus_slots::start_slot_worker(
|
||||||
babe_link.config.slot_duration(),
|
babe_link.config.slot_duration(),
|
||||||
@@ -523,12 +525,8 @@ fn aux_storage_cleanup<C: HeaderMetadata<Block> + HeaderBackend<Block>, Block: B
|
|||||||
Ok(meta) => {
|
Ok(meta) => {
|
||||||
hashes.insert(meta.parent);
|
hashes.insert(meta.parent);
|
||||||
},
|
},
|
||||||
Err(err) => warn!(
|
Err(err) =>
|
||||||
target: "babe",
|
warn!(target: LOG_TARGET, "Failed to lookup metadata for block `{:?}`: {}", first, err,),
|
||||||
"Failed to lookup metadata for block `{:?}`: {}",
|
|
||||||
first,
|
|
||||||
err,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleans data for finalized block's ancestors
|
// Cleans data for finalized block's ancestors
|
||||||
@@ -716,7 +714,7 @@ where
|
|||||||
type AuxData = ViableEpochDescriptor<B::Hash, NumberFor<B>, Epoch>;
|
type AuxData = ViableEpochDescriptor<B::Hash, NumberFor<B>, Epoch>;
|
||||||
|
|
||||||
fn logging_target(&self) -> &'static str {
|
fn logging_target(&self) -> &'static str {
|
||||||
"babe"
|
LOG_TARGET
|
||||||
}
|
}
|
||||||
|
|
||||||
fn block_import(&mut self) -> &mut Self::BlockImport {
|
fn block_import(&mut self) -> &mut Self::BlockImport {
|
||||||
@@ -749,7 +747,7 @@ where
|
|||||||
slot: Slot,
|
slot: Slot,
|
||||||
epoch_descriptor: &ViableEpochDescriptor<B::Hash, NumberFor<B>, Epoch>,
|
epoch_descriptor: &ViableEpochDescriptor<B::Hash, NumberFor<B>, Epoch>,
|
||||||
) -> Option<Self::Claim> {
|
) -> Option<Self::Claim> {
|
||||||
debug!(target: "babe", "Attempting to claim slot {}", slot);
|
debug!(target: LOG_TARGET, "Attempting to claim slot {}", slot);
|
||||||
let s = authorship::claim_slot(
|
let s = authorship::claim_slot(
|
||||||
slot,
|
slot,
|
||||||
self.epoch_changes
|
self.epoch_changes
|
||||||
@@ -760,7 +758,7 @@ where
|
|||||||
);
|
);
|
||||||
|
|
||||||
if s.is_some() {
|
if s.is_some() {
|
||||||
debug!(target: "babe", "Claimed slot {}", slot);
|
debug!(target: LOG_TARGET, "Claimed slot {}", slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
s
|
s
|
||||||
@@ -777,7 +775,7 @@ where
|
|||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(e) =>
|
Err(e) =>
|
||||||
if e.is_full() {
|
if e.is_full() {
|
||||||
warn!(target: "babe", "Trying to notify a slot but the channel is full");
|
warn!(target: LOG_TARGET, "Trying to notify a slot but the channel is full");
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
@@ -904,10 +902,10 @@ pub fn find_pre_digest<B: BlockT>(header: &B::Header) -> Result<PreDigest, Error
|
|||||||
|
|
||||||
let mut pre_digest: Option<_> = None;
|
let mut pre_digest: Option<_> = None;
|
||||||
for log in header.digest().logs() {
|
for log in header.digest().logs() {
|
||||||
trace!(target: "babe", "Checking log {:?}, looking for pre runtime digest", log);
|
trace!(target: LOG_TARGET, "Checking log {:?}, looking for pre runtime digest", log);
|
||||||
match (log.as_babe_pre_digest(), pre_digest.is_some()) {
|
match (log.as_babe_pre_digest(), pre_digest.is_some()) {
|
||||||
(Some(_), true) => return Err(babe_err(Error::MultiplePreRuntimeDigests)),
|
(Some(_), true) => return Err(babe_err(Error::MultiplePreRuntimeDigests)),
|
||||||
(None, _) => trace!(target: "babe", "Ignoring digest not meant for us"),
|
(None, _) => trace!(target: LOG_TARGET, "Ignoring digest not meant for us"),
|
||||||
(s, false) => pre_digest = s,
|
(s, false) => pre_digest = s,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -920,13 +918,13 @@ fn find_next_epoch_digest<B: BlockT>(
|
|||||||
) -> Result<Option<NextEpochDescriptor>, Error<B>> {
|
) -> Result<Option<NextEpochDescriptor>, Error<B>> {
|
||||||
let mut epoch_digest: Option<_> = None;
|
let mut epoch_digest: Option<_> = None;
|
||||||
for log in header.digest().logs() {
|
for log in header.digest().logs() {
|
||||||
trace!(target: "babe", "Checking log {:?}, looking for epoch change digest.", log);
|
trace!(target: LOG_TARGET, "Checking log {:?}, looking for epoch change digest.", log);
|
||||||
let log = log.try_to::<ConsensusLog>(OpaqueDigestItemId::Consensus(&BABE_ENGINE_ID));
|
let log = log.try_to::<ConsensusLog>(OpaqueDigestItemId::Consensus(&BABE_ENGINE_ID));
|
||||||
match (log, epoch_digest.is_some()) {
|
match (log, epoch_digest.is_some()) {
|
||||||
(Some(ConsensusLog::NextEpochData(_)), true) =>
|
(Some(ConsensusLog::NextEpochData(_)), true) =>
|
||||||
return Err(babe_err(Error::MultipleEpochChangeDigests)),
|
return Err(babe_err(Error::MultipleEpochChangeDigests)),
|
||||||
(Some(ConsensusLog::NextEpochData(epoch)), false) => epoch_digest = Some(epoch),
|
(Some(ConsensusLog::NextEpochData(epoch)), false) => epoch_digest = Some(epoch),
|
||||||
_ => trace!(target: "babe", "Ignoring digest not meant for us"),
|
_ => trace!(target: LOG_TARGET, "Ignoring digest not meant for us"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -939,13 +937,13 @@ fn find_next_config_digest<B: BlockT>(
|
|||||||
) -> Result<Option<NextConfigDescriptor>, Error<B>> {
|
) -> Result<Option<NextConfigDescriptor>, Error<B>> {
|
||||||
let mut config_digest: Option<_> = None;
|
let mut config_digest: Option<_> = None;
|
||||||
for log in header.digest().logs() {
|
for log in header.digest().logs() {
|
||||||
trace!(target: "babe", "Checking log {:?}, looking for epoch change digest.", log);
|
trace!(target: LOG_TARGET, "Checking log {:?}, looking for epoch change digest.", log);
|
||||||
let log = log.try_to::<ConsensusLog>(OpaqueDigestItemId::Consensus(&BABE_ENGINE_ID));
|
let log = log.try_to::<ConsensusLog>(OpaqueDigestItemId::Consensus(&BABE_ENGINE_ID));
|
||||||
match (log, config_digest.is_some()) {
|
match (log, config_digest.is_some()) {
|
||||||
(Some(ConsensusLog::NextConfigData(_)), true) =>
|
(Some(ConsensusLog::NextConfigData(_)), true) =>
|
||||||
return Err(babe_err(Error::MultipleConfigChangeDigests)),
|
return Err(babe_err(Error::MultipleConfigChangeDigests)),
|
||||||
(Some(ConsensusLog::NextConfigData(config)), false) => config_digest = Some(config),
|
(Some(ConsensusLog::NextConfigData(config)), false) => config_digest = Some(config),
|
||||||
_ => trace!(target: "babe", "Ignoring digest not meant for us"),
|
_ => trace!(target: LOG_TARGET, "Ignoring digest not meant for us"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1075,7 +1073,10 @@ where
|
|||||||
None => match generate_key_owner_proof(&best_id)? {
|
None => match generate_key_owner_proof(&best_id)? {
|
||||||
Some(proof) => proof,
|
Some(proof) => proof,
|
||||||
None => {
|
None => {
|
||||||
debug!(target: "babe", "Equivocation offender is not part of the authority set.");
|
debug!(
|
||||||
|
target: LOG_TARGET,
|
||||||
|
"Equivocation offender is not part of the authority set."
|
||||||
|
);
|
||||||
return Ok(())
|
return Ok(())
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -1091,7 +1092,7 @@ where
|
|||||||
)
|
)
|
||||||
.map_err(Error::RuntimeApi)?;
|
.map_err(Error::RuntimeApi)?;
|
||||||
|
|
||||||
info!(target: "babe", "Submitted equivocation report for author {:?}", author);
|
info!(target: LOG_TARGET, "Submitted equivocation report for author {:?}", author);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -1121,7 +1122,7 @@ where
|
|||||||
mut block: BlockImportParams<Block, ()>,
|
mut block: BlockImportParams<Block, ()>,
|
||||||
) -> BlockVerificationResult<Block> {
|
) -> BlockVerificationResult<Block> {
|
||||||
trace!(
|
trace!(
|
||||||
target: "babe",
|
target: LOG_TARGET,
|
||||||
"Verifying origin: {:?} header: {:?} justification(s): {:?} body: {:?}",
|
"Verifying origin: {:?} header: {:?} justification(s): {:?} body: {:?}",
|
||||||
block.origin,
|
block.origin,
|
||||||
block.header,
|
block.header,
|
||||||
@@ -1140,7 +1141,11 @@ where
|
|||||||
return Ok((block, Default::default()))
|
return Ok((block, Default::default()))
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!(target: "babe", "We have {:?} logs in this header", block.header.digest().logs().len());
|
debug!(
|
||||||
|
target: LOG_TARGET,
|
||||||
|
"We have {:?} logs in this header",
|
||||||
|
block.header.digest().logs().len()
|
||||||
|
);
|
||||||
|
|
||||||
let create_inherent_data_providers = self
|
let create_inherent_data_providers = self
|
||||||
.create_inherent_data_providers
|
.create_inherent_data_providers
|
||||||
@@ -1204,7 +1209,10 @@ where
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
warn!(target: "babe", "Error checking/reporting BABE equivocation: {}", err);
|
warn!(
|
||||||
|
target: LOG_TARGET,
|
||||||
|
"Error checking/reporting BABE equivocation: {}", err
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(inner_body) = block.body {
|
if let Some(inner_body) = block.body {
|
||||||
@@ -1233,7 +1241,7 @@ where
|
|||||||
block.body = Some(inner_body);
|
block.body = Some(inner_body);
|
||||||
}
|
}
|
||||||
|
|
||||||
trace!(target: "babe", "Checked {:?}; importing.", pre_header);
|
trace!(target: LOG_TARGET, "Checked {:?}; importing.", pre_header);
|
||||||
telemetry!(
|
telemetry!(
|
||||||
self.telemetry;
|
self.telemetry;
|
||||||
CONSENSUS_TRACE;
|
CONSENSUS_TRACE;
|
||||||
@@ -1252,7 +1260,7 @@ where
|
|||||||
Ok((block, Default::default()))
|
Ok((block, Default::default()))
|
||||||
},
|
},
|
||||||
CheckedHeader::Deferred(a, b) => {
|
CheckedHeader::Deferred(a, b) => {
|
||||||
debug!(target: "babe", "Checking {:?} failed; {:?}, {:?}.", hash, a, b);
|
debug!(target: LOG_TARGET, "Checking {:?} failed; {:?}, {:?}.", hash, a, b);
|
||||||
telemetry!(
|
telemetry!(
|
||||||
self.telemetry;
|
self.telemetry;
|
||||||
CONSENSUS_DEBUG;
|
CONSENSUS_DEBUG;
|
||||||
@@ -1520,21 +1528,23 @@ where
|
|||||||
log::Level::Info
|
log::Level::Info
|
||||||
};
|
};
|
||||||
|
|
||||||
log!(target: "babe",
|
log!(
|
||||||
log_level,
|
target: LOG_TARGET,
|
||||||
"👶 New epoch {} launching at block {} (block slot {} >= start slot {}).",
|
log_level,
|
||||||
viable_epoch.as_ref().epoch_index,
|
"👶 New epoch {} launching at block {} (block slot {} >= start slot {}).",
|
||||||
hash,
|
viable_epoch.as_ref().epoch_index,
|
||||||
slot,
|
hash,
|
||||||
viable_epoch.as_ref().start_slot,
|
slot,
|
||||||
|
viable_epoch.as_ref().start_slot,
|
||||||
);
|
);
|
||||||
|
|
||||||
let next_epoch = viable_epoch.increment((next_epoch_descriptor, epoch_config));
|
let next_epoch = viable_epoch.increment((next_epoch_descriptor, epoch_config));
|
||||||
|
|
||||||
log!(target: "babe",
|
log!(
|
||||||
log_level,
|
target: LOG_TARGET,
|
||||||
"👶 Next epoch starts at slot {}",
|
log_level,
|
||||||
next_epoch.as_ref().start_slot,
|
"👶 Next epoch starts at slot {}",
|
||||||
|
next_epoch.as_ref().start_slot,
|
||||||
);
|
);
|
||||||
|
|
||||||
// prune the tree of epochs not part of the finalized chain or
|
// prune the tree of epochs not part of the finalized chain or
|
||||||
@@ -1565,7 +1575,7 @@ where
|
|||||||
};
|
};
|
||||||
|
|
||||||
if let Err(e) = prune_and_import() {
|
if let Err(e) = prune_and_import() {
|
||||||
debug!(target: "babe", "Failed to launch next epoch: {}", e);
|
debug!(target: LOG_TARGET, "Failed to launch next epoch: {}", e);
|
||||||
*epoch_changes =
|
*epoch_changes =
|
||||||
old_epoch_changes.expect("set `Some` above and not taken; qed");
|
old_epoch_changes.expect("set `Some` above and not taken; qed");
|
||||||
return Err(e)
|
return Err(e)
|
||||||
|
|||||||
@@ -323,7 +323,7 @@ impl TestNetFactory for BabeTestNet {
|
|||||||
use substrate_test_runtime_client::DefaultTestClientBuilderExt;
|
use substrate_test_runtime_client::DefaultTestClientBuilderExt;
|
||||||
|
|
||||||
let client = client.as_client();
|
let client = client.as_client();
|
||||||
trace!(target: "babe", "Creating a verifier");
|
trace!(target: LOG_TARGET, "Creating a verifier");
|
||||||
|
|
||||||
// ensure block import and verifier are linked correctly.
|
// ensure block import and verifier are linked correctly.
|
||||||
let data = maybe_link
|
let data = maybe_link
|
||||||
@@ -352,12 +352,12 @@ impl TestNetFactory for BabeTestNet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn peer(&mut self, i: usize) -> &mut BabePeer {
|
fn peer(&mut self, i: usize) -> &mut BabePeer {
|
||||||
trace!(target: "babe", "Retrieving a peer");
|
trace!(target: LOG_TARGET, "Retrieving a peer");
|
||||||
&mut self.peers[i]
|
&mut self.peers[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn peers(&self) -> &Vec<BabePeer> {
|
fn peers(&self) -> &Vec<BabePeer> {
|
||||||
trace!(target: "babe", "Retrieving peers");
|
trace!(target: LOG_TARGET, "Retrieving peers");
|
||||||
&self.peers
|
&self.peers
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -583,7 +583,7 @@ fn can_author_block() {
|
|||||||
// with secondary slots enabled it should never be empty
|
// with secondary slots enabled it should never be empty
|
||||||
match claim_slot(i.into(), &epoch, &keystore) {
|
match claim_slot(i.into(), &epoch, &keystore) {
|
||||||
None => i += 1,
|
None => i += 1,
|
||||||
Some(s) => debug!(target: "babe", "Authored block {:?}", s.0),
|
Some(s) => debug!(target: LOG_TARGET, "Authored block {:?}", s.0),
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise with only vrf-based primary slots we might need to try a couple
|
// otherwise with only vrf-based primary slots we might need to try a couple
|
||||||
@@ -593,7 +593,7 @@ fn can_author_block() {
|
|||||||
match claim_slot(i.into(), &epoch, &keystore) {
|
match claim_slot(i.into(), &epoch, &keystore) {
|
||||||
None => i += 1,
|
None => i += 1,
|
||||||
Some(s) => {
|
Some(s) => {
|
||||||
debug!(target: "babe", "Authored block {:?}", s.0);
|
debug!(target: LOG_TARGET, "Authored block {:?}", s.0);
|
||||||
break
|
break
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,9 +17,9 @@
|
|||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
//! Verification for BABE headers.
|
//! Verification for BABE headers.
|
||||||
use super::{
|
use crate::{
|
||||||
authorship::{calculate_primary_threshold, check_primary_threshold, secondary_slot_author},
|
authorship::{calculate_primary_threshold, check_primary_threshold, secondary_slot_author},
|
||||||
babe_err, find_pre_digest, BlockT, Epoch, Error,
|
babe_err, find_pre_digest, BlockT, Epoch, Error, LOG_TARGET,
|
||||||
};
|
};
|
||||||
use log::{debug, trace};
|
use log::{debug, trace};
|
||||||
use sc_consensus_slots::CheckedHeader;
|
use sc_consensus_slots::CheckedHeader;
|
||||||
@@ -67,7 +67,7 @@ pub(super) fn check_header<B: BlockT + Sized>(
|
|||||||
let authorities = &epoch.authorities;
|
let authorities = &epoch.authorities;
|
||||||
let pre_digest = pre_digest.map(Ok).unwrap_or_else(|| find_pre_digest::<B>(&header))?;
|
let pre_digest = pre_digest.map(Ok).unwrap_or_else(|| find_pre_digest::<B>(&header))?;
|
||||||
|
|
||||||
trace!(target: "babe", "Checking header");
|
trace!(target: LOG_TARGET, "Checking header");
|
||||||
let seal = header
|
let seal = header
|
||||||
.digest_mut()
|
.digest_mut()
|
||||||
.pop()
|
.pop()
|
||||||
@@ -93,7 +93,8 @@ pub(super) fn check_header<B: BlockT + Sized>(
|
|||||||
|
|
||||||
match &pre_digest {
|
match &pre_digest {
|
||||||
PreDigest::Primary(primary) => {
|
PreDigest::Primary(primary) => {
|
||||||
debug!(target: "babe",
|
debug!(
|
||||||
|
target: LOG_TARGET,
|
||||||
"Verifying primary block #{} at slot: {}",
|
"Verifying primary block #{} at slot: {}",
|
||||||
header.number(),
|
header.number(),
|
||||||
primary.slot,
|
primary.slot,
|
||||||
@@ -104,7 +105,8 @@ pub(super) fn check_header<B: BlockT + Sized>(
|
|||||||
PreDigest::SecondaryPlain(secondary)
|
PreDigest::SecondaryPlain(secondary)
|
||||||
if epoch.config.allowed_slots.is_secondary_plain_slots_allowed() =>
|
if epoch.config.allowed_slots.is_secondary_plain_slots_allowed() =>
|
||||||
{
|
{
|
||||||
debug!(target: "babe",
|
debug!(
|
||||||
|
target: LOG_TARGET,
|
||||||
"Verifying secondary plain block #{} at slot: {}",
|
"Verifying secondary plain block #{} at slot: {}",
|
||||||
header.number(),
|
header.number(),
|
||||||
secondary.slot,
|
secondary.slot,
|
||||||
@@ -115,7 +117,8 @@ pub(super) fn check_header<B: BlockT + Sized>(
|
|||||||
PreDigest::SecondaryVRF(secondary)
|
PreDigest::SecondaryVRF(secondary)
|
||||||
if epoch.config.allowed_slots.is_secondary_vrf_slots_allowed() =>
|
if epoch.config.allowed_slots.is_secondary_vrf_slots_allowed() =>
|
||||||
{
|
{
|
||||||
debug!(target: "babe",
|
debug!(
|
||||||
|
target: LOG_TARGET,
|
||||||
"Verifying secondary VRF block #{} at slot: {}",
|
"Verifying secondary VRF block #{} at slot: {}",
|
||||||
header.number(),
|
header.number(),
|
||||||
secondary.slot,
|
secondary.slot,
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ use crate::{
|
|||||||
pub use basic_queue::BasicQueue;
|
pub use basic_queue::BasicQueue;
|
||||||
use sp_consensus::{error::Error as ConsensusError, BlockOrigin, CacheKeyId};
|
use sp_consensus::{error::Error as ConsensusError, BlockOrigin, CacheKeyId};
|
||||||
|
|
||||||
|
const LOG_TARGET: &str = "sync::import-queue";
|
||||||
|
|
||||||
/// A commonly-used Import Queue type.
|
/// A commonly-used Import Queue type.
|
||||||
///
|
///
|
||||||
/// This defines the transaction type of the `BasicQueue` to be the transaction type for a client.
|
/// This defines the transaction type of the `BasicQueue` to be the transaction type for a client.
|
||||||
@@ -247,15 +249,15 @@ pub(crate) async fn import_single_block_metered<
|
|||||||
(Some(header), justifications) => (header, justifications),
|
(Some(header), justifications) => (header, justifications),
|
||||||
(None, _) => {
|
(None, _) => {
|
||||||
if let Some(ref peer) = peer {
|
if let Some(ref peer) = peer {
|
||||||
debug!(target: "sync", "Header {} was not provided by {} ", block.hash, peer);
|
debug!(target: LOG_TARGET, "Header {} was not provided by {} ", block.hash, peer);
|
||||||
} else {
|
} else {
|
||||||
debug!(target: "sync", "Header {} was not provided ", block.hash);
|
debug!(target: LOG_TARGET, "Header {} was not provided ", block.hash);
|
||||||
}
|
}
|
||||||
return Err(BlockImportError::IncompleteHeader(peer))
|
return Err(BlockImportError::IncompleteHeader(peer))
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
trace!(target: "sync", "Header {} has {:?} logs", block.hash, header.digest().logs().len());
|
trace!(target: LOG_TARGET, "Header {} has {:?} logs", block.hash, header.digest().logs().len());
|
||||||
|
|
||||||
let number = *header.number();
|
let number = *header.number();
|
||||||
let hash = block.hash;
|
let hash = block.hash;
|
||||||
@@ -263,27 +265,31 @@ pub(crate) async fn import_single_block_metered<
|
|||||||
|
|
||||||
let import_handler = |import| match import {
|
let import_handler = |import| match import {
|
||||||
Ok(ImportResult::AlreadyInChain) => {
|
Ok(ImportResult::AlreadyInChain) => {
|
||||||
trace!(target: "sync", "Block already in chain {}: {:?}", number, hash);
|
trace!(target: LOG_TARGET, "Block already in chain {}: {:?}", number, hash);
|
||||||
Ok(BlockImportStatus::ImportedKnown(number, peer))
|
Ok(BlockImportStatus::ImportedKnown(number, peer))
|
||||||
},
|
},
|
||||||
Ok(ImportResult::Imported(aux)) =>
|
Ok(ImportResult::Imported(aux)) =>
|
||||||
Ok(BlockImportStatus::ImportedUnknown(number, aux, peer)),
|
Ok(BlockImportStatus::ImportedUnknown(number, aux, peer)),
|
||||||
Ok(ImportResult::MissingState) => {
|
Ok(ImportResult::MissingState) => {
|
||||||
debug!(target: "sync", "Parent state is missing for {}: {:?}, parent: {:?}",
|
debug!(
|
||||||
number, hash, parent_hash);
|
target: LOG_TARGET,
|
||||||
|
"Parent state is missing for {}: {:?}, parent: {:?}", number, hash, parent_hash
|
||||||
|
);
|
||||||
Err(BlockImportError::MissingState)
|
Err(BlockImportError::MissingState)
|
||||||
},
|
},
|
||||||
Ok(ImportResult::UnknownParent) => {
|
Ok(ImportResult::UnknownParent) => {
|
||||||
debug!(target: "sync", "Block with unknown parent {}: {:?}, parent: {:?}",
|
debug!(
|
||||||
number, hash, parent_hash);
|
target: LOG_TARGET,
|
||||||
|
"Block with unknown parent {}: {:?}, parent: {:?}", number, hash, parent_hash
|
||||||
|
);
|
||||||
Err(BlockImportError::UnknownParent)
|
Err(BlockImportError::UnknownParent)
|
||||||
},
|
},
|
||||||
Ok(ImportResult::KnownBad) => {
|
Ok(ImportResult::KnownBad) => {
|
||||||
debug!(target: "sync", "Peer gave us a bad block {}: {:?}", number, hash);
|
debug!(target: LOG_TARGET, "Peer gave us a bad block {}: {:?}", number, hash);
|
||||||
Err(BlockImportError::BadBlock(peer))
|
Err(BlockImportError::BadBlock(peer))
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
debug!(target: "sync", "Error importing block {}: {:?}: {}", number, hash, e);
|
debug!(target: LOG_TARGET, "Error importing block {}: {:?}: {}", number, hash, e);
|
||||||
Err(BlockImportError::Other(e))
|
Err(BlockImportError::Other(e))
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -324,9 +330,16 @@ pub(crate) async fn import_single_block_metered<
|
|||||||
|
|
||||||
let (import_block, maybe_keys) = verifier.verify(import_block).await.map_err(|msg| {
|
let (import_block, maybe_keys) = verifier.verify(import_block).await.map_err(|msg| {
|
||||||
if let Some(ref peer) = peer {
|
if let Some(ref peer) = peer {
|
||||||
trace!(target: "sync", "Verifying {}({}) from {} failed: {}", number, hash, peer, msg);
|
trace!(
|
||||||
|
target: LOG_TARGET,
|
||||||
|
"Verifying {}({}) from {} failed: {}",
|
||||||
|
number,
|
||||||
|
hash,
|
||||||
|
peer,
|
||||||
|
msg
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
trace!(target: "sync", "Verifying {}({}) failed: {}", number, hash, msg);
|
trace!(target: LOG_TARGET, "Verifying {}({}) failed: {}", number, hash, msg);
|
||||||
}
|
}
|
||||||
if let Some(metrics) = metrics.as_ref() {
|
if let Some(metrics) = metrics.as_ref() {
|
||||||
metrics.report_verification(false, started.elapsed());
|
metrics.report_verification(false, started.elapsed());
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ use crate::{
|
|||||||
buffered_link::{self, BufferedLinkReceiver, BufferedLinkSender},
|
buffered_link::{self, BufferedLinkReceiver, BufferedLinkSender},
|
||||||
import_single_block_metered, BlockImportError, BlockImportStatus, BoxBlockImport,
|
import_single_block_metered, BlockImportError, BlockImportStatus, BoxBlockImport,
|
||||||
BoxJustificationImport, ImportQueue, ImportQueueService, IncomingBlock, Link,
|
BoxJustificationImport, ImportQueue, ImportQueueService, IncomingBlock, Link,
|
||||||
RuntimeOrigin, Verifier,
|
RuntimeOrigin, Verifier, LOG_TARGET,
|
||||||
},
|
},
|
||||||
metrics::Metrics,
|
metrics::Metrics,
|
||||||
};
|
};
|
||||||
@@ -129,14 +129,14 @@ impl<B: BlockT> ImportQueueService<B> for BasicQueueHandle<B> {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
trace!(target: "sync", "Scheduling {} blocks for import", blocks.len());
|
trace!(target: LOG_TARGET, "Scheduling {} blocks for import", blocks.len());
|
||||||
let res = self
|
let res = self
|
||||||
.block_import_sender
|
.block_import_sender
|
||||||
.unbounded_send(worker_messages::ImportBlocks(origin, blocks));
|
.unbounded_send(worker_messages::ImportBlocks(origin, blocks));
|
||||||
|
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
log::error!(
|
log::error!(
|
||||||
target: "sync",
|
target: LOG_TARGET,
|
||||||
"import_blocks: Background import task is no longer alive"
|
"import_blocks: Background import task is no longer alive"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -156,7 +156,7 @@ impl<B: BlockT> ImportQueueService<B> for BasicQueueHandle<B> {
|
|||||||
|
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
log::error!(
|
log::error!(
|
||||||
target: "sync",
|
target: LOG_TARGET,
|
||||||
"import_justification: Background import task is no longer alive"
|
"import_justification: Background import task is no longer alive"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -179,7 +179,10 @@ impl<B: BlockT, Transaction: Send> ImportQueue<B> for BasicQueue<B, Transaction>
|
|||||||
/// Poll actions from network.
|
/// Poll actions from network.
|
||||||
fn poll_actions(&mut self, cx: &mut Context, link: &mut dyn Link<B>) {
|
fn poll_actions(&mut self, cx: &mut Context, link: &mut dyn Link<B>) {
|
||||||
if self.result_port.poll_actions(cx, link).is_err() {
|
if self.result_port.poll_actions(cx, link).is_err() {
|
||||||
log::error!(target: "sync", "poll_actions: Background import task is no longer alive");
|
log::error!(
|
||||||
|
target: LOG_TARGET,
|
||||||
|
"poll_actions: Background import task is no longer alive"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,7 +234,7 @@ async fn block_import_process<B: BlockT, Transaction: Send + 'static>(
|
|||||||
Some(blocks) => blocks,
|
Some(blocks) => blocks,
|
||||||
None => {
|
None => {
|
||||||
log::debug!(
|
log::debug!(
|
||||||
target: "block-import",
|
target: LOG_TARGET,
|
||||||
"Stopping block import because the import channel was closed!",
|
"Stopping block import because the import channel was closed!",
|
||||||
);
|
);
|
||||||
return
|
return
|
||||||
@@ -305,7 +308,7 @@ impl<B: BlockT> BlockImportWorker<B> {
|
|||||||
// down and we should end this future.
|
// down and we should end this future.
|
||||||
if worker.result_sender.is_closed() {
|
if worker.result_sender.is_closed() {
|
||||||
log::debug!(
|
log::debug!(
|
||||||
target: "block-import",
|
target: LOG_TARGET,
|
||||||
"Stopping block import because result channel was closed!",
|
"Stopping block import because result channel was closed!",
|
||||||
);
|
);
|
||||||
return
|
return
|
||||||
@@ -318,7 +321,7 @@ impl<B: BlockT> BlockImportWorker<B> {
|
|||||||
worker.import_justification(who, hash, number, justification).await,
|
worker.import_justification(who, hash, number, justification).await,
|
||||||
None => {
|
None => {
|
||||||
log::debug!(
|
log::debug!(
|
||||||
target: "block-import",
|
target: LOG_TARGET,
|
||||||
"Stopping block import because justification channel was closed!",
|
"Stopping block import because justification channel was closed!",
|
||||||
);
|
);
|
||||||
return
|
return
|
||||||
@@ -353,7 +356,7 @@ impl<B: BlockT> BlockImportWorker<B> {
|
|||||||
.await
|
.await
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
debug!(
|
debug!(
|
||||||
target: "sync",
|
target: LOG_TARGET,
|
||||||
"Justification import failed for hash = {:?} with number = {:?} coming from node = {:?} with error: {}",
|
"Justification import failed for hash = {:?} with number = {:?} coming from node = {:?} with error: {}",
|
||||||
hash,
|
hash,
|
||||||
number,
|
number,
|
||||||
@@ -407,7 +410,7 @@ async fn import_many_blocks<B: BlockT, V: Verifier<B>, Transaction: Send + 'stat
|
|||||||
_ => Default::default(),
|
_ => Default::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
trace!(target: "sync", "Starting import of {} blocks {}", count, blocks_range);
|
trace!(target: LOG_TARGET, "Starting import of {} blocks {}", count, blocks_range);
|
||||||
|
|
||||||
let mut imported = 0;
|
let mut imported = 0;
|
||||||
let mut results = vec![];
|
let mut results = vec![];
|
||||||
@@ -447,7 +450,7 @@ async fn import_many_blocks<B: BlockT, V: Verifier<B>, Transaction: Send + 'stat
|
|||||||
|
|
||||||
if import_result.is_ok() {
|
if import_result.is_ok() {
|
||||||
trace!(
|
trace!(
|
||||||
target: "sync",
|
target: LOG_TARGET,
|
||||||
"Block imported successfully {:?} ({})",
|
"Block imported successfully {:?} ({})",
|
||||||
block_number,
|
block_number,
|
||||||
block_hash,
|
block_hash,
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
//! that expect babe-specific digests.
|
//! that expect babe-specific digests.
|
||||||
|
|
||||||
use super::ConsensusDataProvider;
|
use super::ConsensusDataProvider;
|
||||||
use crate::Error;
|
use crate::{Error, LOG_TARGET};
|
||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
use sc_client_api::{AuxStore, UsageProvider};
|
use sc_client_api::{AuxStore, UsageProvider};
|
||||||
use sc_consensus_babe::{
|
use sc_consensus_babe::{
|
||||||
@@ -179,7 +179,7 @@ where
|
|||||||
let epoch = epoch_changes
|
let epoch = epoch_changes
|
||||||
.viable_epoch(&epoch_descriptor, |slot| Epoch::genesis(&self.config, slot))
|
.viable_epoch(&epoch_descriptor, |slot| Epoch::genesis(&self.config, slot))
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
log::info!(target: "babe", "create_digest: no viable_epoch :(");
|
log::info!(target: LOG_TARGET, "create_digest: no viable_epoch :(");
|
||||||
sp_consensus::Error::InvalidAuthoritiesSet
|
sp_consensus::Error::InvalidAuthoritiesSet
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@@ -290,7 +290,7 @@ where
|
|||||||
let has_authority = epoch.authorities.iter().any(|(id, _)| *id == *authority);
|
let has_authority = epoch.authorities.iter().any(|(id, _)| *id == *authority);
|
||||||
|
|
||||||
if !has_authority {
|
if !has_authority {
|
||||||
log::info!(target: "manual-seal", "authority not found");
|
log::info!(target: LOG_TARGET, "authority not found");
|
||||||
let timestamp = inherents
|
let timestamp = inherents
|
||||||
.timestamp_inherent_data()?
|
.timestamp_inherent_data()?
|
||||||
.ok_or_else(|| Error::StringError("No timestamp inherent data".into()))?;
|
.ok_or_else(|| Error::StringError("No timestamp inherent data".into()))?;
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ pub use self::{
|
|||||||
use sc_transaction_pool_api::TransactionPool;
|
use sc_transaction_pool_api::TransactionPool;
|
||||||
use sp_api::{ProvideRuntimeApi, TransactionFor};
|
use sp_api::{ProvideRuntimeApi, TransactionFor};
|
||||||
|
|
||||||
|
const LOG_TARGET: &str = "manual-seal";
|
||||||
|
|
||||||
/// The `ConsensusEngineId` of Manual Seal.
|
/// The `ConsensusEngineId` of Manual Seal.
|
||||||
pub const MANUAL_SEAL_ENGINE_ID: ConsensusEngineId = [b'm', b'a', b'n', b'l'];
|
pub const MANUAL_SEAL_ENGINE_ID: ConsensusEngineId = [b'm', b'a', b'n', b'l'];
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ use sp_runtime::{
|
|||||||
};
|
};
|
||||||
use std::{cmp::Ordering, collections::HashMap, marker::PhantomData, sync::Arc, time::Duration};
|
use std::{cmp::Ordering, collections::HashMap, marker::PhantomData, sync::Arc, time::Duration};
|
||||||
|
|
||||||
|
const LOG_TARGET: &str = "pow";
|
||||||
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum Error<B: BlockT> {
|
pub enum Error<B: BlockT> {
|
||||||
#[error("Header uses the wrong engine {0:?}")]
|
#[error("Header uses the wrong engine {0:?}")]
|
||||||
@@ -531,7 +533,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
if sync_oracle.is_major_syncing() {
|
if sync_oracle.is_major_syncing() {
|
||||||
debug!(target: "pow", "Skipping proposal due to sync.");
|
debug!(target: LOG_TARGET, "Skipping proposal due to sync.");
|
||||||
worker.on_major_syncing();
|
worker.on_major_syncing();
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -540,7 +542,7 @@ where
|
|||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!(
|
warn!(
|
||||||
target: "pow",
|
target: LOG_TARGET,
|
||||||
"Unable to pull new block for authoring. \
|
"Unable to pull new block for authoring. \
|
||||||
Select best chain error: {}",
|
Select best chain error: {}",
|
||||||
err
|
err
|
||||||
@@ -561,7 +563,7 @@ where
|
|||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!(
|
warn!(
|
||||||
target: "pow",
|
target: LOG_TARGET,
|
||||||
"Unable to propose new block for authoring. \
|
"Unable to propose new block for authoring. \
|
||||||
Fetch difficulty failed: {}",
|
Fetch difficulty failed: {}",
|
||||||
err,
|
err,
|
||||||
@@ -577,7 +579,7 @@ where
|
|||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!(
|
warn!(
|
||||||
target: "pow",
|
target: LOG_TARGET,
|
||||||
"Unable to propose new block for authoring. \
|
"Unable to propose new block for authoring. \
|
||||||
Creating inherent data providers failed: {}",
|
Creating inherent data providers failed: {}",
|
||||||
err,
|
err,
|
||||||
@@ -590,7 +592,7 @@ where
|
|||||||
Ok(r) => r,
|
Ok(r) => r,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
warn!(
|
warn!(
|
||||||
target: "pow",
|
target: LOG_TARGET,
|
||||||
"Unable to propose new block for authoring. \
|
"Unable to propose new block for authoring. \
|
||||||
Creating inherent data failed: {}",
|
Creating inherent data failed: {}",
|
||||||
e,
|
e,
|
||||||
@@ -610,7 +612,7 @@ where
|
|||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!(
|
warn!(
|
||||||
target: "pow",
|
target: LOG_TARGET,
|
||||||
"Unable to propose new block for authoring. \
|
"Unable to propose new block for authoring. \
|
||||||
Creating proposer failed: {:?}",
|
Creating proposer failed: {:?}",
|
||||||
err,
|
err,
|
||||||
@@ -624,7 +626,7 @@ where
|
|||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!(
|
warn!(
|
||||||
target: "pow",
|
target: LOG_TARGET,
|
||||||
"Unable to propose new block for authoring. \
|
"Unable to propose new block for authoring. \
|
||||||
Creating proposal failed: {}",
|
Creating proposal failed: {}",
|
||||||
err,
|
err,
|
||||||
@@ -654,14 +656,14 @@ where
|
|||||||
fn find_pre_digest<B: BlockT>(header: &B::Header) -> Result<Option<Vec<u8>>, Error<B>> {
|
fn find_pre_digest<B: BlockT>(header: &B::Header) -> Result<Option<Vec<u8>>, Error<B>> {
|
||||||
let mut pre_digest: Option<_> = None;
|
let mut pre_digest: Option<_> = None;
|
||||||
for log in header.digest().logs() {
|
for log in header.digest().logs() {
|
||||||
trace!(target: "pow", "Checking log {:?}, looking for pre runtime digest", log);
|
trace!(target: LOG_TARGET, "Checking log {:?}, looking for pre runtime digest", log);
|
||||||
match (log, pre_digest.is_some()) {
|
match (log, pre_digest.is_some()) {
|
||||||
(DigestItem::PreRuntime(POW_ENGINE_ID, _), true) =>
|
(DigestItem::PreRuntime(POW_ENGINE_ID, _), true) =>
|
||||||
return Err(Error::MultiplePreRuntimeDigests),
|
return Err(Error::MultiplePreRuntimeDigests),
|
||||||
(DigestItem::PreRuntime(POW_ENGINE_ID, v), false) => {
|
(DigestItem::PreRuntime(POW_ENGINE_ID, v), false) => {
|
||||||
pre_digest = Some(v.clone());
|
pre_digest = Some(v.clone());
|
||||||
},
|
},
|
||||||
(_, _) => trace!(target: "pow", "Ignoring digest not meant for us"),
|
(_, _) => trace!(target: LOG_TARGET, "Ignoring digest not meant for us"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ use std::{
|
|||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{PowAlgorithm, PowIntermediate, Seal, INTERMEDIATE_KEY, POW_ENGINE_ID};
|
use crate::{PowAlgorithm, PowIntermediate, Seal, INTERMEDIATE_KEY, LOG_TARGET, POW_ENGINE_ID};
|
||||||
|
|
||||||
/// Mining metadata. This is the information needed to start an actual mining loop.
|
/// Mining metadata. This is the information needed to start an actual mining loop.
|
||||||
#[derive(Clone, Eq, PartialEq)]
|
#[derive(Clone, Eq, PartialEq)]
|
||||||
@@ -159,26 +159,16 @@ where
|
|||||||
) {
|
) {
|
||||||
Ok(true) => (),
|
Ok(true) => (),
|
||||||
Ok(false) => {
|
Ok(false) => {
|
||||||
warn!(
|
warn!(target: LOG_TARGET, "Unable to import mined block: seal is invalid",);
|
||||||
target: "pow",
|
|
||||||
"Unable to import mined block: seal is invalid",
|
|
||||||
);
|
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!(
|
warn!(target: LOG_TARGET, "Unable to import mined block: {}", err,);
|
||||||
target: "pow",
|
|
||||||
"Unable to import mined block: {}",
|
|
||||||
err,
|
|
||||||
);
|
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
warn!(
|
warn!(target: LOG_TARGET, "Unable to import mined block: metadata does not exist",);
|
||||||
target: "pow",
|
|
||||||
"Unable to import mined block: metadata does not exist",
|
|
||||||
);
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,10 +182,7 @@ where
|
|||||||
} {
|
} {
|
||||||
build
|
build
|
||||||
} else {
|
} else {
|
||||||
warn!(
|
warn!(target: LOG_TARGET, "Unable to import mined block: build does not exist",);
|
||||||
target: "pow",
|
|
||||||
"Unable to import mined block: build does not exist",
|
|
||||||
);
|
|
||||||
return false
|
return false
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -225,18 +212,13 @@ where
|
|||||||
);
|
);
|
||||||
|
|
||||||
info!(
|
info!(
|
||||||
target: "pow",
|
target: LOG_TARGET,
|
||||||
"✅ Successfully mined block on top of: {}",
|
"✅ Successfully mined block on top of: {}", build.metadata.best_hash
|
||||||
build.metadata.best_hash
|
|
||||||
);
|
);
|
||||||
true
|
true
|
||||||
},
|
},
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!(
|
warn!(target: LOG_TARGET, "Unable to import mined block: {}", err,);
|
||||||
target: "pow",
|
|
||||||
"Unable to import mined block: {}",
|
|
||||||
err,
|
|
||||||
);
|
|
||||||
false
|
false
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ use std::{
|
|||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const LOG_TARGET: &str = "slots";
|
||||||
|
|
||||||
/// The changes that need to applied to the storage to create the state for a block.
|
/// The changes that need to applied to the storage to create the state for a block.
|
||||||
///
|
///
|
||||||
/// See [`sp_state_machine::StorageChanges`] for more information.
|
/// See [`sp_state_machine::StorageChanges`] for more information.
|
||||||
@@ -198,9 +200,9 @@ pub trait SimpleSlotWorker<B: BlockT> {
|
|||||||
> {
|
> {
|
||||||
let slot = slot_info.slot;
|
let slot = slot_info.slot;
|
||||||
let telemetry = self.telemetry();
|
let telemetry = self.telemetry();
|
||||||
let logging_target = self.logging_target();
|
let log_target = self.logging_target();
|
||||||
|
|
||||||
let inherent_data = Self::create_inherent_data(&slot_info, &logging_target).await?;
|
let inherent_data = Self::create_inherent_data(&slot_info, &log_target).await?;
|
||||||
|
|
||||||
let proposing_remaining_duration = self.proposing_remaining_duration(&slot_info);
|
let proposing_remaining_duration = self.proposing_remaining_duration(&slot_info);
|
||||||
let logs = self.pre_digest_data(slot, claim);
|
let logs = self.pre_digest_data(slot, claim);
|
||||||
@@ -220,19 +222,19 @@ pub trait SimpleSlotWorker<B: BlockT> {
|
|||||||
let proposal = match futures::future::select(proposing, proposing_remaining).await {
|
let proposal = match futures::future::select(proposing, proposing_remaining).await {
|
||||||
Either::Left((Ok(p), _)) => p,
|
Either::Left((Ok(p), _)) => p,
|
||||||
Either::Left((Err(err), _)) => {
|
Either::Left((Err(err), _)) => {
|
||||||
warn!(target: logging_target, "Proposing failed: {}", err);
|
warn!(target: log_target, "Proposing failed: {}", err);
|
||||||
|
|
||||||
return None
|
return None
|
||||||
},
|
},
|
||||||
Either::Right(_) => {
|
Either::Right(_) => {
|
||||||
info!(
|
info!(
|
||||||
target: logging_target,
|
target: log_target,
|
||||||
"⌛️ Discarding proposal for slot {}; block production took too long", slot,
|
"⌛️ Discarding proposal for slot {}; block production took too long", slot,
|
||||||
);
|
);
|
||||||
// If the node was compiled with debug, tell the user to use release optimizations.
|
// If the node was compiled with debug, tell the user to use release optimizations.
|
||||||
#[cfg(build_type = "debug")]
|
#[cfg(build_type = "debug")]
|
||||||
info!(
|
info!(
|
||||||
target: logging_target,
|
target: log_target,
|
||||||
"👉 Recompile your node in `--release` mode to mitigate this problem.",
|
"👉 Recompile your node in `--release` mode to mitigate this problem.",
|
||||||
);
|
);
|
||||||
telemetry!(
|
telemetry!(
|
||||||
@@ -525,13 +527,13 @@ pub async fn start_slot_worker<B, C, W, SO, CIDP, Proof>(
|
|||||||
let slot_info = match slots.next_slot().await {
|
let slot_info = match slots.next_slot().await {
|
||||||
Ok(r) => r,
|
Ok(r) => r,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
warn!(target: "slots", "Error while polling for next slot: {}", e);
|
warn!(target: LOG_TARGET, "Error while polling for next slot: {}", e);
|
||||||
return
|
return
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if sync_oracle.is_major_syncing() {
|
if sync_oracle.is_major_syncing() {
|
||||||
debug!(target: "slots", "Skipping proposal slot due to sync.");
|
debug!(target: LOG_TARGET, "Skipping proposal slot due to sync.");
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
//!
|
//!
|
||||||
//! This is used instead of `futures_timer::Interval` because it was unreliable.
|
//! This is used instead of `futures_timer::Interval` because it was unreliable.
|
||||||
|
|
||||||
use super::{InherentDataProviderExt, Slot};
|
use super::{InherentDataProviderExt, Slot, LOG_TARGET};
|
||||||
use sp_consensus::{Error, SelectChain};
|
use sp_consensus::{Error, SelectChain};
|
||||||
use sp_inherents::{CreateInherentDataProviders, InherentDataProvider};
|
use sp_inherents::{CreateInherentDataProviders, InherentDataProvider};
|
||||||
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
|
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
|
||||||
@@ -146,7 +146,7 @@ where
|
|||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::warn!(
|
log::warn!(
|
||||||
target: "slots",
|
target: LOG_TARGET,
|
||||||
"Unable to author block in slot. No best block header: {}",
|
"Unable to author block in slot. No best block header: {}",
|
||||||
e,
|
e,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ use sc_consensus::shared_data::{SharedData, SharedDataLocked};
|
|||||||
use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_INFO};
|
use sc_telemetry::{telemetry, TelemetryHandle, CONSENSUS_INFO};
|
||||||
use sp_finality_grandpa::{AuthorityId, AuthorityList};
|
use sp_finality_grandpa::{AuthorityId, AuthorityList};
|
||||||
|
|
||||||
use crate::SetId;
|
use crate::{SetId, LOG_TARGET};
|
||||||
|
|
||||||
/// Error type returned on operations on the `AuthoritySet`.
|
/// Error type returned on operations on the `AuthoritySet`.
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
@@ -314,7 +314,7 @@ where
|
|||||||
let number = pending.canon_height.clone();
|
let number = pending.canon_height.clone();
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
target: "afg",
|
target: LOG_TARGET,
|
||||||
"Inserting potential standard set change signaled at block {:?} (delayed by {:?} blocks).",
|
"Inserting potential standard set change signaled at block {:?} (delayed by {:?} blocks).",
|
||||||
(&number, &hash),
|
(&number, &hash),
|
||||||
pending.delay,
|
pending.delay,
|
||||||
@@ -323,7 +323,7 @@ where
|
|||||||
self.pending_standard_changes.import(hash, number, pending, is_descendent_of)?;
|
self.pending_standard_changes.import(hash, number, pending, is_descendent_of)?;
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
target: "afg",
|
target: LOG_TARGET,
|
||||||
"There are now {} alternatives for the next pending standard change (roots), and a \
|
"There are now {} alternatives for the next pending standard change (roots), and a \
|
||||||
total of {} pending standard changes (across all forks).",
|
total of {} pending standard changes (across all forks).",
|
||||||
self.pending_standard_changes.roots().count(),
|
self.pending_standard_changes.roots().count(),
|
||||||
@@ -362,7 +362,7 @@ where
|
|||||||
.unwrap_or_else(|i| i);
|
.unwrap_or_else(|i| i);
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
target: "afg",
|
target: LOG_TARGET,
|
||||||
"Inserting potential forced set change at block {:?} (delayed by {:?} blocks).",
|
"Inserting potential forced set change at block {:?} (delayed by {:?} blocks).",
|
||||||
(&pending.canon_height, &pending.canon_hash),
|
(&pending.canon_height, &pending.canon_hash),
|
||||||
pending.delay,
|
pending.delay,
|
||||||
@@ -370,7 +370,11 @@ where
|
|||||||
|
|
||||||
self.pending_forced_changes.insert(idx, pending);
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -475,7 +479,7 @@ where
|
|||||||
if standard_change.effective_number() <= median_last_finalized &&
|
if standard_change.effective_number() <= median_last_finalized &&
|
||||||
is_descendent_of(&standard_change.canon_hash, &change.canon_hash)?
|
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 #{:?}",
|
"Not applying authority set change forced at block #{:?}, due to pending standard change at block #{:?}",
|
||||||
change.canon_height,
|
change.canon_height,
|
||||||
standard_change.effective_number(),
|
standard_change.effective_number(),
|
||||||
@@ -488,7 +492,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
// apply this change: make the set canonical
|
// apply this change: make the set canonical
|
||||||
afg_log!(
|
grandpa_log!(
|
||||||
initial_sync,
|
initial_sync,
|
||||||
"👴 Applying authority set change forced at block #{:?}",
|
"👴 Applying authority set change forced at block #{:?}",
|
||||||
change.canon_height,
|
change.canon_height,
|
||||||
@@ -570,7 +574,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(change) = change {
|
if let Some(change) = change {
|
||||||
afg_log!(
|
grandpa_log!(
|
||||||
initial_sync,
|
initial_sync,
|
||||||
"👴 Applying authority set change scheduled at block #{:?}",
|
"👴 Applying authority set change scheduled at block #{:?}",
|
||||||
change.canon_height,
|
change.canon_height,
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ use crate::{
|
|||||||
CompletedRound, CompletedRounds, CurrentRounds, HasVoted, SharedVoterSetState,
|
CompletedRound, CompletedRounds, CurrentRounds, HasVoted, SharedVoterSetState,
|
||||||
VoterSetState,
|
VoterSetState,
|
||||||
},
|
},
|
||||||
GrandpaJustification, NewAuthoritySet,
|
GrandpaJustification, NewAuthoritySet, LOG_TARGET,
|
||||||
};
|
};
|
||||||
|
|
||||||
const VERSION_KEY: &[u8] = b"grandpa_schema_version";
|
const VERSION_KEY: &[u8] = b"grandpa_schema_version";
|
||||||
@@ -100,8 +100,8 @@ where
|
|||||||
// previously we only supported at most one pending change per fork
|
// previously we only supported at most one pending change per fork
|
||||||
&|_, _| Ok(false),
|
&|_, _| Ok(false),
|
||||||
) {
|
) {
|
||||||
warn!(target: "afg", "Error migrating pending authority set change: {}", err);
|
warn!(target: LOG_TARGET, "Error migrating pending authority set change: {}", err);
|
||||||
warn!(target: "afg", "Node is in a potentially inconsistent state.");
|
warn!(target: LOG_TARGET, "Node is in a potentially inconsistent state.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,8 +384,11 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
// genesis.
|
// genesis.
|
||||||
info!(target: "afg", "👴 Loading GRANDPA authority set \
|
info!(
|
||||||
from genesis on what appears to be first startup.");
|
target: LOG_TARGET,
|
||||||
|
"👴 Loading GRANDPA authority set \
|
||||||
|
from genesis on what appears to be first startup."
|
||||||
|
);
|
||||||
|
|
||||||
let genesis_authorities = genesis_authorities()?;
|
let genesis_authorities = genesis_authorities()?;
|
||||||
let genesis_set = AuthoritySet::genesis(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 sp_runtime::traits::{Block as BlockT, NumberFor, Zero};
|
||||||
|
|
||||||
use super::{benefit, cost, Round, SetId, NEIGHBOR_REBROADCAST_PERIOD};
|
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::{
|
use std::{
|
||||||
collections::{HashSet, VecDeque},
|
collections::{HashSet, VecDeque},
|
||||||
@@ -578,8 +578,13 @@ impl<N: Ord> Peers<N> {
|
|||||||
last_update: Some(now),
|
last_update: Some(now),
|
||||||
};
|
};
|
||||||
|
|
||||||
trace!(target: "afg", "Peer {} updated view. Now at {:?}, {:?}",
|
trace!(
|
||||||
who, peer.view.round, peer.view.set_id);
|
target: LOG_TARGET,
|
||||||
|
"Peer {} updated view. Now at {:?}, {:?}",
|
||||||
|
who,
|
||||||
|
peer.view.round,
|
||||||
|
peer.view.set_id
|
||||||
|
);
|
||||||
|
|
||||||
Ok(Some(&peer.view))
|
Ok(Some(&peer.view))
|
||||||
}
|
}
|
||||||
@@ -801,8 +806,12 @@ impl<Block: BlockT> Inner<Block> {
|
|||||||
|
|
||||||
let set_id = local_view.set_id;
|
let set_id = local_view.set_id;
|
||||||
|
|
||||||
debug!(target: "afg", "Voter {} noting beginning of round {:?} to network.",
|
debug!(
|
||||||
self.config.name(), (round, set_id));
|
target: LOG_TARGET,
|
||||||
|
"Voter {} noting beginning of round {:?} to network.",
|
||||||
|
self.config.name(),
|
||||||
|
(round, set_id)
|
||||||
|
);
|
||||||
|
|
||||||
local_view.update_round(round);
|
local_view.update_round(round);
|
||||||
|
|
||||||
@@ -824,7 +833,7 @@ impl<Block: BlockT> Inner<Block> {
|
|||||||
authorities.iter().collect::<HashSet<_>>();
|
authorities.iter().collect::<HashSet<_>>();
|
||||||
|
|
||||||
if diff_authorities {
|
if diff_authorities {
|
||||||
debug!(target: "afg",
|
debug!(target: LOG_TARGET,
|
||||||
"Gossip validator noted set {:?} twice with different authorities. \
|
"Gossip validator noted set {:?} twice with different authorities. \
|
||||||
Was the authority set hard forked?",
|
Was the authority set hard forked?",
|
||||||
set_id,
|
set_id,
|
||||||
@@ -912,7 +921,7 @@ impl<Block: BlockT> Inner<Block> {
|
|||||||
|
|
||||||
// ensure authority is part of the set.
|
// ensure authority is part of the set.
|
||||||
if !self.authorities.contains(&full.message.id) {
|
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!(
|
telemetry!(
|
||||||
self.config.telemetry;
|
self.config.telemetry;
|
||||||
CONSENSUS_DEBUG;
|
CONSENSUS_DEBUG;
|
||||||
@@ -929,7 +938,7 @@ impl<Block: BlockT> Inner<Block> {
|
|||||||
full.round.0,
|
full.round.0,
|
||||||
full.set_id.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!(
|
telemetry!(
|
||||||
self.config.telemetry;
|
self.config.telemetry;
|
||||||
CONSENSUS_DEBUG;
|
CONSENSUS_DEBUG;
|
||||||
@@ -964,7 +973,7 @@ impl<Block: BlockT> Inner<Block> {
|
|||||||
if full.message.precommits.len() != full.message.auth_data.len() ||
|
if full.message.precommits.len() != full.message.auth_data.len() ||
|
||||||
full.message.precommits.is_empty()
|
full.message.precommits.is_empty()
|
||||||
{
|
{
|
||||||
debug!(target: "afg", "Malformed compact commit");
|
debug!(target: LOG_TARGET, "Malformed compact commit");
|
||||||
telemetry!(
|
telemetry!(
|
||||||
self.config.telemetry;
|
self.config.telemetry;
|
||||||
CONSENSUS_DEBUG;
|
CONSENSUS_DEBUG;
|
||||||
@@ -1023,9 +1032,9 @@ impl<Block: BlockT> Inner<Block> {
|
|||||||
PendingCatchUp::Processing { .. } => {
|
PendingCatchUp::Processing { .. } => {
|
||||||
self.pending_catch_up = PendingCatchUp::None;
|
self.pending_catch_up = PendingCatchUp::None;
|
||||||
},
|
},
|
||||||
state => debug!(target: "afg",
|
state => debug!(
|
||||||
"Noted processed catch up message when state was: {:?}",
|
target: LOG_TARGET,
|
||||||
state,
|
"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()))
|
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,
|
request.round.0,
|
||||||
who,
|
who,
|
||||||
last_completed_round.number,
|
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);
|
let (catch_up_allowed, catch_up_report) = self.note_catch_up_request(who, &request);
|
||||||
|
|
||||||
if catch_up_allowed {
|
if catch_up_allowed {
|
||||||
debug!(target: "afg", "Sending catch-up request for round {} to {}",
|
debug!(
|
||||||
round,
|
target: LOG_TARGET,
|
||||||
who,
|
"Sending catch-up request for round {} to {}", round, who,
|
||||||
);
|
);
|
||||||
|
|
||||||
catch_up = Some(GossipMessage::<Block>::CatchUpRequest(request));
|
catch_up = Some(GossipMessage::<Block>::CatchUpRequest(request));
|
||||||
@@ -1347,7 +1358,7 @@ impl<Block: BlockT> GossipValidator<Block> {
|
|||||||
let metrics = match prometheus_registry.map(Metrics::register) {
|
let metrics = match prometheus_registry.map(Metrics::register) {
|
||||||
Some(Ok(metrics)) => Some(metrics),
|
Some(Ok(metrics)) => Some(metrics),
|
||||||
Some(Err(e)) => {
|
Some(Err(e)) => {
|
||||||
debug!(target: "afg", "Failed to register metrics: {:?}", e);
|
debug!(target: LOG_TARGET, "Failed to register metrics: {:?}", e);
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
None => None,
|
None => None,
|
||||||
@@ -1466,7 +1477,7 @@ impl<Block: BlockT> GossipValidator<Block> {
|
|||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
message_name = None;
|
message_name = None;
|
||||||
debug!(target: "afg", "Error decoding message: {}", e);
|
debug!(target: LOG_TARGET, "Error decoding message: {}", e);
|
||||||
telemetry!(
|
telemetry!(
|
||||||
self.telemetry;
|
self.telemetry;
|
||||||
CONSENSUS_DEBUG;
|
CONSENSUS_DEBUG;
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT, Numb
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
environment::HasVoted, CatchUp, Commit, CommunicationIn, CommunicationOutH, CompactCommit,
|
environment::HasVoted, CatchUp, Commit, CommunicationIn, CommunicationOutH, CompactCommit,
|
||||||
Error, Message, SignedMessage,
|
Error, Message, SignedMessage, LOG_TARGET,
|
||||||
};
|
};
|
||||||
use gossip::{
|
use gossip::{
|
||||||
FullCatchUpMessage, FullCommitMessage, GossipMessage, GossipValidator, PeerReport, VoteMessage,
|
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());
|
gossip_engine.lock().register_gossip_message(topic, message.encode());
|
||||||
}
|
}
|
||||||
|
|
||||||
trace!(target: "afg",
|
trace!(
|
||||||
|
target: LOG_TARGET,
|
||||||
"Registered {} messages for topic {:?} (round: {}, set_id: {})",
|
"Registered {} messages for topic {:?} (round: {}, set_id: {})",
|
||||||
round.votes.len(),
|
round.votes.len(),
|
||||||
topic,
|
topic,
|
||||||
@@ -340,13 +341,19 @@ impl<B: BlockT, N: Network<B>> NetworkBridge<B, N> {
|
|||||||
|
|
||||||
match decoded {
|
match decoded {
|
||||||
Err(ref e) => {
|
Err(ref e) => {
|
||||||
debug!(target: "afg", "Skipping malformed message {:?}: {}", notification, e);
|
debug!(
|
||||||
|
target: LOG_TARGET,
|
||||||
|
"Skipping malformed message {:?}: {}", notification, e
|
||||||
|
);
|
||||||
future::ready(None)
|
future::ready(None)
|
||||||
},
|
},
|
||||||
Ok(GossipMessage::Vote(msg)) => {
|
Ok(GossipMessage::Vote(msg)) => {
|
||||||
// check signature.
|
// check signature.
|
||||||
if !voters.contains(&msg.message.id) {
|
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)
|
return future::ready(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,7 +395,7 @@ impl<B: BlockT, N: Network<B>> NetworkBridge<B, N> {
|
|||||||
future::ready(Some(msg.message))
|
future::ready(Some(msg.message))
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
debug!(target: "afg", "Skipping unknown message type");
|
debug!(target: LOG_TARGET, "Skipping unknown message type");
|
||||||
future::ready(None)
|
future::ready(None)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -631,7 +638,12 @@ fn incoming_global<B: BlockT>(
|
|||||||
// this could be optimized by decoding piecewise.
|
// this could be optimized by decoding piecewise.
|
||||||
let decoded = GossipMessage::<B>::decode(&mut ¬ification.message[..]);
|
let decoded = GossipMessage::<B>::decode(&mut ¬ification.message[..]);
|
||||||
if let Err(ref e) = decoded {
|
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())
|
future::ready(decoded.map(move |d| (notification, d)).ok())
|
||||||
})
|
})
|
||||||
@@ -642,7 +654,7 @@ fn incoming_global<B: BlockT>(
|
|||||||
GossipMessage::CatchUp(msg) =>
|
GossipMessage::CatchUp(msg) =>
|
||||||
process_catch_up(msg, notification, &gossip_engine, &gossip_validator, &voters),
|
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
|
None
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -748,7 +760,7 @@ impl<Block: BlockT> Sink<Message<Block::Header>> for OutgoingMessages<Block> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
debug!(
|
debug!(
|
||||||
target: "afg",
|
target: LOG_TARGET,
|
||||||
"Announcing block {} to peers which we voted on in round {} in set {}",
|
"Announcing block {} to peers which we voted on in round {} in set {}",
|
||||||
target_hash,
|
target_hash,
|
||||||
self.round,
|
self.round,
|
||||||
@@ -813,7 +825,7 @@ fn check_compact_commit<Block: BlockT>(
|
|||||||
return Err(cost::MALFORMED_COMMIT)
|
return Err(cost::MALFORMED_COMMIT)
|
||||||
}
|
}
|
||||||
} else {
|
} 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)
|
return Err(cost::MALFORMED_COMMIT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -838,7 +850,7 @@ fn check_compact_commit<Block: BlockT>(
|
|||||||
set_id.0,
|
set_id.0,
|
||||||
&mut buf,
|
&mut buf,
|
||||||
) {
|
) {
|
||||||
debug!(target: "afg", "Bad commit message signature {}", id);
|
debug!(target: LOG_TARGET, "Bad commit message signature {}", id);
|
||||||
telemetry!(
|
telemetry!(
|
||||||
telemetry;
|
telemetry;
|
||||||
CONSENSUS_DEBUG;
|
CONSENSUS_DEBUG;
|
||||||
@@ -886,7 +898,10 @@ fn check_catch_up<Block: BlockT>(
|
|||||||
return Err(cost::MALFORMED_CATCH_UP)
|
return Err(cost::MALFORMED_CATCH_UP)
|
||||||
}
|
}
|
||||||
} else {
|
} 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)
|
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(
|
if !sp_finality_grandpa::check_message_signature_with_buffer(
|
||||||
&msg, id, sig, round, set_id, buf,
|
&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!(
|
||||||
telemetry;
|
telemetry;
|
||||||
CONSENSUS_DEBUG;
|
CONSENSUS_DEBUG;
|
||||||
|
|||||||
@@ -21,17 +21,19 @@
|
|||||||
use futures::{future::FutureExt as _, prelude::*, ready, stream::Stream};
|
use futures::{future::FutureExt as _, prelude::*, ready, stream::Stream};
|
||||||
use futures_timer::Delay;
|
use futures_timer::Delay;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender};
|
|
||||||
use std::{
|
use std::{
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
task::{Context, Poll},
|
task::{Context, Poll},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::gossip::{GossipMessage, NeighborPacket};
|
|
||||||
use sc_network::PeerId;
|
use sc_network::PeerId;
|
||||||
|
use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender};
|
||||||
use sp_runtime::traits::{Block as BlockT, NumberFor};
|
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.
|
/// A sender used to send neighbor packets to a background job.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub(super) struct NeighborPacketSender<B: BlockT>(
|
pub(super) struct NeighborPacketSender<B: BlockT>(
|
||||||
@@ -46,7 +48,7 @@ impl<B: BlockT> NeighborPacketSender<B> {
|
|||||||
neighbor_packet: NeighborPacket<NumberFor<B>>,
|
neighbor_packet: NeighborPacket<NumberFor<B>>,
|
||||||
) {
|
) {
|
||||||
if let Err(err) = self.0.unbounded_send((who, neighbor_packet)) {
|
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,
|
until_imported::UntilVoteTargetImported,
|
||||||
voting_rule::VotingRule as VotingRuleT,
|
voting_rule::VotingRule as VotingRuleT,
|
||||||
ClientForGrandpa, CommandOrError, Commit, Config, Error, NewAuthoritySet, Precommit, Prevote,
|
ClientForGrandpa, CommandOrError, Commit, Config, Error, NewAuthoritySet, Precommit, Prevote,
|
||||||
PrimaryPropose, SignedMessage, VoterCommand,
|
PrimaryPropose, SignedMessage, VoterCommand, LOG_TARGET,
|
||||||
};
|
};
|
||||||
|
|
||||||
type HistoricalVotes<Block> = finality_grandpa::HistoricalVotes<
|
type HistoricalVotes<Block> = finality_grandpa::HistoricalVotes<
|
||||||
@@ -551,7 +551,10 @@ where
|
|||||||
{
|
{
|
||||||
Some(proof) => proof,
|
Some(proof) => proof,
|
||||||
None => {
|
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(())
|
return Ok(())
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -609,8 +612,13 @@ where
|
|||||||
let tree_route = match tree_route_res {
|
let tree_route = match tree_route_res {
|
||||||
Ok(tree_route) => tree_route,
|
Ok(tree_route) => tree_route,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
debug!(target: "afg", "Encountered error computing ancestry between block {:?} and base {:?}: {}",
|
debug!(
|
||||||
block, base, e);
|
target: LOG_TARGET,
|
||||||
|
"Encountered error computing ancestry between block {:?} and base {:?}: {}",
|
||||||
|
block,
|
||||||
|
base,
|
||||||
|
e
|
||||||
|
);
|
||||||
|
|
||||||
return Err(GrandpaError::NotDescendent)
|
return Err(GrandpaError::NotDescendent)
|
||||||
},
|
},
|
||||||
@@ -955,7 +963,8 @@ where
|
|||||||
historical_votes: &HistoricalVotes<Block>,
|
historical_votes: &HistoricalVotes<Block>,
|
||||||
) -> Result<(), Self::Error> {
|
) -> Result<(), Self::Error> {
|
||||||
debug!(
|
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(),
|
self.config.name(),
|
||||||
round,
|
round,
|
||||||
self.set_id,
|
self.set_id,
|
||||||
@@ -1016,7 +1025,8 @@ where
|
|||||||
historical_votes: &HistoricalVotes<Block>,
|
historical_votes: &HistoricalVotes<Block>,
|
||||||
) -> Result<(), Self::Error> {
|
) -> Result<(), Self::Error> {
|
||||||
debug!(
|
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(),
|
self.config.name(),
|
||||||
round,
|
round,
|
||||||
self.set_id,
|
self.set_id,
|
||||||
@@ -1102,9 +1112,12 @@ where
|
|||||||
Self::Signature,
|
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()) {
|
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,
|
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()) {
|
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))? {
|
let base_header = match client.header(BlockId::Hash(block))? {
|
||||||
Some(h) => h,
|
Some(h) => h,
|
||||||
None => {
|
None => {
|
||||||
debug!(target: "afg",
|
debug!(
|
||||||
|
target: LOG_TARGET,
|
||||||
"Encountered error finding best chain containing {:?}: couldn't find base block",
|
"Encountered error finding best chain containing {:?}: couldn't find base block",
|
||||||
block,
|
block,
|
||||||
);
|
);
|
||||||
@@ -1172,7 +1189,10 @@ where
|
|||||||
// proceed onwards. most of the time there will be no pending transition. the limit, if any, is
|
// 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.
|
// guaranteed to be higher than or equal to the given base number.
|
||||||
let limit = authority_set.current_limit(*base_header.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 {
|
let result = match select_chain.finality_target(block, None).await {
|
||||||
Ok(best_hash) => {
|
Ok(best_hash) => {
|
||||||
@@ -1234,7 +1254,10 @@ where
|
|||||||
.or_else(|| Some((target_header.hash(), *target_header.number())))
|
.or_else(|| Some((target_header.hash(), *target_header.number())))
|
||||||
},
|
},
|
||||||
Err(e) => {
|
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
|
None
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -1273,7 +1296,7 @@ where
|
|||||||
// This can happen after a forced change (triggered manually from the runtime when
|
// 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
|
// 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.
|
// 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,
|
hash,
|
||||||
number,
|
number,
|
||||||
status.finalized_number,
|
status.finalized_number,
|
||||||
@@ -1303,7 +1326,10 @@ where
|
|||||||
) {
|
) {
|
||||||
if let Some(sender) = justification_sender {
|
if let Some(sender) = justification_sender {
|
||||||
if let Err(err) = sender.notify(justification) {
|
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
|
client
|
||||||
.apply_finality(import_op, hash, persisted_justification, true)
|
.apply_finality(import_op, hash, persisted_justification, true)
|
||||||
.map_err(|e| {
|
.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
|
e
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
debug!(target: "afg", "Finalizing blocks up to ({:?}, {})", number, hash);
|
debug!(target: LOG_TARGET, "Finalizing blocks up to ({:?}, {})", number, hash);
|
||||||
|
|
||||||
telemetry!(
|
telemetry!(
|
||||||
telemetry;
|
telemetry;
|
||||||
@@ -1376,13 +1407,17 @@ where
|
|||||||
let (new_id, set_ref) = authority_set.current();
|
let (new_id, set_ref) = authority_set.current();
|
||||||
|
|
||||||
if set_ref.len() > 16 {
|
if set_ref.len() > 16 {
|
||||||
afg_log!(
|
grandpa_log!(
|
||||||
initial_sync,
|
initial_sync,
|
||||||
"👴 Applying GRANDPA set change to new set with {} authorities",
|
"👴 Applying GRANDPA set change to new set with {} authorities",
|
||||||
set_ref.len(),
|
set_ref.len(),
|
||||||
);
|
);
|
||||||
} else {
|
} 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!(
|
telemetry!(
|
||||||
@@ -1411,8 +1446,11 @@ where
|
|||||||
);
|
);
|
||||||
|
|
||||||
if let Err(e) = write_result {
|
if let Err(e) = write_result {
|
||||||
warn!(target: "afg", "Failed to write updated authority set to disk. Bailing.");
|
warn!(
|
||||||
warn!(target: "afg", "Node is in a potentially inconsistent state.");
|
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())
|
return Err(e.into())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ use crate::{
|
|||||||
authorities::{AuthoritySetChangeId, AuthoritySetChanges},
|
authorities::{AuthoritySetChangeId, AuthoritySetChanges},
|
||||||
best_justification,
|
best_justification,
|
||||||
justification::GrandpaJustification,
|
justification::GrandpaJustification,
|
||||||
SharedAuthoritySet,
|
SharedAuthoritySet, LOG_TARGET,
|
||||||
};
|
};
|
||||||
|
|
||||||
const MAX_UNKNOWN_HEADERS: usize = 100_000;
|
const MAX_UNKNOWN_HEADERS: usize = 100_000;
|
||||||
@@ -163,7 +163,7 @@ where
|
|||||||
"Requested finality proof for descendant of #{} while we only have finalized #{}.",
|
"Requested finality proof for descendant of #{} while we only have finalized #{}.",
|
||||||
block, info.finalized_number,
|
block, info.finalized_number,
|
||||||
);
|
);
|
||||||
trace!(target: "afg", "{}", &err);
|
trace!(target: LOG_TARGET, "{}", &err);
|
||||||
return Err(FinalityProofError::BlockNotYetFinalized)
|
return Err(FinalityProofError::BlockNotYetFinalized)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,7 +175,7 @@ where
|
|||||||
justification
|
justification
|
||||||
} else {
|
} else {
|
||||||
trace!(
|
trace!(
|
||||||
target: "afg",
|
target: LOG_TARGET,
|
||||||
"No justification found for the latest finalized block. \
|
"No justification found for the latest finalized block. \
|
||||||
Returning empty proof.",
|
Returning empty proof.",
|
||||||
);
|
);
|
||||||
@@ -194,7 +194,7 @@ where
|
|||||||
grandpa_justification
|
grandpa_justification
|
||||||
} else {
|
} else {
|
||||||
trace!(
|
trace!(
|
||||||
target: "afg",
|
target: LOG_TARGET,
|
||||||
"No justification found when making finality proof for {}. \
|
"No justification found when making finality proof for {}. \
|
||||||
Returning empty proof.",
|
Returning empty proof.",
|
||||||
block,
|
block,
|
||||||
@@ -205,7 +205,7 @@ where
|
|||||||
},
|
},
|
||||||
AuthoritySetChangeId::Unknown => {
|
AuthoritySetChangeId::Unknown => {
|
||||||
warn!(
|
warn!(
|
||||||
target: "afg",
|
target: LOG_TARGET,
|
||||||
"AuthoritySetChanges does not cover the requested block #{} due to missing data. \
|
"AuthoritySetChanges does not cover the requested block #{} due to missing data. \
|
||||||
You need to resync to populate AuthoritySetChanges properly.",
|
You need to resync to populate AuthoritySetChanges properly.",
|
||||||
block,
|
block,
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ use crate::{
|
|||||||
justification::GrandpaJustification,
|
justification::GrandpaJustification,
|
||||||
notification::GrandpaJustificationSender,
|
notification::GrandpaJustificationSender,
|
||||||
AuthoritySetChanges, ClientForGrandpa, CommandOrError, Error, NewAuthoritySet, VoterCommand,
|
AuthoritySetChanges, ClientForGrandpa, CommandOrError, Error, NewAuthoritySet, VoterCommand,
|
||||||
|
LOG_TARGET,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A block-import handler for GRANDPA.
|
/// A block-import handler for GRANDPA.
|
||||||
@@ -589,18 +590,16 @@ where
|
|||||||
Ok(ImportResult::Imported(aux)) => aux,
|
Ok(ImportResult::Imported(aux)) => aux,
|
||||||
Ok(r) => {
|
Ok(r) => {
|
||||||
debug!(
|
debug!(
|
||||||
target: "afg",
|
target: LOG_TARGET,
|
||||||
"Restoring old authority set after block import result: {:?}",
|
"Restoring old authority set after block import result: {:?}", r,
|
||||||
r,
|
|
||||||
);
|
);
|
||||||
pending_changes.revert();
|
pending_changes.revert();
|
||||||
return Ok(r)
|
return Ok(r)
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
debug!(
|
debug!(
|
||||||
target: "afg",
|
target: LOG_TARGET,
|
||||||
"Restoring old authority set after block import error: {}",
|
"Restoring old authority set after block import error: {}", e,
|
||||||
e,
|
|
||||||
);
|
);
|
||||||
pending_changes.revert();
|
pending_changes.revert();
|
||||||
return Err(ConsensusError::ClientImport(e.to_string()))
|
return Err(ConsensusError::ClientImport(e.to_string()))
|
||||||
@@ -665,7 +664,7 @@ where
|
|||||||
import_res.unwrap_or_else(|err| {
|
import_res.unwrap_or_else(|err| {
|
||||||
if needs_justification {
|
if needs_justification {
|
||||||
debug!(
|
debug!(
|
||||||
target: "afg",
|
target: LOG_TARGET,
|
||||||
"Requesting justification from peers due to imported block #{} that enacts authority set change with invalid justification: {}",
|
"Requesting justification from peers due to imported block #{} that enacts authority set change with invalid justification: {}",
|
||||||
number,
|
number,
|
||||||
err
|
err
|
||||||
@@ -678,7 +677,7 @@ where
|
|||||||
None =>
|
None =>
|
||||||
if needs_justification {
|
if needs_justification {
|
||||||
debug!(
|
debug!(
|
||||||
target: "afg",
|
target: LOG_TARGET,
|
||||||
"Imported unjustified block #{} that enacts authority set change, waiting for finality for enactment.",
|
"Imported unjustified block #{} that enacts authority set change, waiting for finality for enactment.",
|
||||||
number,
|
number,
|
||||||
);
|
);
|
||||||
@@ -803,7 +802,7 @@ where
|
|||||||
|
|
||||||
match result {
|
match result {
|
||||||
Err(CommandOrError::VoterCommand(command)) => {
|
Err(CommandOrError::VoterCommand(command)) => {
|
||||||
afg_log!(
|
grandpa_log!(
|
||||||
initial_sync,
|
initial_sync,
|
||||||
"👴 Imported justification for block #{} that triggers \
|
"👴 Imported justification for block #{} that triggers \
|
||||||
command {}, signaling voter.",
|
command {}, signaling voter.",
|
||||||
|
|||||||
@@ -93,10 +93,12 @@ use std::{
|
|||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const LOG_TARGET: &str = "grandpa";
|
||||||
|
|
||||||
// utility logging macro that takes as first argument a conditional to
|
// utility logging macro that takes as first argument a conditional to
|
||||||
// decide whether to log under debug or info level (useful to restrict
|
// decide whether to log under debug or info level (useful to restrict
|
||||||
// logging under initial sync).
|
// logging under initial sync).
|
||||||
macro_rules! afg_log {
|
macro_rules! grandpa_log {
|
||||||
($condition:expr, $($msg: expr),+ $(,)?) => {
|
($condition:expr, $($msg: expr),+ $(,)?) => {
|
||||||
{
|
{
|
||||||
let log_level = if $condition {
|
let log_level = if $condition {
|
||||||
@@ -105,7 +107,7 @@ macro_rules! afg_log {
|
|||||||
log::Level::Info
|
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 {
|
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."
|
"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.
|
// 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) {
|
let metrics = match prometheus_registry.as_ref().map(Metrics::register) {
|
||||||
Some(Ok(metrics)) => Some(metrics),
|
Some(Ok(metrics)) => Some(metrics),
|
||||||
Some(Err(e)) => {
|
Some(Err(e)) => {
|
||||||
debug!(target: "afg", "Failed to register metrics: {:?}", e);
|
debug!(target: LOG_TARGET, "Failed to register metrics: {:?}", e);
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
None => None,
|
None => None,
|
||||||
@@ -913,7 +916,12 @@ where
|
|||||||
/// state. This method should be called when we know that the authority set
|
/// state. This method should be called when we know that the authority set
|
||||||
/// has changed (e.g. as signalled by a voter command).
|
/// has changed (e.g. as signalled by a voter command).
|
||||||
fn rebuild_voter(&mut self) {
|
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 =
|
let maybe_authority_id =
|
||||||
local_authority_id(&self.env.voters, self.env.config.keystore.as_ref());
|
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
|
// Repoint shared_voter_state so that the RPC endpoint can query the state
|
||||||
if self.shared_voter_state.reset(voter.voter_state()).is_none() {
|
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. \
|
"Timed out trying to update shared GRANDPA voter state. \
|
||||||
RPC endpoints may return stale data."
|
RPC endpoints may return stale data."
|
||||||
);
|
);
|
||||||
@@ -1043,7 +1052,7 @@ where
|
|||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
VoterCommand::Pause(reason) => {
|
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.
|
// not racing because old voter is shut down.
|
||||||
self.env.update_voter_set_state(|voter_set_state| {
|
self.env.update_voter_set_state(|voter_set_state| {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ use crate::{
|
|||||||
environment, global_communication,
|
environment, global_communication,
|
||||||
notification::GrandpaJustificationSender,
|
notification::GrandpaJustificationSender,
|
||||||
ClientForGrandpa, CommandOrError, CommunicationIn, Config, Error, LinkHalf, VoterCommand,
|
ClientForGrandpa, CommandOrError, CommunicationIn, Config, Error, LinkHalf, VoterCommand,
|
||||||
VoterSetState,
|
VoterSetState, LOG_TARGET,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ObserverChain<'a, Block: BlockT, Client> {
|
struct ObserverChain<'a, Block: BlockT, Client> {
|
||||||
@@ -145,7 +145,7 @@ where
|
|||||||
// proceed processing with new finalized block number
|
// proceed processing with new finalized block number
|
||||||
future::ok(finalized_number)
|
future::ok(finalized_number)
|
||||||
} else {
|
} 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);
|
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.
|
// update it on-disk in case we restart as validator in the future.
|
||||||
self.persistent_data.set_state = match command {
|
self.persistent_data.set_state = match command {
|
||||||
VoterCommand::Pause(reason) => {
|
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 completed_rounds = self.persistent_data.set_state.read().completed_rounds();
|
||||||
let set_state = VoterSetState::Paused { completed_rounds };
|
let set_state = VoterSetState::Paused { completed_rounds };
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
BlockStatus as BlockStatusT, BlockSyncRequester as BlockSyncRequesterT, CommunicationIn, Error,
|
BlockStatus as BlockStatusT, BlockSyncRequester as BlockSyncRequesterT, CommunicationIn, Error,
|
||||||
SignedMessage,
|
SignedMessage, LOG_TARGET,
|
||||||
};
|
};
|
||||||
|
|
||||||
use finality_grandpa::voter;
|
use finality_grandpa::voter;
|
||||||
@@ -296,7 +296,7 @@ where
|
|||||||
let next_log = *last_log + LOG_PENDING_INTERVAL;
|
let next_log = *last_log + LOG_PENDING_INTERVAL;
|
||||||
if Instant::now() >= next_log {
|
if Instant::now() >= next_log {
|
||||||
debug!(
|
debug!(
|
||||||
target: "afg",
|
target: LOG_TARGET,
|
||||||
"Waiting to import block {} before {} {} messages can be imported. \
|
"Waiting to import block {} before {} {} messages can be imported. \
|
||||||
Requesting network sync service to retrieve block from. \
|
Requesting network sync service to retrieve block from. \
|
||||||
Possible fork?",
|
Possible fork?",
|
||||||
@@ -346,7 +346,7 @@ where
|
|||||||
|
|
||||||
fn warn_authority_wrong_target<H: ::std::fmt::Display>(hash: H, id: AuthorityId) {
|
fn warn_authority_wrong_target<H: ::std::fmt::Display>(hash: H, id: AuthorityId) {
|
||||||
warn!(
|
warn!(
|
||||||
target: "afg",
|
target: LOG_TARGET,
|
||||||
"Authority {:?} signed GRANDPA message with \
|
"Authority {:?} signed GRANDPA message with \
|
||||||
wrong block number for hash {}",
|
wrong block number for hash {}",
|
||||||
id,
|
id,
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ mod tests;
|
|||||||
|
|
||||||
pub use pallet::*;
|
pub use pallet::*;
|
||||||
|
|
||||||
|
const LOG_TARGET: &str = "runtime::aura";
|
||||||
|
|
||||||
#[frame_support::pallet]
|
#[frame_support::pallet]
|
||||||
pub mod pallet {
|
pub mod pallet {
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -222,7 +224,7 @@ impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T> {
|
|||||||
if last_authorities != next_authorities {
|
if last_authorities != next_authorities {
|
||||||
if next_authorities.len() as u32 > T::MaxAuthorities::get() {
|
if next_authorities.len() as u32 > T::MaxAuthorities::get() {
|
||||||
log::warn!(
|
log::warn!(
|
||||||
target: "runtime::aura",
|
target: LOG_TARGET,
|
||||||
"next authorities list larger than {}, truncating",
|
"next authorities list larger than {}, truncating",
|
||||||
T::MaxAuthorities::get(),
|
T::MaxAuthorities::get(),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ use sp_staking::{
|
|||||||
};
|
};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
|
|
||||||
use crate::{Call, Config, Pallet};
|
use crate::{Call, Config, Pallet, LOG_TARGET};
|
||||||
|
|
||||||
/// A trait with utility methods for handling equivocation reports in BABE.
|
/// A trait with utility methods for handling equivocation reports in BABE.
|
||||||
/// The trait provides methods for reporting an offence triggered by a valid
|
/// The trait provides methods for reporting an offence triggered by a valid
|
||||||
@@ -161,15 +161,9 @@ where
|
|||||||
};
|
};
|
||||||
|
|
||||||
match SubmitTransaction::<T, Call<T>>::submit_unsigned_transaction(call.into()) {
|
match SubmitTransaction::<T, Call<T>>::submit_unsigned_transaction(call.into()) {
|
||||||
Ok(()) => log::info!(
|
Ok(()) => log::info!(target: LOG_TARGET, "Submitted BABE equivocation report.",),
|
||||||
target: "runtime::babe",
|
Err(e) =>
|
||||||
"Submitted BABE equivocation report.",
|
log::error!(target: LOG_TARGET, "Error submitting equivocation report: {:?}", e,),
|
||||||
),
|
|
||||||
Err(e) => log::error!(
|
|
||||||
target: "runtime::babe",
|
|
||||||
"Error submitting equivocation report: {:?}",
|
|
||||||
e,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -192,7 +186,7 @@ impl<T: Config> Pallet<T> {
|
|||||||
TransactionSource::Local | TransactionSource::InBlock => { /* allowed */ },
|
TransactionSource::Local | TransactionSource::InBlock => { /* allowed */ },
|
||||||
_ => {
|
_ => {
|
||||||
log::warn!(
|
log::warn!(
|
||||||
target: "runtime::babe",
|
target: LOG_TARGET,
|
||||||
"rejecting unsigned report equivocation transaction because it is not local/in-block.",
|
"rejecting unsigned report equivocation transaction because it is not local/in-block.",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ use sp_consensus_vrf::schnorrkel;
|
|||||||
|
|
||||||
pub use sp_consensus_babe::{AuthorityId, PUBLIC_KEY_LENGTH, RANDOMNESS_LENGTH, VRF_OUTPUT_LENGTH};
|
pub use sp_consensus_babe::{AuthorityId, PUBLIC_KEY_LENGTH, RANDOMNESS_LENGTH, VRF_OUTPUT_LENGTH};
|
||||||
|
|
||||||
|
const LOG_TARGET: &str = "runtime::babe";
|
||||||
|
|
||||||
mod default_weights;
|
mod default_weights;
|
||||||
mod equivocation;
|
mod equivocation;
|
||||||
mod randomness;
|
mod randomness;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ use sp_staking::{
|
|||||||
SessionIndex,
|
SessionIndex,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{Call, Config, Pallet};
|
use super::{Call, Config, Pallet, LOG_TARGET};
|
||||||
|
|
||||||
/// A trait with utility methods for handling equivocation reports in GRANDPA.
|
/// A trait with utility methods for handling equivocation reports in GRANDPA.
|
||||||
/// The offence type is generic, and the trait provides , reporting an offence
|
/// The offence type is generic, and the trait provides , reporting an offence
|
||||||
@@ -170,15 +170,9 @@ where
|
|||||||
};
|
};
|
||||||
|
|
||||||
match SubmitTransaction::<T, Call<T>>::submit_unsigned_transaction(call.into()) {
|
match SubmitTransaction::<T, Call<T>>::submit_unsigned_transaction(call.into()) {
|
||||||
Ok(()) => log::info!(
|
Ok(()) => log::info!(target: LOG_TARGET, "Submitted GRANDPA equivocation report.",),
|
||||||
target: "runtime::afg",
|
Err(e) =>
|
||||||
"Submitted GRANDPA equivocation report.",
|
log::error!(target: LOG_TARGET, "Error submitting equivocation report: {:?}", e,),
|
||||||
),
|
|
||||||
Err(e) => log::error!(
|
|
||||||
target: "runtime::afg",
|
|
||||||
"Error submitting equivocation report: {:?}",
|
|
||||||
e,
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -211,7 +205,7 @@ impl<T: Config> Pallet<T> {
|
|||||||
TransactionSource::Local | TransactionSource::InBlock => { /* allowed */ },
|
TransactionSource::Local | TransactionSource::InBlock => { /* allowed */ },
|
||||||
_ => {
|
_ => {
|
||||||
log::warn!(
|
log::warn!(
|
||||||
target: "runtime::afg",
|
target: LOG_TARGET,
|
||||||
"rejecting unsigned report equivocation transaction because it is not local/in-block."
|
"rejecting unsigned report equivocation transaction because it is not local/in-block."
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,8 @@ pub use equivocation::{
|
|||||||
|
|
||||||
pub use pallet::*;
|
pub use pallet::*;
|
||||||
|
|
||||||
|
const LOG_TARGET: &str = "runtime::grandpa";
|
||||||
|
|
||||||
#[frame_support::pallet]
|
#[frame_support::pallet]
|
||||||
pub mod pallet {
|
pub mod pallet {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
use crate::LOG_TARGET;
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
traits::{Get, StorageVersion},
|
traits::{Get, StorageVersion},
|
||||||
weights::Weight,
|
weights::Weight,
|
||||||
@@ -34,14 +35,14 @@ pub const OLD_PREFIX: &[u8] = b"GrandpaFinality";
|
|||||||
pub fn migrate<T: crate::Config, N: AsRef<str>>(new_pallet_name: N) -> Weight {
|
pub fn migrate<T: crate::Config, N: AsRef<str>>(new_pallet_name: N) -> Weight {
|
||||||
if new_pallet_name.as_ref().as_bytes() == OLD_PREFIX {
|
if new_pallet_name.as_ref().as_bytes() == OLD_PREFIX {
|
||||||
log::info!(
|
log::info!(
|
||||||
target: "runtime::afg",
|
target: LOG_TARGET,
|
||||||
"New pallet name is equal to the old prefix. No migration needs to be done.",
|
"New pallet name is equal to the old prefix. No migration needs to be done.",
|
||||||
);
|
);
|
||||||
return Weight::zero()
|
return Weight::zero()
|
||||||
}
|
}
|
||||||
let storage_version = StorageVersion::get::<crate::Pallet<T>>();
|
let storage_version = StorageVersion::get::<crate::Pallet<T>>();
|
||||||
log::info!(
|
log::info!(
|
||||||
target: "runtime::afg",
|
target: LOG_TARGET,
|
||||||
"Running migration to v3.1 for grandpa with storage version {:?}",
|
"Running migration to v3.1 for grandpa with storage version {:?}",
|
||||||
storage_version,
|
storage_version,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user