mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 12:11:02 +00:00
Wire Finality Verifier Pallet Into Runtimes (#696)
* Add Finality Verifier pallet to runtimes * Implement simple ancestry checker * Use the new checker in runtimes * Remove unused import warning * Bump max allowed ancestry proof size * Add a few optimization suggestions when verifying ancestry * Use session length as upper bound for ancestry proof size * Remove unused time units
This commit is contained in:
committed by
Bastian Köcher
parent
d73100cb30
commit
8c7d0ca35d
@@ -37,11 +37,16 @@ use bp_runtime::{Chain, HeaderOf};
|
||||
use finality_grandpa::voter_set::VoterSet;
|
||||
use frame_support::{dispatch::DispatchError, ensure, traits::Get};
|
||||
use frame_system::ensure_signed;
|
||||
use num_traits::AsPrimitive;
|
||||
use sp_runtime::traits::Header as HeaderT;
|
||||
use sp_std::vec::Vec;
|
||||
|
||||
#[cfg(test)]
|
||||
mod mock;
|
||||
|
||||
// Re-export in crate namespace for `construct_runtime!`
|
||||
pub use pallet::*;
|
||||
|
||||
#[frame_support::pallet]
|
||||
pub mod pallet {
|
||||
use super::*;
|
||||
@@ -69,7 +74,7 @@ pub mod pallet {
|
||||
/// The maximum length of headers we can have in a single ancestry proof. This prevents
|
||||
/// unbounded iteration when verifying proofs.
|
||||
#[pallet::constant]
|
||||
type MaxHeadersInSingleProof: Get<u8>;
|
||||
type MaxHeadersInSingleProof: Get<<Self::BridgedChain as Chain>::BlockNumber>;
|
||||
}
|
||||
|
||||
#[pallet::pallet]
|
||||
@@ -100,7 +105,7 @@ pub mod pallet {
|
||||
let _ = ensure_signed(origin)?;
|
||||
|
||||
ensure!(
|
||||
ancestry_proof.len() <= T::MaxHeadersInSingleProof::get() as usize,
|
||||
ancestry_proof.len() <= T::MaxHeadersInSingleProof::get().as_(),
|
||||
<Error<T>>::OversizedAncestryProof
|
||||
);
|
||||
|
||||
@@ -149,7 +154,6 @@ pub mod pallet {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::pallet::*;
|
||||
use super::*;
|
||||
use crate::mock::{run_test, test_header, Origin, TestRuntime};
|
||||
use bp_test_utils::{authority_list, make_justification_for_header};
|
||||
|
||||
Reference in New Issue
Block a user