mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 06:21:02 +00:00
Define const LOG_TARGET for bridge pallets
Signed-off-by: Serban Iorga <serban@parity.io>
This commit is contained in:
committed by
Bastian Köcher
parent
852f629d78
commit
6b67d6b262
@@ -59,6 +59,9 @@ pub mod benchmarking;
|
||||
pub use pallet::*;
|
||||
pub use weights::WeightInfo;
|
||||
|
||||
/// The target that will be used when publishing logs related to this pallet.
|
||||
const LOG_TARGET: &str = "runtime::bridge-grandpa";
|
||||
|
||||
/// Block number of the bridged chain.
|
||||
pub type BridgedBlockNumber<T, I> = BlockNumberOf<<T as Config<I>>::BridgedChain>;
|
||||
/// Block hash of the bridged chain.
|
||||
@@ -119,7 +122,7 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
impl<T: Config<I>, I: 'static> OwnedBridgeModule<T> for Pallet<T, I> {
|
||||
const LOG_TARGET: &'static str = "runtime::bridge-grandpa";
|
||||
const LOG_TARGET: &'static str = LOG_TARGET;
|
||||
type OwnerStorage = PalletOwner<T, I>;
|
||||
type OperatingMode = BasicOperatingMode;
|
||||
type OperatingModeStorage = PalletOperatingMode<T, I>;
|
||||
@@ -149,7 +152,11 @@ pub mod pallet {
|
||||
ensure!(Self::request_count() < T::MaxRequests::get(), <Error<T, I>>::TooManyRequests);
|
||||
|
||||
let (hash, number) = (finality_target.hash(), finality_target.number());
|
||||
log::trace!(target: "runtime::bridge-grandpa", "Going to try and finalize header {:?}", finality_target);
|
||||
log::trace!(
|
||||
target: LOG_TARGET,
|
||||
"Going to try and finalize header {:?}",
|
||||
finality_target
|
||||
);
|
||||
|
||||
let best_finalized = BestFinalized::<T, I>::get();
|
||||
let best_finalized =
|
||||
@@ -158,7 +165,7 @@ pub mod pallet {
|
||||
Some(best_finalized) => best_finalized,
|
||||
None => {
|
||||
log::error!(
|
||||
target: "runtime::bridge-grandpa",
|
||||
target: LOG_TARGET,
|
||||
"Cannot finalize header {:?} because pallet is not yet initialized",
|
||||
finality_target,
|
||||
);
|
||||
@@ -179,7 +186,11 @@ pub mod pallet {
|
||||
try_enact_authority_change::<T, I>(&finality_target, set_id)?;
|
||||
<RequestCount<T, I>>::mutate(|count| *count += 1);
|
||||
insert_header::<T, I>(*finality_target, hash);
|
||||
log::info!(target: "runtime::bridge-grandpa", "Successfully imported finalized header with hash {:?}!", hash);
|
||||
log::info!(
|
||||
target: LOG_TARGET,
|
||||
"Successfully imported finalized header with hash {:?}!",
|
||||
hash
|
||||
);
|
||||
|
||||
// mandatory header is a header that changes authorities set. The pallet can't go
|
||||
// further without importing this header. So every bridge MUST import mandatory headers.
|
||||
@@ -213,7 +224,7 @@ pub mod pallet {
|
||||
initialize_bridge::<T, I>(init_data.clone());
|
||||
|
||||
log::info!(
|
||||
target: "runtime::bridge-grandpa",
|
||||
target: LOG_TARGET,
|
||||
"Pallet has been initialized with the following parameters: {:?}",
|
||||
init_data
|
||||
);
|
||||
@@ -392,7 +403,7 @@ pub mod pallet {
|
||||
change_enacted = true;
|
||||
|
||||
log::info!(
|
||||
target: "runtime::bridge-grandpa",
|
||||
target: LOG_TARGET,
|
||||
"Transitioned from authority set {} to {}! New authorities are: {:?}",
|
||||
current_set_id,
|
||||
current_set_id + 1,
|
||||
@@ -429,7 +440,7 @@ pub mod pallet {
|
||||
)
|
||||
.map_err(|e| {
|
||||
log::error!(
|
||||
target: "runtime::bridge-grandpa",
|
||||
target: LOG_TARGET,
|
||||
"Received invalid justification for {:?}: {:?}",
|
||||
hash,
|
||||
e,
|
||||
@@ -455,7 +466,7 @@ pub mod pallet {
|
||||
// Update ring buffer pointer and remove old header.
|
||||
<ImportedHashesPointer<T, I>>::put((index + 1) % T::HeadersToKeep::get());
|
||||
if let Ok(hash) = pruning {
|
||||
log::debug!(target: "runtime::bridge-grandpa", "Pruning old header: {:?}.", hash);
|
||||
log::debug!(target: LOG_TARGET, "Pruning old header: {:?}.", hash);
|
||||
<ImportedHeaders<T, I>>::remove(hash);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,6 +90,9 @@ mod mock;
|
||||
|
||||
pub use pallet::*;
|
||||
|
||||
/// The target that will be used when publishing logs related to this pallet.
|
||||
const LOG_TARGET: &str = "runtime::bridge-messages";
|
||||
|
||||
#[frame_support::pallet]
|
||||
pub mod pallet {
|
||||
use super::*;
|
||||
@@ -217,7 +220,7 @@ pub mod pallet {
|
||||
pub struct Pallet<T, I = ()>(PhantomData<(T, I)>);
|
||||
|
||||
impl<T: Config<I>, I: 'static> OwnedBridgeModule<T> for Pallet<T, I> {
|
||||
const LOG_TARGET: &'static str = "runtime::bridge-messages";
|
||||
const LOG_TARGET: &'static str = LOG_TARGET;
|
||||
type OwnerStorage = PalletOwner<T, I>;
|
||||
type OperatingMode = MessagesOperatingMode;
|
||||
type OperatingModeStorage = PalletOperatingMode<T, I>;
|
||||
@@ -309,7 +312,7 @@ pub mod pallet {
|
||||
)
|
||||
.map_err(|err| {
|
||||
log::trace!(
|
||||
target: "runtime::bridge-messages",
|
||||
target: LOG_TARGET,
|
||||
"Submitter can't pay additional fee {:?} for the message {:?}/{:?} to {:?}: {:?}",
|
||||
additional_fee,
|
||||
lane_id,
|
||||
@@ -389,11 +392,7 @@ pub mod pallet {
|
||||
T::InboundPayload,
|
||||
>(proof, messages_count)
|
||||
.map_err(|err| {
|
||||
log::trace!(
|
||||
target: "runtime::bridge-messages",
|
||||
"Rejecting invalid messages proof: {:?}",
|
||||
err,
|
||||
);
|
||||
log::trace!(target: LOG_TARGET, "Rejecting invalid messages proof: {:?}", err,);
|
||||
|
||||
Error::<T, I>::InvalidMessagesProof
|
||||
})?;
|
||||
@@ -409,7 +408,7 @@ pub mod pallet {
|
||||
let updated_latest_confirmed_nonce = lane.receive_state_update(lane_state);
|
||||
if let Some(updated_latest_confirmed_nonce) = updated_latest_confirmed_nonce {
|
||||
log::trace!(
|
||||
target: "runtime::bridge-messages",
|
||||
target: LOG_TARGET,
|
||||
"Received lane {:?} state update: latest_confirmed_nonce={}",
|
||||
lane_id,
|
||||
updated_latest_confirmed_nonce,
|
||||
@@ -426,7 +425,7 @@ pub mod pallet {
|
||||
let dispatch_weight = T::MessageDispatch::dispatch_weight(&mut message);
|
||||
if dispatch_weight > dispatch_weight_left {
|
||||
log::trace!(
|
||||
target: "runtime::bridge-messages",
|
||||
target: LOG_TARGET,
|
||||
"Cannot dispatch any more messages on lane {:?}. Weight: declared={}, left={}",
|
||||
lane_id,
|
||||
dispatch_weight,
|
||||
@@ -478,7 +477,7 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
log::trace!(
|
||||
target: "runtime::bridge-messages",
|
||||
target: LOG_TARGET,
|
||||
"Received messages: total={}, valid={}. Weight used: {}/{}",
|
||||
total_messages,
|
||||
valid_messages,
|
||||
@@ -524,7 +523,7 @@ pub mod pallet {
|
||||
let (lane_id, lane_data) = T::TargetHeaderChain::verify_messages_delivery_proof(proof)
|
||||
.map_err(|err| {
|
||||
log::trace!(
|
||||
target: "runtime::bridge-messages",
|
||||
target: LOG_TARGET,
|
||||
"Rejecting invalid messages delivery proof: {:?}",
|
||||
err,
|
||||
);
|
||||
@@ -564,7 +563,7 @@ pub mod pallet {
|
||||
to_confirm_messages_count,
|
||||
) => {
|
||||
log::trace!(
|
||||
target: "runtime::bridge-messages",
|
||||
target: LOG_TARGET,
|
||||
"Messages delivery proof contains too many messages to confirm: {} vs declared {}",
|
||||
to_confirm_messages_count,
|
||||
relayers_state.total_messages,
|
||||
@@ -574,7 +573,7 @@ pub mod pallet {
|
||||
},
|
||||
error => {
|
||||
log::trace!(
|
||||
target: "runtime::bridge-messages",
|
||||
target: LOG_TARGET,
|
||||
"Messages delivery proof contains invalid unrewarded relayers vec: {:?}",
|
||||
error,
|
||||
);
|
||||
@@ -593,7 +592,7 @@ pub mod pallet {
|
||||
Some(difference) if difference == 0 => (),
|
||||
Some(difference) => {
|
||||
log::trace!(
|
||||
target: "runtime::bridge-messages",
|
||||
target: LOG_TARGET,
|
||||
"T::OnDeliveryConfirmed callback has spent less weight than expected. Refunding: \
|
||||
{} - {} = {}",
|
||||
preliminary_callback_overhead,
|
||||
@@ -608,7 +607,7 @@ pub mod pallet {
|
||||
"T::OnDeliveryConfirmed callback consumed too much weight."
|
||||
);
|
||||
log::error!(
|
||||
target: "runtime::bridge-messages",
|
||||
target: LOG_TARGET,
|
||||
"T::OnDeliveryConfirmed callback has spent more weight that it is allowed to: \
|
||||
{} vs {}",
|
||||
preliminary_callback_overhead,
|
||||
@@ -634,7 +633,7 @@ pub mod pallet {
|
||||
}
|
||||
|
||||
log::trace!(
|
||||
target: "runtime::bridge-messages",
|
||||
target: LOG_TARGET,
|
||||
"Received messages delivery proof up to (and including) {} at lane {:?}",
|
||||
last_delivered_nonce,
|
||||
lane_id,
|
||||
@@ -829,7 +828,7 @@ fn send_message<T: Config<I>, I: 'static>(
|
||||
// let's first check if message can be delivered to target chain
|
||||
T::TargetHeaderChain::verify_message(&payload).map_err(|err| {
|
||||
log::trace!(
|
||||
target: "runtime::bridge-messages",
|
||||
target: LOG_TARGET,
|
||||
"Message to lane {:?} is rejected by target chain: {:?}",
|
||||
lane_id,
|
||||
err,
|
||||
@@ -849,7 +848,7 @@ fn send_message<T: Config<I>, I: 'static>(
|
||||
)
|
||||
.map_err(|err| {
|
||||
log::trace!(
|
||||
target: "runtime::bridge-messages",
|
||||
target: LOG_TARGET,
|
||||
"Message to lane {:?} is rejected by lane verifier: {:?}",
|
||||
lane_id,
|
||||
err,
|
||||
@@ -866,7 +865,7 @@ fn send_message<T: Config<I>, I: 'static>(
|
||||
)
|
||||
.map_err(|err| {
|
||||
log::trace!(
|
||||
target: "runtime::bridge-messages",
|
||||
target: LOG_TARGET,
|
||||
"Message to lane {:?} is rejected because submitter is unable to pay fee {:?}: {:?}",
|
||||
lane_id,
|
||||
delivery_and_dispatch_fee,
|
||||
@@ -892,7 +891,7 @@ fn send_message<T: Config<I>, I: 'static>(
|
||||
Some(difference) if difference == 0 => (),
|
||||
Some(difference) => {
|
||||
log::trace!(
|
||||
target: "runtime::bridge-messages",
|
||||
target: LOG_TARGET,
|
||||
"T::OnMessageAccepted callback has spent less weight than expected. Refunding: \
|
||||
{} - {} = {}",
|
||||
single_message_callback_overhead,
|
||||
@@ -904,7 +903,7 @@ fn send_message<T: Config<I>, I: 'static>(
|
||||
None => {
|
||||
debug_assert!(false, "T::OnMessageAccepted callback consumed too much weight.");
|
||||
log::error!(
|
||||
target: "runtime::bridge-messages",
|
||||
target: LOG_TARGET,
|
||||
"T::OnMessageAccepted callback has spent more weight that it is allowed to: \
|
||||
{} vs {}",
|
||||
single_message_callback_overhead,
|
||||
@@ -923,7 +922,7 @@ fn send_message<T: Config<I>, I: 'static>(
|
||||
}
|
||||
|
||||
log::trace!(
|
||||
target: "runtime::bridge-messages",
|
||||
target: LOG_TARGET,
|
||||
"Accepted message {} to lane {:?}. Message size: {:?}",
|
||||
nonce,
|
||||
lane_id,
|
||||
|
||||
@@ -48,6 +48,9 @@ mod extension;
|
||||
#[cfg(test)]
|
||||
mod mock;
|
||||
|
||||
/// The target that will be used when publishing logs related to this pallet.
|
||||
const LOG_TARGET: &str = "runtime::bridge-parachains";
|
||||
|
||||
/// Block hash of the bridged relay chain.
|
||||
pub type RelayBlockHash = bp_polkadot_core::Hash;
|
||||
/// Block number of the bridged relay chain.
|
||||
@@ -208,7 +211,7 @@ pub mod pallet {
|
||||
// if we're not tracking this parachain, we'll just ignore its head proof here
|
||||
if !T::TrackedParachains::contains(¶chain) {
|
||||
log::trace!(
|
||||
target: "runtime::bridge-parachains",
|
||||
target: LOG_TARGET,
|
||||
"The head of parachain {:?} has been provided, but it is not tracked by the pallet",
|
||||
parachain,
|
||||
);
|
||||
@@ -219,7 +222,7 @@ pub mod pallet {
|
||||
Ok(Some(parachain_head)) => parachain_head,
|
||||
Ok(None) => {
|
||||
log::trace!(
|
||||
target: "runtime::bridge-parachains",
|
||||
target: LOG_TARGET,
|
||||
"The head of parachain {:?} is None. {}",
|
||||
parachain,
|
||||
if BestParaHeads::<T, I>::contains_key(¶chain) {
|
||||
@@ -232,7 +235,7 @@ pub mod pallet {
|
||||
},
|
||||
Err(e) => {
|
||||
log::trace!(
|
||||
target: "runtime::bridge-parachains",
|
||||
target: LOG_TARGET,
|
||||
"The read of head of parachain {:?} has failed: {:?}",
|
||||
parachain,
|
||||
e,
|
||||
@@ -325,7 +328,7 @@ pub mod pallet {
|
||||
// check if this head has already been imported before
|
||||
if updated_head_hash == stored_best_head.head_hash {
|
||||
log::trace!(
|
||||
target: "runtime::bridge-parachains",
|
||||
target: LOG_TARGET,
|
||||
"The head of parachain {:?} can't be updated to {}, because it has been already updated\
|
||||
to the same value at previous relay chain block: {} < {}",
|
||||
parachain,
|
||||
@@ -341,7 +344,7 @@ pub mod pallet {
|
||||
None => 0,
|
||||
Some(stored_best_head) => {
|
||||
log::trace!(
|
||||
target: "runtime::bridge-parachains",
|
||||
target: LOG_TARGET,
|
||||
"The head of parachain {:?} can't be updated to {}, because it has been already updated\
|
||||
to {} at better relay chain block: {} > {}",
|
||||
parachain,
|
||||
@@ -370,7 +373,7 @@ pub mod pallet {
|
||||
);
|
||||
ImportedParaHeads::<T, I>::insert(parachain, updated_head_hash, updated_head);
|
||||
log::trace!(
|
||||
target: "runtime::bridge-parachains",
|
||||
target: LOG_TARGET,
|
||||
"Updated head of parachain {:?} to {}",
|
||||
parachain,
|
||||
updated_head_hash,
|
||||
@@ -380,7 +383,7 @@ pub mod pallet {
|
||||
let prune_happened = head_hash_to_prune.is_ok();
|
||||
if let Ok(head_hash_to_prune) = head_hash_to_prune {
|
||||
log::trace!(
|
||||
target: "runtime::bridge-parachains",
|
||||
target: LOG_TARGET,
|
||||
"Pruning old head of parachain {:?}: {}",
|
||||
parachain,
|
||||
head_hash_to_prune,
|
||||
|
||||
Reference in New Issue
Block a user