mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 14:57:56 +00:00
Fix offchain election to respect the weight (#7215)
* Mockup * Fix offchain election to respect the weight * Fix builds a bit * Update frame/staking/src/offchain_election.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * Update frame/staking/src/offchain_election.rs Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> * Make it build, binary search * Fix a number of grumbles * one more fix. * remove unwrap. * better alg. * Better alg again. * Final fixes * Fix * Rollback to normal * Final touches. * Better tests. * Update frame/staking/src/lib.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Proper maxExtWeight * Final fix * Final fix for the find_voter Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
@@ -17,24 +17,29 @@
|
||||
|
||||
//! Test utilities
|
||||
|
||||
use std::{collections::HashSet, cell::RefCell};
|
||||
use sp_runtime::Perbill;
|
||||
use sp_runtime::curve::PiecewiseLinear;
|
||||
use sp_runtime::traits::{IdentityLookup, Convert, SaturatedConversion, Zero};
|
||||
use sp_runtime::testing::{Header, UintAuthorityId, TestXt};
|
||||
use sp_staking::{SessionIndex, offence::{OffenceDetails, OnOffenceHandler}};
|
||||
use sp_core::H256;
|
||||
use crate::*;
|
||||
use frame_support::{
|
||||
assert_ok, impl_outer_origin, parameter_types, impl_outer_dispatch, impl_outer_event,
|
||||
StorageValue, StorageMap, StorageDoubleMap, IterableStorageMap,
|
||||
traits::{Currency, Get, FindAuthor, OnFinalize, OnInitialize},
|
||||
weights::{Weight, constants::RocksDbWeight},
|
||||
assert_ok, impl_outer_dispatch, impl_outer_event, impl_outer_origin, parameter_types,
|
||||
traits::{Currency, FindAuthor, Get, OnFinalize, OnInitialize},
|
||||
weights::{constants::RocksDbWeight, Weight},
|
||||
IterableStorageMap, StorageDoubleMap, StorageMap, StorageValue,
|
||||
};
|
||||
use sp_core::H256;
|
||||
use sp_io;
|
||||
use sp_npos_elections::{
|
||||
build_support_map, evaluate_support, reduce, ExtendedBalance, StakedAssignment, ElectionScore,
|
||||
build_support_map, evaluate_support, reduce, ElectionScore, ExtendedBalance, StakedAssignment,
|
||||
};
|
||||
use crate::*;
|
||||
use sp_runtime::{
|
||||
curve::PiecewiseLinear,
|
||||
testing::{Header, TestXt, UintAuthorityId},
|
||||
traits::{Convert, IdentityLookup, SaturatedConversion, Zero},
|
||||
Perbill,
|
||||
};
|
||||
use sp_staking::{
|
||||
offence::{OffenceDetails, OnOffenceHandler},
|
||||
SessionIndex,
|
||||
};
|
||||
use std::{cell::RefCell, collections::HashSet};
|
||||
|
||||
pub const INIT_TIMESTAMP: u64 = 30_000;
|
||||
|
||||
@@ -194,7 +199,7 @@ pub struct Test;
|
||||
|
||||
parameter_types! {
|
||||
pub const BlockHashCount: u64 = 250;
|
||||
pub const MaximumBlockWeight: Weight = 1024;
|
||||
pub const MaximumBlockWeight: Weight = frame_support::weights::constants::WEIGHT_PER_SECOND * 2;
|
||||
pub const MaximumBlockLength: u32 = 2 * 1024;
|
||||
pub const AvailableBlockRatio: Perbill = Perbill::one();
|
||||
pub const MaxLocks: u32 = 1024;
|
||||
@@ -293,6 +298,7 @@ parameter_types! {
|
||||
pub const MaxNominatorRewardedPerValidator: u32 = 64;
|
||||
pub const UnsignedPriority: u64 = 1 << 20;
|
||||
pub const MinSolutionScoreBump: Perbill = Perbill::zero();
|
||||
pub const OffchainSolutionWeightLimit: Weight = MaximumBlockWeight::get();
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
@@ -331,10 +337,12 @@ impl Trait for Test {
|
||||
type MinSolutionScoreBump = MinSolutionScoreBump;
|
||||
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
|
||||
type UnsignedPriority = UnsignedPriority;
|
||||
type OffchainSolutionWeightLimit = OffchainSolutionWeightLimit;
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
impl<LocalCall> frame_system::offchain::SendTransactionTypes<LocalCall> for Test where
|
||||
impl<LocalCall> frame_system::offchain::SendTransactionTypes<LocalCall> for Test
|
||||
where
|
||||
Call: From<LocalCall>,
|
||||
{
|
||||
type OverarchingCall = Call;
|
||||
|
||||
Reference in New Issue
Block a user