Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Panic on invalid unsigned election solution. (#6485)
Browse files Browse the repository at this point in the history
* Panic on invalid

* Fix return

* Fix refund
  • Loading branch information
kianenigma authored Jun 25, 2020
1 parent efab94e commit 9f51ec7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions frame/staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2194,18 +2194,20 @@ decl_module! {
size: ElectionSize,
) -> DispatchResultWithPostInfo {
ensure_none(origin)?;
Self::check_and_replace_solution(
let adjustments = Self::check_and_replace_solution(
winners,
compact,
ElectionCompute::Unsigned,
score,
era,
size,
)
// TODO: instead of returning an error, panic. This makes the entire produced block
// invalid.
// This ensures that block authors will not ever try and submit a solution which is not
// an improvement, since they will lose their authoring points/rewards.
).expect(
"An unsigned solution can only be submitted by validators; A validator should \
always produce correct solutions, else this block should not be imported, thus \
effectively depriving the validators from their authoring reward. Hence, this panic
is expected."
);
Ok(adjustments)
}
}
}
Expand Down

0 comments on commit 9f51ec7

Please sign in to comment.