Skip to content

Commit

Permalink
Merge branch 'main' into region-pallet
Browse files Browse the repository at this point in the history
  • Loading branch information
cuteolaf authored Apr 19, 2024
2 parents a54de3f + 47bb083 commit 6ad91fb
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 9 deletions.
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.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ pallet-transaction-payment = { version = "28.0.0", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { version = "28.0.0", default-features = false }
pallet-utility = { version = "28.0.0", default-features = false}
pallet-message-queue = { version = "31.0.0", default-features = false }
pallet-multisig = { version = "28.0.0", default-features = false }
pallet-proxy = { version = "28.0.0", default-features = false }
pallet-utility = { version = "28.0.0", default-features = false }
sp-api = { version = "26.0.0", default-features = false }
sp-blockchain = { version = "28.0.0", default-features = false }
sp-io = { version = "30.0.0", default-features = false }
Expand Down
11 changes: 11 additions & 0 deletions runtime/regionx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ pallet-aura = { workspace = true }
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-sudo = { workspace = true }
pallet-timestamp = { workspace = true }
Expand Down Expand Up @@ -122,8 +124,11 @@ std = [
"pallet-message-queue/std",
"pallet-regions/std",
"regionx-primitives/std",
"pallet-multisig/std",
"pallet-proxy/std",
"pallet-session/std",
"pallet-sudo/std",
"pallet-utility/std",
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
Expand Down Expand Up @@ -170,7 +175,10 @@ runtime-benchmarks = [
"pallet-collator-selection/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"pallet-regions/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-sudo/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
Expand Down Expand Up @@ -202,8 +210,11 @@ try-runtime = [
"pallet-collator-selection/try-runtime",
"pallet-message-queue/try-runtime",
"pallet-regions/try-runtime",
"pallet-multisig/try-runtime",
"pallet-proxy/try-runtime",
"pallet-session/try-runtime",
"pallet-sudo/try-runtime",
"pallet-utility/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-utility/try-runtime",
Expand Down
47 changes: 45 additions & 2 deletions runtime/regionx/src/impls.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::{AssetId, Runtime};
use crate::{AssetId, Runtime, RuntimeCall};
use frame_support::traits::InstanceFilter;
use orml_asset_registry::DefaultAssetMetadata;
use orml_traits::asset_registry::AssetProcessor;
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_runtime::DispatchError;
use sp_runtime::{DispatchError, RuntimeDebug};

#[derive(
Clone, Copy, PartialOrd, Ord, PartialEq, Eq, Debug, Encode, Decode, TypeInfo, MaxEncodedLen,
Expand All @@ -28,3 +29,45 @@ impl AssetProcessor<AssetId, DefaultAssetMetadata<Runtime>> for CustomAssetProce
Ok(())
}
}

/// The type used to represent the kinds of proxying allowed.
#[derive(
Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
Encode,
Decode,
RuntimeDebug,
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,
// TODO: add more proxies in future related to coretime trading.
}

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::Balances { .. } | RuntimeCall::Assets { .. }),
ProxyType::CancelProxy =>
matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })),
}
}
}
67 changes: 60 additions & 7 deletions runtime/regionx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,51 @@ impl pallet_regions::Config for Runtime {
type Timeout = ConstU64<1000>; // TODO: FIXME
}

parameter_types! {
// One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes.
pub const DepositBase: Balance = deposit(1, 88);
// Additional storage item size of 32 bytes.
pub const DepositFactor: Balance = deposit(0, 32);
pub const MaxSignatories: u32 = 100;
}

impl pallet_multisig::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type Currency = Balances;
type DepositBase = DepositBase;
type DepositFactor = DepositFactor;
type MaxSignatories = MaxSignatories;
type WeightInfo = pallet_multisig::weights::SubstrateWeight<Runtime>;
}

parameter_types! {
// One storage item; key size 32, value size 8; .
pub const ProxyDepositBase: Balance = deposit(1, 40);
// Additional storage item size of 33 bytes.
pub const ProxyDepositFactor: Balance = deposit(0, 33);
pub const MaxProxies: u16 = 32;
// One storage item; key size 32, value size 16
pub const AnnouncementDepositBase: Balance = deposit(1, 48);
pub const AnnouncementDepositFactor: Balance = 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 = pallet_proxy::weights::SubstrateWeight<Runtime>;
type MaxPending = MaxPending;
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = AnnouncementDepositBase;
type AnnouncementDepositFactor = AnnouncementDepositFactor;
}

// Create the runtime by composing the FRAME pallets that were previously configured.
construct_runtime!(
pub enum Runtime
Expand Down Expand Up @@ -613,18 +658,23 @@ construct_runtime!(
Aura: pallet_aura = 33,
AuraExt: cumulus_pallet_aura_ext = 34,

// Handy utilities
Utility: pallet_utility = 40,
Multisig: pallet_multisig = 41,
Proxy: pallet_proxy = 42,

// XCM helpers.
XcmpQueue: cumulus_pallet_xcmp_queue = 40,
PolkadotXcm: pallet_xcm = 41,
CumulusXcm: cumulus_pallet_xcm = 42,
MessageQueue: pallet_message_queue = 43,
XcmpQueue: cumulus_pallet_xcmp_queue = 50,
PolkadotXcm: pallet_xcm = 51,
CumulusXcm: cumulus_pallet_xcm = 52,
MessageQueue: pallet_message_queue = 53,

// ISMP
Ismp: pallet_ismp = 50,
IsmpParachain: ismp_parachain = 51,
Ismp: pallet_ismp = 60,
IsmpParachain: ismp_parachain = 61,

// Main stage:
Regions: pallet_regions = 60,
Regions: pallet_regions = 70,
}
);

Expand All @@ -635,6 +685,9 @@ mod benches {
[pallet_assets, Assets]
[pallet_balances, Balances]
[pallet_session, SessionBench::<Runtime>]
[pallet_multisig, Multisig]
[pallet_proxy, Proxy]
[pallet_timestamp, Utility]
[pallet_timestamp, Timestamp]
[pallet_utility, Utility],
[pallet_sudo, Sudo]
Expand Down

0 comments on commit 6ad91fb

Please sign in to comment.