Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
AurevoirXavier committed Jun 25, 2024
1 parent 229a035 commit 97466dc
Show file tree
Hide file tree
Showing 27 changed files with 522 additions and 346 deletions.
23 changes: 14 additions & 9 deletions 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ pallet-balances = { git = "https://github.com/parityt
pallet-collective = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
pallet-conviction-voting = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
pallet-democracy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
pallet-message-queue = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
pallet-preimage = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
pallet-proxy = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
pallet-referenda = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.7.2", default-features = false }
Expand Down
54 changes: 31 additions & 23 deletions runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ dc-primitives = { workspace = true }
fp-account = { workspace = true }
pallet-evm = { workspace = true }

# polkadot
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }

# substrate
frame-support = { workspace = true }
frame-system = { workspace = true }
pallet-assets = { workspace = true, optional = true }
pallet-authorship = { workspace = true }
pallet-balances = { workspace = true }
pallet-collective = { workspace = true }
sp-core = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }
# polkadot-sdk
cumulus-primitives-core = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
pallet-assets = { workspace = true, optional = true }
pallet-authorship = { workspace = true }
pallet-balances = { workspace = true }
pallet-collective = { workspace = true }
pallet-message-queue = { workspace = true }
sp-core = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }

[features]
default = ["std"]
Expand All @@ -54,27 +54,35 @@ std = [
"fp-account/std",
"pallet-evm/std",

# polkadot
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",

# substrate
# polkadot-sdk
"cumulus-primitives-core/std",
"frame-support/std",
"frame-system/std",
"pallet-authorship/std",
"pallet-balances/std",
"pallet-collective/std",
"pallet-message-queue/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
# substrate optional
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
# polkadot-sdk optional
"pallet-assets?/std",
]

test = []

runtime-benchmarks = [
# polkadot-sdk
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
# polkadot-sdk optional
"pallet-assets/runtime-benchmarks",
]
2 changes: 1 addition & 1 deletion runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
// along with Darwinia. If not, see <https://www.gnu.org/licenses/>.

#![cfg_attr(not(feature = "std"), no_std)]
#![deny(unused_crate_dependencies)]
// TODO:
// #![deny(missing_docs)]

pub mod gov_origin;
pub mod message_queue;
pub mod migration_helper;
pub mod pallet_config;
pub mod xcm_configs;
Expand Down
59 changes: 59 additions & 0 deletions runtime/common/src/message_queue.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// This file is part of Darwinia.
//
// Copyright (C) Darwinia Network
// SPDX-License-Identifier: GPL-3.0
//
// Darwinia is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Darwinia is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Darwinia. If not, see <https://www.gnu.org/licenses/>.

//! Helpers to deal with configuring the message queue in the runtime.

// core
use core::marker::PhantomData;
// polkadot-sdk
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
use frame_support::traits::{QueueFootprint, QueuePausedQuery};
use pallet_message_queue::OnQueueChanged;
use sp_runtime::traits::Convert;

/// Narrow the scope of the `Inner` query from `AggregateMessageOrigin` to `ParaId`.
///
/// All non-`Sibling` variants will be ignored.
pub struct NarrowOriginToSibling<Inner>(PhantomData<Inner>);
impl<Inner: QueuePausedQuery<ParaId>> QueuePausedQuery<AggregateMessageOrigin>
for NarrowOriginToSibling<Inner>
{
fn is_paused(origin: &AggregateMessageOrigin) -> bool {
match origin {
AggregateMessageOrigin::Sibling(id) => Inner::is_paused(id),
_ => false,
}
}
}
impl<Inner: OnQueueChanged<ParaId>> OnQueueChanged<AggregateMessageOrigin>
for NarrowOriginToSibling<Inner>
{
fn on_queue_changed(origin: AggregateMessageOrigin, fp: QueueFootprint) {
if let AggregateMessageOrigin::Sibling(id) = origin {
Inner::on_queue_changed(id, fp)
}
}
}

/// Convert a sibling `ParaId` to an `AggregateMessageOrigin`.
pub struct ParaIdToSibling;
impl Convert<ParaId, AggregateMessageOrigin> for ParaIdToSibling {
fn convert(para_id: ParaId) -> AggregateMessageOrigin {
AggregateMessageOrigin::Sibling(para_id)
}
}
12 changes: 6 additions & 6 deletions runtime/common/src/pallet_config.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// darwinia
use crate::gov_origin::ROOT;
use dc_primitives::{AccountId, Balance};
use dc_primitives::*;
// substrate
use frame_support::{traits::LockIdentifier, PalletId};
use sp_std::prelude::*;

#[cfg(not(feature = "runtime-benchmarks"))]
Expand All @@ -11,12 +9,14 @@ pub const EXISTENTIAL_DEPOSIT: Balance = 0;
pub const EXISTENTIAL_DEPOSIT: Balance = 1;

frame_support::parameter_types! {
pub const TreasuryPid: PalletId = PalletId(*b"da/trsry");
pub const TreasuryPid: frame_support::PalletId = frame_support::PalletId(*b"da/trsry");

pub const FeeMarketLid: LockIdentifier = *b"da/feecr";
pub const FeeMarketLid: frame_support::traits::LockIdentifier = *b"da/feecr";

pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
pub const MaxBalance: Balance = Balance::max_value();

pub AssetCreators: Vec<AccountId> = vec![ROOT];
pub const RelayOrigin: cumulus_primitives_core::AggregateMessageOrigin = cumulus_primitives_core::AggregateMessageOrigin::Parent;

pub AssetCreators: Vec<AccountId> = vec![super::gov_origin::ROOT];
}
Loading

0 comments on commit 97466dc

Please sign in to comment.