diff --git a/Cargo.lock b/Cargo.lock index 46df2a5460cfe2d10760ac185c9d96bff4163689..c4f15f40cebd8d261d48bd05410a8e2d0c0a2ad9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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" diff --git a/runtime/common/src/pallets_config.rs b/runtime/common/src/pallets_config.rs index 93e22bfa4431e973a5415d8269fc1966da6c2d20..c57a126ca6dc8b8ef81816ff466b5df57dd9903a 100644 --- a/runtime/common/src/pallets_config.rs +++ b/runtime/common/src/pallets_config.rs @@ -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 { diff --git a/runtime/g1/Cargo.toml b/runtime/g1/Cargo.toml index e12cc5fcf1deda839c2a4f723575eb371e8b04dc..e16e911376bc62e9fa18aab04f3e7a0169d8c6ab 100644 --- a/runtime/g1/Cargo.toml +++ b/runtime/g1/Cargo.toml @@ -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' diff --git a/runtime/g1/src/lib.rs b/runtime/g1/src/lib.rs index c1b7654777c7d8a48f56f89154777625265c175a..1f6242d85e19333e1d5f0ae36d587f8dd0bb8e17 100644 --- a/runtime/g1/src/lib.rs +++ b/runtime/g1/src/lib.rs @@ -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, diff --git a/runtime/gdev/Cargo.toml b/runtime/gdev/Cargo.toml index 68362062565c245edbb7b1928bd709c39c0d14ab..29fb2f9aa189d56602312809df704d940416932b 100644 --- a/runtime/gdev/Cargo.toml +++ b/runtime/gdev/Cargo.toml @@ -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' diff --git a/runtime/gdev/src/lib.rs b/runtime/gdev/src/lib.rs index b32ddf09c93f6a59b0a7765f87abc08b0ce16317..a6c6f192db5cb8a36daa6c70fad7c596f35c82ef 100644 --- a/runtime/gdev/src/lib.rs +++ b/runtime/gdev/src/lib.rs @@ -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, diff --git a/runtime/gtest/Cargo.toml b/runtime/gtest/Cargo.toml index 0be68f7c4e63d8f7bde8bcff97ec53dad98937cb..bfaa9575507966af9a76494df6427d027c51bde5 100644 --- a/runtime/gtest/Cargo.toml +++ b/runtime/gtest/Cargo.toml @@ -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' diff --git a/runtime/gtest/src/lib.rs b/runtime/gtest/src/lib.rs index daa107033bd8d1324b281b58aa007d851a008783..e20e00ab14b6081f97dfe3dc9d2af7483fc1b0c1 100644 --- a/runtime/gtest/src/lib.rs +++ b/runtime/gtest/src/lib.rs @@ -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,