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 = [
"pallet-identity",
"pallet-multisig",
"pallet-randomness-collective-flip",
"pallet-scheduler",
"pallet-sudo",
"pallet-timestamp",
"pallet-transaction-payment",
......@@ -1895,6 +1896,7 @@ dependencies = [
"pallet-identity",
"pallet-multisig",
"pallet-randomness-collective-flip",
"pallet-scheduler",
"pallet-sudo",
"pallet-transaction-payment",
"pallet-transaction-payment-rpc-runtime-api",
......@@ -2040,6 +2042,7 @@ dependencies = [
"pallet-identity",
"pallet-multisig",
"pallet-randomness-collective-flip",
"pallet-scheduler",
"pallet-sudo",
"pallet-timestamp",
"pallet-transaction-payment",
......@@ -4062,6 +4065,21 @@ dependencies = [
"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]]
name = "pallet-session"
version = "4.0.0-dev"
......
......@@ -19,6 +19,8 @@ macro_rules! pallets_config {
{$($custom:tt)*} => {
$($custom)*
// SYSTEM //
impl frame_system::Config for Runtime {
/// The basic call filter to use in dispatchable.
type BaseCallFilter = frame_support::traits::Everything;
......@@ -71,28 +73,41 @@ macro_rules! pallets_config {
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
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;
// SCHEDULER //
type HandleEquivocation = ();
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 Origin = Origin;
type PalletsOrigin = OriginCaller;
type Call = Call;
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = frame_system::EnsureSigned<AccountId>;
type OriginPrivilegeCmp = OriginPrivilegeCmp;
type MaxScheduledPerBlock = MaxScheduledPerBlock;
type WeightInfo = pallet_scheduler::weights::SubstrateWeight<Runtime>;
type PreimageProvider = ();
type NoPreimagePostponement = ();
}
type WeightInfo = ();
// MONEY //
type MaxAuthorities = MaxAuthorities;
}
impl pallet_balances::Config for Runtime {
impl pallet_balances::Config for Runtime {
type MaxLocks = MaxLocks;
type MaxReserves = ();
type ReserveIdentifier = [u8; 8];
......@@ -114,6 +129,29 @@ macro_rules! pallets_config {
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 //
impl pallet_utility::Config for Runtime {
......
......@@ -136,6 +136,11 @@ default-features = false
git = 'https://github.com/librelois/substrate.git'
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]
default-features = false
git = 'https://github.com/librelois/substrate.git'
......
......@@ -158,12 +158,14 @@ construct_runtime!(
{
// Basic stuff
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.
Aura: pallet_aura::{Pallet, Config<T>} = 2,
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 3,
// Money management
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 5,
TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 32,
......@@ -177,7 +179,7 @@ construct_runtime!(
// Cunning utilities.
Utility: pallet_utility::{Pallet, Call, Event} = 30,
// Universal dividend.
// Money creation
UdAccountsStorage: pallet_ud_accounts_storage::{Pallet, Config<T>, Storage} = 40,
UniversalDividend: pallet_universal_dividend::{Pallet, Config<T>, Storage, Event<T>} = 41,
......
......@@ -137,6 +137,11 @@ default-features = false
git = 'https://github.com/librelois/substrate.git'
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]
default-features = false
git = 'https://github.com/librelois/substrate.git'
......
......@@ -145,7 +145,7 @@ construct_runtime!(
{
// Basic stuff
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,
TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 32,
......
......@@ -136,6 +136,11 @@ default-features = false
git = 'https://github.com/librelois/substrate.git'
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]
default-features = false
git = 'https://github.com/librelois/substrate.git'
......
......@@ -158,7 +158,7 @@ construct_runtime!(
{
// Basic stuff
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.
Aura: pallet_aura::{Pallet, Config<T>} = 2,
......
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