diff --git a/substrate/runtime/Cargo.toml b/substrate/runtime/Cargo.toml index 4c9654a2..7fba0184 100644 --- a/substrate/runtime/Cargo.toml +++ b/substrate/runtime/Cargo.toml @@ -46,14 +46,15 @@ pallet-timestamp = { git = "https://github.com/serai-dex/substrate", default-fea pallet-transaction-payment = { git = "https://github.com/serai-dex/substrate", default-features = false } coins-pallet = { package = "serai-coins-pallet", path = "../coins/pallet", default-features = false } -in-instructions-pallet = { package = "serai-in-instructions-pallet", path = "../in-instructions/pallet", default-features = false } +pallet-session = { git = "https://github.com/serai-dex/substrate", default-features = false } validator-sets-pallet = { package = "serai-validator-sets-pallet", path = "../validator-sets/pallet", default-features = false } staking-pallet = { package = "serai-staking-pallet", path = "../staking/pallet", default-features = false } +in-instructions-pallet = { package = "serai-in-instructions-pallet", path = "../in-instructions/pallet", default-features = false } + signals-pallet = { package = "serai-signals-pallet", path = "../signals/pallet", default-features = false } -pallet-session = { git = "https://github.com/serai-dex/substrate", default-features = false } pallet-babe = { git = "https://github.com/serai-dex/substrate", default-features = false } pallet-grandpa = { git = "https://github.com/serai-dex/substrate", default-features = false } @@ -100,14 +101,15 @@ std = [ "pallet-transaction-payment/std", "coins-pallet/std", - "in-instructions-pallet/std", + "pallet-session/std", "validator-sets-pallet/std", "staking-pallet/std", + "in-instructions-pallet/std", + "signals-pallet/std", - "pallet-session/std", "pallet-babe/std", "pallet-grandpa/std", diff --git a/substrate/runtime/src/lib.rs b/substrate/runtime/src/lib.rs index 1e252a27..25bb7b02 100644 --- a/substrate/runtime/src/lib.rs +++ b/substrate/runtime/src/lib.rs @@ -17,14 +17,15 @@ pub use pallet_timestamp as timestamp; pub use pallet_transaction_payment as transaction_payment; pub use coins_pallet as coins; -pub use in_instructions_pallet as in_instructions; +pub use pallet_session as session; pub use staking_pallet as staking; pub use validator_sets_pallet as validator_sets; +pub use in_instructions_pallet as in_instructions; + pub use signals_pallet as signals; -pub use pallet_session as session; pub use pallet_babe as babe; pub use pallet_grandpa as grandpa; @@ -147,37 +148,51 @@ parameter_types! { pub struct CallFilter; impl Contains for CallFilter { fn contains(call: &RuntimeCall) -> bool { - if let RuntimeCall::Timestamp(call) = call { - return matches!(call, timestamp::Call::set { .. }); - } + match call { + RuntimeCall::System(call) => match call { + system::Call::remark { .. } => false, + system::Call::set_heap_pages { .. } => false, + system::Call::set_code { .. } => false, + system::Call::set_code_without_checks { .. } => false, + system::Call::set_storage { .. } => false, + system::Call::kill_storage { .. } => false, + system::Call::kill_prefix { .. } => false, + system::Call::remark_with_event { .. } => false, + system::Call::__Ignore(_, _) => false, + }, - if let RuntimeCall::Coins(call) = call { - return matches!(call, coins::Call::transfer { .. } | coins::Call::burn { .. }); - } + RuntimeCall::Timestamp(call) => match call { + timestamp::Call::set { .. } => true, + timestamp::Call::__Ignore(_, _) => false, + }, - if let RuntimeCall::InInstructions(call) = call { - return matches!(call, in_instructions::Call::execute_batch { .. }); - } + RuntimeCall::Session(call) => match call { + session::Call::set_keys { .. } => true, + session::Call::purge_keys { .. } => true, + session::Call::__Ignore(_, _) => false, + }, - if let RuntimeCall::Staking(call) = call { - return matches!( - call, - staking::Call::stake { .. } | - staking::Call::unstake { .. } | - staking::Call::allocate { .. } | - staking::Call::deallocate { .. } - ); - } + // All of these pallets are our own, and all of their written calls are intended to be called + RuntimeCall::Coins(call) => !matches!(call, coins::Call::__Ignore(_, _)), + RuntimeCall::ValidatorSets(call) => !matches!(call, validator_sets::Call::__Ignore(_, _)), + RuntimeCall::Staking(call) => !matches!(call, staking::Call::__Ignore(_, _)), + RuntimeCall::InInstructions(call) => !matches!(call, in_instructions::Call::__Ignore(_, _)), + RuntimeCall::Signals(call) => !matches!(call, signals::Call::__Ignore(_, _)), - if let RuntimeCall::ValidatorSets(call) = call { - return matches!(call, validator_sets::Call::set_keys { .. }); - } + RuntimeCall::Babe(call) => match call { + babe::Call::report_equivocation { .. } => true, + babe::Call::report_equivocation_unsigned { .. } => true, + babe::Call::plan_config_change { .. } => false, + babe::Call::__Ignore(_, _) => false, + }, - if let RuntimeCall::Session(call) = call { - return matches!(call, session::Call::set_keys { .. }); + RuntimeCall::Grandpa(call) => match call { + grandpa::Call::report_equivocation { .. } => true, + grandpa::Call::report_equivocation_unsigned { .. } => true, + grandpa::Call::note_stalled { .. } => false, + grandpa::Call::__Ignore(_, _) => false, + }, } - - false } } @@ -230,23 +245,6 @@ impl coins::Config for Runtime { type RuntimeEvent = RuntimeEvent; } -impl in_instructions::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} - -impl validator_sets::Config for Runtime { - type RuntimeEvent = RuntimeEvent; -} -impl staking::Config for Runtime {} - -impl signals::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - // 1 week - type ValidityDuration = ConstU32<{ (7 * 24 * 60 * 60) / (TARGET_BLOCK_TIME as u32) }>; - // 2 weeks - type LockInDuration = ConstU32<{ (2 * 7 * 24 * 60 * 60) / (TARGET_BLOCK_TIME as u32) }>; -} - pub struct IdentityValidatorIdOf; impl Convert> for IdentityValidatorIdOf { fn convert(key: PublicKey) -> Option { @@ -266,6 +264,23 @@ impl session::Config for Runtime { type WeightInfo = session::weights::SubstrateWeight; } +impl validator_sets::Config for Runtime { + type RuntimeEvent = RuntimeEvent; +} +impl staking::Config for Runtime {} + +impl signals::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + // 1 week + type ValidityDuration = ConstU32<{ (7 * 24 * 60 * 60) / (TARGET_BLOCK_TIME as u32) }>; + // 2 weeks + type LockInDuration = ConstU32<{ (2 * 7 * 24 * 60 * 60) / (TARGET_BLOCK_TIME as u32) }>; +} + +impl in_instructions::Config for Runtime { + type RuntimeEvent = RuntimeEvent; +} + impl babe::Config for Runtime { #[allow(clippy::identity_op)] type EpochDuration = ConstU64<{ 1 * DAYS }>; @@ -330,14 +345,15 @@ construct_runtime!( TransactionPayment: transaction_payment, Coins: coins, - InInstructions: in_instructions, + Session: session, ValidatorSets: validator_sets, Staking: staking, + InInstructions: in_instructions, + Signals: signals, - Session: session, Babe: babe, Grandpa: grandpa,