Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

grandpa: remove deprecated afg log target #13064

Merged
merged 2 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/finality-grandpa/src/communication/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,7 @@ impl<Block: BlockT> Inner<Block> {
&full.message.signature,
full.round.0,
full.set_id.0,
LOG_TARGET,
) {
debug!(target: LOG_TARGET, "Bad message signature {}", full.message.id);
telemetry!(
Expand Down
3 changes: 2 additions & 1 deletion client/finality-grandpa/src/communication/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@ fn check_compact_commit<Block: BlockT>(
round.0,
set_id.0,
&mut buf,
LOG_TARGET,
) {
debug!(target: LOG_TARGET, "Bad commit message signature {}", id);
telemetry!(
Expand Down Expand Up @@ -935,7 +936,7 @@ fn check_catch_up<Block: BlockT>(
signatures_checked += 1;

if !sp_finality_grandpa::check_message_signature_with_buffer(
&msg, id, sig, round, set_id, buf,
&msg, id, sig, round, set_id, buf, LOG_TARGET,
) {
debug!(target: LOG_TARGET, "Bad catch up message signature {}", id);
telemetry!(
Expand Down
3 changes: 2 additions & 1 deletion client/finality-grandpa/src/justification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use sp_blockchain::{Error as ClientError, HeaderBackend};
use sp_finality_grandpa::AuthorityId;
use sp_runtime::traits::{Block as BlockT, Header as HeaderT, NumberFor};

use crate::{AuthorityList, Commit, Error};
use crate::{AuthorityList, Commit, Error, LOG_TARGET};

/// A GRANDPA justification for block finality, it includes a commit message and
/// an ancestry proof including all headers routing all precommit target blocks
Expand Down Expand Up @@ -212,6 +212,7 @@ impl<Block: BlockT> GrandpaJustification<Block> {
self.justification.round,
set_id,
&mut buf,
LOG_TARGET,
) {
return Err(ClientError::BadJustification(
"invalid signature for precommit in grandpa justification".to_string(),
Expand Down
8 changes: 4 additions & 4 deletions client/tracing/src/logging/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ mod tests {
fn test_logger_filters() {
run_test_in_another_process("test_logger_filters", || {
let test_directives =
"afg=debug,sync=trace,client=warn,telemetry,something-with-dash=error";
"grandpa=debug,sync=trace,client=warn,telemetry,something-with-dash=error";
init_logger(&test_directives);

tracing::dispatcher::get_default(|dispatcher| {
Expand All @@ -402,9 +402,9 @@ mod tests {
dispatcher.enabled(&metadata)
};

assert!(test_filter("afg", Level::INFO));
assert!(test_filter("afg", Level::DEBUG));
assert!(!test_filter("afg", Level::TRACE));
assert!(test_filter("grandpa", Level::INFO));
assert!(test_filter("grandpa", Level::DEBUG));
assert!(!test_filter("grandpa", Level::TRACE));

assert!(test_filter("sync", Level::TRACE));
assert!(test_filter("client", Level::WARN));
Expand Down
4 changes: 2 additions & 2 deletions frame/grandpa/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ benchmarks! {

let equivocation_proof2 = equivocation_proof1.clone();
}: {
sp_finality_grandpa::check_equivocation_proof(equivocation_proof1);
sp_finality_grandpa::check_equivocation_proof(equivocation_proof1, "grandpa");
} verify {
assert!(sp_finality_grandpa::check_equivocation_proof(equivocation_proof2));
assert!(sp_finality_grandpa::check_equivocation_proof(equivocation_proof2, "grandpa"));
}

note_stalled {
Expand Down
2 changes: 1 addition & 1 deletion frame/grandpa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ impl<T: Config> Pallet<T> {

// validate equivocation proof (check votes are different and
// signatures are valid).
if !sp_finality_grandpa::check_equivocation_proof(equivocation_proof) {
if !sp_finality_grandpa::check_equivocation_proof(equivocation_proof, LOG_TARGET) {
return Err(Error::<T>::InvalidEquivocationProof.into())
}

Expand Down
4 changes: 2 additions & 2 deletions primitives/finality-grandpa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
grandpa = { package = "finality-grandpa", version = "0.16.0", default-features = false, features = ["derive-codec"] }
log = { version = "0.4.17", optional = true }
log = { version = "0.4.17", default-features = false }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
serde = { version = "1.0.136", features = ["derive"], optional = true }
sp-api = { version = "4.0.0-dev", default-features = false, path = "../api" }
Expand All @@ -31,7 +31,7 @@ default = ["std"]
std = [
"codec/std",
"grandpa/std",
"log",
"log/std",
"scale-info/std",
"serde",
"sp-api/std",
Expand Down
22 changes: 15 additions & 7 deletions primitives/finality-grandpa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ use sp_runtime::{
};
use sp_std::{borrow::Cow, vec::Vec};

#[cfg(feature = "std")]
use log::debug;

/// Key type for GRANDPA module.
pub const KEY_TYPE: sp_core::crypto::KeyTypeId = sp_application_crypto::key_types::GRANDPA;

Expand Down Expand Up @@ -322,7 +319,7 @@ impl<H, N> Equivocation<H, N> {

/// Verifies the equivocation proof by making sure that both votes target
/// different blocks and that its signatures are valid.
pub fn check_equivocation_proof<H, N>(report: EquivocationProof<H, N>) -> bool
pub fn check_equivocation_proof<H, N>(report: EquivocationProof<H, N>, log_target: &str) -> bool
andresilva marked this conversation as resolved.
Show resolved Hide resolved
where
H: Clone + Encode + PartialEq,
N: Clone + Encode + PartialEq,
Expand All @@ -345,6 +342,7 @@ where
&$equivocation.first.1,
$equivocation.round_number,
report.set_id,
log_target,
);

let valid_second = check_message_signature(
Expand All @@ -353,6 +351,7 @@ where
&$equivocation.second.1,
$equivocation.round_number,
report.set_id,
log_target,
);

return valid_first && valid_second
Expand Down Expand Up @@ -397,12 +396,21 @@ pub fn check_message_signature<H, N>(
signature: &AuthoritySignature,
round: RoundNumber,
set_id: SetId,
log_target: &str,
) -> bool
where
H: Encode,
N: Encode,
{
check_message_signature_with_buffer(message, id, signature, round, set_id, &mut Vec::new())
check_message_signature_with_buffer(
message,
id,
signature,
round,
set_id,
&mut Vec::new(),
log_target,
)
}

/// Check a message signature by encoding the message as a localized payload and
Expand All @@ -416,6 +424,7 @@ pub fn check_message_signature_with_buffer<H, N>(
round: RoundNumber,
set_id: SetId,
buf: &mut Vec<u8>,
log_target: &str,
) -> bool
where
H: Encode,
Expand All @@ -428,8 +437,7 @@ where
let valid = id.verify(&buf, signature);

if !valid {
#[cfg(feature = "std")]
debug!(target: "afg", "Bad signature on message from {:?}", id);
log::debug!(target: log_target, "Bad signature on message from {:?}", id);
}

valid
Expand Down