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

Commit

Permalink
disabled proof size in pre-charging (#153)
Browse files Browse the repository at this point in the history
* disabled proof size, because we can't to do a proper reset later

* Fixed comments

* updated comment

* fixed fmt
  • Loading branch information
akorchyn authored May 26, 2023
1 parent 4b84ac0 commit 05f125b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion chain-extensions/xvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -86,6 +89,7 @@ where
pallet_xvm::Pallet::<T>::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 {
Expand Down

0 comments on commit 05f125b

Please # to comment.