From 05f125b23f36aa68f6606c07a686b6227587e6e5 Mon Sep 17 00:00:00 2001 From: Artur Yurii Korchynskyi <42449190+akorchyn@users.noreply.github.com> Date: Fri, 26 May 2023 16:39:11 +0300 Subject: [PATCH] disabled proof size in pre-charging (#153) * disabled proof size, because we can't to do a proper reset later * Fixed comments * updated comment * fixed fmt --- chain-extensions/xvm/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/chain-extensions/xvm/src/lib.rs b/chain-extensions/xvm/src/lib.rs index 0f96fbb6..851271c1 100644 --- a/chain-extensions/xvm/src/lib.rs +++ b/chain-extensions/xvm/src/lib.rs @@ -68,7 +68,10 @@ where XvmFuncId::XvmCall => { // We need to immediately charge for the worst case scenario. Gas equals Weight in pallet-contracts context. let remaining_weight = env.ext().gas_meter().gas_left(); - let charged_weight = env.charge_weight(remaining_weight)?; + // We don't track used proof size, so we can't refund after. + // So we will charge a 32KB dummy value as a temporary replacement. + let charged_weight = + env.charge_weight(remaining_weight.set_proof_size(32 * 1024))?; let caller = env.ext().caller().clone(); @@ -86,6 +89,7 @@ where pallet_xvm::Pallet::::xvm_bare_call(xvm_context, caller, to, input); let actual_weight = pallet_xvm::consumed_weight(&call_result); + // TODO: implement proof of size refund. env.adjust_weight(charged_weight, Weight::from_ref_time(actual_weight)); match call_result {