Skip to content

Commit

Permalink
fix the build
Browse files Browse the repository at this point in the history
  • Loading branch information
samelamin committed Nov 24, 2023
1 parent da5a21b commit abf4775
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 86 deletions.
4 changes: 3 additions & 1 deletion pallets/briefs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"pallet-deposits/runtime-benchmarks",
"pallet-proposals/runtime-benchmarks"
"pallet-proposals/runtime-benchmarks",
"pallet-disputes/runtime-benchmarks",
"pallet-fellowship/runtime-benchmarks"
]

try-runtime = [
Expand Down
3 changes: 2 additions & 1 deletion pallets/disputes/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::traits::DisputeRaiser;
use crate::Pallet as PalletDisputes;
use frame_benchmarking::v2::*;
use frame_support::{assert_ok, traits::Get, BoundedVec};
use frame_system::pallet_prelude::BlockNumberFor;
use frame_system::Pallet as System;
use sp_std::vec::Vec;

Expand Down Expand Up @@ -161,7 +162,7 @@ mod benchmarks {
}

pub fn get_jury<T: Config>(
accounts: Vec<BlockNumberFor<T>>,
accounts: Vec<AccountIdOf<T>>,
) -> BoundedVec<AccountIdOf<T>, <T as Config>::MaxJurySize> {
accounts.try_into().expect("too many jury members")
}
Expand Down
77 changes: 58 additions & 19 deletions pallets/fellowship/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ use crate::{traits::FellowshipHandle, Config, Role};
use common_types::CurrencyId;
use frame_benchmarking::v2::*;
use frame_support::assert_ok;
use frame_system::pallet_prelude::BlockNumberFor;
use frame_system::Pallet as System;
use frame_system::RawOrigin;
use orml_traits::MultiCurrency;
use sp_runtime::SaturatedConversion;
use sp_std::vec;

#[benchmarks( where BlockNumberFor<T>: AsRef<[u8]>, crate::Event::<T>: Into<<T as frame_system::Config>::RuntimeEvent>)]
#[benchmarks( where crate::Event::<T>: Into<<T as frame_system::Config>::RuntimeEvent>)]
mod benchmarks {
use super::*;

#[benchmark]
fn add_to_fellowship() {
let alice: T::AccountId =
Expand All @@ -23,7 +24,13 @@ mod benchmarks {

#[block]
{
<crate::Pallet<T> as FellowshipHandle<BlockNumberFor<T>>>::add_to_fellowship(&alice, Role::Vetter, 10, Some(&bob), true);
<crate::Pallet<T> as FellowshipHandle<AccountIdOf<T>>>::add_to_fellowship(
&alice,
Role::Vetter,
10,
Some(&bob),
true,
);
}
}

Expand All @@ -47,7 +54,13 @@ mod benchmarks {
let alice: T::AccountId =
create_funded_user::<T>("alice", 1, 1_000_000_000_000_000_000u128);
let bob: T::AccountId = create_funded_user::<T>("bob", 1, 1_000_000_000_000_000_000u128);
<crate::Pallet<T> as FellowshipHandle<BlockNumberFor<T>>>::add_to_fellowship(&alice, Role::Vetter, 10, Some(&bob), true);
<crate::Pallet<T> as FellowshipHandle<AccountIdOf<T>>>::add_to_fellowship(
&alice,
Role::Vetter,
10,
Some(&bob),
true,
);

#[extrinsic_call]
leave_fellowship(RawOrigin::Signed(alice.clone()));
Expand All @@ -60,7 +73,13 @@ mod benchmarks {
let alice: T::AccountId =
create_funded_user::<T>("alice", 1, 1_000_000_000_000_000_000u128);
let bob: T::AccountId = create_funded_user::<T>("bob", 1, 1_000_000_000_000_000_000u128);
<crate::Pallet<T> as FellowshipHandle<BlockNumberFor<T>>>::add_to_fellowship(&alice, Role::Vetter, 10, Some(&bob), true);
<crate::Pallet<T> as FellowshipHandle<AccountIdOf<T>>>::add_to_fellowship(
&alice,
Role::Vetter,
10,
Some(&bob),
true,
);

#[extrinsic_call]
force_remove_and_slash_fellowship(RawOrigin::Root, alice.clone());
Expand All @@ -72,7 +91,13 @@ mod benchmarks {
let alice: T::AccountId =
create_funded_user::<T>("alice", 1, 1_000_000_000_000_000_000u128);
let bob: T::AccountId = create_funded_user::<T>("bob", 1, 1_000_000_000_000_000_000u128);
<crate::Pallet<T> as FellowshipHandle<BlockNumberFor<T>>>::add_to_fellowship(&alice, Role::Vetter, 10, Some(&bob), true);
<crate::Pallet<T> as FellowshipHandle<AccountIdOf<T>>>::add_to_fellowship(
&alice,
Role::Vetter,
10,
Some(&bob),
true,
);

#[extrinsic_call]
add_candidate_to_shortlist(RawOrigin::Signed(alice), bob.clone(), Role::Vetter, 10);
Expand All @@ -84,7 +109,13 @@ mod benchmarks {
let alice: T::AccountId =
create_funded_user::<T>("alice", 1, 1_000_000_000_000_000_000u128);
let bob: T::AccountId = create_funded_user::<T>("bob", 1, 1_000_000_000_000_000_000u128);
<crate::Pallet<T> as FellowshipHandle<BlockNumberFor<T>>>::add_to_fellowship(&alice, Role::Vetter, 10, Some(&bob), true);
<crate::Pallet<T> as FellowshipHandle<AccountIdOf<T>>>::add_to_fellowship(
&alice,
Role::Vetter,
10,
Some(&bob),
true,
);
assert_ok!(Fellowship::<T>::add_candidate_to_shortlist(
RawOrigin::Signed(alice.clone()).into(),
bob.clone(),
Expand All @@ -105,14 +136,20 @@ mod benchmarks {
let charlie: T::AccountId =
create_funded_user::<T>("alice", 1, 1_000_000_000_000_000_000u128);

<crate::Pallet<T> as FellowshipHandle<BlockNumberFor<T>>>::add_to_fellowship(&bob, Role::Vetter, 10, Some(&charlie), true);
assert_ok!(<T::MultiCurrency as MultiCurrency<
BlockNumberFor<T>,
>>::deposit(
CurrencyId::Native,
<crate::Pallet<T> as FellowshipHandle<AccountIdOf<T>>>::add_to_fellowship(
&bob,
1_000_000_000_000_000_000u128.saturated_into()
));
Role::Vetter,
10,
Some(&charlie),
true,
);
assert_ok!(
<T::MultiCurrency as MultiCurrency<AccountIdOf<T>>>::deposit(
CurrencyId::Native,
&bob,
1_000_000_000_000_000_000u128.saturated_into()
)
);

#[extrinsic_call]
pay_deposit_to_remove_pending_status(RawOrigin::Signed(bob.clone()));
Expand All @@ -134,10 +171,12 @@ pub fn create_funded_user<T: Config>(
balance_factor: u128,
) -> T::AccountId {
let user = account(seed, n, 0);
assert_ok!(<T::MultiCurrency as MultiCurrency<
BlockNumberFor<T>,
>>::deposit(
CurrencyId::Native, &user, balance_factor.saturated_into()
));
assert_ok!(
<T::MultiCurrency as MultiCurrency<AccountIdOf<T>>>::deposit(
CurrencyId::Native,
&user,
balance_factor.saturated_into()
)
);
user
}
4 changes: 3 additions & 1 deletion pallets/grants/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ runtime-benchmarks = [
"frame-system/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"pallet-deposits/runtime-benchmarks",
"pallet-proposals/runtime-benchmarks"
"pallet-proposals/runtime-benchmarks",
"pallet-disputes/runtime-benchmarks",
"pallet-fellowship/runtime-benchmarks"
]
try-runtime = [
"common-runtime/try-runtime",
Expand Down
7 changes: 3 additions & 4 deletions pallets/grants/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ use sp_std::{convert::TryInto, str, vec, vec::Vec};

const SEED: u32 = 0;

#[benchmarks( where
[u8; 32]: From<BlockNumberFor<T>>,
)]

// #[benchmarks( where
// [u8; 32]: From<AccountIdOf<T>>,
// )]
#[benchmarks]
mod benchmarks {
use super::*;
Expand Down
8 changes: 6 additions & 2 deletions pallets/proposals/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ frame-system = { git = "https://github.com/paritytech/polkadot-sdk", branch = "r
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-identity = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0"}
cumulus-pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
cumulus-primitives-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }
xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0", default-features = false }

orml-currencies = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v1.1.0" }
orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v1.1.0", default-features = false }
orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v1.1.0", default-features = false }
orml-xtokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v1.1.0", default-features = false }
Expand All @@ -54,9 +56,7 @@ sp-core = { git = "https://github.com/paritytech/polkadot-sdk", branch = "releas
sp-io = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0"}
sp-keystore = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0"}
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0"}
pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0"}
pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.1.0"}
orml-currencies = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v1.1.0" }
orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v1.1.0" }
orml-xtokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "polkadot-v1.1.0" }
common-runtime = { path = "../../runtime/common"}
Expand All @@ -79,13 +79,15 @@ std = [
"hex/std",
"lite-json/std",
"log/std",
"orml-currencies/std",
"orml-tokens/std",
"orml-traits/std",
"orml-xtokens/std",
"pallet-balances/std",
"pallet-deposits/std",
"pallet-identity/std",
"pallet-timestamp/std",
"pallet-transaction-payment/std",
"scale-info/std",
"serde/std",
"sp-api/std",
Expand All @@ -101,6 +103,8 @@ runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"pallet-deposits/runtime-benchmarks",
"pallet-disputes/runtime-benchmarks",
"pallet-fellowship/runtime-benchmarks"
]
try-runtime = [
"common-runtime/try-runtime",
Expand Down
Loading

0 comments on commit abf4775

Please sign in to comment.