Skip to content

Commit

Permalink
Add Logging to Finality Verifier Pallet (paritytech#702)
Browse files Browse the repository at this point in the history
* Add some logging to the finality verifier pallet

* Add finality target to happy path log
  • Loading branch information
HCastano authored and serban300 committed Apr 10, 2024
1 parent 707d27a commit 1372008
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions bridges/modules/finality-verifier/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ pub mod pallet {
) -> DispatchResultWithPostInfo {
let _ = ensure_signed(origin)?;

frame_support::debug::trace!("Going to try and finalize header {:?}", finality_target);
frame_support::debug::trace!("Got ancestry proof of length {}", ancestry_proof.len());

ensure!(
ancestry_proof.len() <= T::MaxHeadersInSingleProof::get().as_(),
<Error<T>>::OversizedAncestryProof
Expand All @@ -119,18 +122,30 @@ pub mod pallet {
voter_set,
&justification,
)
.map_err(|_| <Error<T>>::InvalidJustification)?;
.map_err(|e| {
frame_support::debug::error!("Received invalid justification for {:?}: {:?}", finality_target, e);
<Error<T>>::InvalidJustification
})?;

let best_finalized = T::HeaderChain::best_finalized();
frame_support::debug::trace!("Checking ancestry against best finalized header: {:?}", &best_finalized);

ensure!(
T::AncestryChecker::are_ancestors(&best_finalized, &finality_target, &ancestry_proof),
<Error<T>>::InvalidAncestryProof
);

// Note that this won't work if we ever change the `ancestry_proof` format to be
// sparse since this expects a contiguous set of finalized headers.
let _ =
T::HeaderChain::append_finalized_chain(ancestry_proof).map_err(|_| <Error<T>>::FailedToWriteHeader)?;
let _ = T::HeaderChain::append_finalized_chain(ancestry_proof).map_err(|_| {
frame_support::debug::error!("Failed to append finalized header chain.");
<Error<T>>::FailedToWriteHeader
})?;

frame_support::debug::info!(
"Succesfully imported finalized header chain for target header {:?}!",
finality_target
);

Ok(().into())
}
Expand Down

0 comments on commit 1372008

Please sign in to comment.