Adapt pallet-contracts to WeightV2 (#12421)

* Replace contract access weight by proper PoV component

* Return the whole weight struct from dry-runs

* Fixup `seal_call` and `seal_instantiate`

* Fix duplicate extrinsics

* Remove ContractAccessWeight from runtime

* Fix doc link

* Remove leftover debugging output
This commit is contained in:
Alexander Theißen
2022-10-05 13:10:20 +02:00
committed by GitHub
parent 8f048cf522
commit b135a0fae4
8 changed files with 96 additions and 211 deletions
@@ -228,16 +228,11 @@ impl<T: Config> Token<T> for CodeToken {
// contract code. This is why we subtract `T::*::(0)`. We need to do this at this
// point because when charging the general weight for calling the contract we not know the
// size of the contract.
let ref_time_weight = match *self {
match *self {
Reinstrument(len) => T::WeightInfo::reinstrument(len),
Load(len) => {
let computation = T::WeightInfo::call_with_code_per_byte(len)
.saturating_sub(T::WeightInfo::call_with_code_per_byte(0));
let bandwidth = T::ContractAccessWeight::get().saturating_mul(len as u64);
computation.max(bandwidth)
},
};
ref_time_weight
Load(len) => T::WeightInfo::call_with_code_per_byte(len)
.saturating_sub(T::WeightInfo::call_with_code_per_byte(0))
.set_proof_size(len.into()),
}
}
}