-
Notifications
You must be signed in to change notification settings - Fork 154
Bridge-Hubs: Add proxy pallet #1045
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
||
|
|
@@ -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, | ||
|
|
@@ -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 { .. } | ||
| ) | ||
|
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 { .. } | ||
| ), | ||
|
clangenb marked this conversation as resolved.
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, | ||
|
clangenb marked this conversation as resolved.
|
||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+569
to
+614
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| 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 | ||
|
|
@@ -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, | ||
|
|
@@ -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] | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.