mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 20:21:06 +00:00
Add storage size component to weights (#12277)
* Add storage size component to weights * Rename storage_size to proof_size * Update primitives/weights/src/weight_v2.rs Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fixes * cargo fmt * Implement custom Decode and CompactAs * Add missing import * Fixes * Remove CompactAs implementation * Properly migrate from 1D weight * Remove #[pallet::compact] from Weight parameters * More #[pallet::compact] removals * Add unit tests * Set appropriate default block proof size * cargo fmt * Remove nonsensical weight constant * Test only for the reference time weight in frame_system::limits * Only check for reference time weight on idle * Use destructuring syntax * Update test expectations * Fixes * Fixes * Fixes * Correctly migrate from 1D weights * cargo fmt * Migrate using extra extrinsics instead of custom Decode * Fixes * Silence dispatch call warnings that were previously allowed * Fix gas_left test * Use OldWeight instead of u64 * Fixes * Only check for reference time weight in election provider * Fix test expectations * Fix test expectations * Use only reference time weight in grandpa test * Use only reference time weight in examples test * Use only reference time weight in examples test * Fix test expectations Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Alexander Theißen <alex.theissen@me.com>
This commit is contained in:
@@ -1008,8 +1008,10 @@ pub mod pallet {
|
||||
// unlikely to ever return an error: if phase is signed, snapshot will exist.
|
||||
let size = Self::snapshot_metadata().ok_or(Error::<T>::MissingSnapshotMetadata)?;
|
||||
|
||||
// TODO: account for proof size weight
|
||||
ensure!(
|
||||
Self::solution_weight_of(&raw_solution, size).all_lt(T::SignedMaxWeight::get()),
|
||||
Self::solution_weight_of(&raw_solution, size).ref_time() <
|
||||
T::SignedMaxWeight::get().ref_time(),
|
||||
Error::<T>::SignedTooMuchWeight,
|
||||
);
|
||||
|
||||
@@ -2336,8 +2338,9 @@ mod tests {
|
||||
};
|
||||
|
||||
let mut active = 1;
|
||||
while weight_with(active)
|
||||
.all_lte(<Runtime as frame_system::Config>::BlockWeights::get().max_block) ||
|
||||
// TODO: account for proof size weight
|
||||
while weight_with(active).ref_time() <=
|
||||
<Runtime as frame_system::Config>::BlockWeights::get().max_block.ref_time() ||
|
||||
active == all_voters
|
||||
{
|
||||
active += 1;
|
||||
|
||||
@@ -638,7 +638,8 @@ impl<T: MinerConfig> Miner<T> {
|
||||
};
|
||||
|
||||
let next_voters = |current_weight: Weight, voters: u32, step: u32| -> Result<u32, ()> {
|
||||
if current_weight.all_lt(max_weight) {
|
||||
// TODO: account for proof size weight
|
||||
if current_weight.ref_time() < max_weight.ref_time() {
|
||||
let next_voters = voters.checked_add(step);
|
||||
match next_voters {
|
||||
Some(voters) if voters < max_voters => Ok(voters),
|
||||
@@ -673,7 +674,8 @@ impl<T: MinerConfig> Miner<T> {
|
||||
|
||||
// Time to finish. We might have reduced less than expected due to rounding error. Increase
|
||||
// one last time if we have any room left, the reduce until we are sure we are below limit.
|
||||
while voters < max_voters && weight_with(voters + 1).all_lt(max_weight) {
|
||||
// TODO: account for proof size weight
|
||||
while voters < max_voters && weight_with(voters + 1).ref_time() < max_weight.ref_time() {
|
||||
voters += 1;
|
||||
}
|
||||
while voters.checked_sub(1).is_some() && weight_with(voters).any_gt(max_weight) {
|
||||
@@ -681,8 +683,9 @@ impl<T: MinerConfig> Miner<T> {
|
||||
}
|
||||
|
||||
let final_decision = voters.min(size.voters);
|
||||
// TODO: account for proof size weight
|
||||
debug_assert!(
|
||||
weight_with(final_decision).all_lte(max_weight),
|
||||
weight_with(final_decision).ref_time() <= max_weight.ref_time(),
|
||||
"weight_with({}) <= {}",
|
||||
final_decision,
|
||||
max_weight,
|
||||
|
||||
Reference in New Issue
Block a user