Skip to content
Snippets Groups Projects
Unverified Commit baef83b3 authored by bgallois's avatar bgallois
Browse files

add digest decoding complexity

parent 7c308146
No related branches found
No related tags found
No related merge requests found
Pipeline #33798 waiting for manual action
......@@ -5855,6 +5855,7 @@ dependencies = [
"pallet-session",
"parity-scale-codec",
"scale-info",
"sp-consensus-babe",
"sp-core",
"sp-distance",
"sp-inherents",
......
......@@ -12,7 +12,9 @@ version = '1.0.0'
[features]
default = ['std']
runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks",
"pallet-balances", "pallet-identity/runtime-benchmarks",
"pallet-balances",
"pallet-identity/runtime-benchmarks",
"sp-consensus-babe",
]
std = [
'codec/std',
......@@ -35,6 +37,7 @@ pallet-authority-members = { path = "../authority-members", default-features = f
pallet-identity = { path = "../identity", default-features = false }
pallet-membership = { path = "../membership", default-features = false }
sp-distance = { path = "../../primitives/distance", default-features = false }
sp-consensus-babe = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.42', default-features = false, optional = true }
# substrate
scale-info = { version = "2.1.1", default-features = false, features = [
......@@ -101,6 +104,6 @@ branch = 'duniter-substrate-v0.9.42'
targets = ['x86_64-unknown-linux-gnu']
[dev-dependencies]
pallet-balances = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.42' }
sp-io = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.42' }
sp-keystore = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.42' }
pallet-balances = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.42', default-features = false }
sp-io = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.42', default-features = false }
sp-keystore = { git = 'https://github.com/duniter/substrate', branch = 'duniter-substrate-v0.9.42', default-features = false }
......@@ -18,6 +18,7 @@
use super::*;
use codec::Encode;
use frame_benchmarking::{benchmarks, vec};
use frame_support::traits::{Currency, OnFinalize};
use frame_system::RawOrigin;
......@@ -55,10 +56,15 @@ benchmarks! {
assert!(IdentityDistanceStatus::<T>::get(&idty) == Some((caller, DistanceStatus::Pending)), "Request not added");
}
update_evaluation {
let idty = T::IdtyIndex::one();
let caller: T::AccountId = pallet_identity::Identities::<T>::get(idty).unwrap().owner_key;
let caller_origin: <T as frame_system::Config>::RuntimeOrigin = RawOrigin::Signed(caller.clone()).into();
let i in 1 .. MAX_EVALUATIONS_PER_SESSION => populate_pool::<T>(i)?;
let digest_data = sp_consensus_babe::digests::PreDigest::SecondaryPlain(
sp_consensus_babe::digests::SecondaryPlainPreDigest { authority_index: 0u32, slot: Default::default() },
);
let digest = sp_runtime::DigestItem::PreRuntime(*b"BABE", digest_data.encode());
let _ = <frame_system::Pallet<T>>::deposit_log(digest);
let idty = T::IdtyIndex::one();
let caller: T::AccountId = pallet_identity::Identities::<T>::get(idty).unwrap().owner_key;
let caller_origin: <T as frame_system::Config>::RuntimeOrigin = RawOrigin::Signed(caller.clone()).into();
let i in 1 .. MAX_EVALUATIONS_PER_SESSION => populate_pool::<T>(i)?;
}: _<T::RuntimeOrigin>(RawOrigin::None.into(), ComputationResult{distances: vec![Perbill::one(); i as usize]})
force_update_evaluation {
let idty = T::IdtyIndex::one();
......
......@@ -220,9 +220,6 @@ macro_rules! pallets_config {
}
impl pallet_authorship::Config for Runtime {
type EventHandler = ImOnline;
#[cfg(feature = "runtime-benchmarks")]
type FindAuthor = common_runtime::providers::ConstantAuthor<Self::AccountId>;
#[cfg(not(feature = "runtime-benchmarks"))]
type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>;
}
impl pallet_im_online::Config for Runtime {
......
......@@ -155,16 +155,3 @@ macro_rules! impl_benchmark_setup_handler {
impl_benchmark_setup_handler!(pallet_membership::SetupBenchmark<<T as pallet_identity::Config>::IdtyIndex, T::AccountId>);
#[cfg(feature = "runtime-benchmarks")]
impl_benchmark_setup_handler!(pallet_identity::traits::SetupBenchmark<<T as pallet_identity::Config>::IdtyIndex, T::AccountId>);
#[cfg(feature = "runtime-benchmarks")]
pub struct ConstantAuthor<T>(PhantomData<T>);
#[cfg(feature = "runtime-benchmarks")]
impl<T: From<[u8; 32]>> frame_support::traits::FindAuthor<T> for ConstantAuthor<T> {
fn find_author<'a, I>(_: I) -> Option<T>
where
I: 'a + IntoIterator<Item = (sp_runtime::ConsensusEngineId, &'a [u8])>,
{
Some([0; 32].into())
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment