mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 19:07:57 +00:00
More renaming to move away from phragmen. (#6886)
This commit is contained in:
@@ -1300,34 +1300,34 @@ decl_error! {
|
||||
/// Rewards for this era have already been claimed for this validator.
|
||||
AlreadyClaimed,
|
||||
/// The submitted result is received out of the open window.
|
||||
PhragmenEarlySubmission,
|
||||
OffchainElectionEarlySubmission,
|
||||
/// The submitted result is not as good as the one stored on chain.
|
||||
PhragmenWeakSubmission,
|
||||
OffchainElectionWeakSubmission,
|
||||
/// The snapshot data of the current window is missing.
|
||||
SnapshotUnavailable,
|
||||
/// Incorrect number of winners were presented.
|
||||
PhragmenBogusWinnerCount,
|
||||
OffchainElectionBogusWinnerCount,
|
||||
/// One of the submitted winners is not an active candidate on chain (index is out of range
|
||||
/// in snapshot).
|
||||
PhragmenBogusWinner,
|
||||
OffchainElectionBogusWinner,
|
||||
/// Error while building the assignment type from the compact. This can happen if an index
|
||||
/// is invalid, or if the weights _overflow_.
|
||||
PhragmenBogusCompact,
|
||||
OffchainElectionBogusCompact,
|
||||
/// One of the submitted nominators is not an active nominator on chain.
|
||||
PhragmenBogusNominator,
|
||||
OffchainElectionBogusNominator,
|
||||
/// One of the submitted nominators has an edge to which they have not voted on chain.
|
||||
PhragmenBogusNomination,
|
||||
OffchainElectionBogusNomination,
|
||||
/// One of the submitted nominators has an edge which is submitted before the last non-zero
|
||||
/// slash of the target.
|
||||
PhragmenSlashedNomination,
|
||||
OffchainElectionSlashedNomination,
|
||||
/// A self vote must only be originated from a validator to ONLY themselves.
|
||||
PhragmenBogusSelfVote,
|
||||
OffchainElectionBogusSelfVote,
|
||||
/// The submitted result has unknown edges that are not among the presented winners.
|
||||
PhragmenBogusEdge,
|
||||
OffchainElectionBogusEdge,
|
||||
/// The claimed score does not match with the one computed from the data.
|
||||
PhragmenBogusScore,
|
||||
OffchainElectionBogusScore,
|
||||
/// The election size is invalid.
|
||||
PhragmenBogusElectionSize,
|
||||
OffchainElectionBogusElectionSize,
|
||||
/// The call is not allowed at the given time due to restrictions of election period.
|
||||
CallNotAllowed,
|
||||
/// Incorrect previous history depth input provided.
|
||||
@@ -2542,14 +2542,14 @@ impl<T: Trait> Module<T> {
|
||||
// check window open
|
||||
ensure!(
|
||||
Self::era_election_status().is_open(),
|
||||
Error::<T>::PhragmenEarlySubmission.with_weight(T::DbWeight::get().reads(1)),
|
||||
Error::<T>::OffchainElectionEarlySubmission.with_weight(T::DbWeight::get().reads(1)),
|
||||
);
|
||||
|
||||
// check current era.
|
||||
if let Some(current_era) = Self::current_era() {
|
||||
ensure!(
|
||||
current_era == era,
|
||||
Error::<T>::PhragmenEarlySubmission.with_weight(T::DbWeight::get().reads(2)),
|
||||
Error::<T>::OffchainElectionEarlySubmission.with_weight(T::DbWeight::get().reads(2)),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2557,7 +2557,7 @@ impl<T: Trait> Module<T> {
|
||||
if let Some(queued_score) = Self::queued_score() {
|
||||
ensure!(
|
||||
is_score_better(score, queued_score, T::MinSolutionScoreBump::get()),
|
||||
Error::<T>::PhragmenWeakSubmission.with_weight(T::DbWeight::get().reads(3)),
|
||||
Error::<T>::OffchainElectionWeakSubmission.with_weight(T::DbWeight::get().reads(3)),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -2594,13 +2594,13 @@ impl<T: Trait> Module<T> {
|
||||
// size of the solution must be correct.
|
||||
ensure!(
|
||||
snapshot_validators_length == u32::from(election_size.validators),
|
||||
Error::<T>::PhragmenBogusElectionSize,
|
||||
Error::<T>::OffchainElectionBogusElectionSize,
|
||||
);
|
||||
|
||||
// check the winner length only here and when we know the length of the snapshot validators
|
||||
// length.
|
||||
let desired_winners = Self::validator_count().min(snapshot_validators_length);
|
||||
ensure!(winners.len() as u32 == desired_winners, Error::<T>::PhragmenBogusWinnerCount);
|
||||
ensure!(winners.len() as u32 == desired_winners, Error::<T>::OffchainElectionBogusWinnerCount);
|
||||
|
||||
let snapshot_nominators_len = <SnapshotNominators<T>>::decode_len()
|
||||
.map(|l| l as u32)
|
||||
@@ -2609,7 +2609,7 @@ impl<T: Trait> Module<T> {
|
||||
// rest of the size of the solution must be correct.
|
||||
ensure!(
|
||||
snapshot_nominators_len == election_size.nominators,
|
||||
Error::<T>::PhragmenBogusElectionSize,
|
||||
Error::<T>::OffchainElectionBogusElectionSize,
|
||||
);
|
||||
|
||||
// decode snapshot validators.
|
||||
@@ -2621,7 +2621,7 @@ impl<T: Trait> Module<T> {
|
||||
// NOTE: at the moment, since staking is explicitly blocking any offence until election
|
||||
// is closed, we don't check here if the account id at `snapshot_validators[widx]` is
|
||||
// actually a validator. If this ever changes, this loop needs to also check this.
|
||||
snapshot_validators.get(widx as usize).cloned().ok_or(Error::<T>::PhragmenBogusWinner)
|
||||
snapshot_validators.get(widx as usize).cloned().ok_or(Error::<T>::OffchainElectionBogusWinner)
|
||||
}).collect::<Result<Vec<T::AccountId>, Error<T>>>()?;
|
||||
|
||||
// decode the rest of the snapshot.
|
||||
@@ -2643,7 +2643,7 @@ impl<T: Trait> Module<T> {
|
||||
).map_err(|e| {
|
||||
// log the error since it is not propagated into the runtime error.
|
||||
log!(warn, "💸 un-compacting solution failed due to {:?}", e);
|
||||
Error::<T>::PhragmenBogusCompact
|
||||
Error::<T>::OffchainElectionBogusCompact
|
||||
})?;
|
||||
|
||||
// check all nominators actually including the claimed vote. Also check correct self votes.
|
||||
@@ -2659,7 +2659,7 @@ impl<T: Trait> Module<T> {
|
||||
// have bigger problems.
|
||||
log!(error, "💸 detected an error in the staking locking and snapshot.");
|
||||
// abort.
|
||||
return Err(Error::<T>::PhragmenBogusNominator.into());
|
||||
return Err(Error::<T>::OffchainElectionBogusNominator.into());
|
||||
}
|
||||
|
||||
if !is_validator {
|
||||
@@ -2676,25 +2676,25 @@ impl<T: Trait> Module<T> {
|
||||
// each target in the provided distribution must be actually nominated by the
|
||||
// nominator after the last non-zero slash.
|
||||
if nomination.targets.iter().find(|&tt| tt == t).is_none() {
|
||||
return Err(Error::<T>::PhragmenBogusNomination.into());
|
||||
return Err(Error::<T>::OffchainElectionBogusNomination.into());
|
||||
}
|
||||
|
||||
if <Self as Store>::SlashingSpans::get(&t).map_or(
|
||||
false,
|
||||
|spans| nomination.submitted_in < spans.last_nonzero_slash(),
|
||||
) {
|
||||
return Err(Error::<T>::PhragmenSlashedNomination.into());
|
||||
return Err(Error::<T>::OffchainElectionSlashedNomination.into());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// a self vote
|
||||
ensure!(distribution.len() == 1, Error::<T>::PhragmenBogusSelfVote);
|
||||
ensure!(distribution[0].0 == *who, Error::<T>::PhragmenBogusSelfVote);
|
||||
ensure!(distribution.len() == 1, Error::<T>::OffchainElectionBogusSelfVote);
|
||||
ensure!(distribution[0].0 == *who, Error::<T>::OffchainElectionBogusSelfVote);
|
||||
// defensive only. A compact assignment of length one does NOT encode the weight and
|
||||
// it is always created to be 100%.
|
||||
ensure!(
|
||||
distribution[0].1 == OffchainAccuracy::one(),
|
||||
Error::<T>::PhragmenBogusSelfVote,
|
||||
Error::<T>::OffchainElectionBogusSelfVote,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2713,11 +2713,11 @@ impl<T: Trait> Module<T> {
|
||||
&staked_assignments,
|
||||
);
|
||||
// This technically checks that all targets in all nominators were among the winners.
|
||||
ensure!(num_error == 0, Error::<T>::PhragmenBogusEdge);
|
||||
ensure!(num_error == 0, Error::<T>::OffchainElectionBogusEdge);
|
||||
|
||||
// Check if the score is the same as the claimed one.
|
||||
let submitted_score = evaluate_support(&supports);
|
||||
ensure!(submitted_score == claimed_score, Error::<T>::PhragmenBogusScore);
|
||||
ensure!(submitted_score == claimed_score, Error::<T>::OffchainElectionBogusScore);
|
||||
|
||||
// At last, alles Ok. Exposures and store the result.
|
||||
let exposures = Self::collect_exposure(supports);
|
||||
|
||||
Reference in New Issue
Block a user