mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 06:21:11 +00:00
Deprecate Weight::from_{ref_time, proof_size} (#13475)
* Deprecate Weight::from_{ref_time, proof_size}
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
* Update templates
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
* Use from_parts
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
* Use from_parts
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
* Dont revert comment 🤦
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet_balances
* Update weight files
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
* More fixes
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
* Adapt to Master changes
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
---------
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: command-bot <>
This commit is contained in:
committed by
GitHub
parent
7981d4aa59
commit
9e56e1acdd
@@ -275,19 +275,19 @@ mod tests {
|
||||
struct SimpleToken(u64);
|
||||
impl Token<Test> for SimpleToken {
|
||||
fn weight(&self) -> Weight {
|
||||
Weight::from_ref_time(self.0)
|
||||
Weight::from_parts(self.0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let gas_meter = GasMeter::<Test>::new(Weight::from_ref_time(50000));
|
||||
assert_eq!(gas_meter.gas_left(), Weight::from_ref_time(50000));
|
||||
let gas_meter = GasMeter::<Test>::new(Weight::from_parts(50000, 0));
|
||||
assert_eq!(gas_meter.gas_left(), Weight::from_parts(50000, 0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tracing() {
|
||||
let mut gas_meter = GasMeter::<Test>::new(Weight::from_ref_time(50000));
|
||||
let mut gas_meter = GasMeter::<Test>::new(Weight::from_parts(50000, 0));
|
||||
assert!(!gas_meter.charge(SimpleToken(1)).is_err());
|
||||
|
||||
let mut tokens = gas_meter.tokens().iter();
|
||||
@@ -304,7 +304,7 @@ mod tests {
|
||||
// Make sure that the gas meter does not charge in case of overcharger
|
||||
#[test]
|
||||
fn overcharge_does_not_charge() {
|
||||
let mut gas_meter = GasMeter::<Test>::new(Weight::from_ref_time(200));
|
||||
let mut gas_meter = GasMeter::<Test>::new(Weight::from_parts(200, 0));
|
||||
|
||||
// The first charge is should lead to OOG.
|
||||
assert!(gas_meter.charge(SimpleToken(300)).is_err());
|
||||
@@ -317,7 +317,7 @@ mod tests {
|
||||
// possible.
|
||||
#[test]
|
||||
fn charge_exact_amount() {
|
||||
let mut gas_meter = GasMeter::<Test>::new(Weight::from_ref_time(25));
|
||||
let mut gas_meter = GasMeter::<Test>::new(Weight::from_parts(25, 0));
|
||||
assert!(!gas_meter.charge(SimpleToken(25)).is_err());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ impl ChainExtension<Test> for TestExtension {
|
||||
},
|
||||
2 => {
|
||||
let mut env = env.buf_in_buf_out();
|
||||
let weight = Weight::from_ref_time(env.read(5)?[4].into());
|
||||
let weight = Weight::from_parts(env.read(5)?[4].into(), 0);
|
||||
env.charge_weight(weight)?;
|
||||
Ok(RetVal::Converging(id))
|
||||
},
|
||||
@@ -705,7 +705,7 @@ fn run_out_of_gas() {
|
||||
RuntimeOrigin::signed(ALICE),
|
||||
addr, // newly created account
|
||||
0,
|
||||
Weight::from_ref_time(1_000_000_000_000).set_proof_size(u64::MAX),
|
||||
Weight::from_parts(1_000_000_000_000, u64::MAX),
|
||||
None,
|
||||
vec![],
|
||||
),
|
||||
@@ -2115,7 +2115,7 @@ fn lazy_removal_partial_remove_works() {
|
||||
|
||||
// We create a contract with some extra keys above the weight limit
|
||||
let extra_keys = 7u32;
|
||||
let weight_limit = Weight::from_ref_time(5_000_000_000);
|
||||
let weight_limit = Weight::from_parts(5_000_000_000, 0);
|
||||
let (_, max_keys) = ContractInfo::<Test>::deletion_budget(1, weight_limit);
|
||||
let vals: Vec<_> = (0..max_keys + extra_keys)
|
||||
.map(|i| (blake2_256(&i.encode()), (i as u32), (i as u32).encode()))
|
||||
|
||||
@@ -282,7 +282,7 @@ impl RuntimeCosts {
|
||||
fn token<T: Config>(&self, s: &HostFnWeights<T>) -> RuntimeToken {
|
||||
use self::RuntimeCosts::*;
|
||||
let weight = match *self {
|
||||
MeteringBlock(amount) => s.gas.saturating_add(Weight::from_ref_time(amount)),
|
||||
MeteringBlock(amount) => s.gas.saturating_add(Weight::from_parts(amount, 0)),
|
||||
CopyFromContract(len) => s.return_per_byte.saturating_mul(len.into()),
|
||||
CopyToContract(len) => s.input_per_byte.saturating_mul(len.into()),
|
||||
Caller => s.caller,
|
||||
@@ -903,7 +903,7 @@ impl<'a, E: Ext + 'a> Runtime<'a, E> {
|
||||
self.charge_gas(RuntimeCosts::CallSurchargeTransfer)?;
|
||||
}
|
||||
self.ext.call(
|
||||
Weight::from_ref_time(gas),
|
||||
Weight::from_parts(gas, 0),
|
||||
callee,
|
||||
value,
|
||||
input_data,
|
||||
@@ -958,7 +958,7 @@ impl<'a, E: Ext + 'a> Runtime<'a, E> {
|
||||
salt_ptr: u32,
|
||||
salt_len: u32,
|
||||
) -> Result<ReturnCode, TrapReason> {
|
||||
let gas = Weight::from_ref_time(gas);
|
||||
let gas = Weight::from_parts(gas, 0);
|
||||
self.charge_gas(RuntimeCosts::InstantiateBase { input_data_len, salt_len })?;
|
||||
let value: BalanceOf<<E as Ext>::T> = self.read_sandbox_memory_as(memory, value_ptr)?;
|
||||
if value > 0u32.into() {
|
||||
@@ -1802,7 +1802,7 @@ pub mod env {
|
||||
out_ptr: u32,
|
||||
out_len_ptr: u32,
|
||||
) -> Result<(), TrapReason> {
|
||||
let gas = Weight::from_ref_time(gas);
|
||||
let gas = Weight::from_parts(gas, 0);
|
||||
ctx.charge_gas(RuntimeCosts::WeightToFee)?;
|
||||
Ok(ctx.write_sandbox_output(
|
||||
memory,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user