diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa71fca..b977067 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -231,7 +231,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - runtime: [ "shell", "integritee" ] + runtime: [ "integritee-kusama", "integritee-polkadot" ] steps: - uses: actions/checkout@v3 @@ -321,10 +321,7 @@ jobs: fail-fast: false matrix: chain: [ integritee ] - config: [ rococo, westend, kusama, polkadot, moonbase, paseo ] - include: - - chain: shell - config: kusama-lease2 + config: [ kusama, polkadot, paseo ] steps: - name: Checkout uses: actions/checkout@v3 @@ -418,7 +415,7 @@ jobs: needs: [ "release" ] strategy: matrix: - runtime: [ "shell", "integritee" ] + runtime: [ "integritee-kusama", "integritee-polkadot" ] steps: - uses: actions/checkout@v3 - uses: actions/download-artifact@v3 diff --git a/Cargo.lock b/Cargo.lock index 4cbebb6..29502c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4344,7 +4344,6 @@ dependencies = [ "sc-transaction-pool-api", "serde", "serde_json", - "shell-runtime", "sp-api", "sp-block-builder", "sp-blockchain", @@ -12515,66 +12514,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "shell-runtime" -version = "1.13.18" -dependencies = [ - "cumulus-pallet-aura-ext", - "cumulus-pallet-dmp-queue", - "cumulus-pallet-parachain-system", - "cumulus-pallet-xcm", - "cumulus-pallet-xcmp-queue", - "cumulus-primitives-aura", - "cumulus-primitives-core", - "cumulus-primitives-timestamp", - "cumulus-primitives-utility", - "frame-benchmarking", - "frame-executive", - "frame-metadata-hash-extension", - "frame-support", - "frame-system", - "frame-system-rpc-runtime-api", - "frame-try-runtime", - "hex", - "hex-literal", - "integritee-parachains-common", - "log", - "pallet-aura", - "pallet-balances", - "pallet-message-queue", - "pallet-sudo", - "pallet-timestamp", - "pallet-transaction-payment", - "pallet-transaction-payment-rpc-runtime-api", - "pallet-vesting", - "pallet-xcm", - "pallet-xcm-transactor", - "parachains-common", - "parity-scale-codec", - "polkadot-parachain-primitives", - "polkadot-runtime-common", - "scale-info", - "sp-api", - "sp-block-builder", - "sp-consensus-aura", - "sp-core", - "sp-genesis-builder", - "sp-inherents", - "sp-io", - "sp-offchain", - "sp-runtime", - "sp-session", - "sp-std", - "sp-transaction-pool", - "sp-version", - "staging-parachain-info", - "staging-xcm", - "staging-xcm-builder", - "staging-xcm-executor", - "substrate-wasm-builder", - "xcm-transactor-primitives", -] - [[package]] name = "shlex" version = "1.1.0" diff --git a/Cargo.toml b/Cargo.toml index 1321a03..5905559 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,6 @@ members = [ "polkadot-parachains/common", "polkadot-parachains/integritee-kusama", "polkadot-parachains/integritee-polkadot", - "polkadot-parachains/shell-runtime", ] [profile.release] diff --git a/polkadot-parachains/Cargo.toml b/polkadot-parachains/Cargo.toml index ef03214..19b65ac 100644 --- a/polkadot-parachains/Cargo.toml +++ b/polkadot-parachains/Cargo.toml @@ -27,7 +27,6 @@ serde_json = { workspace = true } integritee-parachains-common = { path = "common" } integritee-kusama-runtime = { path = "integritee-kusama" } integritee-polkadot-runtime = { path = "integritee-polkadot" } -shell-runtime = { path = "shell-runtime" } # Substrate dependencies frame-benchmarking = { workspace = true, features = ["std"] } @@ -120,7 +119,6 @@ runtime-benchmarks = [ "polkadot-cli/runtime-benchmarks", "polkadot-primitives/runtime-benchmarks", "sc-service/runtime-benchmarks", - "shell-runtime/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "polkadot-service/runtime-benchmarks", ] @@ -132,5 +130,4 @@ try-runtime = [ "polkadot-cli/try-runtime", "sp-runtime/try-runtime", "integritee-kusama-runtime/try-runtime", - "shell-runtime/try-runtime", ] diff --git a/polkadot-parachains/shell-runtime/Cargo.toml b/polkadot-parachains/shell-runtime/Cargo.toml deleted file mode 100644 index 133f644..0000000 --- a/polkadot-parachains/shell-runtime/Cargo.toml +++ /dev/null @@ -1,169 +0,0 @@ -[package] -name = "shell-runtime" -description = "The Integritee shell parachain runtime" -# align major.minor revision with polkadot SDK. patch should match spec_version -version = "1.13.18" -authors = ["Integritee AG "] -homepage = "https://integritee.network/" -repository = "https://github.com/integritee-network/parachain" -edition = "2021" - -[dependencies] -log = { workspace = true } -parity-scale-codec = { workspace = true } -scale-info = { workspace = true } - -integritee-parachains-common = { path = "../common", default-features = false } - -# Substrate dependencies -cumulus-pallet-aura-ext = { workspace = true } -cumulus-pallet-dmp-queue = { workspace = true } -cumulus-pallet-parachain-system = { workspace = true } -cumulus-pallet-xcm = { workspace = true } -cumulus-pallet-xcmp-queue = { workspace = true } -cumulus-primitives-aura = { workspace = true } -cumulus-primitives-core = { workspace = true } -cumulus-primitives-timestamp = { workspace = true } -cumulus-primitives-utility = { workspace = true } -frame-benchmarking = { workspace = true, optional = true } -frame-executive = { workspace = true } -frame-metadata-hash-extension = { workspace = true } -frame-support = { workspace = true } -frame-system = { workspace = true } -frame-system-rpc-runtime-api = { workspace = true } -frame-try-runtime = { workspace = true, optional = true } -pallet-aura = { workspace = true } -pallet-balances = { workspace = true } -pallet-message-queue = { workspace = true } -pallet-sudo = { workspace = true } -pallet-timestamp = { workspace = true } -pallet-transaction-payment = { workspace = true } -pallet-transaction-payment-rpc-runtime-api = { workspace = true } -pallet-vesting = { workspace = true } -pallet-xcm = { workspace = true } -pallet-xcm-transactor = { workspace = true } -parachains-common = { workspace = true } -polkadot-parachain-primitives = { workspace = true } -polkadot-runtime-common = { workspace = true } -sp-api = { workspace = true } -sp-block-builder = { workspace = true } -sp-consensus-aura = { workspace = true } -sp-core = { workspace = true } -sp-genesis-builder = { workspace = true } -sp-inherents = { workspace = true } -sp-io = { workspace = true } -sp-offchain = { workspace = true } -sp-runtime = { workspace = true } -sp-session = { workspace = true } -sp-std = { workspace = true } -sp-transaction-pool = { workspace = true } -sp-version = { workspace = true } -staging-parachain-info = { workspace = true } -staging-xcm = { workspace = true } -staging-xcm-builder = { workspace = true } -staging-xcm-executor = { workspace = true } -xcm-transactor-primitives = { workspace = true } - -[dev-dependencies] -hex = { workspace = true } -hex-literal = { workspace = true } - -[build-dependencies] -substrate-wasm-builder = { workspace = true, optional = true, features = ["metadata-hash"] } - -[features] -default = ["std"] -std = [ - "cumulus-pallet-aura-ext/std", - "cumulus-pallet-dmp-queue/std", - "cumulus-pallet-parachain-system/std", - "cumulus-pallet-xcm/std", - "cumulus-pallet-xcmp-queue/std", - "cumulus-primitives-aura/std", - "cumulus-primitives-core/std", - "cumulus-primitives-timestamp/std", - "cumulus-primitives-utility/std", - "frame-executive/std", - "frame-metadata-hash-extension/std", - "frame-support/std", - "frame-system-rpc-runtime-api/std", - "frame-system/std", - "integritee-parachains-common/std", - "log/std", - "pallet-aura/std", - "pallet-balances/std", - "pallet-message-queue/std", - "pallet-sudo/std", - "pallet-timestamp/std", - "pallet-transaction-payment-rpc-runtime-api/std", - "pallet-transaction-payment/std", - "pallet-vesting/std", - "pallet-xcm-transactor/std", - "pallet-xcm/std", - "parachains-common/std", - "parity-scale-codec/std", - "polkadot-parachain-primitives/std", - "polkadot-runtime-common/std", - "scale-info/std", - "sp-api/std", - "sp-block-builder/std", - "sp-consensus-aura/std", - "sp-core/std", - "sp-genesis-builder/std", - "sp-inherents/std", - "sp-io/std", - "sp-offchain/std", - "sp-runtime/std", - "sp-session/std", - "sp-std/std", - "sp-transaction-pool/std", - "sp-version/std", - "staging-parachain-info/std", - "staging-xcm-builder/std", - "staging-xcm-executor/std", - "staging-xcm/std", - "substrate-wasm-builder", - "xcm-transactor-primitives/std", -] -# Weird cargo behaviour: We have to feature gate the `runtime-benchmarks` behind -# a feature here. Otherwise the feature is automatically activated in dependencies -# when we compile the whole workspace with the `runtime-benchmarks` feature, which -# leads to compiler erros in the `shell-runtime` because the benchmarks are not -# implemented. -runtime-benchmarks = [ - "cumulus-pallet-parachain-system/runtime-benchmarks", - "cumulus-pallet-xcmp-queue/runtime-benchmarks", - "frame-benchmarking/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "pallet-balances/runtime-benchmarks", - "pallet-message-queue/runtime-benchmarks", - "pallet-sudo/runtime-benchmarks", - "pallet-timestamp/runtime-benchmarks", - "pallet-vesting/runtime-benchmarks", - "pallet-xcm/runtime-benchmarks", - "parachains-common/runtime-benchmarks", - "polkadot-runtime-common/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", - "staging-xcm-builder/runtime-benchmarks", -] - -try-runtime = [ - "cumulus-pallet-aura-ext/try-runtime", - "cumulus-pallet-dmp-queue/try-runtime", - "cumulus-pallet-parachain-system/try-runtime", - "cumulus-pallet-xcm/try-runtime", - "cumulus-pallet-xcmp-queue/try-runtime", - "frame-executive/try-runtime", - "frame-system/try-runtime", - "frame-try-runtime/try-runtime", - "pallet-aura/try-runtime", - "pallet-balances/try-runtime", - "pallet-message-queue/try-runtime", - "pallet-timestamp/try-runtime", - "pallet-transaction-payment/try-runtime", - "pallet-vesting/try-runtime", - "pallet-xcm-transactor/try-runtime", - "pallet-xcm/try-runtime", - "staging-parachain-info/try-runtime", -] diff --git a/polkadot-parachains/shell-runtime/build.rs b/polkadot-parachains/shell-runtime/build.rs deleted file mode 100644 index 9d66e46..0000000 --- a/polkadot-parachains/shell-runtime/build.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2019-2021 Parity Technologies (UK) Ltd. -// This file is part of Cumulus. - -// Substrate 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. - -// Substrate 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 Cumulus. If not, see . - -#[cfg(feature = "std")] -fn main() { - substrate_wasm_builder::WasmBuilder::init_with_defaults() - .enable_metadata_hash("TEER", 12) - .build() -} - -#[cfg(not(feature = "std"))] -fn main() {} diff --git a/polkadot-parachains/shell-runtime/src/lib.rs b/polkadot-parachains/shell-runtime/src/lib.rs deleted file mode 100644 index 1735e41..0000000 --- a/polkadot-parachains/shell-runtime/src/lib.rs +++ /dev/null @@ -1,555 +0,0 @@ -// Copyright 2021 Integritee AG and Supercomputing Systems AG -// This file is part of the "Integritee parachain" and is -// based on Cumulus from Parity Technologies (UK) Ltd. - -// Integritee parachain 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. - -// Cumulus 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 Integritee parachain. If not, see . - -#![cfg_attr(not(feature = "std"), no_std)] -// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. -#![recursion_limit = "256"] - -// Make the WASM binary available. -#[cfg(feature = "std")] -include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); - -use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases; -use cumulus_primitives_core::AggregateMessageOrigin; -use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo}; -use parachains_common::message_queue::NarrowOriginToSibling; -use sp_api::impl_runtime_apis; -use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; -use sp_runtime::{ - create_runtime_str, generic, impl_opaque_keys, - traits::{Block as BlockT, ConvertInto}, - transaction_validity::{TransactionSource, TransactionValidity}, - ApplyExtrinsicResult, -}; -use sp_std::prelude::*; -#[cfg(feature = "std")] -use sp_version::NativeVersion; -use sp_version::RuntimeVersion; -// A few exports that help ease life for downstream crates. -use frame_support::derive_impl; -pub use frame_support::{ - construct_runtime, - dispatch::DispatchClass, - genesis_builder_helper::{build_state, get_preset}, - match_types, parameter_types, - traits::{IsInVec, Randomness, WithdrawReasons}, - weights::{ - constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight}, - IdentityFee, Weight, - }, - StorageValue, -}; -use frame_system::limits::{BlockLength, BlockWeights}; -pub use integritee_parachains_common::{ - AccountId, Address, Balance, BlockNumber, Hash, Header, Nonce, Signature, - BLOCK_PROCESSING_VELOCITY, MILLISECS_PER_BLOCK, RELAY_CHAIN_SLOT_DURATION_MILLIS, - UNINCLUDED_SEGMENT_CAPACITY, -}; -use integritee_parachains_common::{ - AuraId, AVERAGE_ON_INITIALIZE_RATIO, MAXIMUM_BLOCK_WEIGHT, NORMAL_DISPATCH_RATIO, SLOT_DURATION, -}; -pub use pallet_balances::Call as BalancesCall; -#[cfg(any(feature = "std", test))] -pub use sp_runtime::BuildStorage; -pub use sp_runtime::{Perbill, Permill}; -// XCM imports -use frame_support::{ - traits::{ConstBool, Contains}, - weights::ConstantMultiplier, -}; - -pub mod xcm_config; - -pub type SessionHandlers = (); - -/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know -/// the specifics of the runtime. They can then be made to be agnostic over specific formats -/// of data like extrinsics, allowing for them to continue syncing the network through upgrades -/// to even the core data structures. -pub mod opaque { - pub use integritee_parachains_common::opaque::*; -} - -impl_opaque_keys! { - pub struct SessionKeys { - pub aura: Aura, - } -} - -/// This runtime version. -#[sp_version::runtime_version] -pub const VERSION: RuntimeVersion = RuntimeVersion { - spec_name: create_runtime_str!("integritee-parachain"), - impl_name: create_runtime_str!("integritee-shell"), - authoring_version: 0, - spec_version: 18, - impl_version: 0, - apis: RUNTIME_API_VERSIONS, - transaction_version: 1, - state_version: 0, -}; - -/// A timestamp: milliseconds since the unix epoch. -pub type Moment = u64; - -pub const TEER: Balance = 1_000_000_000_000; -pub const MILLITEER: Balance = 1_000_000_000; -pub const MICROTEER: Balance = 1_000_000; - -/// The version information used to identify this runtime when compiled natively. -#[cfg(feature = "std")] -pub fn native_version() -> NativeVersion { - NativeVersion { runtime_version: VERSION, can_author_with: Default::default() } -} - -parameter_types! { - pub const BlockHashCount: BlockNumber = 250; - pub const Version: RuntimeVersion = VERSION; - pub RuntimeBlockLength: BlockLength = - BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO); - pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder() - .base_block(BlockExecutionWeight::get()) - .for_class(DispatchClass::all(), |weights| { - weights.base_extrinsic = ExtrinsicBaseWeight::get(); - }) - .for_class(DispatchClass::Normal, |weights| { - weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT); - }) - .for_class(DispatchClass::Operational, |weights| { - weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT); - // Operational transactions have some extra reserved space, so that they - // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`. - weights.reserved = Some( - MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT - ); - }) - .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO) - .build_or_panic(); - pub const SS58Prefix: u8 = 13; -} - -pub struct DisableTokenTxFilter; - -impl Contains for DisableTokenTxFilter { - fn contains(call: &RuntimeCall) -> bool { - !matches!( - call, - RuntimeCall::Balances(_) | - RuntimeCall::Vesting(pallet_vesting::Call::vested_transfer { .. }) - ) - } -} - -/// The default types are being injected by [`derive_impl`](`frame_support::derive_impl`) from -/// [`ParaChainDefaultConfig`](`struct@frame_system::config_preludes::ParaChainDefaultConfig`), -/// but overridden as needed. -#[derive_impl(frame_system::config_preludes::ParaChainDefaultConfig as frame_system::DefaultConfig)] -impl frame_system::Config for Runtime { - type BaseCallFilter = DisableTokenTxFilter; - type BlockWeights = RuntimeBlockWeights; - type BlockLength = RuntimeBlockLength; - type Block = Block; - type AccountId = AccountId; - type Nonce = Nonce; - type Hash = Hash; - type BlockHashCount = BlockHashCount; - type DbWeight = RocksDbWeight; - type Version = Version; - type AccountData = pallet_balances::AccountData; - type SS58Prefix = SS58Prefix; - type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode; - type MaxConsumers = frame_support::traits::ConstU32<16>; -} - -parameter_types! { - pub const MinimumPeriod: u64 = SLOT_DURATION / 2; -} - -impl pallet_timestamp::Config for Runtime { - /// A timestamp: milliseconds since the unix epoch. - type Moment = Moment; - type OnTimestampSet = (); - type MinimumPeriod = MinimumPeriod; - type WeightInfo = (); -} - -parameter_types! { - pub const ExistentialDeposit: u128 = MILLITEER; - pub const TransferFee: u128 = MILLITEER; - pub const CreationFee: u128 = MILLITEER; - pub const TransactionByteFee: u128 = MICROTEER; - pub const MaxLocks: u32 = 50; - pub const MaxReserves: u32 = 50; -} - -impl pallet_balances::Config for Runtime { - type MaxLocks = MaxLocks; - /// The type for recording an account's balance. - type Balance = Balance; - /// The ubiquitous event type. - type RuntimeEvent = RuntimeEvent; - type DustRemoval = (); - type ExistentialDeposit = ExistentialDeposit; - type AccountStore = System; - type WeightInfo = (); - type MaxReserves = MaxReserves; - type ReserveIdentifier = [u8; 8]; - type FreezeIdentifier = (); - type MaxFreezes = (); - type RuntimeHoldReason = (); - type RuntimeFreezeReason = (); -} - -impl pallet_transaction_payment::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type OnChargeTransaction = pallet_transaction_payment::FungibleAdapter; - type WeightToFee = IdentityFee; - type FeeMultiplierUpdate = (); - type LengthToFee = ConstantMultiplier; - type OperationalFeeMultiplier = (); -} - -impl pallet_sudo::Config for Runtime { - type RuntimeCall = RuntimeCall; - type RuntimeEvent = RuntimeEvent; - type WeightInfo = (); -} - -parameter_types! { - pub const MinVestedTransfer: Balance = 100 * TEER; - pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons = - WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE); -} - -impl pallet_vesting::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type Currency = Balances; - type BlockNumberToBalance = ConvertInto; - type BlockNumberProvider = System; - type MinVestedTransfer = MinVestedTransfer; - type WeightInfo = pallet_vesting::weights::SubstrateWeight; - type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons; - const MAX_VESTING_SCHEDULES: u32 = 28; -} - -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; -} - -type ConsensusHook = cumulus_pallet_aura_ext::FixedVelocityConsensusHook< - Runtime, - RELAY_CHAIN_SLOT_DURATION_MILLIS, - BLOCK_PROCESSING_VELOCITY, - UNINCLUDED_SEGMENT_CAPACITY, ->; - -impl cumulus_pallet_parachain_system::Config for Runtime { - type WeightInfo = (); - type RuntimeEvent = RuntimeEvent; - type OnSystemEvent = (); - type SelfParaId = staging_parachain_info::Pallet; - type DmpQueue = frame_support::traits::EnqueueWithOrigin; - type ReservedDmpWeight = ReservedDmpWeight; - type OutboundXcmpMessageSource = XcmpQueue; - type XcmpMessageHandler = XcmpQueue; - type ReservedXcmpWeight = ReservedXcmpWeight; - type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases; - type ConsensusHook = ConsensusHook; -} - -impl staging_parachain_info::Config for Runtime {} - -impl cumulus_pallet_aura_ext::Config 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 = staging_xcm_builder::ProcessXcmMessage< - AggregateMessageOrigin, - staging_xcm_executor::XcmExecutor, - RuntimeCall, - >; - type Size = u32; - // The XCMP queue pallet is only ever able to handle the `Sibling(ParaId)` origin: - type QueueChangeHandler = NarrowOriginToSibling; - type QueuePausedQuery = NarrowOriginToSibling; - type HeapSize = sp_core::ConstU32<{ 64 * 1024 }>; - type MaxStale = sp_core::ConstU32<8>; - type ServiceWeight = MessageQueueServiceWeight; - type IdleMaxServiceWeight = (); -} - -parameter_types! { - pub const AssetDeposit: Balance = TEER; - pub const ApprovalDeposit: Balance = 100 * MILLITEER; - pub const StringLimit: u32 = 50; - pub const MetadataDepositBase: Balance = TEER; - pub const MetadataDepositPerByte: Balance = 10 * MILLITEER; - pub const MaxInstructions: u32 = 100; - pub const MaxAuthorities: u32 = 100_000; -} - -impl pallet_aura::Config for Runtime { - type AuthorityId = AuraId; - type DisabledValidators = (); - type MaxAuthorities = MaxAuthorities; - type AllowMultipleBlocksPerSlot = ConstBool; - type SlotDuration = pallet_aura::MinimumPeriodTimesTwo; -} - -construct_runtime!( - pub enum Runtime - { - // System support stuff. - System: frame_system = 0, - ParachainSystem: cumulus_pallet_parachain_system = 1, - Timestamp: pallet_timestamp = 3, - ParachainInfo: staging_parachain_info = 4, - Sudo: pallet_sudo = 5, - - // Monetary stuff. - Balances: pallet_balances = 10, - TransactionPayment: pallet_transaction_payment = 11, - Vesting: pallet_vesting = 12, - - Aura: pallet_aura = 23, - AuraExt: cumulus_pallet_aura_ext = 24, - - XcmpQueue: cumulus_pallet_xcmp_queue = 30, - PolkadotXcm: pallet_xcm = 31, - CumulusXcm: cumulus_pallet_xcm = 32, - MessageQueue: pallet_message_queue = 33, - XcmTransactor: pallet_xcm_transactor = 34, - } -); - -/// The SignedExtension to the basic transaction logic. -pub type SignedExtra = ( - frame_system::CheckNonZeroSender, - frame_system::CheckSpecVersion, - frame_system::CheckTxVersion, - frame_system::CheckGenesis, - frame_system::CheckEra, - frame_system::CheckNonce, - frame_system::CheckWeight, - pallet_transaction_payment::ChargeTransactionPayment, - frame_metadata_hash_extension::CheckMetadataHash, -); -/// Unchecked extrinsic type as expected by this runtime. -pub type UncheckedExtrinsic = - generic::UncheckedExtrinsic; -/// Extrinsic type that has already been checked. -pub type CheckedExtrinsic = generic::CheckedExtrinsic; -/// Block type as expected by this runtime. -pub type Block = generic::Block; -/// A Block signed with a Justification -pub type SignedBlock = generic::SignedBlock; -/// BlockId type as expected by this runtime. -pub type BlockId = generic::BlockId; - -/// Executive: handles dispatch to the various modules. -pub type Executive = frame_executive::Executive< - Runtime, - Block, - frame_system::ChainContext, - Runtime, - AllPalletsWithSystem, // Solochain: AllPalletsReversedWithSystemFirst, Statemint: AllPallets. Which one to take? - (), ->; - -#[cfg(feature = "runtime-benchmarks")] -mod benches { - frame_benchmarking::define_benchmarks!( - [frame_system, SystemBench::] - [pallet_balances, Balances] - [pallet_timestamp, Timestamp] - [pallet_sudo, Sudo] - [cumulus_pallet_xcmp_queue, XcmpQueue] - ); -} - -impl_runtime_apis! { - impl sp_consensus_aura::AuraApi for Runtime { - fn slot_duration() -> sp_consensus_aura::SlotDuration { - sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration()) - } - - fn authorities() -> Vec { - pallet_aura::Authorities::::get().into_inner() - } - } - - impl cumulus_primitives_aura::AuraUnincludedSegmentApi for Runtime { - fn can_build_upon( - included_hash: ::Hash, - slot: cumulus_primitives_aura::Slot, - ) -> bool { - ConsensusHook::can_build_upon(included_hash, slot) - } - } - - impl sp_api::Core for Runtime { - fn version() -> RuntimeVersion { - VERSION - } - - fn execute_block(block: Block) { - Executive::execute_block(block) - } - - fn initialize_block(header: &::Header) -> sp_runtime::ExtrinsicInclusionMode { - Executive::initialize_block(header) - } - } - - impl sp_api::Metadata for Runtime { - fn metadata() -> OpaqueMetadata { - OpaqueMetadata::new(Runtime::metadata().into()) - } - - fn metadata_at_version(version: u32) -> Option { - Runtime::metadata_at_version(version) - } - - fn metadata_versions() -> sp_std::vec::Vec { - Runtime::metadata_versions() - } - } - - impl sp_block_builder::BlockBuilder for Runtime { - fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { - Executive::apply_extrinsic(extrinsic) - } - - fn finalize_block() -> ::Header { - Executive::finalize_block() - } - - fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { - data.create_extrinsics() - } - - fn check_inherents( - block: Block, - data: sp_inherents::InherentData, - ) -> sp_inherents::CheckInherentsResult { - data.check_extrinsics(&block) - } - } - - impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { - fn validate_transaction( - source: TransactionSource, - tx: ::Extrinsic, - block_hash: ::Hash, - ) -> TransactionValidity { - Executive::validate_transaction(source, tx, block_hash) - } - } - - impl sp_offchain::OffchainWorkerApi for Runtime { - fn offchain_worker(header: &::Header) { - Executive::offchain_worker(header) - } - } - - impl sp_session::SessionKeys for Runtime { - fn generate_session_keys(seed: Option>) -> Vec { - SessionKeys::generate(seed) - } - - fn decode_session_keys( - encoded: Vec, - ) -> Option, KeyTypeId)>> { - SessionKeys::decode_into_raw_public_keys(&encoded) - } - } - - impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { - fn account_nonce(account: AccountId) -> Nonce { - System::account_nonce(account) - } - } - - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi for Runtime { - fn query_info(uxt: ::Extrinsic, len: u32) -> RuntimeDispatchInfo { - TransactionPayment::query_info(uxt, len) - } - fn query_fee_details(uxt: ::Extrinsic, len: u32) -> FeeDetails { - TransactionPayment::query_fee_details(uxt, len) - } - fn query_weight_to_fee(weight: Weight) -> Balance { - TransactionPayment::weight_to_fee(weight) - } - fn query_length_to_fee(length: u32) -> Balance { - TransactionPayment::length_to_fee(length) - } - } - - impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi - for Runtime - { - fn query_call_info(call: RuntimeCall, len: u32) -> RuntimeDispatchInfo { - TransactionPayment::query_call_info(call, len) - } - fn query_call_fee_details(call: RuntimeCall, len: u32) -> FeeDetails { - TransactionPayment::query_call_fee_details(call, len) - } - fn query_weight_to_fee(weight: Weight) -> Balance { - TransactionPayment::weight_to_fee(weight) - } - fn query_length_to_fee(length: u32) -> Balance { - TransactionPayment::length_to_fee(length) - } - } - - impl cumulus_primitives_core::CollectCollationInfo for Runtime { - fn collect_collation_info(header: &::Header) -> cumulus_primitives_core::CollationInfo { - ParachainSystem::collect_collation_info(header) - } - } - - impl sp_genesis_builder::GenesisBuilder for Runtime { - fn build_state(config: Vec) -> sp_genesis_builder::Result { - build_state::(config) - } - - fn get_preset(id: &Option) -> Option> { - get_preset::(id, |_| None) - } - - fn preset_names() -> Vec { - vec![] - } - } -} - -cumulus_pallet_parachain_system::register_validate_block! { - Runtime = Runtime, - BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::, -} diff --git a/polkadot-parachains/shell-runtime/src/xcm_config.rs b/polkadot-parachains/shell-runtime/src/xcm_config.rs deleted file mode 100644 index e997a5c..0000000 --- a/polkadot-parachains/shell-runtime/src/xcm_config.rs +++ /dev/null @@ -1,376 +0,0 @@ -// Copyright 2021 Integritee AG and Supercomputing Systems AG -// This file is part of the "Integritee parachain" and is -// based on Cumulus from Parity Technologies (UK) Ltd. - -// Integritee parachain 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. - -// Cumulus 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 Integritee parachain. If not, see . - -//! XCM configuration for Integritee Runtime. -//! - -use super::{ - AccountId, Balance, Balances, MaxInstructions, MessageQueue, ParachainInfo, ParachainSystem, - PolkadotXcm, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, XcmpQueue, TEER, -}; -use core::marker::PhantomData; -use cumulus_primitives_core::{AggregateMessageOrigin, GlobalConsensus}; -use frame_support::{ - pallet_prelude::{Get, Weight}, - parameter_types, - traits::{Everything, Nothing, TransformOrigin}, - weights::IdentityFee, -}; -use frame_system::EnsureRoot; -use integritee_parachains_common::xcm_config::{ - IsNativeConcrete, MultiNativeAsset, RelativeReserveProvider, Reserve, -}; -use pallet_xcm::XcmPassthrough; -use parachains_common::message_queue::ParaIdToSibling; -use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; -use polkadot_parachain_primitives::primitives::Sibling; -use polkadot_runtime_common::xcm_sender::NoPriceForMessageDelivery; -use scale_info::TypeInfo; -use sp_core::ConstU32; -use sp_runtime::{traits::Convert, RuntimeDebug}; -use sp_std::{ - convert::{From, Into}, - prelude::*, -}; -use staging_xcm::latest::prelude::*; -use staging_xcm_builder::{ - AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, - AllowTopLevelPaidExecutionFrom, DenyReserveTransferToRelayChain, DenyThenTry, EnsureXcmOrigin, - FixedWeightBounds, FrameTransactionalProcessor, FungibleAdapter, ParentAsSuperuser, - ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - UsingComponents, -}; -use staging_xcm_executor::XcmExecutor; -use xcm_transactor_primitives::*; - -const fn teer_general_key() -> Junction { - const TEER_KEY: [u8; 32] = *b"TEER0000000000000000000000000000"; - GeneralKey { length: 4, data: TEER_KEY } -} - -const TEER_GENERAL_KEY: Junction = teer_general_key(); - -parameter_types! { - pub const RelayChainLocation: Location = Location::parent(); - pub const RelayNetwork: NetworkId = NetworkId::Kusama; - pub RelayChainOrigin: RuntimeOrigin = cumulus_pallet_xcm::Origin::Relay.into(); - // The universal location within the global consensus system - pub UniversalLocation: InteriorLocation = - [GlobalConsensus(RelayNetwork::get()), Parachain(ParachainInfo::parachain_id().into())].into(); - - pub SelfReserve: Location = Location { - parents:0, - interior: [TEER_GENERAL_KEY].into() - }; -} - -// Supported Currencies. -#[derive( - Encode, - Decode, - Eq, - PartialEq, - Copy, - Clone, - RuntimeDebug, - PartialOrd, - Ord, - TypeInfo, - MaxEncodedLen, -)] -pub enum CurrencyId { - TEER, -} - -/// Converts a CurrencyId into a Location, used by xtoken for XCMP. -pub struct CurrencyIdConvert; - -impl Convert> for CurrencyIdConvert { - fn convert(id: CurrencyId) -> Option { - match id { - CurrencyId::TEER => Some(Location { - parents: 1, - interior: [Parachain(ParachainInfo::parachain_id().into()), TEER_GENERAL_KEY] - .into(), - }), - } - } -} - -/// Converts a Mulitloaction into a CurrencyId. Used by XCMP LocalAssetTransactor for asset filtering: -/// we only accept Assets that are convertable to a "CurrencyId". -impl Convert> for CurrencyIdConvert { - fn convert(location: Location) -> Option { - let self_para_id: u32 = ParachainInfo::parachain_id().into(); - - match location.unpack() { - (1, interior) => match interior { - [Parachain(id), TEER_GENERAL_KEY] if *id == self_para_id => Some(CurrencyId::TEER), - _ => None, - }, - (0, [TEER_GENERAL_KEY]) => Some(CurrencyId::TEER), - _ => None, - } - } -} - -/// Converts a Asset into a CurrencyId, using the defined Location. -impl Convert> for CurrencyIdConvert { - fn convert(asset: Asset) -> Option { - Self::convert(asset.id.0) - } -} - -/// The means for routing XCM messages which are not for local execution into the right message -/// queues. -pub type XcmRouter = ( - // Two routers - use UMP to communicate with the relay chain: - cumulus_primitives_utility::ParentAsUmp, - // ..and XCMP to communicate with the sibling chains. - XcmpQueue, -); - -/// 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. -pub type LocationToAccountId = ( - // The parent (Relay-chain) origin converts to the default `AccountId`. - ParentIsPreset, - // Sibling parachain origins convert to AccountId via the `ParaId::into`. - SiblingParachainConvertsVia, - // Straight up local `AccountId32` origins just alias directly to `AccountId`. - AccountId32Aliases, -); - -/// Means for transacting assets on this chain. -pub type LocalAssetTransactor = FungibleAdapter< - // Use this currency: - Balances, - // Matcher: matches concrete fungible assets whose `id` could be converted into `CurrencyId`. - IsNativeConcrete, - // Do a simple punn to convert an AccountId32 Location into a native chain account ID: - LocationToAccountId, - // Our chain's account ID type (we can't get away without mentioning it explicitly): - AccountId, - // We don't track any teleports. - (), ->; - -/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance, -/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can -/// biases the kind of local `Origin` it will become. -pub type XcmOriginToTransactDispatchOrigin = ( - // Sovereign account converter; this attempts to derive an `AccountId` from the origin location - // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for - // foreign chains who want to have a local sovereign account on this chain which they control. - SovereignSignedViaLocation, - // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when - // recognised. - RelayChainAsNative, - // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when - // recognised. - SiblingParachainAsNative, - // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a - // transaction from the Root origin. - ParentAsSuperuser, - // Native signed account converter; this just converts an `AccountId32` origin into a normal - // `Origin::Signed` origin of the same 32-byte value. - SignedAccountId32AsNative, - // Xcm origins can be represented natively under the Xcm pallet's Xcm origin. - XcmPassthrough, -); - -/// This struct offers uses RelativeReserveProvider to output relative views of Locations -/// However, additionally accepts a Location that aims at representing the chain part -/// (parent: 1, Parachain(paraId)) of the absolute representation of our chain. -/// If a token reserve matches against this absolute view, we return Some(Location::here()) -/// This helps users by preventing errors when they try to transfer a token through xtokens -/// to our chain (either inserting the relative or the absolute value). -pub struct AbsoluteAndRelativeReserve(PhantomData); - -impl Reserve for AbsoluteAndRelativeReserve -where - AbsoluteLocation: Get, -{ - fn reserve(asset: &Asset) -> Option { - RelativeReserveProvider::reserve(asset).map(|relative_reserve| { - if relative_reserve == AbsoluteLocation::get() { - Location::here() - } else { - relative_reserve - } - }) - } -} - -parameter_types! { - // Weight for one XCM operation. Copied from moonbeam. - pub UnitWeightCost: Weight = Weight::from_parts(200_000_000u64, DEFAULT_PROOF_SIZE); - // One TEER buys 1 second of weight. - pub const WeightPrice: (Location, u128) = (Location::parent(), TEER); -} - -pub type Barrier = DenyThenTry< - DenyReserveTransferToRelayChain, - ( - TakeWeightCredit, - AllowTopLevelPaidExecutionFrom, - // Expected responses are OK. - AllowKnownQueryResponses, - // Subscriptions for version tracking are OK. - AllowSubscriptionsFrom, - ), ->; - -pub struct SafeCallFilter; - -impl frame_support::traits::Contains for SafeCallFilter { - fn contains(_call: &RuntimeCall) -> bool { - // This is safe, as we prevent arbitrary xcm-transact executions. - // For rationale, see:https://github.com/paritytech/polkadot/blob/19fdd197aff085f7f66e54942999fd536e7df475/runtime/kusama/src/xcm_config.rs#L171 - true - } -} - -parameter_types! { - pub const MaxAssetsIntoHolding: u32 = 64; -} - -pub struct XcmConfig; - -impl staging_xcm_executor::Config for XcmConfig { - type RuntimeCall = RuntimeCall; - type XcmSender = XcmRouter; - // How to withdraw and deposit an asset. - type AssetTransactor = LocalAssetTransactor; - type OriginConverter = XcmOriginToTransactDispatchOrigin; - type IsReserve = MultiNativeAsset>; - type IsTeleporter = (); // No teleport for now. Better be safe than sorry. - type UniversalLocation = UniversalLocation; - type Barrier = Barrier; - type Weigher = FixedWeightBounds; - type Trader = UsingComponents, SelfReserve, AccountId, Balances, ()>; - type ResponseHandler = PolkadotXcm; - type SubscriptionService = PolkadotXcm; - type AssetTrap = PolkadotXcm; - type AssetClaims = PolkadotXcm; - type CallDispatcher = RuntimeCall; - type PalletInstancesInfo = crate::AllPalletsWithSystem; - type MaxAssetsIntoHolding = MaxAssetsIntoHolding; - type AssetLocker = (); - type AssetExchanger = (); - type FeeManager = (); - type MessageExporter = (); - type UniversalAliases = Nothing; - type SafeCallFilter = SafeCallFilter; - type Aliasers = Nothing; - type TransactionalProcessor = FrameTransactionalProcessor; - type HrmpNewChannelOpenRequestHandler = (); - type HrmpChannelAcceptedHandler = (); - type HrmpChannelClosingHandler = (); - type XcmRecorder = (); -} - -// Converts a Signed Local Origin into a Location -pub type LocalOriginToLocation = SignedToAccountId32; - -// FIXME: We should probably update the configuration here. -// See acala and moonbeam example : https://github.com/integritee-network/parachain/issues/103 -impl pallet_xcm::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type SendXcmOrigin = EnsureXcmOrigin; // Prohibit sending arbitrary XCMs from users of this chain - type XcmRouter = XcmRouter; - type ExecuteXcmOrigin = EnsureXcmOrigin; // Allow any local origin in XCM execution. - type XcmExecuteFilter = Nothing; // Disable generic XCM execution. This does not affect Teleport or Reserve Transfer. - type XcmExecutor = XcmExecutor; - type XcmTeleportFilter = Nothing; // Do not allow teleports - type XcmReserveTransferFilter = Everything; // Transfer are allowed - type Weigher = FixedWeightBounds; - type UniversalLocation = UniversalLocation; - type RuntimeOrigin = RuntimeOrigin; - type RuntimeCall = RuntimeCall; - const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100; - type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion; - type Currency = Balances; - type CurrencyMatcher = (); - type TrustedLockers = (); - type SovereignAccountOf = LocationToAccountId; - type MaxLockers = ConstU32<8>; - // TODO pallet-xcm weights - type WeightInfo = pallet_xcm::TestWeightInfo; - type AdminOrigin = EnsureRoot; - type MaxRemoteLockConsumers = ConstU32<0>; - type RemoteLockConsumerIdentifier = (); -} - -parameter_types! { - pub const IntegriteeKsmParaId: u32 = 2015; - pub const ShellRuntimeParaId: u32 = 2267; -} - -impl pallet_xcm_transactor::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type RelayCallBuilder = RelayCallBuilder; - type XcmSender = XcmRouter; - type SwapOrigin = EnsureRoot; - type ShellRuntimeParaId = ShellRuntimeParaId; - type IntegriteeKsmParaId = IntegriteeKsmParaId; - type WeightInfo = (); -} - -impl cumulus_pallet_xcm::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type XcmExecutor = XcmExecutor; -} - -// FIXME: Update to PolkadotXcm. -impl cumulus_pallet_xcmp_queue::Config for Runtime { - type RuntimeEvent = RuntimeEvent; - type ChannelInfo = ParachainSystem; - type VersionWrapper = (); - // Enqueue XCMP messages from siblings for later processing. - type XcmpQueue = TransformOrigin; - type MaxInboundSuspended = sp_core::ConstU32<1_000>; - type ControllerOrigin = EnsureRoot; - type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin; - type WeightInfo = cumulus_pallet_xcmp_queue::weights::SubstrateWeight; - type PriceForSiblingDelivery = NoPriceForMessageDelivery; - type MaxActiveOutboundChannels = ConstU32<128>; - // Most on-chain HRMP channels are configured to use 102400 bytes of max message size, so we - // need to set the page size larger than that until we reduce the channel size on-chain. - type MaxPageSize = ConstU32<{ 103 * 1024 }>; -} - -impl cumulus_pallet_xcmp_queue::migration::v5::V5Config for Runtime { - // This must be the same as the `ChannelInfo` from the `Config`: - type ChannelList = ParachainSystem; -} - -parameter_types! { - // This is how we are going to detect whether the asset is a Reserve asset - pub SelfLocation: Location = Location::here(); - // We need this to be able to catch when someone is trying to execute a non- - // cross-chain transfer in xtokens through the absolute path way - pub SelfLocationAbsolute: Location = Location { - parents:1, - interior: [Parachain(ParachainInfo::parachain_id().into())].into() - }; -} - -/// Copied from moonbeam: https://github.com/PureStake/moonbeam/blob/095031d171b0c163e5649ee35acbc36eef681a82/primitives/xcm/src/ethereum_xcm.rs#L34 -pub const DEFAULT_PROOF_SIZE: u64 = 128 * 1024; diff --git a/polkadot-parachains/src/chain_spec.rs b/polkadot-parachains/src/chain_spec.rs index 7c9b714..c083c69 100644 --- a/polkadot-parachains/src/chain_spec.rs +++ b/polkadot-parachains/src/chain_spec.rs @@ -121,48 +121,6 @@ impl IntegriteeDevKeys { ] } } - -pub fn shell_chain_spec( - para_id: ParaId, - genesis_keys: GenesisKeys, - relay_chain: RelayChain, -) -> ChainSpec { - let mut properties = sc_chain_spec::Properties::new(); - properties.insert("tokenSymbol".into(), "TEER".into()); - properties.insert("tokenDecimals".into(), 12.into()); - properties.insert("ss58Format".into(), 13.into()); - - let (root, endowed, authorities) = match genesis_keys { - GenesisKeys::Integritee => - (IntegriteeKeys::root(), vec![IntegriteeKeys::root()], IntegriteeKeys::authorities()), - GenesisKeys::IntegriteeDev => ( - IntegriteeDevKeys::root(), - vec![IntegriteeDevKeys::root()], - IntegriteeDevKeys::authorities(), - ), - GenesisKeys::WellKnown => - (WellKnownKeys::root(), WellKnownKeys::endowed(), WellKnownKeys::authorities()), - }; - - #[allow(deprecated)] - ChainSpec::builder( - shell_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), - Extensions { relay_chain: relay_chain.to_string(), para_id: para_id.into() }, - ) - .with_name("Integritee Shell") - .with_id(&format!("shell-{}", relay_chain.to_string())) - .with_protocol_id(relay_chain.protocol_id()) - .with_chain_type(relay_chain.chain_type()) - .with_properties(properties) - .with_genesis_config_patch(shell_genesis_config( - root.clone(), - endowed.clone(), - authorities.clone(), - para_id, - )) - .build() -} - pub fn integritee_chain_spec( para_id: ParaId, genesis_keys: GenesisKeys, @@ -258,34 +216,6 @@ fn integritee_genesis_config( }) } -fn shell_genesis_config( - root_key: AccountId, - endowed_accounts: Vec, - initial_authorities: Vec, - parachain_id: ParaId, -) -> serde_json::Value { - serde_json::json!({ - "aura": { - "authorities": initial_authorities - .into_iter() - .map(|acc| { - Decode::decode(&mut acc.encode().as_ref()).unwrap() }, // session keys - ) - .collect::>(), - }, - "balances": { - "balances": endowed_accounts.iter().cloned().map(|k| (k, 100 * TEER)).collect::>(), - }, - "parachainInfo": { - "parachainId": parachain_id, - }, - "polkadotXcm": { - "safeXcmVersion": Some(SAFE_XCM_VERSION), - }, - "sudo": { "key": Some(root_key) } - }) -} - pub enum RelayChain { RococoLocal, WestendLocal, diff --git a/polkadot-parachains/src/command.rs b/polkadot-parachains/src/command.rs index 0f83dd4..9993dcc 100644 --- a/polkadot-parachains/src/command.rs +++ b/polkadot-parachains/src/command.rs @@ -1,14 +1,12 @@ //! //! this file DOES HAVE CUSTOMIZATIONS for integritee runtimes. Upon upgrades of polkadot-sdk, -//! look for blocks with `is_shell()` branching use crate::{ chain_spec, chain_spec::{ integritee_chain_spec, integritee_moonbase_config, integritee_paseo_config, - shell_chain_spec, shell_kusama_config, shell_kusama_lease2_config, - shell_kusama_lease3_config, shell_polkadot_config, shell_rococo_config, - shell_westend_config, GenesisKeys, RelayChain, + shell_kusama_config, shell_kusama_lease2_config, shell_kusama_lease3_config, + shell_polkadot_config, shell_rococo_config, shell_westend_config, GenesisKeys, RelayChain, }, cli::{Cli, RelayChainCli, Subcommand}, }; @@ -69,12 +67,11 @@ fn load_spec( // live config initialize "integritee-rococo-fresh" => Box::new(integritee_chain_spec(ROCOCO_PARA_ID.into(), GenesisKeys::Integritee, RelayChain::Rococo)), - "integritee-westend-fresh" => Box::new(shell_chain_spec(WESTEND_PARA_ID.into(), GenesisKeys::Integritee, RelayChain::Westend)), - "integritee-kusama-fresh" => Box::new(shell_chain_spec(KUSAMA_PARA_ID.into(), GenesisKeys::Integritee, RelayChain::Kusama)), - "integritee-polkadot-fresh" => Box::new(shell_chain_spec(POLKADOT_PARA_ID.into(), GenesisKeys::Integritee, RelayChain::Polkadot)), + "integritee-westend-fresh" => Box::new(integritee_chain_spec(WESTEND_PARA_ID.into(), GenesisKeys::Integritee, RelayChain::Westend)), + "integritee-kusama-fresh" => Box::new(integritee_chain_spec(KUSAMA_PARA_ID.into(), GenesisKeys::Integritee, RelayChain::Kusama)), + "integritee-polkadot-fresh" => Box::new(integritee_chain_spec(POLKADOT_PARA_ID.into(), GenesisKeys::Integritee, RelayChain::Polkadot)), "integritee-moonbase-fresh" => Box::new(integritee_chain_spec(MOONBASE_PARA_ID.into(), GenesisKeys::IntegriteeDev, RelayChain::Moonbase)), "integritee-paseo-fresh" => Box::new(integritee_chain_spec(PASEO_PARA_ID.into(), GenesisKeys::Integritee, RelayChain::Paseo)), - "shell-kusama-fresh" => Box::new(shell_chain_spec(KUSAMA_SWAP_PARA_ID.into(), GenesisKeys::Integritee, RelayChain::Kusama)), // on-the-spot specs "integritee-rococo-local" => Box::new(integritee_chain_spec(LOCAL_PARA_ID.into(), GenesisKeys::Integritee, RelayChain::RococoLocal)), @@ -91,19 +88,7 @@ fn load_spec( "integritee-polkadot-local" => Box::new(integritee_chain_spec(LOCAL_PARA_ID.into(), GenesisKeys::Integritee, RelayChain::PolkadotLocal)), "integritee-polkadot-local-dev" => Box::new(integritee_chain_spec(LOCAL_PARA_ID.into(), GenesisKeys::WellKnown, RelayChain::PolkadotLocal)), - - "shell-rococo-local" => Box::new(shell_chain_spec(KUSAMA_SWAP_PARA_ID.into(), GenesisKeys::Integritee, RelayChain::RococoLocal)), - "shell-rococo-local-dev" => Box::new(shell_chain_spec(KUSAMA_SWAP_PARA_ID.into(), GenesisKeys::WellKnown, RelayChain::RococoLocal)), - - "shell-westend-local" => Box::new(shell_chain_spec(KUSAMA_SWAP_PARA_ID.into(), GenesisKeys::Integritee, RelayChain::WestendLocal)), - "shell-westend-local-dev" => Box::new(shell_chain_spec(KUSAMA_SWAP_PARA_ID.into(), GenesisKeys::WellKnown, RelayChain::WestendLocal)), - - "shell-kusama-local" => Box::new(shell_chain_spec(KUSAMA_SWAP_PARA_ID.into(), GenesisKeys::Integritee, RelayChain::KusamaLocal)), - "shell-kusama-local-dev" => Box::new(shell_chain_spec(KUSAMA_SWAP_PARA_ID.into(), GenesisKeys::WellKnown, RelayChain::KusamaLocal)), - - "shell-polkadot-local" => Box::new(shell_chain_spec(KUSAMA_SWAP_PARA_ID.into(), GenesisKeys::Integritee, RelayChain::PolkadotLocal)), - "shell-polkadot-local-dev" => Box::new(shell_chain_spec(KUSAMA_SWAP_PARA_ID.into(), GenesisKeys::WellKnown, RelayChain::PolkadotLocal)), - + "" => panic!("Please supply chain_spec to be loaded."), path => { let chain_spec = chain_spec::ChainSpec::from_json_file(path.into())?; @@ -188,8 +173,7 @@ impl SubstrateCli for RelayChainCli { macro_rules! construct_partials { ($config:expr, |$partials:ident| $code:expr) => { if $config.chain_spec.is_shell() { - let $partials = crate::service_shell::new_partial(&$config)?; - $code + unimplemented!() } else { let $partials = crate::service::new_partial(&$config)?; $code @@ -201,13 +185,7 @@ macro_rules! construct_async_run { (|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{ let runner = $cli.create_runner($cmd)?; if runner.config().chain_spec.is_shell() { - runner.async_run(|$config| { - let $components = crate::service_shell::new_partial( - &$config, - )?; - let task_manager = $components.task_manager; - { $( $code )* }.map(|v| (v, task_manager)) - }) + unimplemented!() } else { runner.async_run(|$config| { let $components = crate::service::new_partial( @@ -360,16 +338,7 @@ pub fn run() -> Result<()> { info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" }); if config.chain_spec.is_shell() { - crate::service_shell::start_parachain_node( - config, - polkadot_config, - collator_options, - id, - hwbench, - ) - .await - .map(|r| r.0) - .map_err(Into::into) + unimplemented!() } else { crate::service::start_parachain_node( config, diff --git a/polkadot-parachains/src/main.rs b/polkadot-parachains/src/main.rs index ed46e38..72ed283 100644 --- a/polkadot-parachains/src/main.rs +++ b/polkadot-parachains/src/main.rs @@ -8,8 +8,6 @@ mod chain_spec; #[macro_use] mod service; -#[macro_use] -mod service_shell; mod cli; mod command; mod rpc; diff --git a/polkadot-parachains/src/service_shell.rs b/polkadot-parachains/src/service_shell.rs deleted file mode 100644 index cc23854..0000000 --- a/polkadot-parachains/src/service_shell.rs +++ /dev/null @@ -1,411 +0,0 @@ -//! Service and ServiceFactory implementation. Specialized wrapper over substrate service. - -// Integritee customization -use substrate_prometheus_endpoint as prometheus_endpoint; - -// std -use std::{sync::Arc, time::Duration}; - -use cumulus_client_cli::CollatorOptions; -// Local Runtime Types -use integritee_parachains_common::opaque::{Block, Hash}; -use shell_runtime::RuntimeApi; - -// Cumulus Imports -use cumulus_client_collator::service::CollatorService; -use cumulus_client_consensus_aura::collators::lookahead::{self as aura, Params as AuraParams}; -use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport; -use cumulus_client_consensus_proposer::Proposer; -use cumulus_client_service::{ - build_network, build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks, - BuildNetworkParams, CollatorSybilResistance, DARecoveryProfile, ParachainHostFunctions, - StartRelayChainTasksParams, -}; -use cumulus_primitives_core::{ - relay_chain::{CollatorPair, ValidationCode}, - ParaId, -}; -use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface}; - -// Substrate Imports -use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE; -use prometheus_endpoint::Registry; -use sc_client_api::Backend; -use sc_consensus::ImportQueue; -use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY}; -use sc_network::NetworkBlock; -use sc_network_sync::SyncingService; -use sc_service::{Configuration, PartialComponents, TFullBackend, TFullClient, TaskManager}; -use sc_telemetry::{Telemetry, TelemetryHandle, TelemetryWorker, TelemetryWorkerHandle}; -use sc_transaction_pool_api::OffchainTransactionPoolFactory; -use sp_keystore::KeystorePtr; - -type ParachainExecutor = WasmExecutor; - -type ParachainClient = TFullClient; - -type ParachainBackend = TFullBackend; - -type ParachainBlockImport = TParachainBlockImport, ParachainBackend>; - -/// Assembly of PartialComponents (enough to run chain ops subcommands) -pub type Service = PartialComponents< - ParachainClient, - ParachainBackend, - (), - sc_consensus::DefaultImportQueue, - sc_transaction_pool::FullPool, - (ParachainBlockImport, Option, Option), ->; - -/// Starts a `ServiceBuilder` for a full service. -/// -/// Use this macro if you don't actually need the full service, but just the builder in order to -/// be able to perform chain operations. -pub fn new_partial(config: &Configuration) -> Result { - let telemetry = config - .telemetry_endpoints - .clone() - .filter(|x| !x.is_empty()) - .map(|endpoints| -> Result<_, sc_telemetry::Error> { - let worker = TelemetryWorker::new(16)?; - let telemetry = worker.handle().new_telemetry(endpoints); - Ok((worker, telemetry)) - }) - .transpose()?; - - let heap_pages = config - .default_heap_pages - .map_or(DEFAULT_HEAP_ALLOC_STRATEGY, |h| HeapAllocStrategy::Static { extra_pages: h as _ }); - - let executor = ParachainExecutor::builder() - .with_execution_method(config.wasm_method) - .with_onchain_heap_alloc_strategy(heap_pages) - .with_offchain_heap_alloc_strategy(heap_pages) - .with_max_runtime_instances(config.max_runtime_instances) - .with_runtime_cache_size(config.runtime_cache_size) - .build(); - - let (client, backend, keystore_container, task_manager) = - sc_service::new_full_parts_record_import::( - config, - telemetry.as_ref().map(|(_, telemetry)| telemetry.handle()), - executor, - true, - )?; - let client = Arc::new(client); - - let telemetry_worker_handle = telemetry.as_ref().map(|(worker, _)| worker.handle()); - - let telemetry = telemetry.map(|(worker, telemetry)| { - task_manager.spawn_handle().spawn("telemetry", None, worker.run()); - telemetry - }); - - let transaction_pool = sc_transaction_pool::BasicPool::new_full( - config.transaction_pool.clone(), - config.role.is_authority().into(), - config.prometheus_registry(), - task_manager.spawn_essential_handle(), - client.clone(), - ); - - let block_import = ParachainBlockImport::new(client.clone(), backend.clone()); - - let import_queue = build_import_queue( - client.clone(), - block_import.clone(), - config, - telemetry.as_ref().map(|telemetry| telemetry.handle()), - &task_manager, - ); - - Ok(PartialComponents { - backend, - client, - import_queue, - keystore_container, - task_manager, - transaction_pool, - select_chain: (), - other: (block_import, telemetry, telemetry_worker_handle), - }) -} - -/// Build the import queue for the parachain runtime. -fn build_import_queue( - client: Arc, - block_import: ParachainBlockImport, - config: &Configuration, - telemetry: Option, - task_manager: &TaskManager, -) -> sc_consensus::DefaultImportQueue { - cumulus_client_consensus_aura::equivocation_import_queue::fully_verifying_import_queue::< - sp_consensus_aura::sr25519::AuthorityPair, - _, - _, - _, - _, - >( - client, - block_import, - move |_, _| async move { - let timestamp = sp_timestamp::InherentDataProvider::from_system_time(); - Ok(timestamp) - }, - &task_manager.spawn_essential_handle(), - config.prometheus_registry(), - telemetry, - ) -} - -#[allow(clippy::too_many_arguments)] -fn start_consensus( - client: Arc, - backend: Arc, - block_import: ParachainBlockImport, - prometheus_registry: Option<&Registry>, - telemetry: Option, - task_manager: &TaskManager, - relay_chain_interface: Arc, - transaction_pool: Arc>, - sync_oracle: Arc>, - keystore: KeystorePtr, - relay_chain_slot_duration: Duration, - para_id: ParaId, - collator_key: CollatorPair, - overseer_handle: OverseerHandle, - announce_block: Arc>) + Send + Sync>, -) -> Result<(), sc_service::Error> { - let proposer_factory = sc_basic_authorship::ProposerFactory::with_proof_recording( - task_manager.spawn_handle(), - client.clone(), - transaction_pool, - prometheus_registry, - telemetry.clone(), - ); - - let proposer = Proposer::new(proposer_factory); - - let collator_service = CollatorService::new( - client.clone(), - Arc::new(task_manager.spawn_handle()), - announce_block, - client.clone(), - ); - - let params = AuraParams { - create_inherent_data_providers: move |_, ()| async move { Ok(()) }, - block_import, - para_client: client.clone(), - para_backend: backend, - relay_client: relay_chain_interface, - code_hash_provider: move |block_hash| { - client.code_at(block_hash).ok().map(|c| ValidationCode::from(c).hash()) - }, - sync_oracle, - keystore, - collator_key, - para_id, - overseer_handle, - relay_chain_slot_duration, - proposer, - collator_service, - authoring_duration: Duration::from_millis(2000), - reinitialize: false, - }; - - let fut = - aura::run::( - params, - ); - task_manager.spawn_essential_handle().spawn("aura", None, fut); - - Ok(()) -} - -/// Start a node with the given parachain `Configuration` and relay chain `Configuration`. -#[sc_tracing::logging::prefix_logs_with("Parachain")] -pub async fn start_parachain_node( - parachain_config: Configuration, - polkadot_config: Configuration, - collator_options: CollatorOptions, - para_id: ParaId, - hwbench: Option, -) -> sc_service::error::Result<(TaskManager, Arc)> { - let parachain_config = prepare_node_config(parachain_config); - - let params = new_partial(¶chain_config)?; - let (block_import, mut telemetry, telemetry_worker_handle) = params.other; - let net_config = sc_network::config::FullNetworkConfiguration::< - _, - _, - sc_network::NetworkWorker, - >::new(¶chain_config.network); - - let client = params.client.clone(); - let backend = params.backend.clone(); - let mut task_manager = params.task_manager; - - let (relay_chain_interface, collator_key) = build_relay_chain_interface( - polkadot_config, - ¶chain_config, - telemetry_worker_handle, - &mut task_manager, - collator_options.clone(), - hwbench.clone(), - ) - .await - .map_err(|e| sc_service::Error::Application(Box::new(e) as Box<_>))?; - - let validator = parachain_config.role.is_authority(); - let prometheus_registry = parachain_config.prometheus_registry().cloned(); - let transaction_pool = params.transaction_pool.clone(); - let import_queue_service = params.import_queue.service(); - - // NOTE: because we use Aura here explicitly, we can use `CollatorSybilResistance::Resistant` - // when starting the network. - let (network, system_rpc_tx, tx_handler_controller, start_network, sync_service) = - build_network(BuildNetworkParams { - parachain_config: ¶chain_config, - net_config, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - para_id, - spawn_handle: task_manager.spawn_handle(), - relay_chain_interface: relay_chain_interface.clone(), - import_queue: params.import_queue, - sybil_resistance_level: CollatorSybilResistance::Resistant, // because of Aura - }) - .await?; - - if parachain_config.offchain_worker.enabled { - use futures::FutureExt; - - task_manager.spawn_handle().spawn( - "offchain-workers-runner", - "offchain-work", - sc_offchain::OffchainWorkers::new(sc_offchain::OffchainWorkerOptions { - runtime_api_provider: client.clone(), - keystore: Some(params.keystore_container.keystore()), - offchain_db: backend.offchain_storage(), - transaction_pool: Some(OffchainTransactionPoolFactory::new( - transaction_pool.clone(), - )), - network_provider: Arc::new(network.clone()), - is_validator: parachain_config.role.is_authority(), - enable_http_requests: false, - custom_extensions: move |_| vec![], - }) - .run(client.clone(), task_manager.spawn_handle()) - .boxed(), - ); - } - - let rpc_builder = { - let client = client.clone(); - let transaction_pool = transaction_pool.clone(); - - Box::new(move |deny_unsafe, _| { - let deps = crate::rpc::FullDeps { - client: client.clone(), - pool: transaction_pool.clone(), - deny_unsafe, - }; - - crate::rpc::create_full(deps).map_err(Into::into) - }) - }; - - sc_service::spawn_tasks(sc_service::SpawnTasksParams { - rpc_builder, - client: client.clone(), - transaction_pool: transaction_pool.clone(), - task_manager: &mut task_manager, - config: parachain_config, - keystore: params.keystore_container.keystore(), - backend: backend.clone(), - network, - sync_service: sync_service.clone(), - system_rpc_tx, - tx_handler_controller, - telemetry: telemetry.as_mut(), - })?; - - if let Some(hwbench) = hwbench { - sc_sysinfo::print_hwbench(&hwbench); - // Here you can check whether the hardware meets your chains' requirements. Putting a link - // in there and swapping out the requirements for your own are probably a good idea. The - // requirements for a para-chain are dictated by its relay-chain. - match SUBSTRATE_REFERENCE_HARDWARE.check_hardware(&hwbench) { - Err(err) if validator => { - log::warn!( - "⚠️ The hardware does not meet the minimal requirements {} for role 'Authority'.", - err - ); - }, - _ => {}, - } - - if let Some(ref mut telemetry) = telemetry { - let telemetry_handle = telemetry.handle(); - task_manager.spawn_handle().spawn( - "telemetry_hwbench", - None, - sc_sysinfo::initialize_hwbench_telemetry(telemetry_handle, hwbench), - ); - } - } - - let announce_block = { - let sync_service = sync_service.clone(); - Arc::new(move |hash, data| sync_service.announce_block(hash, data)) - }; - - let relay_chain_slot_duration = Duration::from_secs(6); - - let overseer_handle = relay_chain_interface - .overseer_handle() - .map_err(|e| sc_service::Error::Application(Box::new(e)))?; - - start_relay_chain_tasks(StartRelayChainTasksParams { - client: client.clone(), - announce_block: announce_block.clone(), - para_id, - relay_chain_interface: relay_chain_interface.clone(), - task_manager: &mut task_manager, - da_recovery_profile: if validator { - DARecoveryProfile::Collator - } else { - DARecoveryProfile::FullNode - }, - import_queue: import_queue_service, - relay_chain_slot_duration, - recovery_handle: Box::new(overseer_handle.clone()), - sync_service: sync_service.clone(), - })?; - - if validator { - start_consensus( - client.clone(), - backend, - block_import, - prometheus_registry.as_ref(), - telemetry.as_ref().map(|t| t.handle()), - &task_manager, - relay_chain_interface, - transaction_pool, - sync_service, - params.keystore_container.keystore(), - relay_chain_slot_duration, - para_id, - collator_key.expect("Command line arguments do not allow this. qed"), - overseer_handle, - announce_block, - )?; - } - - start_network.start_network(); - - Ok((task_manager, client)) -}