mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-22 10:44:53 +00:00
Use a comprehensive call filter in the runtime
This commit is contained in:
parent
46e1f85085
commit
c3fdb9d9df
2 changed files with 68 additions and 50 deletions
|
@ -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 }
|
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 }
|
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 }
|
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 }
|
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 }
|
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-babe = { git = "https://github.com/serai-dex/substrate", default-features = false }
|
||||||
pallet-grandpa = { 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",
|
"pallet-transaction-payment/std",
|
||||||
|
|
||||||
"coins-pallet/std",
|
"coins-pallet/std",
|
||||||
"in-instructions-pallet/std",
|
|
||||||
|
|
||||||
|
"pallet-session/std",
|
||||||
"validator-sets-pallet/std",
|
"validator-sets-pallet/std",
|
||||||
"staking-pallet/std",
|
"staking-pallet/std",
|
||||||
|
|
||||||
|
"in-instructions-pallet/std",
|
||||||
|
|
||||||
"signals-pallet/std",
|
"signals-pallet/std",
|
||||||
|
|
||||||
"pallet-session/std",
|
|
||||||
"pallet-babe/std",
|
"pallet-babe/std",
|
||||||
"pallet-grandpa/std",
|
"pallet-grandpa/std",
|
||||||
|
|
||||||
|
|
|
@ -17,14 +17,15 @@ pub use pallet_timestamp as timestamp;
|
||||||
pub use pallet_transaction_payment as transaction_payment;
|
pub use pallet_transaction_payment as transaction_payment;
|
||||||
|
|
||||||
pub use coins_pallet as coins;
|
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 staking_pallet as staking;
|
||||||
pub use validator_sets_pallet as validator_sets;
|
pub use validator_sets_pallet as validator_sets;
|
||||||
|
|
||||||
|
pub use in_instructions_pallet as in_instructions;
|
||||||
|
|
||||||
pub use signals_pallet as signals;
|
pub use signals_pallet as signals;
|
||||||
|
|
||||||
pub use pallet_session as session;
|
|
||||||
pub use pallet_babe as babe;
|
pub use pallet_babe as babe;
|
||||||
pub use pallet_grandpa as grandpa;
|
pub use pallet_grandpa as grandpa;
|
||||||
|
|
||||||
|
@ -147,37 +148,51 @@ parameter_types! {
|
||||||
pub struct CallFilter;
|
pub struct CallFilter;
|
||||||
impl Contains<RuntimeCall> for CallFilter {
|
impl Contains<RuntimeCall> for CallFilter {
|
||||||
fn contains(call: &RuntimeCall) -> bool {
|
fn contains(call: &RuntimeCall) -> bool {
|
||||||
if let RuntimeCall::Timestamp(call) = call {
|
match call {
|
||||||
return matches!(call, timestamp::Call::set { .. });
|
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 {
|
RuntimeCall::Timestamp(call) => match call {
|
||||||
return matches!(call, coins::Call::transfer { .. } | coins::Call::burn { .. });
|
timestamp::Call::set { .. } => true,
|
||||||
}
|
timestamp::Call::__Ignore(_, _) => false,
|
||||||
|
},
|
||||||
|
|
||||||
if let RuntimeCall::InInstructions(call) = call {
|
RuntimeCall::Session(call) => match call {
|
||||||
return matches!(call, in_instructions::Call::execute_batch { .. });
|
session::Call::set_keys { .. } => true,
|
||||||
}
|
session::Call::purge_keys { .. } => true,
|
||||||
|
session::Call::__Ignore(_, _) => false,
|
||||||
|
},
|
||||||
|
|
||||||
if let RuntimeCall::Staking(call) = call {
|
// All of these pallets are our own, and all of their written calls are intended to be called
|
||||||
return matches!(
|
RuntimeCall::Coins(call) => !matches!(call, coins::Call::__Ignore(_, _)),
|
||||||
call,
|
RuntimeCall::ValidatorSets(call) => !matches!(call, validator_sets::Call::__Ignore(_, _)),
|
||||||
staking::Call::stake { .. } |
|
RuntimeCall::Staking(call) => !matches!(call, staking::Call::__Ignore(_, _)),
|
||||||
staking::Call::unstake { .. } |
|
RuntimeCall::InInstructions(call) => !matches!(call, in_instructions::Call::__Ignore(_, _)),
|
||||||
staking::Call::allocate { .. } |
|
RuntimeCall::Signals(call) => !matches!(call, signals::Call::__Ignore(_, _)),
|
||||||
staking::Call::deallocate { .. }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let RuntimeCall::ValidatorSets(call) = call {
|
RuntimeCall::Babe(call) => match call {
|
||||||
return matches!(call, validator_sets::Call::set_keys { .. });
|
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 {
|
RuntimeCall::Grandpa(call) => match call {
|
||||||
return matches!(call, session::Call::set_keys { .. });
|
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;
|
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;
|
pub struct IdentityValidatorIdOf;
|
||||||
impl Convert<PublicKey, Option<PublicKey>> for IdentityValidatorIdOf {
|
impl Convert<PublicKey, Option<PublicKey>> for IdentityValidatorIdOf {
|
||||||
fn convert(key: PublicKey) -> Option<PublicKey> {
|
fn convert(key: PublicKey) -> Option<PublicKey> {
|
||||||
|
@ -266,6 +264,23 @@ impl session::Config for Runtime {
|
||||||
type WeightInfo = session::weights::SubstrateWeight<Runtime>;
|
type WeightInfo = session::weights::SubstrateWeight<Runtime>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
impl babe::Config for Runtime {
|
||||||
#[allow(clippy::identity_op)]
|
#[allow(clippy::identity_op)]
|
||||||
type EpochDuration = ConstU64<{ 1 * DAYS }>;
|
type EpochDuration = ConstU64<{ 1 * DAYS }>;
|
||||||
|
@ -330,14 +345,15 @@ construct_runtime!(
|
||||||
TransactionPayment: transaction_payment,
|
TransactionPayment: transaction_payment,
|
||||||
|
|
||||||
Coins: coins,
|
Coins: coins,
|
||||||
InInstructions: in_instructions,
|
|
||||||
|
|
||||||
|
Session: session,
|
||||||
ValidatorSets: validator_sets,
|
ValidatorSets: validator_sets,
|
||||||
Staking: staking,
|
Staking: staking,
|
||||||
|
|
||||||
|
InInstructions: in_instructions,
|
||||||
|
|
||||||
Signals: signals,
|
Signals: signals,
|
||||||
|
|
||||||
Session: session,
|
|
||||||
Babe: babe,
|
Babe: babe,
|
||||||
Grandpa: grandpa,
|
Grandpa: grandpa,
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue