chore: regenerate umbrella crate, fix feature propagation

This commit is contained in:
2025-12-16 11:28:32 +03:00
parent dd6d48f528
commit 620b0e3aa0
1358 changed files with 9464 additions and 7656 deletions
@@ -26,9 +26,9 @@ use pezframe_support::{
BoundedVec,
};
use pezframe_system::RawOrigin;
use rand::{prelude::SliceRandom, rngs::SmallRng, SeedableRng};
use pezsp_arithmetic::{per_things::Percent, traits::One};
use pezsp_runtime::InnerOf;
use rand::{prelude::SliceRandom, rngs::SmallRng, SeedableRng};
use crate::{unsigned::IndexAssignmentOf, *};
@@ -252,7 +252,9 @@ mod benchmarks {
#[block]
{
Pezpallet::<T>::finalize_signed_phase_accept_solution(ready, &receiver, deposit, call_fee);
Pezpallet::<T>::finalize_signed_phase_accept_solution(
ready, &receiver, deposit, call_fee,
);
}
assert_eq!(T::Currency::free_balance(&receiver), initial_balance + reward + call_fee);
@@ -330,8 +332,9 @@ mod benchmarks {
let witness = SolutionOrSnapshotSize { voters: v, targets: t };
let raw_solution = solution_with_size::<T>(witness, a, d)?;
let ready_solution = Pezpallet::<T>::feasibility_check(raw_solution, ElectionCompute::Signed)
.map_err(<&str>::from)?;
let ready_solution =
Pezpallet::<T>::feasibility_check(raw_solution, ElectionCompute::Signed)
.map_err(<&str>::from)?;
CurrentPhase::<T>::put(Phase::Signed);
// Assume a queued solution is stored, regardless of where it comes from.
QueuedSolution::<T>::put(ready_solution);
@@ -396,8 +399,10 @@ mod benchmarks {
};
let caller = pezframe_benchmarking::whitelisted_caller();
let deposit =
Pezpallet::<T>::deposit_for(&solution, SnapshotMetadata::<T>::get().unwrap_or_default());
let deposit = Pezpallet::<T>::deposit_for(
&solution,
SnapshotMetadata::<T>::get().unwrap_or_default(),
);
T::Currency::make_free_balance_be(
&caller,
T::Currency::minimum_balance() * 1000u32.into() + deposit,
@@ -406,7 +411,9 @@ mod benchmarks {
#[extrinsic_call]
_(RawOrigin::Signed(caller), Box::new(solution));
assert!(Pezpallet::<T>::signed_submissions().len() as u32 == T::SignedMaxSubmissions::get());
assert!(
Pezpallet::<T>::signed_submissions().len() as u32 == T::SignedMaxSubmissions::get()
);
Ok(())
}
@@ -23,10 +23,10 @@
//! ## Phases
//!
//! The timeline of pezpallet is as follows. At each block,
//! [`pezframe_election_provider_support::ElectionDataProvider::next_election_prediction`] is used to
//! estimate the time remaining to the next call to
//! [`pezframe_election_provider_support::ElectionProvider::elect`]. Based on this, a phase is chosen.
//! The timeline is as follows.
//! [`pezframe_election_provider_support::ElectionDataProvider::next_election_prediction`] is used
//! to estimate the time remaining to the next call to
//! [`pezframe_election_provider_support::ElectionProvider::elect`]. Based on this, a phase is
//! chosen. The timeline is as follows.
//!
//! ```ignore
//! elect()
@@ -39,7 +39,8 @@
//! `next_election_prediction`, but only ends when a call to [`ElectionProvider::elect`] happens. If
//! no `elect` happens, the signed phase is extended.
//!
//! > Given this, it is rather important for the user of this pezpallet to ensure it always terminates
//! > Given this, it is rather important for the user of this pezpallet to ensure it always
//! > terminates
//! election via `elect` before requesting a new one.
//!
//! Each of the phases can be disabled by essentially setting their length to zero. If both phases
@@ -67,11 +68,11 @@
//! origin can not bail out in any way, if their solution is queued.
//!
//! Upon the end of the signed phase, the solutions are examined from best to worse (i.e. `pop()`ed
//! until drained). Each solution undergoes an expensive `Pezpallet::feasibility_check`, which ensures
//! the score claimed by this score was correct, and it is valid based on the election data (i.e.
//! votes and targets). At each step, if the current best solution passes the feasibility check,
//! it is considered to be the best one. The sender of the origin is rewarded, and the rest of the
//! queued solutions get their deposit back and are discarded, without being checked.
//! until drained). Each solution undergoes an expensive `Pezpallet::feasibility_check`, which
//! ensures the score claimed by this score was correct, and it is valid based on the election data
//! (i.e. votes and targets). At each step, if the current best solution passes the feasibility
//! check, it is considered to be the best one. The sender of the origin is rewarded, and the rest
//! of the queued solutions get their deposit back and are discarded, without being checked.
//!
//! The following example covers all of the cases at the end of the signed phase:
//!
@@ -124,13 +125,13 @@
//! provided
//! 2. Any other unforeseen internal error
//!
//! A call to `T::ElectionProvider::elect` is made, and `Ok(_)` cannot be returned, then the pezpallet
//! proceeds to the [`Phase::Emergency`]. During this phase, any solution can be submitted from
//! [`Config::ForceOrigin`], without any checking, via [`Pezpallet::set_emergency_election_result`]
//! transaction. Hence, `[`Config::ForceOrigin`]` should only be set to a trusted origin, such as
//! the council or root. Once submitted, the forced solution is kept in [`QueuedSolution`] until the
//! next call to `T::ElectionProvider::elect`, where it is returned and [`Phase`] goes back to
//! `Off`.
//! A call to `T::ElectionProvider::elect` is made, and `Ok(_)` cannot be returned, then the
//! pezpallet proceeds to the [`Phase::Emergency`]. During this phase, any solution can be submitted
//! from [`Config::ForceOrigin`], without any checking, via
//! [`Pezpallet::set_emergency_election_result`] transaction. Hence, `[`Config::ForceOrigin`]`
//! should only be set to a trusted origin, such as the council or root. Once submitted, the forced
//! solution is kept in [`QueuedSolution`] until the next call to `T::ElectionProvider::elect`,
//! where it is returned and [`Phase`] goes back to `Off`.
//!
//! This implies that the user of this pezpallet (i.e. a staking pezpallet) should re-try calling
//! `T::ElectionProvider::elect` in case of error, until `OK(_)` is returned.
@@ -172,8 +173,8 @@
//!
//! ## Error types
//!
//! This pezpallet provides a verbose error system to ease future debugging and debugging. The overall
//! hierarchy of errors is as follows:
//! This pezpallet provides a verbose error system to ease future debugging and debugging. The
//! overall hierarchy of errors is as follows:
//!
//! 1. [`pezpallet::Error`]: These are the errors that can be returned in the dispatchables of the
//! pezpallet, either signed or unsigned. Since decomposition with nested enums is not possible
@@ -192,8 +193,8 @@
//! ## Multi-page election support
//!
//! The [`pezframe_election_provider_support::ElectionDataProvider`] and
//! [`pezframe_election_provider_support::ElectionProvider`] traits used by this pezpallet can support a
//! multi-page election.
//! [`pezframe_election_provider_support::ElectionProvider`] traits used by this pezpallet can
//! support a multi-page election.
//!
//! However, this pezpallet only supports single-page election and data
//! provider and all the relevant trait implementation and configurations reflect that assumption.
@@ -206,11 +207,11 @@
//! **Emergency-phase recovery script**: This script should be taken out of staking-miner in
//! pezkuwi and ideally live in `bizinikiwi/utils/pezframe/elections`.
//!
//! **Challenge Phase**. We plan on adding a third phase to the pezpallet, called the challenge phase.
//! This is a phase in which no further solutions are processed, and the current best solution might
//! be challenged by anyone (signed or unsigned). The main plan here is to enforce the solution to
//! be PJR. Checking PJR on-chain is quite expensive, yet proving that a solution is **not** PJR is
//! rather cheap. If a queued solution is successfully proven bad:
//! **Challenge Phase**. We plan on adding a third phase to the pezpallet, called the challenge
//! phase. This is a phase in which no further solutions are processed, and the current best
//! solution might be challenged by anyone (signed or unsigned). The main plan here is to enforce
//! the solution to be PJR. Checking PJR on-chain is quite expensive, yet proving that a solution is
//! **not** PJR is rather cheap. If a queued solution is successfully proven bad:
//!
//! 1. We must surely slash whoever submitted that solution (might be a challenge for unsigned
//! solutions).
@@ -258,7 +259,6 @@ use pezframe_support::{
DefaultNoBound, EqNoBound, PartialEqNoBound,
};
use pezframe_system::{ensure_none, offchain::CreateBare, pezpallet_prelude::BlockNumberFor};
use scale_info::TypeInfo;
use pezsp_arithmetic::{
traits::{CheckedAdd, Zero},
UpperOf,
@@ -271,6 +271,7 @@ use pezsp_runtime::{
},
DispatchError, ModuleError, PerThing, Perbill, RuntimeDebug, SaturatedConversion,
};
use scale_info::TypeInfo;
#[cfg(feature = "try-runtime")]
use pezsp_runtime::TryRuntimeError;
@@ -576,8 +577,8 @@ pub enum FeasibilityError {
WrongWinnerCount,
/// The snapshot is not available.
///
/// Kinda defensive: The pezpallet should technically never attempt to do a feasibility check when
/// no snapshot is present.
/// Kinda defensive: The pezpallet should technically never attempt to do a feasibility check
/// when no snapshot is present.
SnapshotUnavailable,
/// Internal error from the election crate.
NposElection(pezsp_npos_elections::Error),
@@ -1008,8 +1009,8 @@ pub mod pezpallet {
Ok(())
}
/// Set a solution in the queue, to be handed out to the client of this pezpallet in the next
/// call to `ElectionProvider::elect`.
/// Set a solution in the queue, to be handed out to the client of this pezpallet in the
/// next call to `ElectionProvider::elect`.
///
/// This can only be set by `T::ForceOrigin`, and only when the phase is `Emergency`.
///
@@ -17,6 +17,8 @@
use super::*;
use crate::{self as multi_phase, signed::GeometricDepositBase, unsigned::MinerConfig};
use multi_phase::unsigned::{IndexAssignmentOf, VoterOf};
use parking_lot::RwLock;
use pezframe_election_provider_support::{
bounds::{DataProviderBounds, ElectionBounds, ElectionBoundsBuilder},
data_provider, onchain, ElectionDataProvider, NposSolution, SequentialPhragmen,
@@ -28,8 +30,6 @@ use pezframe_support::{
weights::{constants, Weight},
BoundedVec,
};
use multi_phase::unsigned::{IndexAssignmentOf, VoterOf};
use parking_lot::RwLock;
use pezsp_core::{
offchain::{
testing::{PoolState, TestOffchainExt, TestTransactionPoolExt},
@@ -680,7 +680,9 @@ impl ExtBuilder {
#[cfg(feature = "try-runtime")]
ext.execute_with(|| {
pezframe_support::assert_ok!(
<MultiPhase as pezframe_support::traits::Hooks<u64>>::try_state(System::block_number())
<MultiPhase as pezframe_support::traits::Hooks<u64>>::try_state(
System::block_number()
)
);
});
}
@@ -33,10 +33,10 @@ use pezframe_support::{
traits::Get,
weights::constants::{WEIGHT_PROOF_SIZE_PER_MB, WEIGHT_REF_TIME_PER_SECOND},
};
use remote_externalities::{Builder, Mode, OnlineConfig, Transport};
use pezsp_core::{ConstU32, H256};
use pezsp_npos_elections::BalancingConfig;
use pezsp_runtime::{Perbill, Weight};
use remote_externalities::{Builder, Mode, OnlineConfig, Transport};
pub mod pezkuwi {
use super::*;
@@ -35,7 +35,6 @@ use pezframe_system::{
offchain::{CreateBare, SubmitTransaction},
pezpallet_prelude::BlockNumberFor,
};
use scale_info::TypeInfo;
use pezsp_npos_elections::{
assignment_ratio_to_staked_normalized, assignment_staked_to_ratio_normalized, ElectionResult,
ElectionScore, EvaluateSupport,
@@ -44,6 +43,7 @@ use pezsp_runtime::{
offchain::storage::{MutateStorageError, StorageValueRef},
DispatchError, SaturatedConversion,
};
use scale_info::TypeInfo;
/// Storage key used to store the last block number at which offchain worker ran.
pub(crate) const OFFCHAIN_LAST_BLOCK: &[u8] = b"parity/multi-phase-unsigned-election";
@@ -64,12 +64,15 @@ pub type MinerVoterOf<T> = pezframe_election_provider_support::Voter<
>;
/// The relative distribution of a voter's stake among the winning targets.
pub type Assignment<T> =
pezsp_npos_elections::Assignment<<T as pezframe_system::Config>::AccountId, SolutionAccuracyOf<T>>;
pub type Assignment<T> = pezsp_npos_elections::Assignment<
<T as pezframe_system::Config>::AccountId,
SolutionAccuracyOf<T>,
>;
/// The [`IndexAssignment`][pezframe_election_provider_support::IndexAssignment] type specialized for a
/// particular runtime `T`.
pub type IndexAssignmentOf<T> = pezframe_election_provider_support::IndexAssignmentOf<SolutionOf<T>>;
/// The [`IndexAssignment`][pezframe_election_provider_support::IndexAssignment] type specialized
/// for a particular runtime `T`.
pub type IndexAssignmentOf<T> =
pezframe_election_provider_support::IndexAssignmentOf<SolutionOf<T>>;
/// Error type of the pezpallet's [`crate::Config::Solver`].
pub type SolverErrorOf<T> = <<T as Config>::Solver as NposSolver>::Error;
@@ -477,8 +480,8 @@ impl<T: MinerConfig> Miner<T> {
})
}
/// Convert a raw solution from [`pezsp_npos_elections::ElectionResult`] to [`RawSolution`], which
/// is ready to be submitted to the chain.
/// Convert a raw solution from [`pezsp_npos_elections::ElectionResult`] to [`RawSolution`],
/// which is ready to be submitted to the chain.
///
/// Will always reduce the solution as well.
pub fn prepare_election_result_with_snapshot<Accuracy: PerThing128>(