mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 08:41:02 +00:00
fixed TODOs for weights v2 (#1860)
This commit is contained in:
committed by
Bastian Köcher
parent
795a049937
commit
a5a3f8065f
@@ -30,14 +30,14 @@ pub const XCM_LANE: LaneId = LaneId([0, 0, 0, 0]);
|
||||
/// 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: u64 = 2 * crate::xcm_config::BASE_XCM_WEIGHT;
|
||||
pub const BASE_XCM_WEIGHT_TWICE: Weight = crate::xcm_config::BaseXcmWeight::get().saturating_mul(2);
|
||||
|
||||
parameter_types! {
|
||||
/// 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);
|
||||
pub const WeightCredit: Weight = BASE_XCM_WEIGHT_TWICE;
|
||||
}
|
||||
|
||||
/// Message payload for Millau -> Rialto messages.
|
||||
|
||||
@@ -30,14 +30,14 @@ pub const XCM_LANE: LaneId = LaneId([0, 0, 0, 0]);
|
||||
/// 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: u64 = 2 * crate::xcm_config::BASE_XCM_WEIGHT;
|
||||
pub const BASE_XCM_WEIGHT_TWICE: Weight = crate::xcm_config::BaseXcmWeight::get().saturating_mul(2);
|
||||
|
||||
parameter_types! {
|
||||
/// 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);
|
||||
pub const WeightCredit: Weight = BASE_XCM_WEIGHT_TWICE;
|
||||
}
|
||||
|
||||
/// Message payload for Millau -> RialtoParachain messages.
|
||||
|
||||
@@ -93,13 +93,9 @@ type LocalOriginConverter = (
|
||||
SignedAccountId32AsNative<ThisNetwork, RuntimeOrigin>,
|
||||
);
|
||||
|
||||
/// The amount of weight an XCM operation takes. This is a safe overestimate.
|
||||
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.
|
||||
// TODO: https://github.com/paritytech/parity-bridges-common/issues/1543 - check `set_proof_size` 0 or 64*1024 or 1026?
|
||||
pub const BaseXcmWeight: Weight = Weight::from_parts(BASE_XCM_WEIGHT, 0);
|
||||
pub const BaseXcmWeight: Weight = Weight::from_parts(1_000_000_000, 64 * 1024);
|
||||
/// Maximum number of instructions in a single XCM fragment. A sanity check against weight
|
||||
/// calculations getting too crazy.
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
@@ -314,17 +310,14 @@ mod tests {
|
||||
};
|
||||
|
||||
let dispatch_weight = MessageDispatcher::dispatch_weight(&mut incoming_message);
|
||||
assert_eq!(
|
||||
dispatch_weight,
|
||||
frame_support::weights::Weight::from_ref_time(1_000_000_000)
|
||||
);
|
||||
assert_eq!(dispatch_weight, BaseXcmWeight::get());
|
||||
|
||||
let dispatch_result =
|
||||
MessageDispatcher::dispatch(&AccountId::from([0u8; 32]), incoming_message);
|
||||
assert_eq!(
|
||||
dispatch_result,
|
||||
MessageDispatchResult {
|
||||
unspent_weight: frame_support::weights::Weight::from_ref_time(0),
|
||||
unspent_weight: frame_support::weights::Weight::zero(),
|
||||
dispatch_level_result: (),
|
||||
}
|
||||
);
|
||||
|
||||
@@ -368,13 +368,9 @@ pub type XcmOriginToTransactDispatchOrigin = (
|
||||
// TODO: until https://github.com/paritytech/parity-bridges-common/issues/1417 is fixed (in either way),
|
||||
// the following constant must match the similar constant in the Millau runtime.
|
||||
|
||||
/// One XCM operation is `1_000_000_000` weight - almost certainly a conservative estimate.
|
||||
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.
|
||||
// TODO: https://github.com/paritytech/parity-bridges-common/issues/1543 - check `set_proof_size` 0 or 64*1024 or 1026?
|
||||
pub UnitWeightCost: Weight = Weight::from_parts(BASE_XCM_WEIGHT, 0);
|
||||
pub const UnitWeightCost: Weight = Weight::from_parts(1_000_000, 64 * 1024);
|
||||
// One UNIT buys 1 second of weight.
|
||||
pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), UNIT);
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
@@ -902,17 +898,14 @@ mod tests {
|
||||
};
|
||||
|
||||
let dispatch_weight = MessageDispatcher::dispatch_weight(&mut incoming_message);
|
||||
assert_eq!(
|
||||
dispatch_weight,
|
||||
frame_support::weights::Weight::from_ref_time(1_000_000_000)
|
||||
);
|
||||
assert_eq!(dispatch_weight, UnitWeightCost::get());
|
||||
|
||||
let dispatch_result =
|
||||
MessageDispatcher::dispatch(&AccountId::from([0u8; 32]), incoming_message);
|
||||
assert_eq!(
|
||||
dispatch_result,
|
||||
MessageDispatchResult {
|
||||
unspent_weight: frame_support::weights::Weight::from_ref_time(0),
|
||||
unspent_weight: frame_support::weights::Weight::zero(),
|
||||
dispatch_level_result: (),
|
||||
}
|
||||
);
|
||||
|
||||
@@ -33,14 +33,14 @@ pub const XCM_LANE: LaneId = LaneId([0, 0, 0, 0]);
|
||||
/// 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: u64 = 2 * crate::BASE_XCM_WEIGHT;
|
||||
pub const BASE_XCM_WEIGHT_TWICE: Weight = crate::UnitWeightCost::get().saturating_mul(2);
|
||||
|
||||
parameter_types! {
|
||||
/// 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);
|
||||
pub const WeightCredit: Weight = BASE_XCM_WEIGHT_TWICE;
|
||||
}
|
||||
|
||||
/// Message payload for RialtoParachain -> Millau messages.
|
||||
|
||||
@@ -253,7 +253,10 @@ fn testnet_genesis(
|
||||
max_upward_queue_count: 8,
|
||||
max_upward_queue_size: 1024 * 1024,
|
||||
max_downward_message_size: 1024 * 1024,
|
||||
ump_service_total_weight: Weight::from_ref_time(100_000_000_000),
|
||||
ump_service_total_weight: Weight::from_parts(
|
||||
100_000_000_000,
|
||||
polkadot_primitives::v2::MAX_POV_SIZE as u64,
|
||||
),
|
||||
max_upward_message_size: 50 * 1024,
|
||||
max_upward_message_num_per_candidate: 5,
|
||||
hrmp_sender_deposit: 0,
|
||||
|
||||
@@ -30,14 +30,14 @@ pub const XCM_LANE: LaneId = LaneId([0, 0, 0, 0]);
|
||||
/// 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: u64 = 2 * crate::xcm_config::BASE_XCM_WEIGHT;
|
||||
pub const BASE_XCM_WEIGHT_TWICE: Weight = crate::xcm_config::BaseXcmWeight::get().saturating_mul(2);
|
||||
|
||||
parameter_types! {
|
||||
/// 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);
|
||||
pub const WeightCredit: Weight = BASE_XCM_WEIGHT_TWICE;
|
||||
}
|
||||
|
||||
/// Message payload for Rialto -> Millau messages.
|
||||
|
||||
@@ -21,7 +21,7 @@ use crate::{
|
||||
RuntimeOrigin, ShiftSessionManager, Slots, UncheckedExtrinsic,
|
||||
};
|
||||
|
||||
use frame_support::{parameter_types, traits::KeyOwnerProofSystem, weights::Weight};
|
||||
use frame_support::{parameter_types, traits::KeyOwnerProofSystem};
|
||||
use frame_system::EnsureRoot;
|
||||
use polkadot_primitives::v2::{ValidatorId, ValidatorIndex};
|
||||
use polkadot_runtime_common::{paras_registrar, paras_sudo_wrapper, slots};
|
||||
@@ -163,44 +163,3 @@ impl slots::Config for Runtime {
|
||||
}
|
||||
|
||||
impl paras_sudo_wrapper::Config for Runtime {}
|
||||
|
||||
pub struct ZeroWeights;
|
||||
|
||||
impl polkadot_runtime_common::paras_registrar::WeightInfo for ZeroWeights {
|
||||
fn reserve() -> Weight {
|
||||
Weight::from_ref_time(0)
|
||||
}
|
||||
fn register() -> Weight {
|
||||
Weight::from_ref_time(0)
|
||||
}
|
||||
fn force_register() -> Weight {
|
||||
Weight::from_ref_time(0)
|
||||
}
|
||||
fn deregister() -> Weight {
|
||||
Weight::from_ref_time(0)
|
||||
}
|
||||
fn swap() -> Weight {
|
||||
Weight::from_ref_time(0)
|
||||
}
|
||||
fn schedule_code_upgrade(_: u32) -> Weight {
|
||||
Weight::from_ref_time(0)
|
||||
}
|
||||
fn set_current_head(_: u32) -> Weight {
|
||||
Weight::from_ref_time(0)
|
||||
}
|
||||
}
|
||||
|
||||
impl polkadot_runtime_common::slots::WeightInfo for ZeroWeights {
|
||||
fn force_lease() -> Weight {
|
||||
Weight::from_ref_time(0)
|
||||
}
|
||||
fn manage_lease_period_start(_c: u32, _t: u32) -> Weight {
|
||||
Weight::from_ref_time(0)
|
||||
}
|
||||
fn clear_all_leases() -> Weight {
|
||||
Weight::from_ref_time(0)
|
||||
}
|
||||
fn trigger_onboard() -> Weight {
|
||||
Weight::from_ref_time(0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,13 +87,9 @@ type LocalOriginConverter = (
|
||||
SignedAccountId32AsNative<ThisNetwork, RuntimeOrigin>,
|
||||
);
|
||||
|
||||
/// The amount of weight an XCM operation takes. This is a safe overestimate.
|
||||
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.
|
||||
// TODO: https://github.com/paritytech/parity-bridges-common/issues/1543 - check `set_proof_size` 0 or 64*1024 or 1026?
|
||||
pub const BaseXcmWeight: Weight = Weight::from_parts(BASE_XCM_WEIGHT, 0);
|
||||
pub const BaseXcmWeight: Weight = Weight::from_parts(1_000_000_000, 64 * 1024);
|
||||
/// Maximum number of instructions in a single XCM fragment. A sanity check against weight
|
||||
/// calculations getting too crazy.
|
||||
pub const MaxInstructions: u32 = 100;
|
||||
@@ -273,17 +269,14 @@ mod tests {
|
||||
};
|
||||
|
||||
let dispatch_weight = MessageDispatcher::dispatch_weight(&mut incoming_message);
|
||||
assert_eq!(
|
||||
dispatch_weight,
|
||||
frame_support::weights::Weight::from_ref_time(1_000_000_000)
|
||||
);
|
||||
assert_eq!(dispatch_weight, BaseXcmWeight::get());
|
||||
|
||||
let dispatch_result =
|
||||
MessageDispatcher::dispatch(&AccountId::from([0u8; 32]), incoming_message);
|
||||
assert_eq!(
|
||||
dispatch_result,
|
||||
MessageDispatchResult {
|
||||
unspent_weight: frame_support::weights::Weight::from_ref_time(0),
|
||||
unspent_weight: frame_support::weights::Weight::zero(),
|
||||
dispatch_level_result: (),
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1271,7 +1271,7 @@ mod tests {
|
||||
TEST_RELAYER_A,
|
||||
Err(()).into(),
|
||||
1,
|
||||
Weight::from_ref_time(0),
|
||||
Weight::zero(),
|
||||
),
|
||||
Error::<TestRuntime, ()>::InvalidMessagesProof,
|
||||
);
|
||||
@@ -1287,7 +1287,7 @@ mod tests {
|
||||
TEST_RELAYER_A,
|
||||
Ok(vec![message(1, REGULAR_PAYLOAD)]).into(),
|
||||
u32::MAX,
|
||||
Weight::from_ref_time(0),
|
||||
Weight::zero(),
|
||||
),
|
||||
Error::<TestRuntime, ()>::TooManyMessagesInTheProof,
|
||||
);
|
||||
@@ -1479,7 +1479,7 @@ mod tests {
|
||||
TEST_RELAYER_A,
|
||||
Ok(vec![invalid_message]).into(),
|
||||
1,
|
||||
Weight::from_ref_time(0), /* weight may be zero in this case (all messages are
|
||||
Weight::zero(), /* weight may be zero in this case (all messages are
|
||||
* improperly encoded) */
|
||||
),);
|
||||
|
||||
@@ -1710,11 +1710,7 @@ mod tests {
|
||||
Pallet::<TestRuntime>::inbound_message_data(
|
||||
TEST_LANE_ID,
|
||||
REGULAR_PAYLOAD.encode(),
|
||||
OutboundMessageDetails {
|
||||
nonce: 0,
|
||||
dispatch_weight: Weight::from_ref_time(0),
|
||||
size: 0,
|
||||
},
|
||||
OutboundMessageDetails { nonce: 0, dispatch_weight: Weight::zero(), size: 0 },
|
||||
),
|
||||
InboundMessageDetails { dispatch_weight: REGULAR_PAYLOAD.declared_weight },
|
||||
);
|
||||
|
||||
@@ -374,7 +374,7 @@ impl MessageDispatch<AccountId> for TestMessageDispatch {
|
||||
fn dispatch_weight(message: &mut DispatchMessage<TestPayload>) -> Weight {
|
||||
match message.data.payload.as_ref() {
|
||||
Ok(payload) => payload.declared_weight,
|
||||
Err(_) => Weight::from_ref_time(0),
|
||||
Err(_) => Weight::zero(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ pub fn ensure_weights_are_correct<W: WeightInfoExt>() {
|
||||
|
||||
// verify `receive_message_proof` weight
|
||||
let receive_messages_proof_weight =
|
||||
W::receive_messages_proof_weight(&PreComputedSize(1), 10, Weight::from_ref_time(0));
|
||||
W::receive_messages_proof_weight(&PreComputedSize(1), 10, Weight::zero());
|
||||
assert_ne!(receive_messages_proof_weight.ref_time(), 0);
|
||||
assert_ne!(receive_messages_proof_weight.proof_size(), 0);
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
|
||||
/// time.
|
||||
///
|
||||
/// This is a copy-paste from the cumulus repo's `parachains-common` crate.
|
||||
// TODO: https://github.com/paritytech/parity-bridges-common/issues/1543 - remove `set_proof_size`
|
||||
const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::from_ref_time(constants::WEIGHT_REF_TIME_PER_SECOND)
|
||||
.saturating_div(2)
|
||||
.set_proof_size(polkadot_primitives::v2::MAX_POV_SIZE as u64);
|
||||
@@ -62,9 +61,12 @@ parameter_types! {
|
||||
NORMAL_DISPATCH_RATIO,
|
||||
);
|
||||
|
||||
pub const BlockExecutionWeight: Weight = Weight::from_ref_time(constants::WEIGHT_REF_TIME_PER_NANOS).saturating_mul(5_000_000);
|
||||
|
||||
pub const ExtrinsicBaseWeight: Weight = Weight::from_ref_time(constants::WEIGHT_REF_TIME_PER_NANOS).saturating_mul(125_000);
|
||||
/// Importing a block with 0 Extrinsics.
|
||||
pub const BlockExecutionWeight: Weight = Weight::from_ref_time(constants::WEIGHT_REF_TIME_PER_NANOS)
|
||||
.saturating_mul(5_000_000);
|
||||
/// Executing a NO-OP `System::remarks` Extrinsic.
|
||||
pub const ExtrinsicBaseWeight: Weight = Weight::from_ref_time(constants::WEIGHT_REF_TIME_PER_NANOS)
|
||||
.saturating_mul(125_000);
|
||||
|
||||
pub BlockWeights: limits::BlockWeights = limits::BlockWeights::builder()
|
||||
.base_block(BlockExecutionWeight::get())
|
||||
|
||||
Reference in New Issue
Block a user