Panic on invalid unsigned election solution. (#6485)

* Panic on invalid

* Fix return

* Fix refund
This commit is contained in:
Kian Paimani
2020-06-25 10:22:30 +02:00
committed by GitHub
parent 763b55cc8e
commit f12d4cfcfd
+8 -6
View File
@@ -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)
}
}
}