Skip to content

Commit b0467de

Browse files
authored
Panic on invalid unsigned election solution. (#6485)
* Panic on invalid * Fix return * Fix refund
1 parent aabb65a commit b0467de

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/lib.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,18 +2194,20 @@ decl_module! {
21942194
size: ElectionSize,
21952195
) -> DispatchResultWithPostInfo {
21962196
ensure_none(origin)?;
2197-
Self::check_and_replace_solution(
2197+
let adjustments = Self::check_and_replace_solution(
21982198
winners,
21992199
compact,
22002200
ElectionCompute::Unsigned,
22012201
score,
22022202
era,
22032203
size,
2204-
)
2205-
// TODO: instead of returning an error, panic. This makes the entire produced block
2206-
// invalid.
2207-
// This ensures that block authors will not ever try and submit a solution which is not
2208-
// an improvement, since they will lose their authoring points/rewards.
2204+
).expect(
2205+
"An unsigned solution can only be submitted by validators; A validator should \
2206+
always produce correct solutions, else this block should not be imported, thus \
2207+
effectively depriving the validators from their authoring reward. Hence, this panic
2208+
is expected."
2209+
);
2210+
Ok(adjustments)
22092211
}
22102212
}
22112213
}

0 commit comments

Comments
 (0)