Skip to content

Commit

Permalink
fix: add polkadot-runtime-common to runtime
Browse files Browse the repository at this point in the history
fix runtime: cumulus_pallet_dmp_queue::Config
fix runtime: pallet_tips::Config
add runtime: pallet_message_queue::Config
  • Loading branch information
higherordertech committed Nov 26, 2024
1 parent 34310d2 commit d07d2eb
Show file tree
Hide file tree
Showing 12 changed files with 208 additions and 36 deletions.
4 changes: 4 additions & 0 deletions parachain/Cargo.lock

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

1 change: 1 addition & 0 deletions parachain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ pallet-tips = { git = "https://github.com/paritytech/polkadot-sdk", branch = "re
pallet-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
pallet-xcm = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
parachains-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
polkadot-runtime-common = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
xcm-builder = { package = "staging-xcm-builder", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
xcm-executor = { package = "staging-xcm-executor", git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.11.0", default-features = false }
Expand Down
2 changes: 2 additions & 0 deletions parachain/runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ parachain-info = { workspace = true }

pallet-xcm = { workspace = true }
parachains-common = { workspace = true }
polkadot-runtime-common = { workspace = true }
xcm = { workspace = true }
staging-xcm = { workspace = true }
xcm-builder = { workspace = true }
Expand Down Expand Up @@ -104,6 +105,7 @@ std = [
"orml-traits/std",
"orml-xtokens/std",
"parachains-common/std",
"polkadot-runtime-common/std",
]

runtime-benchmarks = [
Expand Down
7 changes: 6 additions & 1 deletion parachain/runtime/litentry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pallet-democracy = { workspace = true }
pallet-identity = { workspace = true }
pallet-indices = { workspace = true }
pallet-membership = { workspace = true }
pallet-message-queue = { workspace = true }
pallet-multisig = { workspace = true }
pallet-preimage = { workspace = true }
pallet-proxy = { workspace = true }
Expand All @@ -69,6 +70,7 @@ parachain-info = { workspace = true }

pallet-xcm = { workspace = true }
parachains-common = { workspace = true }
polkadot-runtime-common = { workspace = true }
polkadot-parachain-primitives = { workspace = true }
xcm = { workspace = true }
staging-xcm = { workspace = true }
Expand Down Expand Up @@ -132,7 +134,6 @@ polkadot-runtime-parachains = { workspace = true, features = ["std"] }
runtime-common = { workspace = true, features = ["tests"] }
sp-state-machine = { workspace = true, features = ["std"] }
xcm-simulator = { workspace = true }
pallet-message-queue = { workspace = true, features = ["std"] }

[build-dependencies]
substrate-wasm-builder = { workspace = true }
Expand All @@ -157,6 +158,7 @@ runtime-benchmarks = [
"pallet-evm/runtime-benchmarks",
"pallet-identity/runtime-benchmarks",
"pallet-membership/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-parachain-staking/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
Expand Down Expand Up @@ -229,6 +231,7 @@ std = [
"pallet-identity/std",
"pallet-indices/std",
"pallet-membership/std",
"pallet-message-queue/std",
"pallet-multisig/std",
"pallet-parachain-staking/std",
"pallet-preimage/std",
Expand Down Expand Up @@ -280,6 +283,7 @@ std = [
"moonbeam-rpc-primitives-txpool/std",
"precompile-utils/std",
"parachains-common/std",
"polkadot-runtime-common/std",
]
try-runtime = [
"hex",
Expand Down Expand Up @@ -316,6 +320,7 @@ try-runtime = [
"pallet-identity-management/try-runtime",
"pallet-extrinsic-filter/try-runtime",
"pallet-membership/try-runtime",
"pallet-message-queue/try-runtime",
"pallet-multisig/try-runtime",
"pallet-parachain-staking/try-runtime",
"pallet-preimage/try-runtime",
Expand Down
61 changes: 59 additions & 2 deletions parachain/runtime/litentry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ use sp_version::RuntimeVersion;
// XCM Imports
use xcm_builder::PayOverXcm;
use xcm_executor::XcmExecutor;
use xcm::latest::prelude::Junction;

pub use constants::currency::deposit;
pub use core_primitives::{
Expand All @@ -79,6 +80,7 @@ use runtime_common::{
NORMAL_DISPATCH_RATIO, WEIGHT_PER_GAS, WEIGHT_TO_FEE_FACTOR,
impls::{ContainsParts, LocatableAssetConverter, VersionedLocationConverter}
};
use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery;
use xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin};

use pallet_ethereum::{Call::transact, PostLogContent, TransactionStatus};
Expand Down Expand Up @@ -824,18 +826,45 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
type ControllerOrigin = EnsureRootOrAllCouncil;
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
type PriceForSiblingDelivery = ();
type PriceForSiblingDelivery = NoPriceForMessageDelivery<ParaId>;
// Enqueue XCMP messages from siblings for later processing.
type XcmpQueue = TransformOrigin<MessageQueue, AggregateMessageOrigin, ParaId, ParaIdToSibling>;
type MaxInboundSuspended = sp_core::ConstU32<1_000>;
}

parameter_types! {
/// All messages that came into the `DmpSink`.
pub static RecordedMessages: Vec<Vec<u8>> = vec![];
}

/// Can be used as [`Config::DmpSink`] to record all messages that came in.
pub struct RecordingDmpSink;
impl frame_support::traits::HandleMessage for RecordingDmpSink {
type MaxMessageLen = ConstU32<16>;

fn handle_message(msg: frame_support::BoundedSlice<u8, Self::MaxMessageLen>) {
RecordedMessages::mutate(|n| n.push(msg.to_vec()));
}

fn handle_messages<'a>(_: impl Iterator<Item = frame_support::BoundedSlice<'a, u8, Self::MaxMessageLen>>) {
unimplemented!()
}

fn sweep_queue() {
unimplemented!()
}

fn footprint() -> frame_support::traits::QueueFootprint {
unimplemented!()
}
}

impl cumulus_pallet_dmp_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
// TODO need to generate
type WeightInfo = ();
// type WeightInfo = weights::cumulus_pallet_dmp_queue::WeightInfo<Runtime>;
type DmpSink = ();
type DmpSink = RecordingDmpSink;
}

parameter_types! {
Expand Down Expand Up @@ -1232,6 +1261,33 @@ impl pallet_score_staking::Config for Runtime {
impl runtime_common::BaseRuntimeRequirements for Runtime {}
impl runtime_common::ParaRuntimeRequirements for Runtime {}

parameter_types! {
pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block;
}

impl pallet_message_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
#[cfg(feature = "runtime-benchmarks")]
type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor<
cumulus_primitives_core::AggregateMessageOrigin,
>;
#[cfg(not(feature = "runtime-benchmarks"))]
type MessageProcessor = xcm_builder::ProcessXcmMessage<
AggregateMessageOrigin,
xcm_executor::XcmExecutor<xcm_config::XcmConfig>,
RuntimeCall,
>;
type Size = u32;
// The XCMP queue pallet is only ever able to handle the `Sibling(ParaId)` origin:
type QueueChangeHandler = NarrowOriginToSibling<XcmpQueue>;
type QueuePausedQuery = NarrowOriginToSibling<XcmpQueue>;
type HeapSize = sp_core::ConstU32<{ 64 * 1024 }>;
type MaxStale = sp_core::ConstU32<8>;
type ServiceWeight = MessageQueueServiceWeight;
type IdleMaxServiceWeight = ();
}

construct_runtime! {
pub enum Runtime
{
Expand Down Expand Up @@ -1293,6 +1349,7 @@ construct_runtime! {
// XTokens: orml_xtokens = 54,
// 55 is saved for old pallet: Tokens: orml_tokens
Assets: pallet_assets = 56,
MessageQueue: pallet_message_queue = 57,

// Litentry pallets
ChainBridge: pallet_chain_bridge= 60,
Expand Down
6 changes: 0 additions & 6 deletions parachain/runtime/litentry/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ parameter_types! {
pub UniversalLocation: InteriorLocation = Parachain(ParachainInfo::parachain_id().into()).into();
}

impl orml_traits::parameters::frame_support::traits::Get<Junctions> for UniversalLocation {
fn get() -> Junctions {
UniversalLocation::get()
}
}

/// Type for specifying how a `Location` can be converted into an `AccountId`. This is used
/// when determining ownership of accounts for asset transacting and when attempting to use XCM
/// `Transact` in order to determine the dispatch Origin.
Expand Down
6 changes: 5 additions & 1 deletion parachain/runtime/paseo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pallet-democracy = { workspace = true }
pallet-identity = { workspace = true }
pallet-indices = { workspace = true }
pallet-membership = { workspace = true }
pallet-message-queue = { workspace = true }
pallet-multisig = { workspace = true }
pallet-preimage = { workspace = true }
pallet-proxy = { workspace = true }
Expand All @@ -66,6 +67,7 @@ parachain-info = { workspace = true }

pallet-xcm = { workspace = true }
parachains-common = { workspace = true }
polkadot-runtime-common = { workspace = true }
polkadot-parachain-primitives = { workspace = true }
xcm = { workspace = true }
staging-xcm = { workspace = true }
Expand Down Expand Up @@ -132,7 +134,6 @@ polkadot-runtime-parachains = { workspace = true, features = ["std"] }
runtime-common = { workspace = true, features = ["tests"] }
sp-state-machine = { workspace = true, features = ["std"] }
xcm-simulator = { workspace = true }
pallet-message-queue = { workspace = true, features = ["std"] }

[build-dependencies]
substrate-wasm-builder = { workspace = true }
Expand All @@ -157,6 +158,7 @@ runtime-benchmarks = [
"pallet-evm/runtime-benchmarks",
"pallet-identity/runtime-benchmarks",
"pallet-membership/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-parachain-staking/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
Expand Down Expand Up @@ -291,6 +293,7 @@ std = [
"pallet-bitacross/std",
"precompile-utils/std",
"parachains-common/std",
"polkadot-runtime-common/std",
]
try-runtime = [
"cumulus-pallet-aura-ext/try-runtime",
Expand Down Expand Up @@ -326,6 +329,7 @@ try-runtime = [
"pallet-group/try-runtime",
"pallet-identity-management/try-runtime",
"pallet-membership/try-runtime",
"pallet-message-queue/try-runtime",
"pallet-multisig/try-runtime",
"pallet-parachain-staking/try-runtime",
"pallet-preimage/try-runtime",
Expand Down
65 changes: 62 additions & 3 deletions parachain/runtime/paseo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ use sp_version::RuntimeVersion;
// XCM Imports
use xcm_builder::PayOverXcm;
use xcm_executor::XcmExecutor;
use xcm::latest::prelude::Junction;

pub use constants::currency::deposit;
pub use core_primitives::{
Expand All @@ -90,6 +91,7 @@ use runtime_common::{
WEIGHT_TO_FEE_FACTOR,
impls::{ContainsParts, LocatableAssetConverter, VersionedLocationConverter}
};
use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery;
use xcm_config::{XcmConfig, XcmOriginToTransactDispatchOrigin};

use pallet_ethereum::{Call::transact, PostLogContent, TransactionStatus};
Expand Down Expand Up @@ -763,7 +765,9 @@ impl SortedMembers<AccountId> for CouncilProvider {
}

fn sorted_members() -> Vec<AccountId> {
pallet_collective::pallet::Members::<T, I>::get()
// pallet_collective::pallet::Members::<T, I>::get()
// TODO
unimplemented!()
}

#[cfg(feature = "runtime-benchmarks")]
Expand Down Expand Up @@ -879,18 +883,45 @@ impl cumulus_pallet_xcmp_queue::Config for Runtime {
type ControllerOrigin = EnsureRootOrAllCouncil;
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
type PriceForSiblingDelivery = ();
type PriceForSiblingDelivery = NoPriceForMessageDelivery<ParaId>;
// Enqueue XCMP messages from siblings for later processing.
type XcmpQueue = TransformOrigin<MessageQueue, AggregateMessageOrigin, ParaId, ParaIdToSibling>;
type MaxInboundSuspended = sp_core::ConstU32<1_000>;
}

parameter_types! {
/// All messages that came into the `DmpSink`.
pub static RecordedMessages: Vec<Vec<u8>> = vec![];
}

/// Can be used as [`Config::DmpSink`] to record all messages that came in.
pub struct RecordingDmpSink;
impl frame_support::traits::HandleMessage for RecordingDmpSink {
type MaxMessageLen = ConstU32<16>;

fn handle_message(msg: frame_support::BoundedSlice<u8, Self::MaxMessageLen>) {
RecordedMessages::mutate(|n| n.push(msg.to_vec()));
}

fn handle_messages<'a>(_: impl Iterator<Item = frame_support::BoundedSlice<'a, u8, Self::MaxMessageLen>>) {
unimplemented!()
}

fn sweep_queue() {
unimplemented!()
}

fn footprint() -> frame_support::traits::QueueFootprint {
unimplemented!()
}
}

impl cumulus_pallet_dmp_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
// TODO need to generate
type WeightInfo = ();
// type WeightInfo = weights::cumulus_pallet_dmp_queue::WeightInfo<Runtime>;
type DmpSink = ();
type DmpSink = RecordingDmpSink;
}

parameter_types! {
Expand Down Expand Up @@ -1271,6 +1302,33 @@ impl pallet_score_staking::Config for Runtime {
impl runtime_common::BaseRuntimeRequirements for Runtime {}
impl runtime_common::ParaRuntimeRequirements for Runtime {}

parameter_types! {
pub MessageQueueServiceWeight: Weight = Perbill::from_percent(35) * RuntimeBlockWeights::get().max_block;
}

impl pallet_message_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = ();
#[cfg(feature = "runtime-benchmarks")]
type MessageProcessor = pallet_message_queue::mock_helpers::NoopMessageProcessor<
cumulus_primitives_core::AggregateMessageOrigin,
>;
#[cfg(not(feature = "runtime-benchmarks"))]
type MessageProcessor = xcm_builder::ProcessXcmMessage<
AggregateMessageOrigin,
xcm_executor::XcmExecutor<xcm_config::XcmConfig>,
RuntimeCall,
>;
type Size = u32;
// The XCMP queue pallet is only ever able to handle the `Sibling(ParaId)` origin:
type QueueChangeHandler = NarrowOriginToSibling<XcmpQueue>;
type QueuePausedQuery = NarrowOriginToSibling<XcmpQueue>;
type HeapSize = sp_core::ConstU32<{ 64 * 1024 }>;
type MaxStale = sp_core::ConstU32<8>;
type ServiceWeight = MessageQueueServiceWeight;
type IdleMaxServiceWeight = ();
}

construct_runtime! {
pub enum Runtime
{
Expand Down Expand Up @@ -1333,6 +1391,7 @@ construct_runtime! {
// XTokens: orml_xtokens = 54,
// 55 is saved for old pallet: Tokens: orml_tokens
Assets: pallet_assets = 56,
MessageQueue: pallet_message_queue = 57,

// Rococo pallets
ChainBridge: pallet_chain_bridge= 60,
Expand Down
Loading

0 comments on commit d07d2eb

Please sign in to comment.