Skip to content
Snippets Groups Projects
Commit 4dd569c3 authored by Éloïs's avatar Éloïs
Browse files

feat(runtimes): add pallet scheduler

parent 846f4d8d
No related branches found
No related tags found
1 merge request!9upgrade substrate to monthly-2022-01
...@@ -1844,6 +1844,7 @@ dependencies = [ ...@@ -1844,6 +1844,7 @@ dependencies = [
"pallet-identity", "pallet-identity",
"pallet-multisig", "pallet-multisig",
"pallet-randomness-collective-flip", "pallet-randomness-collective-flip",
"pallet-scheduler",
"pallet-sudo", "pallet-sudo",
"pallet-timestamp", "pallet-timestamp",
"pallet-transaction-payment", "pallet-transaction-payment",
...@@ -1895,6 +1896,7 @@ dependencies = [ ...@@ -1895,6 +1896,7 @@ dependencies = [
"pallet-identity", "pallet-identity",
"pallet-multisig", "pallet-multisig",
"pallet-randomness-collective-flip", "pallet-randomness-collective-flip",
"pallet-scheduler",
"pallet-sudo", "pallet-sudo",
"pallet-transaction-payment", "pallet-transaction-payment",
"pallet-transaction-payment-rpc-runtime-api", "pallet-transaction-payment-rpc-runtime-api",
...@@ -2040,6 +2042,7 @@ dependencies = [ ...@@ -2040,6 +2042,7 @@ dependencies = [
"pallet-identity", "pallet-identity",
"pallet-multisig", "pallet-multisig",
"pallet-randomness-collective-flip", "pallet-randomness-collective-flip",
"pallet-scheduler",
"pallet-sudo", "pallet-sudo",
"pallet-timestamp", "pallet-timestamp",
"pallet-transaction-payment", "pallet-transaction-payment",
...@@ -4062,6 +4065,21 @@ dependencies = [ ...@@ -4062,6 +4065,21 @@ dependencies = [
"sp-std", "sp-std",
] ]
[[package]]
name = "pallet-scheduler"
version = "4.0.0-dev"
source = "git+https://github.com/librelois/substrate.git?branch=duniter-monthly-2022-01#dfa512d0e1475ef671bab9b4d76c17f20a1a297a"
dependencies = [
"frame-support",
"frame-system",
"log",
"parity-scale-codec",
"scale-info",
"sp-io",
"sp-runtime",
"sp-std",
]
[[package]] [[package]]
name = "pallet-session" name = "pallet-session"
version = "4.0.0-dev" version = "4.0.0-dev"
......
...@@ -19,6 +19,8 @@ macro_rules! pallets_config { ...@@ -19,6 +19,8 @@ macro_rules! pallets_config {
{$($custom:tt)*} => { {$($custom:tt)*} => {
$($custom)* $($custom)*
// SYSTEM //
impl frame_system::Config for Runtime { impl frame_system::Config for Runtime {
/// The basic call filter to use in dispatchable. /// The basic call filter to use in dispatchable.
type BaseCallFilter = frame_support::traits::Everything; type BaseCallFilter = frame_support::traits::Everything;
...@@ -71,27 +73,40 @@ macro_rules! pallets_config { ...@@ -71,27 +73,40 @@ macro_rules! pallets_config {
type MaxConsumers = frame_support::traits::ConstU32<16>; type MaxConsumers = frame_support::traits::ConstU32<16>;
} }
impl pallet_grandpa::Config for Runtime { // SCHEDULER //
parameter_types! {
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) *
BlockWeights::get().max_block;
pub const MaxScheduledPerBlock: u32 = 50;
}
/// Used the compare the privilege of an origin inside the scheduler.
pub struct OriginPrivilegeCmp;
impl frame_support::traits::PrivilegeCmp<OriginCaller> for OriginPrivilegeCmp {
fn cmp_privilege(left: &OriginCaller, right: &OriginCaller) -> Option<core::cmp::Ordering> {
if left == right {
Some(core::cmp::Ordering::Equal)
} else {
None
}
}
}
impl pallet_scheduler::Config for Runtime {
type Event = Event; type Event = Event;
type Origin = Origin;
type PalletsOrigin = OriginCaller;
type Call = Call; type Call = Call;
type MaximumWeight = MaximumSchedulerWeight;
type KeyOwnerProofSystem = (); type ScheduleOrigin = frame_system::EnsureSigned<AccountId>;
type OriginPrivilegeCmp = OriginPrivilegeCmp;
type KeyOwnerProof = type MaxScheduledPerBlock = MaxScheduledPerBlock;
<Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof; type WeightInfo = pallet_scheduler::weights::SubstrateWeight<Runtime>;
type PreimageProvider = ();
type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<( type NoPreimagePostponement = ();
KeyTypeId,
GrandpaId,
)>>::IdentificationTuple;
type HandleEquivocation = ();
type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;
} }
// MONEY //
impl pallet_balances::Config for Runtime { impl pallet_balances::Config for Runtime {
type MaxLocks = MaxLocks; type MaxLocks = MaxLocks;
type MaxReserves = (); type MaxReserves = ();
...@@ -114,6 +129,29 @@ macro_rules! pallets_config { ...@@ -114,6 +129,29 @@ macro_rules! pallets_config {
type FeeMultiplierUpdate = (); type FeeMultiplierUpdate = ();
} }
// CONSENSUS //
impl pallet_grandpa::Config for Runtime {
type Event = Event;
type Call = Call;
type KeyOwnerProofSystem = ();
type KeyOwnerProof =
<Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;
type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
KeyTypeId,
GrandpaId,
)>>::IdentificationTuple;
type HandleEquivocation = ();
type WeightInfo = ();
type MaxAuthorities = MaxAuthorities;
}
// UTILITY // // UTILITY //
impl pallet_utility::Config for Runtime { impl pallet_utility::Config for Runtime {
......
...@@ -136,6 +136,11 @@ default-features = false ...@@ -136,6 +136,11 @@ default-features = false
git = 'https://github.com/librelois/substrate.git' git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01' branch = 'duniter-monthly-2022-01'
[dependencies.pallet-scheduler]
default-features = false
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.pallet-sudo] [dependencies.pallet-sudo]
default-features = false default-features = false
git = 'https://github.com/librelois/substrate.git' git = 'https://github.com/librelois/substrate.git'
......
...@@ -158,12 +158,14 @@ construct_runtime!( ...@@ -158,12 +158,14 @@ construct_runtime!(
{ {
// Basic stuff // Basic stuff
System: frame_system::{Pallet, Call, Config, Storage, Event<T>} = 0, System: frame_system::{Pallet, Call, Config, Storage, Event<T>} = 0,
//Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 1, Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 1,
// Must be before session. // Must be before session.
Aura: pallet_aura::{Pallet, Config<T>} = 2, Aura: pallet_aura::{Pallet, Config<T>} = 2,
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 3, Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 3,
// Money management
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 5, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 5,
TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 32, TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 32,
...@@ -177,7 +179,7 @@ construct_runtime!( ...@@ -177,7 +179,7 @@ construct_runtime!(
// Cunning utilities. // Cunning utilities.
Utility: pallet_utility::{Pallet, Call, Event} = 30, Utility: pallet_utility::{Pallet, Call, Event} = 30,
// Universal dividend. // Money creation
UdAccountsStorage: pallet_ud_accounts_storage::{Pallet, Config<T>, Storage} = 40, UdAccountsStorage: pallet_ud_accounts_storage::{Pallet, Config<T>, Storage} = 40,
UniversalDividend: pallet_universal_dividend::{Pallet, Config<T>, Storage, Event<T>} = 41, UniversalDividend: pallet_universal_dividend::{Pallet, Config<T>, Storage, Event<T>} = 41,
......
...@@ -137,6 +137,11 @@ default-features = false ...@@ -137,6 +137,11 @@ default-features = false
git = 'https://github.com/librelois/substrate.git' git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01' branch = 'duniter-monthly-2022-01'
[dependencies.pallet-scheduler]
default-features = false
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.pallet-sudo] [dependencies.pallet-sudo]
default-features = false default-features = false
git = 'https://github.com/librelois/substrate.git' git = 'https://github.com/librelois/substrate.git'
......
...@@ -145,7 +145,7 @@ construct_runtime!( ...@@ -145,7 +145,7 @@ construct_runtime!(
{ {
// Basic stuff // Basic stuff
System: frame_system::{Pallet, Call, Config, Storage, Event<T>} = 0, System: frame_system::{Pallet, Call, Config, Storage, Event<T>} = 0,
//Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 1, Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 1,
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 5, Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 5,
TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 32, TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 32,
......
...@@ -136,6 +136,11 @@ default-features = false ...@@ -136,6 +136,11 @@ default-features = false
git = 'https://github.com/librelois/substrate.git' git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01' branch = 'duniter-monthly-2022-01'
[dependencies.pallet-scheduler]
default-features = false
git = 'https://github.com/librelois/substrate.git'
branch = 'duniter-monthly-2022-01'
[dependencies.pallet-sudo] [dependencies.pallet-sudo]
default-features = false default-features = false
git = 'https://github.com/librelois/substrate.git' git = 'https://github.com/librelois/substrate.git'
......
...@@ -158,7 +158,7 @@ construct_runtime!( ...@@ -158,7 +158,7 @@ construct_runtime!(
{ {
// Basic stuff // Basic stuff
System: frame_system::{Pallet, Call, Config, Storage, Event<T>} = 0, System: frame_system::{Pallet, Call, Config, Storage, Event<T>} = 0,
//Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 1, Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 1,
// Must be before session. // Must be before session.
Aura: pallet_aura::{Pallet, Config<T>} = 2, Aura: pallet_aura::{Pallet, Config<T>} = 2,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment