mirror of
https://github.com/pezkuwichain/pezkuwi-runtime-templates.git
synced 2026-06-24 09:21:01 +00:00
[10] add proxy pallet
This commit is contained in:
Generated
+11
-1
@@ -1519,6 +1519,13 @@ dependencies = [
|
|||||||
"unicode-width",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "common"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"polkadot-core-primitives",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "common"
|
name = "common"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@@ -7304,6 +7311,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"color-print",
|
"color-print",
|
||||||
|
"common 0.1.0",
|
||||||
"cumulus-client-cli",
|
"cumulus-client-cli",
|
||||||
"cumulus-client-collator",
|
"cumulus-client-collator",
|
||||||
"cumulus-client-consensus-aura",
|
"cumulus-client-consensus-aura",
|
||||||
@@ -7359,6 +7367,7 @@ dependencies = [
|
|||||||
name = "parachain-template-runtime"
|
name = "parachain-template-runtime"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"common 0.1.0",
|
||||||
"cumulus-pallet-aura-ext",
|
"cumulus-pallet-aura-ext",
|
||||||
"cumulus-pallet-dmp-queue",
|
"cumulus-pallet-dmp-queue",
|
||||||
"cumulus-pallet-parachain-system",
|
"cumulus-pallet-parachain-system",
|
||||||
@@ -7382,6 +7391,7 @@ dependencies = [
|
|||||||
"pallet-collator-selection",
|
"pallet-collator-selection",
|
||||||
"pallet-multisig",
|
"pallet-multisig",
|
||||||
"pallet-parachain-template",
|
"pallet-parachain-template",
|
||||||
|
"pallet-proxy",
|
||||||
"pallet-session",
|
"pallet-session",
|
||||||
"pallet-sudo",
|
"pallet-sudo",
|
||||||
"pallet-timestamp",
|
"pallet-timestamp",
|
||||||
@@ -9483,7 +9493,7 @@ dependencies = [
|
|||||||
"ark-serialize",
|
"ark-serialize",
|
||||||
"ark-std",
|
"ark-std",
|
||||||
"blake2 0.10.6",
|
"blake2 0.10.6",
|
||||||
"common",
|
"common 0.1.0 (git+https://github.com/w3f/ring-proof)",
|
||||||
"fflonk",
|
"fflonk",
|
||||||
"merlin 3.0.0",
|
"merlin 3.0.0",
|
||||||
]
|
]
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
members = ["node", "pallets/template", "runtime"]
|
members = [ "common", "node", "pallets/template", "runtime"]
|
||||||
package.edition = "2021"
|
package.edition = "2021"
|
||||||
package.repository = "https://github.com/paritytech/polkadot-sdk"
|
package.repository = "https://github.com/paritytech/polkadot-sdk"
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
[package]
|
||||||
|
name = "common"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Anonymous"]
|
||||||
|
edition.workspace = true
|
||||||
|
description = "Logic which is common to all runtimes"
|
||||||
|
license = "Apache-2.0"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
pub use currency::*;
|
||||||
|
|
||||||
|
mod currency {
|
||||||
|
use polkadot_core_primitives::Balance;
|
||||||
|
// Unit = the base number of indivisible units for balances
|
||||||
|
pub const UNIT: Balance = 1_000_000_000_000;
|
||||||
|
pub const MILLIUNIT: Balance = 1_000_000_000;
|
||||||
|
pub const MICROUNIT: Balance = 1_000_000;
|
||||||
|
|
||||||
|
/// The existential deposit. Set to 1/10 of the Connected Relay Chain.
|
||||||
|
pub const EXISTENTIAL_DEPOSIT: Balance = MILLIUNIT;
|
||||||
|
|
||||||
|
pub const fn deposit(items: u32, bytes: u32) -> Balance {
|
||||||
|
(items as Balance * 20 * UNIT + bytes as Balance * 100 * MILLIUNIT) / 100
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ futures = "0.3.28"
|
|||||||
|
|
||||||
# Local
|
# Local
|
||||||
parachain-template-runtime = { path = "../runtime" }
|
parachain-template-runtime = { path = "../runtime" }
|
||||||
|
common = { path = "../common" }
|
||||||
|
|
||||||
# Substrate
|
# Substrate
|
||||||
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
use common::EXISTENTIAL_DEPOSIT;
|
||||||
use cumulus_primitives_core::ParaId;
|
use cumulus_primitives_core::ParaId;
|
||||||
use parachain_template_runtime::{AccountId, AuraId, Signature, EXISTENTIAL_DEPOSIT};
|
use parachain_template_runtime::{AccountId, AuraId, Signature};
|
||||||
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
|
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
|
||||||
use sc_service::ChainType;
|
use sc_service::ChainType;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ smallvec = "1.11.0"
|
|||||||
|
|
||||||
# Local
|
# Local
|
||||||
pallet-parachain-template = { path = "../pallets/template", default-features = false }
|
pallet-parachain-template = { path = "../pallets/template", default-features = false }
|
||||||
|
common = { path = "../common", default-features = false }
|
||||||
|
|
||||||
# Substrate
|
# Substrate
|
||||||
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false, optional = true }
|
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false, optional = true }
|
||||||
@@ -41,6 +42,7 @@ pallet-authorship = { git = "https://github.com/paritytech/polkadot-sdk", branch
|
|||||||
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||||
pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
pallet-multisig = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||||
pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
pallet-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||||
|
pallet-proxy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||||
pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
pallet-sudo = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||||
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||||
pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
pallet-transaction-payment = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.3.0", default-features = false }
|
||||||
|
|||||||
+70
-10
@@ -11,6 +11,8 @@ use constants::currency::*;
|
|||||||
mod weights;
|
mod weights;
|
||||||
pub mod xcm_config;
|
pub mod xcm_config;
|
||||||
|
|
||||||
|
use codec::{Decode, Encode, MaxEncodedLen};
|
||||||
|
use common::{deposit, EXISTENTIAL_DEPOSIT, MICROUNIT, MILLIUNIT};
|
||||||
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
|
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
|
||||||
use cumulus_primitives_core::ParaId;
|
use cumulus_primitives_core::ParaId;
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
@@ -18,7 +20,7 @@ use frame_support::{
|
|||||||
dispatch::DispatchClass,
|
dispatch::DispatchClass,
|
||||||
genesis_builder_helper::{build_config, create_default_config},
|
genesis_builder_helper::{build_config, create_default_config},
|
||||||
parameter_types,
|
parameter_types,
|
||||||
traits::{ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse, Everything},
|
traits::{ConstBool, ConstU32, ConstU64, ConstU8, EitherOfDiverse, Everything, InstanceFilter},
|
||||||
weights::{
|
weights::{
|
||||||
constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient,
|
constants::WEIGHT_REF_TIME_PER_SECOND, ConstantMultiplier, Weight, WeightToFeeCoefficient,
|
||||||
WeightToFeeCoefficients, WeightToFeePolynomial,
|
WeightToFeeCoefficients, WeightToFeePolynomial,
|
||||||
@@ -36,6 +38,7 @@ use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
|
|||||||
use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery;
|
use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery;
|
||||||
// Polkadot imports
|
// Polkadot imports
|
||||||
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
|
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
|
||||||
|
use scale_info::TypeInfo;
|
||||||
use smallvec::smallvec;
|
use smallvec::smallvec;
|
||||||
use sp_api::impl_runtime_apis;
|
use sp_api::impl_runtime_apis;
|
||||||
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||||
@@ -46,7 +49,7 @@ use sp_runtime::{
|
|||||||
create_runtime_str, generic, impl_opaque_keys,
|
create_runtime_str, generic, impl_opaque_keys,
|
||||||
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, IdentifyAccount, Verify},
|
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, IdentifyAccount, Verify},
|
||||||
transaction_validity::{TransactionSource, TransactionValidity},
|
transaction_validity::{TransactionSource, TransactionValidity},
|
||||||
ApplyExtrinsicResult, MultiSignature,
|
ApplyExtrinsicResult, MultiSignature, RuntimeDebug,
|
||||||
};
|
};
|
||||||
pub use sp_runtime::{MultiAddress, Perbill, Permill};
|
pub use sp_runtime::{MultiAddress, Perbill, Permill};
|
||||||
use sp_std::prelude::*;
|
use sp_std::prelude::*;
|
||||||
@@ -207,14 +210,6 @@ pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
|
|||||||
pub const HOURS: BlockNumber = MINUTES * 60;
|
pub const HOURS: BlockNumber = MINUTES * 60;
|
||||||
pub const DAYS: BlockNumber = HOURS * 24;
|
pub const DAYS: BlockNumber = HOURS * 24;
|
||||||
|
|
||||||
// Unit = the base number of indivisible units for balances
|
|
||||||
pub const UNIT: Balance = 1_000_000_000_000;
|
|
||||||
pub const MILLIUNIT: Balance = 1_000_000_000;
|
|
||||||
pub const MICROUNIT: Balance = 1_000_000;
|
|
||||||
|
|
||||||
/// The existential deposit. Set to 1/10 of the Connected Relay Chain.
|
|
||||||
pub const EXISTENTIAL_DEPOSIT: Balance = MILLIUNIT;
|
|
||||||
|
|
||||||
/// We assume that ~5% of the block weight is consumed by `on_initialize`
|
/// We assume that ~5% of the block weight is consumed by `on_initialize`
|
||||||
/// handlers. This is used to limit the maximal weight of a single extrinsic.
|
/// handlers. This is used to limit the maximal weight of a single extrinsic.
|
||||||
const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5);
|
const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5);
|
||||||
@@ -341,6 +336,70 @@ impl pallet_authorship::Config for Runtime {
|
|||||||
type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;
|
type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parameter_types! {
|
||||||
|
pub const MaxProxies: u32 = 32;
|
||||||
|
pub const MaxPending: u32 = 32;
|
||||||
|
pub const ProxyDepositBase: Balance = deposit(1, 40);
|
||||||
|
pub const AnnouncementDepositBase: Balance = deposit(1, 48);
|
||||||
|
pub const ProxyDepositFactor: Balance = deposit(0, 33);
|
||||||
|
pub const AnnouncementDepositFactor: Balance = deposit(0, 66);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The type used to represent the kinds of proxying allowed.
|
||||||
|
/// If you are adding new pallets, consider adding new proxy type
|
||||||
|
#[derive(
|
||||||
|
Copy,
|
||||||
|
Clone,
|
||||||
|
Decode,
|
||||||
|
Default,
|
||||||
|
Encode,
|
||||||
|
Eq,
|
||||||
|
MaxEncodedLen,
|
||||||
|
Ord,
|
||||||
|
PartialEq,
|
||||||
|
PartialOrd,
|
||||||
|
RuntimeDebug,
|
||||||
|
TypeInfo,
|
||||||
|
)]
|
||||||
|
pub enum ProxyType {
|
||||||
|
/// Allows to proxy all calls
|
||||||
|
#[default]
|
||||||
|
Any,
|
||||||
|
/// Allows all non-transfer calls
|
||||||
|
NonTransfer,
|
||||||
|
/// Allows to finish the proxy
|
||||||
|
CancelProxy,
|
||||||
|
/// Allows to operate with collators list (invulnerables, candidates, etc.)
|
||||||
|
Collator,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl InstanceFilter<RuntimeCall> for ProxyType {
|
||||||
|
fn filter(&self, c: &RuntimeCall) -> bool {
|
||||||
|
match self {
|
||||||
|
ProxyType::Any => true,
|
||||||
|
ProxyType::NonTransfer => !matches!(c, RuntimeCall::Balances { .. }),
|
||||||
|
ProxyType::CancelProxy =>
|
||||||
|
matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })),
|
||||||
|
ProxyType::Collator => matches!(c, RuntimeCall::CollatorSelection { .. }),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl pallet_proxy::Config for Runtime {
|
||||||
|
type AnnouncementDepositBase = AnnouncementDepositBase;
|
||||||
|
type AnnouncementDepositFactor = AnnouncementDepositFactor;
|
||||||
|
type CallHasher = BlakeTwo256;
|
||||||
|
type Currency = Balances;
|
||||||
|
type MaxPending = MaxPending;
|
||||||
|
type MaxProxies = MaxProxies;
|
||||||
|
type ProxyDepositBase = ProxyDepositBase;
|
||||||
|
type ProxyDepositFactor = ProxyDepositFactor;
|
||||||
|
type ProxyType = ProxyType;
|
||||||
|
type RuntimeCall = RuntimeCall;
|
||||||
|
type RuntimeEvent = RuntimeEvent;
|
||||||
|
type WeightInfo = pallet_proxy::weights::SubstrateWeight<Runtime>;
|
||||||
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
|
pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
|
||||||
}
|
}
|
||||||
@@ -520,6 +579,7 @@ construct_runtime!(
|
|||||||
ParachainSystem: cumulus_pallet_parachain_system = 1,
|
ParachainSystem: cumulus_pallet_parachain_system = 1,
|
||||||
Timestamp: pallet_timestamp = 2,
|
Timestamp: pallet_timestamp = 2,
|
||||||
ParachainInfo: parachain_info = 3,
|
ParachainInfo: parachain_info = 3,
|
||||||
|
Proxy: pallet_proxy = 4,
|
||||||
|
|
||||||
// Monetary stuff.
|
// Monetary stuff.
|
||||||
Balances: pallet_balances = 10,
|
Balances: pallet_balances = 10,
|
||||||
|
|||||||
Reference in New Issue
Block a user