Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
darkforest0202 committed Dec 24, 2023
1 parent 4e8f8e3 commit 2a788e0
Show file tree
Hide file tree
Showing 21 changed files with 2,751 additions and 2,640 deletions.
4,376 changes: 2,031 additions & 2,345 deletions Cargo.lock

Large diffs are not rendered by default.

231 changes: 115 additions & 116 deletions Cargo.toml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ crate-type = ["cdylib", "rlib"]
[dependencies]
bs58 = { version = "0.5.0", default-features = false }
wasm-bindgen = { version = "0.2.87", optional = true }
sp-io = { workspace = true }

[features]
alloc = []
Expand Down
1 change: 1 addition & 0 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![cfg_attr(not(any(test, feature = "std")), no_std)]
#![cfg_attr(nightly, feature(ascii_char))]
extern crate sp_io;

#[cfg(feature = "alloc")]
extern crate alloc;
Expand Down
5 changes: 2 additions & 3 deletions node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@
#![warn(missing_docs)]
#![warn(unused_extern_crates)]

mod chain_spec;
#[macro_use]
mod service;
mod benchmarking;
mod chain_spec;
mod cli;
mod command;
mod rpc;
mod service;

fn main() -> sc_cli::Result<()> {
command::run()
Expand Down
2 changes: 0 additions & 2 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
use std::sync::Arc;

use parachains_common::{AccountId, Balance, Block, Nonce};
use sc_client_api::AuxStore;
pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor};
use sc_transaction_pool_api::TransactionPool;
use sp_api::ProvideRuntimeApi;
Expand Down Expand Up @@ -49,7 +48,6 @@ pub fn create_full<C, P, B>(
where
C: ProvideRuntimeApi<Block>
+ HeaderBackend<Block>
+ AuxStore
+ HeaderMetadata<Block, Error = BlockChainError>
+ Send
+ Sync
Expand Down
1 change: 1 addition & 0 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ where
collator_service,
// Very limited proposal time.
authoring_duration: Duration::from_millis(500),
collation_request_receiver: None,
};

let fut = basic_aura::run::<Block, <AuraId as AppCrypto>::Pair, _, _, _, _, _, _, _>(params);
Expand Down
5 changes: 0 additions & 5 deletions runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ log = { workspace = true }
scale-info = { workspace = true, features = ["derive"] }
smallvec = { workspace = true }

# Local
pallet-lockdown-mode = { workspace = true }

# Substrate
frame-benchmarking = { workspace = true, optional = true}
frame-executive = { workspace = true }
Expand Down Expand Up @@ -111,7 +108,6 @@ std = [
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
"pallet-xcm/std",
"pallet-lockdown-mode/std",
"pallet-treasury/std",
"parachain-info/std",
"polkadot-runtime-common/std",
Expand Down Expand Up @@ -141,7 +137,6 @@ runtime-benchmarks = [
"pallet-collator-selection/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"pallet-lockdown-mode/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
Expand Down
6 changes: 2 additions & 4 deletions runtime/kreivo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ smallvec = { workspace = true }

# Local
pallet-asset-registry ={ workspace = true }
pallet-lockdown-mode = { workspace = true }
pallet-burner = { workspace = true }
pallet-payments = { workspace = true }
pallet-communities = { workspace = true }
runtime-common = { workspace = true }

# Substrate
Expand Down Expand Up @@ -90,6 +88,7 @@ cumulus-primitives-utility = { workspace = true }
pallet-collator-selection = { workspace = true }
parachain-info = { workspace = true }
parachains-common = { workspace = true }
pallet-message-queue = { workspace = true }

[features]
default = [
Expand Down Expand Up @@ -132,10 +131,10 @@ std = [
"pallet-utility/std",
"pallet-payments/std",
"pallet-xcm/std",
"pallet-lockdown-mode/std",
"parachain-info/std",
"polkadot-parachain-primitives/std",
"polkadot-runtime-common/std",
"pallet-message-queue/std",
"runtime-common/std",
"sp-api/std",
"sp-block-builder/std",
Expand Down Expand Up @@ -167,7 +166,6 @@ runtime-benchmarks = [
"pallet-timestamp/runtime-benchmarks",
"pallet-treasury/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"pallet-lockdown-mode/runtime-benchmarks",
"pallet-burner/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
Expand Down
26 changes: 1 addition & 25 deletions runtime/kreivo/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,10 @@
//! Taken from polkadot/runtime/common (at a21cd64) and adapted for parachains.
use super::*;
use cumulus_primitives_core::{relay_chain::BlockNumber as RelayBlockNumber, DmpMessageHandler};
use frame_support::{
traits::{Contains, Currency, InstanceFilter},
weights::Weight,
};
use frame_support::traits::{Contains, Currency, InstanceFilter};
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use sp_runtime::RuntimeDebug;

use pallet_lockdown_mode::impls::PauseXcmExecution;
use sp_runtime::DispatchResult;

/// Type alias to conveniently refer to the `Currency::NegativeImbalance`
/// associated type.
pub type NegativeImbalance<T> =
Expand All @@ -52,23 +45,6 @@ impl Contains<RuntimeCall> for RuntimeBlackListedCalls {
}
}

pub struct LockdownDmpHandler;
impl DmpMessageHandler for LockdownDmpHandler {
fn handle_dmp_messages(_iter: impl Iterator<Item = (RelayBlockNumber, Vec<u8>)>, limit: Weight) -> Weight {
DmpQueue::handle_dmp_messages(_iter, limit)
}
}

pub struct XcmExecutionManager {}
impl PauseXcmExecution for XcmExecutionManager {
fn suspend_xcm_execution() -> DispatchResult {
XcmpQueue::suspend_xcm_execution(RuntimeOrigin::root())
}
fn resume_xcm_execution() -> DispatchResult {
XcmpQueue::resume_xcm_execution(RuntimeOrigin::root())
}
}

/// The type used to represent the kinds of proxying allowed.
#[derive(
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen, scale_info::TypeInfo,
Expand Down
94 changes: 44 additions & 50 deletions runtime/kreivo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,29 @@ pub mod impls;
mod weights;
pub mod xcm_config;

use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
use parachains_common::message_queue::{NarrowOriginToSibling, ParaIdToSibling};
use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery;
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
pub use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto},
transaction_validity::{InvalidTransaction, TransactionSource, TransactionValidity},
ApplyExtrinsicResult, MultiAddress, Percent, Permill,
ApplyExtrinsicResult, MultiAddress, Perbill, Percent, Permill,
};
use sp_std::prelude::*;
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;

use frame_support::{
construct_runtime,
construct_runtime, derive_impl,
dispatch::DispatchClass,
parameter_types,
traits::{AsEnsureOriginWithArg, ConstBool, ConstU32, ConstU64, ConstU8, Contains, EitherOfDiverse},
traits::{
AsEnsureOriginWithArg, ConstBool, ConstU32, ConstU64, ConstU8, Contains, EitherOfDiverse, TransformOrigin,
},
weights::{constants::RocksDbWeight, ConstantMultiplier, Weight},
PalletId,
};
Expand All @@ -43,7 +47,7 @@ use frame_system::{
};

use pallet_xcm::{EnsureXcm, IsVoiceOfBody};
use xcm_config::{RelayLocation, TrustBackedAssetsConvertedConcreteId, XcmConfig, XcmOriginToTransactDispatchOrigin};
use xcm_config::{RelayLocation, TrustBackedAssetsConvertedConcreteId, XcmOriginToTransactDispatchOrigin};

#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
Expand All @@ -55,10 +59,9 @@ pub use weights::{BlockExecutionWeight, ExtrinsicBaseWeight};

// XCM Imports
use xcm::latest::prelude::BodyId;
use xcm_executor::XcmExecutor;

pub use constants::{currency::*, fee::WeightToFee};
pub use impls::{LockdownDmpHandler, ProxyType, RuntimeBlackListedCalls, XcmExecutionManager};
pub use impls::ProxyType;
pub use parachains_common::{
opaque, AccountId, AssetIdForTrustBackedAssets, AuraId, Balance, BlockNumber, Hash, Header, Nonce, Signature,
AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, MINUTES, NORMAL_DISPATCH_RATIO, SLOT_DURATION,
Expand Down Expand Up @@ -158,12 +161,11 @@ construct_runtime!(
XcmpQueue: cumulus_pallet_xcmp_queue = 30,
PolkadotXcm: pallet_xcm = 31,
CumulusXcm: cumulus_pallet_xcm = 32,
DmpQueue: cumulus_pallet_dmp_queue = 33,
MessageQueue: pallet_message_queue = 33,
AssetRegistry: pallet_asset_registry = 34,

// Utils
Sudo: pallet_sudo = 40,
LockdownMode: pallet_lockdown_mode = 41,
Multisig: pallet_multisig = 42,
Utility: pallet_utility = 43,
Proxy: pallet_proxy = 44,
Expand Down Expand Up @@ -204,44 +206,23 @@ parameter_types! {
}

// Configure FRAME pallets to include in runtime.

#[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig as frame_system::DefaultConfig)]
impl frame_system::Config for Runtime {
/// The identifier used to distinguish between accounts.
type AccountId = AccountId;
/// The aggregated dispatch type that is available for extrinsics.
type RuntimeCall = RuntimeCall;
/// The lookup mechanism to get account ID from whatever is passed in
/// dispatchers.
type Lookup = AccountIdLookup<AccountId, ()>;
/// The type for hashing blocks and tries.
type Hash = Hash;
type Block = Block;
type Nonce = Nonce;
/// The hashing algorithm used.
type Hashing = BlakeTwo256;
/// The ubiquitous event type.
type RuntimeEvent = RuntimeEvent;
/// The ubiquitous origin type.
type RuntimeOrigin = RuntimeOrigin;
/// Maximum number of block number to block hash mappings to keep (oldest
/// pruned first).
type BlockHashCount = BlockHashCount;
/// Runtime version.
type Version = Version;
/// Converts a module to an index of this module in the runtime.
type PalletInfo = PalletInfo;
/// The data to be stored in an account.
type AccountData = pallet_balances::AccountData<Balance>;
/// What to do if a new account is created.
type OnNewAccount = ();
/// What to do if an account is fully reaped from the system.
type OnKilledAccount = ();
/// The weight of database operations that the runtime can invoke.
type DbWeight = RocksDbWeight;
/// The basic call filter to use in dispatchable.
type BaseCallFilter = LockdownMode;
/// Weight information for the extrinsics of this pallet.
type SystemWeightInfo = ();
/// Block & extrinsics weights: base values and limits.
type BlockWeights = RuntimeBlockWeights;
/// The maximum length of a block (in bytes).
Expand Down Expand Up @@ -306,40 +287,62 @@ impl pallet_transaction_payment::Config for Runtime {
parameter_types! {
pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
pub const RelayOrigin: AggregateMessageOrigin = AggregateMessageOrigin::Parent;
}

impl cumulus_pallet_parachain_system::Config for Runtime {
type WeightInfo = ();
type RuntimeEvent = RuntimeEvent;
type OnSystemEvent = ();
type SelfParaId = parachain_info::Pallet<Runtime>;
type OutboundXcmpMessageSource = XcmpQueue;
type DmpMessageHandler = LockdownMode;
type DmpQueue = frame_support::traits::EnqueueWithOrigin<MessageQueue, RelayOrigin>;
type ReservedDmpWeight = ReservedDmpWeight;
type XcmpMessageHandler = XcmpQueue;
type ReservedXcmpWeight = ReservedXcmpWeight;
type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases;
}

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;
}

impl parachain_info::Config for Runtime {}

impl cumulus_pallet_aura_ext::Config for Runtime {}

impl cumulus_pallet_xcmp_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ChannelInfo = ParachainSystem;
type VersionWrapper = ();
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
// Enqueue XCMP messages from siblings for later processing.
type XcmpQueue = TransformOrigin<MessageQueue, AggregateMessageOrigin, ParaId, ParaIdToSibling>;
type MaxInboundSuspended = sp_core::ConstU32<1_000>;
type ControllerOrigin = EnsureRoot<AccountId>;
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
type WeightInfo = ();
type PriceForSiblingDelivery = ();
}

impl cumulus_pallet_dmp_queue::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type XcmExecutor = XcmExecutor<XcmConfig>;
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
type PriceForSiblingDelivery = NoPriceForMessageDelivery<ParaId>;
}

parameter_types! {
Expand Down Expand Up @@ -418,15 +421,6 @@ impl pallet_sudo::Config for Runtime {
type WeightInfo = pallet_sudo::weights::SubstrateWeight<Runtime>;
}

impl pallet_lockdown_mode::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type LockdownModeOrigin = frame_system::EnsureRoot<Self::AccountId>;
type BlackListedCalls = RuntimeBlackListedCalls;
type LockdownDmpHandler = LockdownDmpHandler;
type XcmExecutorManager = XcmExecutionManager;
type WeightInfo = pallet_lockdown_mode::weights::SubstrateWeight<Runtime>;
}

parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub const ProposalBondMinimum: Balance = 2000 * CENTS;
Expand Down
31 changes: 31 additions & 0 deletions runtime/kusama-runtime-constants/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "kusama-runtime-constants"
repository.workspace = true
version = "1.0.0"
authors.workspace = true
edition.workspace = true
license.workspace = true

[dependencies]
smallvec = "1.8.0"

frame-support = { workspace = true }
polkadot-primitives = { workspace = true }
polkadot-runtime-common = { workspace = true }
sp-runtime = { workspace = true }
sp-weights = { workspace = true }
sp-core = { workspace = true }

xcm = { workspace = true }

[features]
default = [ "std" ]
std = [
"frame-support/std",
"polkadot-primitives/std",
"polkadot-runtime-common/std",
"sp-core/std",
"sp-runtime/std",
"sp-weights/std",
"xcm/std"
]
Loading

0 comments on commit 2a788e0

Please sign in to comment.