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:
Davide Galassi
2022-12-14 14:56:17 +01:00
committed by GitHub
parent 3e0a1904b7
commit 391adaf443
31 changed files with 343 additions and 247 deletions
+3 -1
View File
@@ -58,6 +58,8 @@ mod tests;
pub use pallet::*;
const LOG_TARGET: &str = "runtime::aura";
#[frame_support::pallet]
pub mod pallet {
use super::*;
@@ -222,7 +224,7 @@ impl<T: Config> OneSessionHandler<T::AccountId> for Pallet<T> {
if last_authorities != next_authorities {
if next_authorities.len() as u32 > T::MaxAuthorities::get() {
log::warn!(
target: "runtime::aura",
target: LOG_TARGET,
"next authorities list larger than {}, truncating",
T::MaxAuthorities::get(),
);
+5 -11
View File
@@ -48,7 +48,7 @@ use sp_staking::{
};
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.
/// 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()) {
Ok(()) => log::info!(
target: "runtime::babe",
"Submitted BABE equivocation report.",
),
Err(e) => log::error!(
target: "runtime::babe",
"Error submitting equivocation report: {:?}",
e,
),
Ok(()) => log::info!(target: LOG_TARGET, "Submitted BABE equivocation report.",),
Err(e) =>
log::error!(target: LOG_TARGET, "Error submitting equivocation report: {:?}", e,),
}
Ok(())
@@ -192,7 +186,7 @@ impl<T: Config> Pallet<T> {
TransactionSource::Local | TransactionSource::InBlock => { /* allowed */ },
_ => {
log::warn!(
target: "runtime::babe",
target: LOG_TARGET,
"rejecting unsigned report equivocation transaction because it is not local/in-block.",
);
+2
View File
@@ -50,6 +50,8 @@ use sp_consensus_vrf::schnorrkel;
pub use sp_consensus_babe::{AuthorityId, PUBLIC_KEY_LENGTH, RANDOMNESS_LENGTH, VRF_OUTPUT_LENGTH};
const LOG_TARGET: &str = "runtime::babe";
mod default_weights;
mod equivocation;
mod randomness;
+5 -11
View File
@@ -52,7 +52,7 @@ use sp_staking::{
SessionIndex,
};
use super::{Call, Config, Pallet};
use super::{Call, Config, Pallet, LOG_TARGET};
/// A trait with utility methods for handling equivocation reports in GRANDPA.
/// 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()) {
Ok(()) => log::info!(
target: "runtime::afg",
"Submitted GRANDPA equivocation report.",
),
Err(e) => log::error!(
target: "runtime::afg",
"Error submitting equivocation report: {:?}",
e,
),
Ok(()) => log::info!(target: LOG_TARGET, "Submitted GRANDPA equivocation report.",),
Err(e) =>
log::error!(target: LOG_TARGET, "Error submitting equivocation report: {:?}", e,),
}
Ok(())
@@ -211,7 +205,7 @@ impl<T: Config> Pallet<T> {
TransactionSource::Local | TransactionSource::InBlock => { /* allowed */ },
_ => {
log::warn!(
target: "runtime::afg",
target: LOG_TARGET,
"rejecting unsigned report equivocation transaction because it is not local/in-block."
);
+2
View File
@@ -70,6 +70,8 @@ pub use equivocation::{
pub use pallet::*;
const LOG_TARGET: &str = "runtime::grandpa";
#[frame_support::pallet]
pub mod pallet {
use super::*;
+3 -2
View File
@@ -15,6 +15,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::LOG_TARGET;
use frame_support::{
traits::{Get, StorageVersion},
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 {
if new_pallet_name.as_ref().as_bytes() == OLD_PREFIX {
log::info!(
target: "runtime::afg",
target: LOG_TARGET,
"New pallet name is equal to the old prefix. No migration needs to be done.",
);
return Weight::zero()
}
let storage_version = StorageVersion::get::<crate::Pallet<T>>();
log::info!(
target: "runtime::afg",
target: LOG_TARGET,
"Running migration to v3.1 for grandpa with storage version {:?}",
storage_version,
);