Revert default proof size back to 64 KB (#7115)

* Revert default proof size back to 64 KB

* Fix test expectations

* Enhance unit test

* cargo fmt

* Fix comment
This commit is contained in:
Keith Yeung
2023-04-24 20:24:44 +08:00
committed by GitHub
parent 439ab875dc
commit a8d80532ce
2 changed files with 22 additions and 3 deletions
+20 -1
View File
@@ -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") };
@@ -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
);
}
+2 -2
View File
@@ -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> {