fixed TODOs for weights v2 (#1860)

This commit is contained in:
Svyatoslav Nikolsky
2023-02-07 15:56:48 +03:00
committed by Bastian Köcher
parent 795a049937
commit a5a3f8065f
13 changed files with 35 additions and 96 deletions
+4 -1
View File
@@ -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.
+1 -42
View File
@@ -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)
}
}
+3 -10
View File
@@ -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: (),
}
);