-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Replace log with tracing on pallet-bridge-grandpa
#9294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
79967fe
8582358
016fc26
45632ae
1be97ce
7da8b77
746c791
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,7 +85,7 @@ impl<T: Config<I>, I: 'static> SubmitFinalityProofHelper<T, I> { | |
|
|
||
| // else - if we can not accept more free headers, "reject" the transaction | ||
| if !Self::has_free_header_slots() { | ||
| log::trace!( | ||
| tracing::trace!( | ||
| target: crate::LOG_TARGET, | ||
| "Cannot accept free {:?} header {:?}. No more free slots remaining", | ||
| T::BridgedChain::ID, | ||
|
|
@@ -99,14 +99,12 @@ impl<T: Config<I>, I: 'static> SubmitFinalityProofHelper<T, I> { | |
| if !call_info.is_mandatory { | ||
| if let Some(free_headers_interval) = T::FreeHeadersInterval::get() { | ||
| if improved_by < free_headers_interval.into() { | ||
| log::trace!( | ||
| tracing::trace!( | ||
| target: crate::LOG_TARGET, | ||
| "Cannot accept free {:?} header {:?}. Too small difference \ | ||
| between submitted headers: {:?} vs {}", | ||
| between submitted headers: {improved_by:?} vs {free_headers_interval}", | ||
|
||
| T::BridgedChain::ID, | ||
| call_info.block_number, | ||
| improved_by, | ||
| free_headers_interval, | ||
| ); | ||
|
|
||
| return Err(Error::<T, I>::BelowFreeHeaderInterval); | ||
|
|
@@ -137,22 +135,22 @@ impl<T: Config<I>, I: 'static> SubmitFinalityProofHelper<T, I> { | |
| current_set_id: Option<SetId>, | ||
| ) -> Result<BlockNumberOf<T::BridgedChain>, Error<T, I>> { | ||
| let best_finalized = BestFinalized::<T, I>::get().ok_or_else(|| { | ||
| log::trace!( | ||
| tracing::trace!( | ||
| target: crate::LOG_TARGET, | ||
| "Cannot finalize header {:?} because pallet is not yet initialized", | ||
| finality_target, | ||
| header=?finality_target, | ||
| "Cannot finalize header because pallet is not yet initialized" | ||
| ); | ||
| <Error<T, I>>::NotInitialized | ||
| })?; | ||
|
|
||
| let improved_by = match finality_target.checked_sub(&best_finalized.number()) { | ||
| Some(improved_by) if improved_by > Zero::zero() => improved_by, | ||
| _ => { | ||
| log::trace!( | ||
| tracing::trace!( | ||
| target: crate::LOG_TARGET, | ||
| "Cannot finalize obsolete header: bundled {:?}, best {:?}", | ||
| finality_target, | ||
| best_finalized, | ||
| bundled=?finality_target, | ||
| best=?best_finalized, | ||
| "Cannot finalize obsolete header" | ||
| ); | ||
|
|
||
| return Err(Error::<T, I>::OldHeader) | ||
|
|
@@ -162,11 +160,11 @@ impl<T: Config<I>, I: 'static> SubmitFinalityProofHelper<T, I> { | |
| if let Some(current_set_id) = current_set_id { | ||
| let actual_set_id = <CurrentAuthoritySet<T, I>>::get().set_id; | ||
| if current_set_id != actual_set_id { | ||
| log::trace!( | ||
| tracing::trace!( | ||
| target: crate::LOG_TARGET, | ||
| "Cannot finalize header signed by unknown authority set: bundled {:?}, best {:?}", | ||
| current_set_id, | ||
| actual_set_id, | ||
| bundled=?current_set_id, | ||
| best=?actual_set_id, | ||
| "Cannot finalize header signed by unknown authority set" | ||
| ); | ||
|
|
||
| return Err(Error::<T, I>::InvalidAuthoritySetId) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -219,10 +219,10 @@ pub mod pallet { | |
| ensure!(init_allowed, <Error<T, I>>::AlreadyInitialized); | ||
| initialize_bridge::<T, I>(init_data.clone())?; | ||
|
|
||
| log::info!( | ||
| tracing::info!( | ||
| target: LOG_TARGET, | ||
| "Pallet has been initialized with the following parameters: {:?}", | ||
| init_data | ||
| parameters=?init_data, | ||
| "Pallet has been initialized" | ||
| ); | ||
|
|
||
| Ok(().into()) | ||
|
|
@@ -292,10 +292,10 @@ pub mod pallet { | |
| ensure_signed(origin)?; | ||
|
|
||
| let (hash, number) = (finality_target.hash(), *finality_target.number()); | ||
| log::trace!( | ||
| tracing::trace!( | ||
| target: LOG_TARGET, | ||
| "Going to try and finalize header {:?}", | ||
| finality_target | ||
| header=?finality_target, | ||
| "Going to try and finalize header" | ||
| ); | ||
|
|
||
| // it checks whether the `number` is better than the current best block number | ||
|
|
@@ -332,10 +332,10 @@ pub mod pallet { | |
| // to pay for the transaction. | ||
| let pays_fee = if may_refund_call_fee { Pays::No } else { Pays::Yes }; | ||
|
|
||
| log::info!( | ||
| tracing::info!( | ||
| target: LOG_TARGET, | ||
| "Successfully imported finalized header with hash {:?}! Free: {}", | ||
| hash, | ||
| ?hash, | ||
| "Successfully imported finalized header! Free: {}", | ||
| if may_refund_call_fee { "Yes" } else { "No" }, | ||
|
||
| ); | ||
|
|
||
|
|
@@ -656,12 +656,12 @@ pub mod pallet { | |
|
|
||
| <CurrentAuthoritySet<T, I>>::put(&next_authorities); | ||
|
|
||
| log::info!( | ||
| tracing::info!( | ||
| target: LOG_TARGET, | ||
| "Transitioned from authority set {} to {}! New authorities are: {:?}", | ||
| old_current_set_id, | ||
| new_current_set_id, | ||
| next_authorities, | ||
| %old_current_set_id, | ||
| %new_current_set_id, | ||
| ?next_authorities, | ||
| "Transitioned from authority set!" | ||
| ); | ||
|
|
||
| Ok(Some(next_authorities.into())) | ||
|
|
@@ -687,11 +687,11 @@ pub mod pallet { | |
| justification, | ||
| ) | ||
| .map_err(|e| { | ||
| log::error!( | ||
| tracing::error!( | ||
| target: LOG_TARGET, | ||
| "Received invalid justification for {:?}: {:?}", | ||
| hash, | ||
| e, | ||
| error=?e, | ||
| ?hash, | ||
| "Received invalid justification" | ||
| ); | ||
| <Error<T, I>>::InvalidJustification | ||
| })?) | ||
|
|
@@ -714,7 +714,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: LOG_TARGET, "Pruning old header: {:?}.", hash); | ||
| tracing::debug!(target: LOG_TARGET, ?hash, "Pruning old header."); | ||
| <ImportedHeaders<T, I>>::remove(hash); | ||
| } | ||
| } | ||
|
|
@@ -729,10 +729,9 @@ pub mod pallet { | |
| let authority_set_length = authority_list.len(); | ||
| let authority_set = StoredAuthoritySet::<T, I>::try_new(authority_list, set_id) | ||
| .inspect_err(|_| { | ||
| log::error!( | ||
| tracing::error!( | ||
| target: LOG_TARGET, | ||
| "Failed to initialize bridge. Number of authorities in the set {} is larger than the configured value {}", | ||
| authority_set_length, | ||
| "Failed to initialize bridge. Number of authorities in the set {authority_set_length} is larger than the configured value {}", | ||
|
||
| T::BridgedChain::MAX_AUTHORITIES_COUNT, | ||
| ); | ||
| })?; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| title: Replace `log` with `tracing` on `pallet-bridge-grandpa` | ||
| doc: | ||
| - audience: Runtime Dev | ||
| description: This PR replaces `log` with `tracing` instrumentation on `pallet-bridge-grandpa` | ||
| by providing structured logging. | ||
| crates: | ||
| - name: bridge-runtime-common | ||
| bump: minor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you leave these
{:?} header {:?}on purpose here ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed