mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 07:47:57 +00:00
[contracts] Adapt storage reading host functions to Weights V2 (#12976)
* update RuntimeCosts to Weights V2, update tests * improve docs * clearer naming and docs to compat_weight helper * Apply suggestions from code review Co-authored-by: Alexander Theißen <alex.theissen@me.com> * save before master merge * HostFnWeights to Weight * added to_weight! macro * Apply suggestions from code review Co-authored-by: Alexander Theißen <alex.theissen@me.com> * RuntimeCosts::ChainExtension to weight_v2 * chain extension to weight v2 Co-authored-by: Alexander Theißen <alex.theissen@me.com>
This commit is contained in:
@@ -381,7 +381,7 @@ pub mod pallet {
|
||||
{
|
||||
/// Deprecated version if [`Self::call`] for use in an in-storage `Call`.
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(T::WeightInfo::call().saturating_add(<Pallet<T>>::compat_weight(*gas_limit)))]
|
||||
#[pallet::weight(T::WeightInfo::call().saturating_add(<Pallet<T>>::compat_weight_limit(*gas_limit)))]
|
||||
#[allow(deprecated)]
|
||||
#[deprecated(note = "1D weight is used in this extrinsic, please migrate to `call`")]
|
||||
pub fn call_old_weight(
|
||||
@@ -396,7 +396,7 @@ pub mod pallet {
|
||||
origin,
|
||||
dest,
|
||||
value,
|
||||
<Pallet<T>>::compat_weight(gas_limit),
|
||||
<Pallet<T>>::compat_weight_limit(gas_limit),
|
||||
storage_deposit_limit,
|
||||
data,
|
||||
)
|
||||
@@ -406,7 +406,7 @@ pub mod pallet {
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(
|
||||
T::WeightInfo::instantiate_with_code(code.len() as u32, data.len() as u32, salt.len() as u32)
|
||||
.saturating_add(<Pallet<T>>::compat_weight(*gas_limit))
|
||||
.saturating_add(<Pallet<T>>::compat_weight_limit(*gas_limit))
|
||||
)]
|
||||
#[allow(deprecated)]
|
||||
#[deprecated(
|
||||
@@ -424,7 +424,7 @@ pub mod pallet {
|
||||
Self::instantiate_with_code(
|
||||
origin,
|
||||
value,
|
||||
<Pallet<T>>::compat_weight(gas_limit),
|
||||
<Pallet<T>>::compat_weight_limit(gas_limit),
|
||||
storage_deposit_limit,
|
||||
code,
|
||||
data,
|
||||
@@ -435,7 +435,7 @@ pub mod pallet {
|
||||
/// Deprecated version if [`Self::instantiate`] for use in an in-storage `Call`.
|
||||
#[pallet::call_index(2)]
|
||||
#[pallet::weight(
|
||||
T::WeightInfo::instantiate(data.len() as u32, salt.len() as u32).saturating_add(<Pallet<T>>::compat_weight(*gas_limit))
|
||||
T::WeightInfo::instantiate(data.len() as u32, salt.len() as u32).saturating_add(<Pallet<T>>::compat_weight_limit(*gas_limit))
|
||||
)]
|
||||
#[allow(deprecated)]
|
||||
#[deprecated(note = "1D weight is used in this extrinsic, please migrate to `instantiate`")]
|
||||
@@ -451,7 +451,7 @@ pub mod pallet {
|
||||
Self::instantiate(
|
||||
origin,
|
||||
value,
|
||||
<Pallet<T>>::compat_weight(gas_limit),
|
||||
<Pallet<T>>::compat_weight_limit(gas_limit),
|
||||
storage_deposit_limit,
|
||||
code_hash,
|
||||
data,
|
||||
@@ -1216,12 +1216,12 @@ impl<T: Config> Pallet<T> {
|
||||
<T::Currency as Inspect<AccountIdOf<T>>>::minimum_balance()
|
||||
}
|
||||
|
||||
/// Convert a 1D Weight to a 2D weight.
|
||||
/// Convert gas_limit from 1D Weight to a 2D Weight.
|
||||
///
|
||||
/// Used by backwards compatible extrinsics. We cannot just set the proof to zero
|
||||
/// or an old `Call` will just fail.
|
||||
fn compat_weight(gas_limit: OldWeight) -> Weight {
|
||||
Weight::from(gas_limit).set_proof_size(u64::from(T::MaxCodeLen::get()) * 2)
|
||||
/// Used by backwards compatible extrinsics. We cannot just set the proof_size weight limit to
|
||||
/// zero or an old `Call` will just fail with OutOfGas.
|
||||
fn compat_weight_limit(gas_limit: OldWeight) -> Weight {
|
||||
Weight::from_parts(gas_limit.0, u64::from(T::MaxCodeLen::get()) * 2)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user