Skip to content
1 change: 1 addition & 0 deletions pallets/attestation/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ pub(crate) mod runtime {
ext
}

#[cfg(feature = "runtime-benchmarks")]
pub fn build_with_keystore(self) -> sp_io::TestExternalities {
let mut ext = self.build();

Expand Down
1 change: 1 addition & 0 deletions pallets/delegation/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ pub(crate) mod runtime {
ext
}

#[cfg(feature = "runtime-benchmarks")]
pub fn build_with_keystore(self) -> sp_io::TestExternalities {
let mut ext = self.build();

Expand Down
3 changes: 1 addition & 2 deletions pallets/did/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,7 @@ impl ExtBuilder {
ext
}

// allowance only required for clippy, this function is actually used
#[allow(dead_code)]
#[cfg(feature = "runtime-benchmarks")]
pub fn build_with_keystore(self) -> sp_io::TestExternalities {
let mut ext = self.build(None);

Expand Down
1 change: 0 additions & 1 deletion pallets/pallet-did-lookup/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ impl ExtBuilder {
ext
}

// allowance only required for clippy, this function is actually used
#[cfg(feature = "runtime-benchmarks")]
pub fn build_with_keystore(self) -> sp_io::TestExternalities {
let mut ext = self.build();
Expand Down
145 changes: 119 additions & 26 deletions runtimes/peregrine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -753,11 +753,19 @@ impl pallet_randomness_collective_flip::Config for Runtime {}
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen, scale_info::TypeInfo,
)]
pub enum ProxyType {
/// Allow for any call.
Any,
/// Allow for calls that do not move tokens out of the caller's account.
NonTransfer,
/// Allow for governance-related calls.
Governance,
/// Allow for staking-related calls.
ParachainStaking,
/// Allow for calls that cancel proxy information.
CancelProxy,
/// Allow for calls that do not result in a deposit being claimed (e.g., for
/// attestations, delegations, or DIDs).
NonDepositClaiming,
}

impl Default for ProxyType {
Expand All @@ -772,47 +780,132 @@ impl InstanceFilter<Call> for ProxyType {
ProxyType::Any => true,
ProxyType::NonTransfer => matches!(
c,
Call::System(..) |
Call::Scheduler(..) |
Call::Timestamp(..) |
Call::Indices(pallet_indices::Call::claim{..}) |
Call::Indices(pallet_indices::Call::free{..}) |
Call::Indices(pallet_indices::Call::freeze{..}) |
// Specifically omitting Indices `transfer`, `force_transfer`
// Specifically omitting the entire Balances pallet
Call::Authorship(..) |
Call::Session(..) |
Call::Democracy(..) |
Call::Council(..) |
Call::TechnicalCommittee(..) |
Call::TechnicalMembership(..) |
Call::Treasury(..) |
Call::Vesting(pallet_vesting::Call::vest{..}) |
Call::Vesting(pallet_vesting::Call::vest_other{..}) |
// Specifically omitting Vesting `vested_transfer`, and `force_vested_transfer`
Call::Utility(..) |
Call::ParachainStaking(..)
Call::Attestation(..)
| Call::Authorship(..)
// Excludes `Balances`
| Call::Council(..) | Call::Ctype(..)
| Call::Delegation(..)
| Call::Democracy(..)
| Call::Did(..)
| Call::DidLookup(..)
| Call::Indices(
// Excludes `force_transfer`, and `transfer`
pallet_indices::Call::claim { .. }
| pallet_indices::Call::free { .. }
| pallet_indices::Call::freeze { .. }
)
// Excludes `KiltLaunch`
| Call::ParachainStaking(..)
// Excludes `ParachainSystem`
| Call::Preimage(..)
| Call::Proxy(..)
| Call::Scheduler(..)
| Call::Session(..)
// Excludes `Sudo`
| Call::System(..)
| Call::TechnicalCommittee(..)
| Call::TechnicalMembership(..)
| Call::Timestamp(..)
| Call::Treasury(..)
| Call::Utility(..)
| Call::Vesting(
// Excludes `force_vested_transfer`, `merge_schedules`, and `vested_transfer`
pallet_vesting::Call::vest { .. }
| pallet_vesting::Call::vest_other { .. }
)
| Call::Web3Names(..),
),
ProxyType::NonDepositClaiming => matches!(
c,
Call::Attestation(
// Excludes `reclaim_deposit`
attestation::Call::add { .. }
| attestation::Call::remove { .. }
| attestation::Call::revoke { .. }
)
| Call::Authorship(..)
// Excludes `Balances`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really want to exclude Balances here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is true that most calls require sudo origin, but technically by calling the balances pallet you could interact with deposits, no? Should we allow some balance calls in this proxy? Or the whole thing? What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say we should not exclude balance transfers here. All calls should be allowed.

| Call::Council(..) | Call::Ctype(..)
| Call::Delegation(
// Excludes `reclaim_deposit`
delegation::Call::add_delegation { .. }
| delegation::Call::create_hierarchy { .. }
| delegation::Call::remove_delegation { .. }
| delegation::Call::revoke_delegation { .. }
)
| Call::Democracy(..)
| Call::Did(
// Excludes `reclaim_deposit`
did::Call::add_key_agreement_key { .. }
| did::Call::add_service_endpoint { .. }
| did::Call::create { .. }
| did::Call::delete { .. }
| did::Call::remove_attestation_key { .. }
| did::Call::remove_delegation_key { .. }
| did::Call::remove_key_agreement_key { .. }
| did::Call::remove_service_endpoint { .. }
| did::Call::set_attestation_key { .. }
| did::Call::set_authentication_key { .. }
| did::Call::set_delegation_key { .. }
| did::Call::submit_did_call { .. }
)
| Call::DidLookup(
// Excludes `reclaim_deposit`
pallet_did_lookup::Call::associate_account { .. }
| pallet_did_lookup::Call::associate_sender { .. }
| pallet_did_lookup::Call::remove_account_association { .. }
| pallet_did_lookup::Call::remove_sender_association { .. }
)
| Call::Indices(..)
// Excludes `KiltLaunch`
| Call::ParachainStaking(..)
// Excludes `ParachainSystem`
| Call::Preimage(..)
| Call::Proxy(..)
| Call::Scheduler(..)
| Call::Session(..)
// Excludes `Sudo`
| Call::System(..)
| Call::TechnicalCommittee(..)
| Call::TechnicalMembership(..)
| Call::Timestamp(..)
| Call::Treasury(..)
| Call::Utility(..)
| Call::Vesting(..)
| Call::Web3Names(
// Excludes `ban`, and `reclaim_deposit`
pallet_web3_names::Call::claim { .. }
| pallet_web3_names::Call::release_by_owner { .. }
| pallet_web3_names::Call::unban { .. }
),
),
ProxyType::Governance => matches!(
c,
Call::Democracy(..)
| Call::Council(..) | Call::TechnicalCommittee(..)
| Call::Treasury(..) | Call::Utility(..)
Call::Council(..)
| Call::Democracy(..)
| Call::TechnicalCommittee(..)
| Call::TechnicalMembership(..)
| Call::Treasury(..) | Call::Utility(..)
),
ProxyType::ParachainStaking => {
matches!(c, Call::ParachainStaking(..) | Call::Session(..) | Call::Utility(..))
}
ProxyType::CancelProxy => {
matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement { .. }))
}
ProxyType::CancelProxy => matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement { .. })),
}
}
fn is_superset(&self, o: &Self) -> bool {
match (self, o) {
(x, y) if x == y => true,
// "anything" always contains any subset
(ProxyType::Any, _) => true,
(_, ProxyType::Any) => false,
// reclaiming deposits is part of NonTransfer but not in NonDepositClaiming
(ProxyType::NonDepositClaiming, ProxyType::NonTransfer) => false,
// everything except NonTransfer and Any is part of NonDepositClaiming
(ProxyType::NonDepositClaiming, _) => true,
// Transfers are part of NonDepositClaiming but not in NonTransfer
(ProxyType::NonTransfer, ProxyType::NonDepositClaiming) => false,
// everything except NonDepositClaiming and Any is part of NonTransfer
(ProxyType::NonTransfer, _) => true,
_ => false,
}
Expand Down
76 changes: 37 additions & 39 deletions runtimes/peregrine/src/weights/pallet_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
//! Autogenerated weights for pallet_proxy
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-01-19, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 128
//! DATE: 2022-03-25, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024

// Executed Command:
// target/release/kilt-parachain
Expand Down Expand Up @@ -49,93 +49,91 @@ pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_proxy::WeightInfo for WeightInfo<T> {
// Storage: Proxy Proxies (r:1 w:0)
fn proxy(p: u32, ) -> Weight {
(22_218_000 as Weight)
// Standard Error: 2_000
.saturating_add((145_000 as Weight).saturating_mul(p as Weight))
(19_267_000 as Weight)
// Standard Error: 12_000
.saturating_add((314_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
}
// Storage: Proxy Proxies (r:1 w:0)
// Storage: Proxy Announcements (r:1 w:1)
// Storage: System Account (r:1 w:1)
fn proxy_announced(a: u32, p: u32, ) -> Weight {
(52_087_000 as Weight)
// Standard Error: 2_000
.saturating_add((486_000 as Weight).saturating_mul(a as Weight))
// Standard Error: 2_000
.saturating_add((140_000 as Weight).saturating_mul(p as Weight))
(43_254_000 as Weight)
// Standard Error: 12_000
.saturating_add((461_000 as Weight).saturating_mul(a as Weight))
// Standard Error: 14_000
.saturating_add((86_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
// Storage: Proxy Announcements (r:1 w:1)
// Storage: System Account (r:1 w:1)
fn remove_announcement(a: u32, _p: u32, ) -> Weight {
(35_943_000 as Weight)
// Standard Error: 1_000
.saturating_add((491_000 as Weight).saturating_mul(a as Weight))
(29_933_000 as Weight)
// Standard Error: 8_000
.saturating_add((515_000 as Weight).saturating_mul(a as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
// Storage: Proxy Announcements (r:1 w:1)
// Storage: System Account (r:1 w:1)
fn reject_announcement(a: u32, p: u32, ) -> Weight {
(35_780_000 as Weight)
// Standard Error: 1_000
.saturating_add((495_000 as Weight).saturating_mul(a as Weight))
// Standard Error: 1_000
.saturating_add((3_000 as Weight).saturating_mul(p as Weight))
fn reject_announcement(a: u32, _p: u32, ) -> Weight {
(30_310_000 as Weight)
// Standard Error: 9_000
.saturating_add((479_000 as Weight).saturating_mul(a as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
// Storage: Proxy Proxies (r:1 w:0)
// Storage: Proxy Announcements (r:1 w:1)
// Storage: System Account (r:1 w:1)
fn announce(a: u32, p: u32, ) -> Weight {
(49_742_000 as Weight)
// Standard Error: 2_000
.saturating_add((487_000 as Weight).saturating_mul(a as Weight))
// Standard Error: 2_000
.saturating_add((141_000 as Weight).saturating_mul(p as Weight))
(41_024_000 as Weight)
// Standard Error: 9_000
.saturating_add((445_000 as Weight).saturating_mul(a as Weight))
// Standard Error: 10_000
.saturating_add((51_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
// Storage: Proxy Proxies (r:1 w:1)
fn add_proxy(p: u32, ) -> Weight {
(41_413_000 as Weight)
// Standard Error: 4_000
.saturating_add((222_000 as Weight).saturating_mul(p as Weight))
(33_452_000 as Weight)
// Standard Error: 21_000
.saturating_add((360_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: Proxy Proxies (r:1 w:1)
fn remove_proxy(p: u32, ) -> Weight {
(33_997_000 as Weight)
// Standard Error: 3_000
.saturating_add((239_000 as Weight).saturating_mul(p as Weight))
(28_225_000 as Weight)
// Standard Error: 19_000
.saturating_add((356_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: Proxy Proxies (r:1 w:1)
fn remove_proxies(p: u32, ) -> Weight {
(33_792_000 as Weight)
// Standard Error: 2_000
.saturating_add((140_000 as Weight).saturating_mul(p as Weight))
(28_040_000 as Weight)
// Standard Error: 19_000
.saturating_add((232_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: unknown [0x3a65787472696e7369635f696e646578] (r:1 w:0)
// Storage: Proxy Proxies (r:1 w:1)
fn anonymous(p: u32, ) -> Weight {
(47_634_000 as Weight)
// Standard Error: 3_000
.saturating_add((33_000 as Weight).saturating_mul(p as Weight))
(39_325_000 as Weight)
// Standard Error: 15_000
.saturating_add((11_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
// Storage: Proxy Proxies (r:1 w:1)
fn kill_anonymous(p: u32, ) -> Weight {
(35_811_000 as Weight)
// Standard Error: 3_000
.saturating_add((140_000 as Weight).saturating_mul(p as Weight))
(30_673_000 as Weight)
// Standard Error: 14_000
.saturating_add((205_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
Expand Down
Loading