Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Revert default proof size back to 64 KB #7115

Merged
merged 5 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion runtime/kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,12 @@ impl pallet_xcm::Config for Runtime {

#[test]
fn karura_liquid_staking_xcm_has_sane_weight_upper_limt() {
use frame_support::dispatch::GetDispatchInfo;
use parity_scale_codec::Decode;
use xcm::VersionedXcm;
use xcm_executor::traits::WeightBounds;

// should be [WithdrawAsset, BuyExecution, Transact, RefundSurplus, DepositAsset]
let blob = hex_literal::hex!("02140004000000000700e40b540213000000000700e40b54020006010700c817a804341801000006010b00c490bf4302140d010003ffffffff000100411f");
let Ok(VersionedXcm::V2(old_xcm)) =
VersionedXcm::<super::RuntimeCall>::decode(&mut &blob[..]) else { panic!("can't decode XCM blob") };
Expand All @@ -441,5 +444,21 @@ fn karura_liquid_staking_xcm_has_sane_weight_upper_limt() {
let weight = <XcmConfig as xcm_executor::Config>::Weigher::weight(&mut xcm)
.expect("weighing XCM failed");

assert_eq!(weight, Weight::from_parts(20_313_281_000, 0));
// Test that the weigher gives us a sensible weight
assert_eq!(weight, Weight::from_parts(20_313_281_000, 65536));

let Some(Transact { require_weight_at_most, call, .. }) =
xcm.inner_mut().into_iter().find(|inst| matches!(inst, Transact { .. })) else {
panic!("no Transact instruction found")
};
// should be pallet_utility.as_derivative { index: 0, call: pallet_staking::bond_extra { max_additional: 2490000000000 } }
let message_call = call.take_decoded().expect("can't decode Transact call");
let call_weight = message_call.get_dispatch_info().weight;
// Ensure that the Transact instruction is giving a sensible `require_weight_at_most` value
assert!(
call_weight.all_lte(*require_weight_at_most),
"call weight ({:?}) was not less than or equal to require_weight_at_most ({:?})",
call_weight,
require_weight_at_most
);
}
4 changes: 2 additions & 2 deletions xcm/src/v3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1191,9 +1191,9 @@ impl<Call> TryFrom<OldXcm<Call>> for Xcm<Call> {
}
}

/// Default value for the proof size weight component. Set at 0 KB.
/// Default value for the proof size weight component when converting from V2. Set at 64 KB.
/// NOTE: Make sure this is removed after we properly account for PoV weights.
const DEFAULT_PROOF_SIZE: u64 = 0;
const DEFAULT_PROOF_SIZE: u64 = 64 * 1024;

// Convert from a v2 instruction to a v3 instruction.
impl<Call> TryFrom<OldInstruction<Call>> for Instruction<Call> {
Expand Down