mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-22 13:51:05 +00:00
Weight v1.5: Opaque Struct (#12138)
* initial idea * update frame_support * update a bunch more * add ord * adjust RuntimeDbWeight * frame_system builds * re-export * frame_support tests pass * frame_executive compile * frame_executive builds * frame_system tests passing * pallet-utility tests pass * fix a bunch of pallets * more * phragmen * state-trie-migration * scheduler and referenda * pallet-election-provider-multi-phase * aura * staking * more * babe * balances * bunch more * sudo * transaction-payment * asset-tx-payment * last pallets * fix alliance merge * fix node template runtime * fix pallet-contracts cc @athei * fix node runtime * fix compile on runtime-benchmarks feature * comment * fix frame-support-test * fix more tests * weight regex * frame system works * fix a bunch * more * more * more * more * more * more fixes * update templates * fix contracts benchmarks * Update lib.rs * Update lib.rs * fix ui * make scalar saturating mul const * more const functions * scalar div * refactor using constant functions * move impl * fix overhead template * use compactas * Update lib.rs
This commit is contained in:
@@ -175,7 +175,7 @@ impl ChainExtension<Test> for TestExtension {
|
||||
},
|
||||
0x8002 => {
|
||||
let mut env = env.buf_in_buf_out();
|
||||
let weight = env.read(5)?[4].into();
|
||||
let weight = Weight::from_ref_time(env.read(5)?[4].into());
|
||||
env.charge_weight(weight)?;
|
||||
Ok(RetVal::Converging(id))
|
||||
},
|
||||
@@ -332,7 +332,7 @@ parameter_types! {
|
||||
|
||||
impl Convert<Weight, BalanceOf<Self>> for Test {
|
||||
fn convert(w: Weight) -> BalanceOf<Self> {
|
||||
w
|
||||
w.ref_time()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -355,6 +355,10 @@ impl Contains<Call> for TestFilter {
|
||||
}
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const DeletionWeightLimit: Weight = Weight::from_ref_time(500_000_000_000);
|
||||
}
|
||||
|
||||
impl Config for Test {
|
||||
type Time = Timestamp;
|
||||
type Randomness = Randomness;
|
||||
@@ -368,7 +372,7 @@ impl Config for Test {
|
||||
type ChainExtension =
|
||||
(TestExtension, DisabledExtension, RevertingExtension, TempStorageExtension);
|
||||
type DeletionQueueDepth = ConstU32<1024>;
|
||||
type DeletionWeightLimit = ConstU64<500_000_000_000>;
|
||||
type DeletionWeightLimit = DeletionWeightLimit;
|
||||
type Schedule = MySchedule;
|
||||
type DepositPerByte = DepositPerByte;
|
||||
type DepositPerItem = DepositPerItem;
|
||||
@@ -384,7 +388,7 @@ pub const BOB: AccountId32 = AccountId32::new([2u8; 32]);
|
||||
pub const CHARLIE: AccountId32 = AccountId32::new([3u8; 32]);
|
||||
pub const DJANGO: AccountId32 = AccountId32::new([4u8; 32]);
|
||||
|
||||
pub const GAS_LIMIT: Weight = 100_000_000_000;
|
||||
pub const GAS_LIMIT: Weight = Weight::from_ref_time(100_000_000_000);
|
||||
|
||||
pub struct ExtBuilder {
|
||||
existential_deposit: u64,
|
||||
@@ -642,7 +646,7 @@ fn run_out_of_gas() {
|
||||
Origin::signed(ALICE),
|
||||
addr, // newly created account
|
||||
0,
|
||||
1_000_000_000_000,
|
||||
Weight::from_ref_time(1_000_000_000_000),
|
||||
None,
|
||||
vec![],
|
||||
),
|
||||
@@ -1826,7 +1830,7 @@ fn lazy_removal_works() {
|
||||
assert_matches!(child::get(trie, &[99]), Some(42));
|
||||
|
||||
// Run the lazy removal
|
||||
Contracts::on_idle(System::block_number(), Weight::max_value());
|
||||
Contracts::on_idle(System::block_number(), Weight::MAX);
|
||||
|
||||
// Value should be gone now
|
||||
assert_matches!(child::get::<i32>(trie, &[99]), None);
|
||||
@@ -1896,7 +1900,7 @@ fn lazy_batch_removal_works() {
|
||||
}
|
||||
|
||||
// Run single lazy removal
|
||||
Contracts::on_idle(System::block_number(), Weight::max_value());
|
||||
Contracts::on_idle(System::block_number(), Weight::MAX);
|
||||
|
||||
// The single lazy removal should have removed all queued tries
|
||||
for trie in tries.iter() {
|
||||
@@ -1911,7 +1915,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 = 5_000_000_000;
|
||||
let weight_limit = Weight::from_ref_time(5_000_000_000);
|
||||
let (_, max_keys) = Storage::<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()))
|
||||
@@ -2085,7 +2089,7 @@ fn lazy_removal_does_no_run_on_low_remaining_weight() {
|
||||
assert_matches!(child::get::<i32>(trie, &[99]), Some(42));
|
||||
|
||||
// Run on_idle with max remaining weight, this should remove the value
|
||||
Contracts::on_idle(System::block_number(), Weight::max_value());
|
||||
Contracts::on_idle(System::block_number(), Weight::MAX);
|
||||
|
||||
// Value should be gone
|
||||
assert_matches!(child::get::<i32>(trie, &[99]), None);
|
||||
@@ -2096,7 +2100,7 @@ fn lazy_removal_does_no_run_on_low_remaining_weight() {
|
||||
fn lazy_removal_does_not_use_all_weight() {
|
||||
let (code, hash) = compile_module::<Test>("self_destruct").unwrap();
|
||||
|
||||
let weight_limit = 5_000_000_000;
|
||||
let weight_limit = Weight::from_ref_time(5_000_000_000);
|
||||
let mut ext = ExtBuilder::default().existential_deposit(50).build();
|
||||
|
||||
let (trie, vals, weight_per_key) = ext.execute_with(|| {
|
||||
@@ -2167,7 +2171,7 @@ fn lazy_removal_does_not_use_all_weight() {
|
||||
let weight_used = Storage::<Test>::process_deletion_queue_batch(weight_limit);
|
||||
|
||||
// We have one less key in our trie than our weight limit suffices for
|
||||
assert_eq!(weight_used, weight_limit - weight_per_key);
|
||||
assert_eq!(weight_used, weight_limit - Weight::from_ref_time(weight_per_key));
|
||||
|
||||
// All the keys are removed
|
||||
for val in vals {
|
||||
@@ -2322,7 +2326,7 @@ fn reinstrument_does_charge() {
|
||||
assert!(result2.gas_consumed > result1.gas_consumed);
|
||||
assert_eq!(
|
||||
result2.gas_consumed,
|
||||
result1.gas_consumed + <Test as Config>::WeightInfo::reinstrument(code_len),
|
||||
result1.gas_consumed + <Test as Config>::WeightInfo::reinstrument(code_len).ref_time(),
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -2430,7 +2434,7 @@ fn gas_estimation_nested_call_fixed_limit() {
|
||||
let input: Vec<u8> = AsRef::<[u8]>::as_ref(&addr_callee)
|
||||
.iter()
|
||||
.cloned()
|
||||
.chain((GAS_LIMIT / 5).to_le_bytes())
|
||||
.chain((GAS_LIMIT / 5).ref_time().to_le_bytes())
|
||||
.collect();
|
||||
|
||||
// Call in order to determine the gas that is required for this call
|
||||
@@ -2454,7 +2458,7 @@ fn gas_estimation_nested_call_fixed_limit() {
|
||||
ALICE,
|
||||
addr_caller,
|
||||
0,
|
||||
result.gas_required,
|
||||
Weight::from_ref_time(result.gas_required),
|
||||
Some(result.storage_deposit.charge_or_zero()),
|
||||
input,
|
||||
false,
|
||||
@@ -2524,7 +2528,7 @@ fn gas_estimation_call_runtime() {
|
||||
ALICE,
|
||||
addr_caller,
|
||||
0,
|
||||
result.gas_required,
|
||||
Weight::from_ref_time(result.gas_required),
|
||||
None,
|
||||
call.encode(),
|
||||
false,
|
||||
|
||||
Reference in New Issue
Block a user