-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Refactor election-provider-multi-phase
solution checks
#8641
Comments
This is not the case in the PR #8290
What does that mean?
I don't see why we don't need to do the In my opinion we can:
Anyway I don't see where my example is wrong, and in the above example lots of validator mine only one wrong solution for the chain. Which is pretty bad IMO. |
I mean feasibility check should only be used internally inside
What we should do is to add a hash of the snapshot to the things that are checked in
Totally agree. |
Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions. |
Quite important. |
We might ditch this, since we will soon get a new election pallet and we don't want to support |
Actually, I have a good reorg in mind, let me know what you think:
Currently, some checks in
feasibility_check
is repeated inunsigned_pre_dispatch_checks
.unsigned_pre_dispatch_checks
itself is called both invalidate_unsigned
(which is used by the txpool), and inpre_dispatch
(which is called exactly when the name says so: prior to dispatch, not validation). Currently, I am being superconservative:I repeat
unsigned_pre_dispatch_checks
issubmit_unsigned
itself which is redundant, because it is already called inpre_dispatch
.Some individual components are checked twice:
DesiredTargets
is checked both infeasibility_check
andunsigned_pre_dispatch_checks
, and given the previous note is technically checked 3 times in a single dispatch pipeline:in the call to
unsigned_pre_dispatch_checks
inpre_dispatch
.in the call to
unsigned_pre_dispatch_checks
insubmit_unsigned
.lastly in the body of the
feasibility_check
.We should rename
unsigned_pre_dispatch_checks
to a properpre_dispatch_checks
that checks:desired_targetsand everything else is done in
feasibility_check
.The standard assumption is that all solutions must go through both of these eventually (and at least once), so we can deduplicate them: things that are checked in
pre_dispatch
need not be checked again infeasibility_check
. Then the question is, what should be inpre_dispatch
and what not?The role of
pre_dispatch
is this: feel the gap about criteria that could change over time. For example, if you are honest, you will always generate a solution that is passesfeasibility_check
. But, if you took an hour to compute it:<QueuedSolution>
might now contain a better solution.With this logic, the
pre_dispatch
should check for:to make sure if you were honest (used the correct snapshot), you will not submit a bad solution due to being out of date (round/phase) or the fact that a better solution was recently accepted (score).
The reason that I historically stuffed
desired_targets
intopre_dispatch
is: During weight/length trimming, we could remove a target, in which case the solution is now invalid, and we don't want to submit this. As a easy fix, I put it inpre_dispatch_checks
because it was called invalidate_unsigned
and fixed this. But this is not a criterion that changes over time: once you generate a solution and trim it, if it has enough winner, it will stay so (until the round maybe changes). So calling intofeasibility_check
inmine_checked
is enough.So all in all:
mine_checked
should still call both of these just in case.feasibility_check
should still be called only insubmit_unsigned
(except for OCW code that calls it).pre_dispatch
should be called in bothvalidate
andpre_dispatch
ofvalidate_unsigned
.Lastly, the cream on the case is that, here you can do something like:
This might sound too big, so maybe make it a follow-up, but the current layout is kinda confused as well. At the least, you can move the check to score only in
and_then
, and since now we are okay with duplicate checks, just callunsigned_pre_dispatch_checks
in there to check round and score (with the other two as... bonus?)Originally posted by @kianenigma in #8290 (comment)
The text was updated successfully, but these errors were encountered: