Deprecate V1 Weights (#13699)

* Remove deprecated pallet calls

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Deprecate old weight

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update Runtime API

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fix tests

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Delete shitty code

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fix doctest

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update frame/alliance/src/lib.rs

Co-authored-by: Koute <koute@users.noreply.github.com>

* Add doc

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* contracts: Use u64 as old weight type

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update frame/contracts/src/lib.rs

Co-authored-by: Alexander Theißen <alex.theissen@me.com>

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Koute <koute@users.noreply.github.com>
Co-authored-by: Alexander Theißen <alex.theissen@me.com>
Co-authored-by: parity-processbot <>
This commit is contained in:
Oliver Tale-Yazdi
2023-04-04 20:57:21 +02:00
committed by GitHub
parent 0766072393
commit 36957d6760
10 changed files with 107 additions and 171 deletions
+14 -5
View File
@@ -370,13 +370,11 @@ mod tests {
gas::GasMeter,
storage::WriteOutcome,
tests::{RuntimeCall, Test, ALICE, BOB},
BalanceOf, CodeHash, Error, Pallet as Contracts,
BalanceOf, CodeHash, Error, OldWeight, Pallet as Contracts,
};
use assert_matches::assert_matches;
use frame_support::{
assert_err, assert_ok,
dispatch::DispatchResultWithPostInfo,
weights::{OldWeight, Weight},
assert_err, assert_ok, dispatch::DispatchResultWithPostInfo, weights::Weight,
};
use pallet_contracts_primitives::{ExecReturnValue, ReturnFlags};
use pretty_assertions::assert_eq;
@@ -1632,13 +1630,24 @@ mod tests {
let output = execute(CODE_GAS_LEFT, vec![], &mut ext).unwrap();
let OldWeight(gas_left) = OldWeight::decode(&mut &*output.data).unwrap();
let gas_left = OldWeight::decode(&mut &*output.data).unwrap();
let actual_left = ext.gas_meter.gas_left();
// TODO: account for proof size weight
assert!(gas_left < gas_limit.ref_time(), "gas_left must be less than initial");
assert!(gas_left > actual_left.ref_time(), "gas_left must be greater than final");
}
/// Test that [`frame_support::weights::OldWeight`] en/decodes the same as our
/// [`crate::OldWeight`].
#[test]
fn old_weight_decode() {
#![allow(deprecated)]
let sp = frame_support::weights::OldWeight(42).encode();
let our = crate::OldWeight::decode(&mut &*sp).unwrap();
assert_eq!(our, 42);
}
const CODE_VALUE_TRANSFERRED: &str = r#"
(module
(import "seal0" "seal_value_transferred" (func $seal_value_transferred (param i32 i32)))