Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable Calls to Identity Pallet #1476

Merged
merged 7 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions polkadot/runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ use frame_election_provider_support::{
use frame_support::{
construct_runtime, parameter_types,
traits::{
ConstU32, Contains, EitherOf, EitherOfDiverse, InstanceFilter, KeyOwnerProofSystem,
PrivilegeCmp, ProcessMessage, ProcessMessageError, StorageMapShim, WithdrawReasons,
ConstU32, Contains, EitherOf, EitherOfDiverse, EverythingBut, InstanceFilter,
KeyOwnerProofSystem, PrivilegeCmp, ProcessMessage, ProcessMessageError, StorageMapShim,
WithdrawReasons,
},
weights::{ConstantMultiplier, WeightMeter},
PalletId,
Expand Down Expand Up @@ -157,11 +158,16 @@ pub fn native_version() -> NativeVersion {
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
}

/// We currently allow all calls.
pub struct BaseFilter;
impl Contains<RuntimeCall> for BaseFilter {
fn contains(_c: &RuntimeCall) -> bool {
true
/// Disable all calls to the Identity pallet. This will lock the state of the pallet, preventing
/// further updates to identities and sub-identities. The locked state will be the genesis state of
/// a new system chain and then removed from the Relay Chain.
pub struct IdentityCalls;
impl Contains<RuntimeCall> for IdentityCalls {
fn contains(c: &RuntimeCall) -> bool {
match c {
RuntimeCall::Identity(_) => true,
joepetrowski marked this conversation as resolved.
Show resolved Hide resolved
_ => false,
}
}
}

Expand All @@ -171,7 +177,7 @@ parameter_types! {
}

impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything;
type BaseCallFilter = EverythingBut<IdentityCalls>;
type BlockWeights = BlockWeights;
type BlockLength = BlockLength;
type RuntimeOrigin = RuntimeOrigin;
Expand Down
19 changes: 16 additions & 3 deletions polkadot/runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ use frame_election_provider_support::{
use frame_support::{
construct_runtime, parameter_types,
traits::{
ConstU32, Contains, EitherOf, EitherOfDiverse, InstanceFilter, KeyOwnerProofSystem,
PrivilegeCmp, ProcessMessage, ProcessMessageError, WithdrawReasons,
ConstU32, Contains, EitherOf, EitherOfDiverse, EverythingBut, InstanceFilter,
KeyOwnerProofSystem, PrivilegeCmp, ProcessMessage, ProcessMessageError, WithdrawReasons,
},
weights::{ConstantMultiplier, WeightMeter},
PalletId,
Expand Down Expand Up @@ -153,8 +153,21 @@ parameter_types! {
pub const SS58Prefix: u8 = 0;
}

/// Disable all calls to the Identity pallet. This will lock the state of the pallet, preventing
/// further updates to identities and sub-identities. The locked state will be the genesis state of
/// a new system chain and then removed from the Relay Chain.
pub struct IdentityCalls;
impl Contains<RuntimeCall> for IdentityCalls {
fn contains(c: &RuntimeCall) -> bool {
match c {
RuntimeCall::Identity(_) => true,
_ => false,
}
}
}

impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything;
type BaseCallFilter = EverythingBut<IdentityCalls>;
type BlockWeights = BlockWeights;
type BlockLength = BlockLength;
type RuntimeOrigin = RuntimeOrigin;
Expand Down
22 changes: 14 additions & 8 deletions polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ use beefy_primitives::{
use frame_support::{
construct_runtime, parameter_types,
traits::{
Contains, EitherOfDiverse, InstanceFilter, KeyOwnerProofSystem, LockIdentifier,
PrivilegeCmp, ProcessMessage, ProcessMessageError, StorageMapShim, WithdrawReasons,
Contains, EitherOfDiverse, EverythingBut, InstanceFilter, KeyOwnerProofSystem,
LockIdentifier, PrivilegeCmp, ProcessMessage, ProcessMessageError, StorageMapShim,
WithdrawReasons,
},
weights::{ConstantMultiplier, WeightMeter},
PalletId,
Expand Down Expand Up @@ -134,11 +135,16 @@ pub fn native_version() -> NativeVersion {
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
}

/// We currently allow all calls.
pub struct BaseFilter;
impl Contains<RuntimeCall> for BaseFilter {
fn contains(_call: &RuntimeCall) -> bool {
true
/// Disable all calls to the Identity pallet. This will lock the state of the pallet, preventing
/// further updates to identities and sub-identities. The locked state will be the genesis state of
/// a new system chain and then removed from the Relay Chain.
pub struct IdentityCalls;
impl Contains<RuntimeCall> for IdentityCalls {
fn contains(c: &RuntimeCall) -> bool {
match c {
RuntimeCall::Identity(_) => true,
_ => false,
}
joepetrowski marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand All @@ -148,7 +154,7 @@ parameter_types! {
}

impl frame_system::Config for Runtime {
type BaseCallFilter = BaseFilter;
type BaseCallFilter = EverythingBut<IdentityCalls>;
type BlockWeights = BlockWeights;
type BlockLength = BlockLength;
type DbWeight = RocksDbWeight;
Expand Down
19 changes: 16 additions & 3 deletions polkadot/runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ use frame_election_provider_support::{bounds::ElectionBoundsBuilder, onchain, Se
use frame_support::{
construct_runtime, parameter_types,
traits::{
ConstU32, InstanceFilter, KeyOwnerProofSystem, ProcessMessage, ProcessMessageError,
WithdrawReasons,
ConstU32, Contains, EverythingBut, InstanceFilter, KeyOwnerProofSystem, ProcessMessage,
ProcessMessageError, WithdrawReasons,
},
weights::{ConstantMultiplier, WeightMeter},
PalletId,
Expand Down Expand Up @@ -146,8 +146,21 @@ parameter_types! {
pub const SS58Prefix: u8 = 42;
}

/// Disable all calls to the Identity pallet. This will lock the state of the pallet, preventing
/// further updates to identities and sub-identities. The locked state will be the genesis state of
/// a new system chain and then removed from the Relay Chain.
pub struct IdentityCalls;
impl Contains<RuntimeCall> for IdentityCalls {
fn contains(c: &RuntimeCall) -> bool {
match c {
RuntimeCall::Identity(_) => true,
_ => false,
}
}
}

impl frame_system::Config for Runtime {
type BaseCallFilter = frame_support::traits::Everything;
type BaseCallFilter = EverythingBut<IdentityCalls>;
type BlockWeights = BlockWeights;
type BlockLength = BlockLength;
type RuntimeOrigin = RuntimeOrigin;
Expand Down