Newer
Older
// Copyright (C) Parity Technologies (UK) Ltd.
Branislav Kontur
committed
// This file is part of Cumulus.
// Cumulus 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 Cumulus. If not, see <http://www.gnu.org/licenses/>.
Adrian Catangiu
committed
//! # Bridge Hub Rococo Runtime
//!
Branislav Kontur
committed
//! This runtime currently supports bridging between:
//! - Rococo <> Westend
Svyatoslav Nikolsky
committed
//! - Rococo <> Rococo Bulletin
Adrian Catangiu
committed
Branislav Kontur
committed
#![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"));
Svyatoslav Nikolsky
committed
pub mod bridge_to_bulletin_config;
pub mod bridge_to_ethereum_config;
Branislav Kontur
committed
pub mod bridge_to_westend_config;
Branislav Kontur
committed
mod weights;
pub mod xcm_config;
use cumulus_pallet_parachain_system::RelayNumberMonotonicallyIncreases;
use snowbridge_beacon_primitives::{Fork, ForkVersions};
use snowbridge_core::{
gwei, meth,
outbound::{Command, Fee},
AgentId, AllowSiblingsOnly, PricingParameters, Rewards,
};
use snowbridge_router_primitives::inbound::MessageToXcm;
Branislav Kontur
committed
use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H160};
Branislav Kontur
committed
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{Block as BlockT, Keccak256},
Branislav Kontur
committed
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, FixedU128,
Branislav Kontur
committed
};
use sp_std::prelude::*;
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use cumulus_primitives_core::ParaId;
Branislav Kontur
committed
use frame_support::{
construct_runtime, derive_impl,
Branislav Kontur
committed
dispatch::DispatchClass,
genesis_builder_helper::{build_state, get_preset},
Branislav Kontur
committed
parameter_types,
traits::{ConstBool, ConstU32, ConstU64, ConstU8, TransformOrigin},
weights::{ConstantMultiplier, Weight},
Branislav Kontur
committed
PalletId,
};
use frame_system::{
limits::{BlockLength, BlockWeights},
EnsureRoot,
};
use testnet_parachains_constants::rococo::{
consensus::*, currency::*, fee::WeightToFee, snowbridge::INBOUND_QUEUE_PALLET_INDEX, time::*,
};
Branislav Kontur
committed
use bridge_hub_common::{
message_queue::{NarrowOriginToSibling, ParaIdToSibling},
AggregateMessageOrigin,
};
use pallet_xcm::EnsureXcm;
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
pub use sp_runtime::{MultiAddress, Perbill, Permill};
use xcm_config::{TreasuryAccount, XcmOriginToTransactDispatchOrigin, XcmRouter};
Branislav Kontur
committed
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
use polkadot_runtime_common::{BlockHashCount, SlowAdjustingFeeUpdate};
use rococo_runtime_constants::system_parachain::{ASSET_HUB_ID, BRIDGE_HUB_ID};
use xcm::latest::prelude::*;
Branislav Kontur
committed
use weights::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight};
use parachains_common::{
impls::DealWithFees, AccountId, Balance, BlockNumber, Hash, Header, Nonce, Signature,
AVERAGE_ON_INITIALIZE_RATIO, NORMAL_DISPATCH_RATIO,
Branislav Kontur
committed
};
#[cfg(feature = "runtime-benchmarks")]
use benchmark_helpers::DoNothingRouter;
Branislav Kontur
committed
/// The address format for describing accounts.
pub type Address = MultiAddress<AccountId, ()>;
/// Block type as expected by this runtime.
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
/// A Block signed with a Justification
pub type SignedBlock = generic::SignedBlock<Block>;
/// BlockId type as expected by this runtime.
pub type BlockId = generic::BlockId<Block>;
/// The SignedExtension to the basic transaction logic.
pub type SignedExtra = (
Branislav Kontur
committed
frame_system::CheckNonZeroSender<Runtime>,
frame_system::CheckSpecVersion<Runtime>,
frame_system::CheckTxVersion<Runtime>,
frame_system::CheckGenesis<Runtime>,
frame_system::CheckEra<Runtime>,
frame_system::CheckNonce<Runtime>,
frame_system::CheckWeight<Runtime>,
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
BridgeRejectObsoleteHeadersAndMessages,
Svyatoslav Nikolsky
committed
(
bridge_to_westend_config::OnBridgeHubRococoRefundBridgeHubWestendMessages,
bridge_to_bulletin_config::OnBridgeHubRococoRefundRococoBulletinMessages,
),
cumulus_primitives_storage_weight_reclaim::StorageWeightReclaim<Runtime>,
Branislav Kontur
committed
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic =
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
Branislav Kontur
committed
/// Migrations to apply on runtime upgrade.
Liam Aharon
committed
pub type Migrations = (
pallet_collator_selection::migration::v1::MigrateToV1<Runtime>,
pallet_multisig::migrations::v1::MigrateToV1<Runtime>,
InitStorageVersions,
cumulus_pallet_xcmp_queue::migration::v4::MigrationToV4<Runtime>,
snowbridge_pallet_system::migration::v0::InitializeOnUpgrade<
Runtime,
ConstU32<BRIDGE_HUB_ID>,
ConstU32<ASSET_HUB_ID>,
>,
Branislav Kontur
committed
// permanent
pallet_xcm::migration::MigrateToLatestXcmVersion<Runtime>,
Liam Aharon
committed
);
/// Migration to initialize storage versions for pallets added after genesis.
///
/// Ideally this would be done automatically (see
/// <https://github.com/paritytech/polkadot-sdk/pull/1297>), but it probably won't be ready for some
/// time and it's beneficial to get try-runtime-cli on-runtime-upgrade checks into the CI, so we're
/// doing it manually.
pub struct InitStorageVersions;
impl frame_support::traits::OnRuntimeUpgrade for InitStorageVersions {
fn on_runtime_upgrade() -> Weight {
use frame_support::traits::{GetStorageVersion, StorageVersion};
use sp_runtime::traits::Saturating;
let mut writes = 0;
if PolkadotXcm::on_chain_storage_version() == StorageVersion::new(0) {
PolkadotXcm::in_code_storage_version().put::<PolkadotXcm>();
Liam Aharon
committed
writes.saturating_inc();
}
if Balances::on_chain_storage_version() == StorageVersion::new(0) {
Balances::in_code_storage_version().put::<Balances>();
Liam Aharon
committed
writes.saturating_inc();
}
<Runtime as frame_system::Config>::DbWeight::get().reads_writes(2, writes)
}
}
Branislav Kontur
committed
/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
Runtime,
Block,
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
Branislav Kontur
committed
>;
impl_opaque_keys! {
pub struct SessionKeys {
pub aura: Aura,
}
}
Loading full blame...