Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [Unreleased]

### Added
- Bridge-Hubs - Add proxy pallet ([#1045](https://github.com/polkadot-fellows/runtimes/pull/1045)).
- AH Polkadot - A new stepped curve primitive. Used for the 'Hard Pressure' inflation changes from [Ref 1710](https://polkadot.subsquare.io/referenda/1710) ([#898](https://github.com/polkadot-fellows/runtimes/pull/898)).

### Changed
Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions system-parachains/bridge-hubs/bridge-hub-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pallet-authorship = { workspace = true }
pallet-balances = { workspace = true }
pallet-message-queue = { workspace = true }
pallet-multisig = { workspace = true }
pallet-proxy = { workspace = true }
pallet-session = { workspace = true }
pallet-timestamp = { workspace = true }
pallet-transaction-payment = { workspace = true }
Expand Down Expand Up @@ -160,6 +161,7 @@ std = [
"pallet-collator-selection/std",
"pallet-message-queue/std",
"pallet-multisig/std",
"pallet-proxy/std",
"pallet-session/std",
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
Expand Down Expand Up @@ -225,6 +227,7 @@ runtime-benchmarks = [
"pallet-collator-selection/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-transaction-payment/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
Expand Down Expand Up @@ -263,6 +266,7 @@ try-runtime = [
"pallet-collator-selection/try-runtime",
"pallet-message-queue/try-runtime",
"pallet-multisig/try-runtime",
"pallet-proxy/try-runtime",
"pallet-session/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-transaction-payment/try-runtime",
Expand Down
112 changes: 111 additions & 1 deletion system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use bridge_hub_common::message_queue::{
AggregateMessageOrigin, NarrowOriginToSibling, ParaIdToSibling,
};
use bridge_to_polkadot_config::bp_polkadot;
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
use cumulus_primitives_core::ParaId;

Expand All @@ -58,7 +59,7 @@ use frame_support::{
parameter_types,
traits::{
tokens::imbalance::ResolveTo, ConstBool, ConstU32, ConstU64, ConstU8, EitherOf,
EitherOfDiverse, Everything, TransformOrigin,
EitherOfDiverse, Everything, InstanceFilter, TransformOrigin,
},
weights::{ConstantMultiplier, Weight},
PalletId,
Expand Down Expand Up @@ -533,6 +534,113 @@ impl pallet_utility::Config for Runtime {
type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
}

/// The type used to represent the kinds of proxying allowed.
#[derive(
Copy,
Clone,
Debug,
Eq,
PartialEq,
Ord,
PartialOrd,
Encode,
Decode,
DecodeWithMemTracking,
MaxEncodedLen,
scale_info::TypeInfo,
)]
pub enum ProxyType {
/// Fully permissioned proxy. Can execute any call on behalf of _proxied_.
Any,
/// Can execute any call that does not transfer funds or assets.
NonTransfer,
/// Proxy with the ability to reject time-delay proxy announcements.
CancelProxy,
/// Collator selection proxy. Can execute calls related to collator selection mechanism.
Collator,
}

impl Default for ProxyType {
fn default() -> Self {
Self::Any
}
}

impl InstanceFilter<RuntimeCall> for ProxyType {
fn filter(&self, c: &RuntimeCall) -> bool {
match self {
ProxyType::Any => true,
ProxyType::NonTransfer => matches!(
c,
RuntimeCall::System(_) |
RuntimeCall::ParachainSystem(_) |
RuntimeCall::Timestamp(_) |
RuntimeCall::CollatorSelection(_) |
RuntimeCall::Session(_) |
RuntimeCall::Utility(_) |
RuntimeCall::Multisig(_) |
RuntimeCall::Proxy(_) |
RuntimeCall::BridgeRelayers(pallet_bridge_relayers::Call::register { .. }) |
RuntimeCall::BridgeRelayers(pallet_bridge_relayers::Call::deregister { .. }) |
RuntimeCall::BridgeRelayers(
pallet_bridge_relayers::Call::claim_rewards { .. }
Comment thread
claravanstaden marked this conversation as resolved.
)
Comment thread
clangenb marked this conversation as resolved.
),
ProxyType::CancelProxy => matches!(
c,
RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
),
ProxyType::Collator => matches!(
c,
RuntimeCall::CollatorSelection { .. } |
RuntimeCall::Utility { .. } |
RuntimeCall::Multisig { .. }
),
Comment thread
clangenb marked this conversation as resolved.
Comment thread
bkchr marked this conversation as resolved.
}
}

fn is_superset(&self, o: &Self) -> bool {
match (self, o) {
(x, y) if x == y => true,
(ProxyType::Any, _) => true,
(_, ProxyType::Any) => false,
(ProxyType::NonTransfer, ProxyType::Collator) => true,
(ProxyType::NonTransfer, ProxyType::CancelProxy) => true,
_ => false,
Comment thread
clangenb marked this conversation as resolved.
}
}
}
Comment on lines +569 to +614

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ProxyType::NonTransfer allows RuntimeCall::Utility(_) and RuntimeCall::Multisig(_) ([Line 580-586]). Both pallets can dispatch arbitrary inner calls (e.g., utility::batch{,_all} wrapping balances::transfer, and multisig executing any call), which effectively bypasses the 'non-transfer' restriction and turns this proxy into an Any proxy. Fix by either (a) removing Utility and Multisig from NonTransfer, or (b) implementing a recursive filter that inspects inner calls and rejects any that transfer funds/assets (and similarly handles nested proxy/batch).


parameter_types! {
// One storage item; key size 32, value size 8.
pub const ProxyDepositBase: Balance = system_para_deposit(1, 40);
// Additional storage item size of 33 bytes.
pub const ProxyDepositFactor: Balance = system_para_deposit(0, 33);
pub const MaxProxies: u16 = 32;
// One storage item; key size 32, value size 16.
pub const AnnouncementDepositBase: Balance = system_para_deposit(1, 48);
pub const AnnouncementDepositFactor: Balance = system_para_deposit(0, 66);
pub const MaxPending: u16 = 32;
}

impl pallet_proxy::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type Currency = Balances;
type ProxyType = ProxyType;
type ProxyDepositBase = ProxyDepositBase;
type ProxyDepositFactor = ProxyDepositFactor;
type MaxProxies = MaxProxies;
type WeightInfo = weights::pallet_proxy::WeightInfo<Runtime>;
type MaxPending = MaxPending;
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = AnnouncementDepositBase;
type AnnouncementDepositFactor = AnnouncementDepositFactor;
type BlockNumberProvider = System;
}

// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
pub enum Runtime
Expand Down Expand Up @@ -563,6 +671,7 @@ construct_runtime!(
// Handy utilities.
Utility: pallet_utility = 40,
Multisig: pallet_multisig = 41,
Proxy: pallet_proxy = 42,

// Pallets that may be used by all bridges.
BridgeRelayers: pallet_bridge_relayers = 50,
Expand Down Expand Up @@ -595,6 +704,7 @@ mod benches {
[pallet_balances, Balances]
[pallet_message_queue, MessageQueue]
[pallet_multisig, Multisig]
[pallet_proxy, Proxy]
[pallet_session, SessionBench::<Runtime>]
[pallet_utility, Utility]
[pallet_timestamp, Timestamp]
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading