Bump Substrate/Polkadot/Cumulus refs (aka Weights v1.5) (#1597)

* update Substrate + Polkadot + Cumulus refs

* Origin -> RuntimeOrigin

* weights v1.5

* update refs once again + `cargo test -p pallet-bridge-grandpa` works

* started work on `cargo test -p pallet-bridge-messages`

* cargo test -p pallet-bridge-relayers

* cargo test -p pallet-bridge-parachains

* cargo test -p millau-runtime

* cargo test -p bridge-runtime-common

* cargo test -p rialto-runtime

* cargo test -p rialto-parachain-runtime

* cargo test -p millau-bridge-node

* cargo test -p rialto-bridge-node

* cargo test -p rialto-parachain-collator

* cargo test -p messages-relay

* cargo test -p parachains-relay

* cargo test -p substrate-relay

* cargo test --all

* cargo check -p millau-runtime --locked --features runtime-benchmarks

* fix remaining test

* fmt

* try to allow clippy failure temporarily

* Revert "try to allow clippy failure temporarily"

This reverts commit d1b6593580f07e0dbeecb7ab0aa92cee98888ed3.

* use min_by

* Revert "use min_by"

This reverts commit 33042f49ed37e8dd0505370289e17f03bf1a56ee.

* Revert "Revert "use min_by""

This reverts commit 1d2204f0b14dc81e5650bb574dedb5fa78c7097d.

* trigger CI

* Revert "trigger CI"

This reverts commit 259d91b5606743bba9d043c69f07eac6c8700ef5.

* new day, new clippy warning

* more clippy issues
This commit is contained in:
Svyatoslav Nikolsky
2022-10-20 10:27:23 +03:00
committed by Bastian Köcher
parent 9e1847d12a
commit a3dc2d2748
66 changed files with 991 additions and 893 deletions
+1
View File
@@ -21,6 +21,7 @@ rialto-runtime = { path = "../runtime" }
beefy-primitives = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master" }
node-inspect = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master", features = ["wasmtime"] }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
+2 -1
View File
@@ -15,6 +15,7 @@
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
use beefy_primitives::crypto::AuthorityId as BeefyId;
use frame_support::weights::Weight;
use polkadot_primitives::v2::{AssignmentId, ValidatorId};
use rialto_runtime::{
AccountId, BabeConfig, BalancesConfig, BeefyConfig, BridgeMillauMessagesConfig,
@@ -252,7 +253,7 @@ fn testnet_genesis(
max_upward_queue_count: 8,
max_upward_queue_size: 1024 * 1024,
max_downward_message_size: 1024 * 1024,
ump_service_total_weight: 100_000_000_000,
ump_service_total_weight: Weight::from_ref_time(100_000_000_000),
max_upward_message_size: 50 * 1024,
max_upward_message_num_per_candidate: 5,
hrmp_sender_deposit: 0,
+47 -27
View File
@@ -63,9 +63,11 @@ use sp_version::RuntimeVersion;
// A few exports that help ease life for downstream crates.
pub use frame_support::{
construct_runtime, parameter_types,
construct_runtime,
dispatch::DispatchClass,
parameter_types,
traits::{Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem},
weights::{constants::WEIGHT_PER_SECOND, DispatchClass, IdentityFee, RuntimeDbWeight, Weight},
weights::{constants::WEIGHT_PER_SECOND, IdentityFee, RuntimeDbWeight, Weight},
StorageValue,
};
@@ -169,7 +171,7 @@ 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 Call = Call;
type RuntimeCall = RuntimeCall;
/// The lookup mechanism to get account ID from whatever is passed in dispatchers.
type Lookup = AccountIdLookup<AccountId, ()>;
/// The index type for storing how many extrinsics an account has signed.
@@ -183,9 +185,9 @@ impl frame_system::Config for Runtime {
/// The header type.
type Header = generic::Header<BlockNumber, Hashing>;
/// The ubiquitous event type.
type Event = Event;
type RuntimeEvent = RuntimeEvent;
/// The ubiquitous origin type.
type Origin = Origin;
type RuntimeOrigin = RuntimeOrigin;
/// Maximum number of block number to block hash mappings to keep (oldest pruned first).
type BlockHashCount = BlockHashCount;
/// Version of the runtime.
@@ -258,8 +260,7 @@ impl pallet_beefy::Config for Runtime {
}
impl pallet_grandpa::Config for Runtime {
type Event = Event;
type Call = Call;
type RuntimeEvent = RuntimeEvent;
type MaxAuthorities = MaxAuthorities;
type KeyOwnerProofSystem = ();
type KeyOwnerProof =
@@ -340,7 +341,7 @@ impl pallet_balances::Config for Runtime {
/// The type for recording an account's balance.
type Balance = Balance;
/// The ubiquitous event type.
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type DustRemoval = ();
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
@@ -360,6 +361,7 @@ parameter_types! {
pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25);
pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(3, 100_000);
pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 1_000_000u128);
pub MaximumMultiplier: Multiplier = sp_runtime::traits::Bounded::max_value();
}
impl pallet_transaction_payment::Config for Runtime {
@@ -372,17 +374,18 @@ impl pallet_transaction_payment::Config for Runtime {
TargetBlockFullness,
AdjustmentVariable,
MinimumMultiplier,
MaximumMultiplier,
>;
type Event = Event;
type RuntimeEvent = RuntimeEvent;
}
impl pallet_sudo::Config for Runtime {
type Event = Event;
type Call = Call;
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
}
impl pallet_session::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type ValidatorId = <Self as frame_system::Config>::AccountId;
type ValidatorIdOf = ();
type ShouldEndSession = Babe;
@@ -399,7 +402,7 @@ impl pallet_authority_discovery::Config for Runtime {
}
impl pallet_bridge_relayers::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type Reward = Balance;
type PaymentProcedure = bp_relayers::MintReward<pallet_balances::Pallet<Runtime>, AccountId>;
type WeightInfo = ();
@@ -444,7 +447,7 @@ parameter_types! {
bp_millau::MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX;
// `IdentityFee` is used by Rialto => we may use weight directly
pub const GetDeliveryConfirmationTransactionFee: Balance =
bp_rialto::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT as _;
bp_rialto::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT.ref_time() as _;
pub const RootAccountForPayments: Option<AccountId> = None;
pub const BridgedChainId: bp_runtime::ChainId = bp_runtime::MILLAU_CHAIN_ID;
}
@@ -453,7 +456,7 @@ parameter_types! {
pub type WithMillauMessagesInstance = ();
impl pallet_bridge_messages::Config<WithMillauMessagesInstance> for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = pallet_bridge_messages::weights::BridgeWeight<Runtime>;
type Parameter = millau_messages::RialtoToMillauMessagesParameter;
type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce;
@@ -529,6 +532,9 @@ construct_runtime!(
Ump: polkadot_runtime_parachains::ump::{Pallet, Call, Storage, Event},
Hrmp: polkadot_runtime_parachains::hrmp::{Pallet, Call, Storage, Event<T>, Config},
SessionInfo: polkadot_runtime_parachains::session_info::{Pallet, Storage},
ParaSessionInfo: polkadot_runtime_parachains::session_info::{Pallet, Storage},
ParasDisputes: polkadot_runtime_parachains::disputes::{Pallet, Call, Storage, Event<T>},
ParasSlashing: polkadot_runtime_parachains::disputes::slashing::{Pallet, Call, Storage, ValidateUnsigned},
// Parachain Onboarding Pallets
Registrar: polkadot_runtime_common::paras_registrar::{Pallet, Call, Storage, Event<T>},
@@ -562,11 +568,12 @@ pub type SignedExtra = (
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
);
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
pub type SignedPayload = generic::SignedPayload<RuntimeCall, SignedExtra>;
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
pub type UncheckedExtrinsic =
generic::UncheckedExtrinsic<Address, RuntimeCall, Signature, SignedExtra>;
/// Extrinsic type that has already been checked.
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, RuntimeCall, SignedExtra>;
/// Executive: handles dispatch to the various modules.
pub type Executive = frame_executive::Executive<
Runtime,
@@ -679,6 +686,23 @@ impl_runtime_apis! {
.map(|(leaves, proof)| (leaves.into_iter().map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf)).collect(), proof))
}
fn generate_historical_batch_proof(
leaf_indices: Vec<mmr::LeafIndex>,
leaves_count: mmr::LeafIndex,
) -> Result<(Vec<mmr::EncodableOpaqueLeaf>, mmr::BatchProof<MmrHash>), mmr::Error> {
Mmr::generate_historical_batch_proof(leaf_indices, leaves_count).map(
|(leaves, proof)| {
(
leaves
.into_iter()
.map(|leaf| mmr::EncodableOpaqueLeaf::from_leaf(&leaf))
.collect(),
proof,
)
},
)
}
fn verify_batch_proof(leaves: Vec<mmr::EncodableOpaqueLeaf>, proof: mmr::BatchProof<MmrHash>)
-> Result<(), mmr::Error>
{
@@ -725,17 +749,17 @@ impl_runtime_apis! {
}
impl sp_consensus_babe::BabeApi<Block> for Runtime {
fn configuration() -> sp_consensus_babe::BabeGenesisConfiguration {
fn configuration() -> sp_consensus_babe::BabeConfiguration {
// The choice of `c` parameter (where `1 - c` represents the
// probability of a slot being empty), is done in accordance to the
// slot duration and expected target block time, for safely
// resisting network delays of maximum two seconds.
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
sp_consensus_babe::BabeGenesisConfiguration {
sp_consensus_babe::BabeConfiguration {
slot_duration: Babe::slot_duration(),
epoch_length: EpochDuration::get(),
c: BABE_GENESIS_EPOCH_CONFIG.c,
genesis_authorities: Babe::authorities().to_vec(),
authorities: Babe::authorities().to_vec(),
randomness: Babe::randomness(),
allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots,
}
@@ -824,7 +848,7 @@ impl_runtime_apis! {
fn candidate_events() -> Vec<polkadot_primitives::v2::CandidateEvent<Hash>> {
polkadot_runtime_parachains::runtime_api_impl::v2::candidate_events::<Runtime, _>(|ev| {
match ev {
Event::Inclusion(ev) => {
RuntimeEvent::Inclusion(ev) => {
Some(ev)
}
_ => None,
@@ -867,10 +891,6 @@ impl_runtime_apis! {
{
polkadot_runtime_parachains::runtime_api_impl::v2::validation_code_hash::<Runtime>(para_id, assumption)
}
fn staging_get_disputes() -> Vec<(polkadot_primitives::v2::SessionIndex, polkadot_primitives::v2::CandidateHash, polkadot_primitives::v2::DisputeState<BlockNumber>)> {
unimplemented!()
}
}
impl sp_authority_discovery::AuthorityDiscoveryApi<Block> for Runtime {
@@ -995,6 +1015,6 @@ mod tests {
// result of large `SessionKeys` struct.
// Total size of Rialto runtime Call is 232.
const MAX_CALL_SIZE: usize = 232;
assert!(core::mem::size_of::<Call>() <= MAX_CALL_SIZE);
assert!(core::mem::size_of::<RuntimeCall>() <= MAX_CALL_SIZE);
}
}
@@ -16,7 +16,7 @@
//! Everything required to serve Millau <-> Rialto messages.
use crate::{Call, OriginCaller, Runtime};
use crate::{OriginCaller, Runtime, RuntimeCall, RuntimeOrigin};
use bp_messages::{
source_chain::{SenderOrigin, TargetHeaderChain},
@@ -28,11 +28,7 @@ use bridge_runtime_common::messages::{
self, BasicConfirmationTransactionEstimation, MessageBridge, MessageTransaction,
};
use codec::{Decode, Encode};
use frame_support::{
parameter_types,
weights::{DispatchClass, Weight},
RuntimeDebug,
};
use frame_support::{dispatch::DispatchClass, parameter_types, weights::Weight, RuntimeDebug};
use scale_info::TypeInfo;
use sp_runtime::{traits::Saturating, FixedPointNumber, FixedU128};
use sp_std::convert::TryFrom;
@@ -45,13 +41,18 @@ pub const INITIAL_MILLAU_FEE_MULTIPLIER: FixedU128 = FixedU128::from_inner(Fixed
/// Weight of 2 XCM instructions is for simple `Trap(42)` program, coming through bridge
/// (it is prepended with `UniversalOrigin` instruction). It is used just for simplest manual
/// tests, confirming that we don't break encoding somewhere between.
pub const BASE_XCM_WEIGHT_TWICE: Weight = 2 * crate::xcm_config::BASE_XCM_WEIGHT;
pub const BASE_XCM_WEIGHT_TWICE: u64 = 2 * crate::xcm_config::BASE_XCM_WEIGHT;
parameter_types! {
/// Millau to Rialto conversion rate. Initially we treat both tokens as equal.
pub storage MillauToRialtoConversionRate: FixedU128 = INITIAL_MILLAU_TO_RIALTO_CONVERSION_RATE;
/// Fee multiplier value at Millau chain.
pub storage MillauFeeMultiplier: FixedU128 = INITIAL_MILLAU_FEE_MULTIPLIER;
/// Weight credit for our test messages.
///
/// 2 XCM instructions is for simple `Trap(42)` program, coming through bridge
/// (it is prepended with `UniversalOrigin` instruction).
pub const WeightCredit: Weight = Weight::from_ref_time(BASE_XCM_WEIGHT_TWICE);
}
/// Message payload for Rialto -> Millau messages.
@@ -62,15 +63,14 @@ pub type ToMillauMessageVerifier =
messages::source::FromThisChainMessageVerifier<WithMillauMessageBridge>;
/// Message payload for Millau -> Rialto messages.
pub type FromMillauMessagePayload = messages::target::FromBridgedChainMessagePayload<Call>;
pub type FromMillauMessagePayload = messages::target::FromBridgedChainMessagePayload<RuntimeCall>;
/// Call-dispatch based message dispatch for Millau -> Rialto messages.
pub type FromMillauMessageDispatch = messages::target::FromBridgedChainMessageDispatch<
WithMillauMessageBridge,
xcm_executor::XcmExecutor<crate::xcm_config::XcmConfig>,
crate::xcm_config::XcmWeigher,
//
frame_support::traits::ConstU64<BASE_XCM_WEIGHT_TWICE>,
WeightCredit,
>;
/// Messages proof for Millau -> Rialto messages.
@@ -117,21 +117,20 @@ impl messages::ChainWithMessages for Rialto {
type AccountId = bp_rialto::AccountId;
type Signer = bp_rialto::AccountSigner;
type Signature = bp_rialto::Signature;
type Weight = Weight;
type Balance = bp_rialto::Balance;
}
impl messages::ThisChainWithMessages for Rialto {
type Origin = crate::Origin;
type Call = crate::Call;
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type ConfirmationTransactionEstimation = BasicConfirmationTransactionEstimation<
Self::AccountId,
{ bp_rialto::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT },
{ bp_rialto::MAX_SINGLE_MESSAGE_DELIVERY_CONFIRMATION_TX_WEIGHT.ref_time() },
{ bp_millau::EXTRA_STORAGE_PROOF_SIZE },
{ bp_rialto::TX_EXTRA_BYTES },
>;
fn is_message_accepted(send_origin: &Self::Origin, lane: &LaneId) -> bool {
fn is_message_accepted(send_origin: &Self::RuntimeOrigin, lane: &LaneId) -> bool {
let here_location =
xcm::v3::MultiLocation::from(crate::xcm_config::UniversalLocation::get());
match send_origin.caller {
@@ -165,7 +164,7 @@ impl messages::ThisChainWithMessages for Rialto {
bp_rialto::BlockWeights::get().get(DispatchClass::Normal).base_extrinsic,
1,
multiplier,
|weight| weight as _,
|weight| weight.ref_time() as _,
transaction,
)
}
@@ -180,7 +179,6 @@ impl messages::ChainWithMessages for Millau {
type AccountId = bp_millau::AccountId;
type Signer = bp_millau::AccountSigner;
type Signature = bp_millau::Signature;
type Weight = Weight;
type Balance = bp_millau::Balance;
}
@@ -199,15 +197,15 @@ impl messages::BridgedChainWithMessages for Millau {
message_dispatch_weight: Weight,
) -> MessageTransaction<Weight> {
let message_payload_len = u32::try_from(message_payload.len()).unwrap_or(u32::MAX);
let extra_bytes_in_payload = Weight::from(message_payload_len)
.saturating_sub(pallet_bridge_messages::EXPECTED_DEFAULT_MESSAGE_LENGTH.into());
let extra_bytes_in_payload = message_payload_len
.saturating_sub(pallet_bridge_messages::EXPECTED_DEFAULT_MESSAGE_LENGTH);
MessageTransaction {
dispatch_weight: extra_bytes_in_payload
.saturating_mul(bp_millau::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT)
dispatch_weight: bp_millau::ADDITIONAL_MESSAGE_BYTE_DELIVERY_WEIGHT
.saturating_mul(extra_bytes_in_payload as u64)
.saturating_add(bp_millau::DEFAULT_MESSAGE_DELIVERY_TX_WEIGHT)
.saturating_sub(if include_pay_dispatch_fee_cost {
0
Weight::from_ref_time(0)
} else {
bp_millau::PAY_INBOUND_DISPATCH_FEE_WEIGHT
})
@@ -227,7 +225,7 @@ impl messages::BridgedChainWithMessages for Millau {
bp_millau::BlockWeights::get().get(DispatchClass::Normal).base_extrinsic,
1,
multiplier,
|weight| weight as _,
|weight| weight.ref_time() as _,
transaction,
)
}
@@ -277,7 +275,7 @@ impl SourceHeaderChain<bp_millau::Balance> for Millau {
}
}
impl SenderOrigin<crate::AccountId> for crate::Origin {
impl SenderOrigin<crate::AccountId> for RuntimeOrigin {
fn linked_account(&self) -> Option<crate::AccountId> {
// XCM deals wit fees in our deployments
None
+46 -24
View File
@@ -17,29 +17,31 @@
//! Parachains support in Rialto runtime.
use crate::{
AccountId, Babe, Balance, Balances, BlockNumber, Call, Event, Origin, Registrar, Runtime,
ShiftSessionManager, Slots, UncheckedExtrinsic,
AccountId, Babe, Balance, Balances, BlockNumber, Registrar, Runtime, RuntimeCall, RuntimeEvent,
RuntimeOrigin, ShiftSessionManager, Slots, UncheckedExtrinsic,
};
use frame_support::{parameter_types, weights::Weight};
use frame_support::{parameter_types, traits::KeyOwnerProofSystem, weights::Weight};
use frame_system::EnsureRoot;
use polkadot_primitives::v2::ValidatorIndex;
use polkadot_primitives::v2::{ValidatorId, ValidatorIndex};
use polkadot_runtime_common::{paras_registrar, paras_sudo_wrapper, slots};
use polkadot_runtime_parachains::{
configuration as parachains_configuration, dmp as parachains_dmp, hrmp as parachains_hrmp,
configuration as parachains_configuration, disputes as parachains_disputes,
disputes::slashing as parachains_slashing, dmp as parachains_dmp, hrmp as parachains_hrmp,
inclusion as parachains_inclusion, initializer as parachains_initializer,
origin as parachains_origin, paras as parachains_paras,
paras_inherent as parachains_paras_inherent, scheduler as parachains_scheduler,
session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump,
};
use sp_core::crypto::KeyTypeId;
use sp_runtime::transaction_validity::TransactionPriority;
impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime
where
Call: From<C>,
RuntimeCall: From<C>,
{
type Extrinsic = UncheckedExtrinsic;
type OverarchingCall = Call;
type OverarchingCall = RuntimeCall;
}
/// Special `RewardValidators` that does nothing ;)
@@ -58,14 +60,14 @@ impl parachains_configuration::Config for Runtime {
impl parachains_dmp::Config for Runtime {}
impl parachains_hrmp::Config for Runtime {
type Event = Event;
type Origin = Origin;
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
type Currency = Balances;
type WeightInfo = parachains_hrmp::TestWeightInfo;
}
impl parachains_inclusion::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type RewardValidators = RewardValidators;
type DisputesHandler = ();
}
@@ -76,6 +78,26 @@ impl parachains_initializer::Config for Runtime {
type WeightInfo = ();
}
impl parachains_disputes::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RewardValidators = ();
type SlashingHandler = ();
type WeightInfo = parachains_disputes::TestWeightInfo;
}
impl parachains_slashing::Config for Runtime {
type KeyOwnerProofSystem = ();
type KeyOwnerProof =
<Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, ValidatorId)>>::Proof;
type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
KeyTypeId,
ValidatorId,
)>>::IdentificationTuple;
type HandleReports = ();
type WeightInfo = parachains_slashing::TestWeightInfo;
type BenchmarkingConfig = parachains_slashing::BenchConfig<200>;
}
impl parachains_origin::Config for Runtime {}
parameter_types! {
@@ -83,7 +105,7 @@ parameter_types! {
}
impl parachains_paras::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = parachains_paras::TestWeightInfo;
type UnsignedPriority = ParasUnsignedPriority;
type NextSessionRotation = Babe;
@@ -106,7 +128,7 @@ parameter_types! {
}
impl parachains_ump::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type UmpSink = ();
type FirstMessageFactorPercent = FirstMessageFactorPercent;
type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
@@ -121,8 +143,8 @@ parameter_types! {
}
impl paras_registrar::Config for Runtime {
type Event = Event;
type Origin = Origin;
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
type Currency = Balances;
type OnSwap = Slots;
type ParaDeposit = ParaDeposit;
@@ -135,7 +157,7 @@ parameter_types! {
}
impl slots::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type Registrar = Registrar;
type LeasePeriod = LeasePeriod;
@@ -150,33 +172,33 @@ pub struct ZeroWeights;
impl polkadot_runtime_common::paras_registrar::WeightInfo for ZeroWeights {
fn reserve() -> Weight {
0
Weight::from_ref_time(0)
}
fn register() -> Weight {
0
Weight::from_ref_time(0)
}
fn force_register() -> Weight {
0
Weight::from_ref_time(0)
}
fn deregister() -> Weight {
0
Weight::from_ref_time(0)
}
fn swap() -> Weight {
0
Weight::from_ref_time(0)
}
}
impl polkadot_runtime_common::slots::WeightInfo for ZeroWeights {
fn force_lease() -> Weight {
0
Weight::from_ref_time(0)
}
fn manage_lease_period_start(_c: u32, _t: u32) -> Weight {
0
Weight::from_ref_time(0)
}
fn clear_all_leases() -> Weight {
0
Weight::from_ref_time(0)
}
fn trigger_onboard() -> Weight {
0
Weight::from_ref_time(0)
}
}
+25 -22
View File
@@ -17,8 +17,8 @@
//! XCM configurations for the Rialto runtime.
use super::{
millau_messages::WithMillauMessageBridge, AccountId, AllPalletsWithSystem, Balances, Call,
Event, Origin, Runtime, WithMillauMessagesInstance, XcmPallet,
millau_messages::WithMillauMessageBridge, AccountId, AllPalletsWithSystem, Balances, Runtime,
RuntimeCall, RuntimeEvent, RuntimeOrigin, WithMillauMessagesInstance, XcmPallet,
};
use bp_rialto::WeightToFee;
use bridge_runtime_common::{
@@ -28,12 +28,11 @@ use bridge_runtime_common::{
use frame_support::{
parameter_types,
traits::{Everything, Nothing},
weights::Weight,
};
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowKnownQueryResponses, AllowTopLevelPaidExecutionFrom,
CurrencyAdapter as XcmCurrencyAdapter, IsConcrete, SignedAccountId32AsNative,
CurrencyAdapter as XcmCurrencyAdapter, IsConcrete, MintLocation, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
};
@@ -52,7 +51,7 @@ parameter_types! {
/// Since Polkadot is a top-level relay-chain with its own consensus, it's just our network ID.
pub UniversalLocation: InteriorMultiLocation = ThisNetwork::get().into();
/// The check account, which holds any native assets that have been teleported out and not back in (yet).
pub CheckAccount: AccountId = XcmPallet::check_account();
pub CheckAccount: (AccountId, MintLocation) = (XcmPallet::check_account(), MintLocation::Local);
}
/// The canonical means of converting a `MultiLocation` into an `AccountId`, used when we want to
@@ -82,17 +81,17 @@ pub type LocalAssetTransactor = XcmCurrencyAdapter<
/// The means that we convert the XCM message origin location into a local dispatch origin.
type LocalOriginConverter = (
// A `Signed` origin of the sovereign account that the original location controls.
SovereignSignedViaLocation<SovereignAccountOf, Origin>,
SovereignSignedViaLocation<SovereignAccountOf, RuntimeOrigin>,
// The AccountId32 location type can be expressed natively as a `Signed` origin.
SignedAccountId32AsNative<ThisNetwork, Origin>,
SignedAccountId32AsNative<ThisNetwork, RuntimeOrigin>,
);
/// The amount of weight an XCM operation takes. This is a safe overestimate.
pub const BASE_XCM_WEIGHT: Weight = 1_000_000_000;
pub const BASE_XCM_WEIGHT: u64 = 1_000_000_000;
parameter_types! {
/// The amount of weight an XCM operation takes. This is a safe overestimate.
pub const BaseXcmWeight: Weight = BASE_XCM_WEIGHT;
pub const BaseXcmWeight: u64 = BASE_XCM_WEIGHT;
/// Maximum number of instructions in a single XCM fragment. A sanity check against weight
/// calculations getting too crazy.
pub const MaxInstructions: u32 = 100;
@@ -120,11 +119,11 @@ pub type Barrier = (
);
/// Incoming XCM weigher type.
pub type XcmWeigher = xcm_builder::FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
pub type XcmWeigher = xcm_builder::FixedWeightBounds<BaseXcmWeight, RuntimeCall, MaxInstructions>;
pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
type Call = Call;
type RuntimeCall = RuntimeCall;
type XcmSender = XcmRouter;
type AssetTransactor = LocalAssetTransactor;
type OriginConverter = LocalOriginConverter;
@@ -146,26 +145,26 @@ impl xcm_executor::Config for XcmConfig {
type FeeManager = ();
type MessageExporter = ();
type UniversalAliases = Nothing;
type CallDispatcher = Call;
type CallDispatcher = RuntimeCall;
}
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior
/// location of this chain.
pub type LocalOriginToLocation = (
// Usual Signed origin to be used in XCM as a corresponding AccountId32
SignedToAccountId32<Origin, AccountId, ThisNetwork>,
SignedToAccountId32<RuntimeOrigin, AccountId, ThisNetwork>,
);
impl pallet_xcm::Config for Runtime {
type Event = Event;
type RuntimeEvent = RuntimeEvent;
// We don't allow any messages to be sent via the transaction yet. This is basically safe to
// enable, (safe the possibility of someone spamming the parachain if they're willing to pay
// the DOT to send from the Relay-chain). But it's useless until we bring in XCM v3 which will
// make `DescendOrigin` a bit more useful.
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmRouter = XcmRouter;
// Anyone can execute XCM messages locally.
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<RuntimeOrigin, LocalOriginToLocation>;
type XcmExecuteFilter = Everything;
type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>;
// Anyone is able to use teleportation regardless of who they are and what they want to
@@ -176,8 +175,8 @@ impl pallet_xcm::Config for Runtime {
type XcmReserveTransferFilter = Everything;
type Weigher = XcmWeigher;
type UniversalLocation = UniversalLocation;
type Origin = Origin;
type Call = Call;
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
type Currency = Balances;
@@ -216,6 +215,7 @@ impl XcmBridge for ToMillauBridge {
#[cfg(test)]
mod tests {
use super::*;
use crate::millau_messages::WeightCredit;
use bp_messages::{
target_chain::{DispatchMessage, DispatchMessageData, MessageDispatch},
MessageKey,
@@ -252,13 +252,13 @@ mod tests {
WithMillauMessageBridge,
XcmExecutor,
XcmWeigher,
frame_support::traits::ConstU64<BASE_XCM_WEIGHT>,
WeightCredit,
>;
new_test_ext().execute_with(|| {
let location: MultiLocation =
(Parent, X1(GlobalConsensus(MillauNetwork::get()))).into();
let xcm: Xcm<Call> = vec![Instruction::Trap(42)].into();
let xcm: Xcm<RuntimeCall> = vec![Instruction::Trap(42)].into();
let mut incoming_message = DispatchMessage {
key: MessageKey { lane_id: [0, 0, 0, 0], nonce: 1 },
@@ -266,7 +266,10 @@ mod tests {
};
let dispatch_weight = MessageDispatcher::dispatch_weight(&mut incoming_message);
assert_eq!(dispatch_weight, 1_000_000_000);
assert_eq!(
dispatch_weight,
frame_support::weights::Weight::from_ref_time(1_000_000_000)
);
let dispatch_result =
MessageDispatcher::dispatch(&AccountId::from([0u8; 32]), incoming_message);
@@ -274,7 +277,7 @@ mod tests {
dispatch_result,
MessageDispatchResult {
dispatch_result: true,
unspent_weight: 0,
unspent_weight: frame_support::weights::Weight::from_ref_time(0),
dispatch_fee_paid_during_dispatch: false,
}
);