-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Panic on invalid unsigned election solution. #6485
Conversation
Let's assume the following:
Is that going to happen often? |
If you are building one a block Y which is older than X, and X happens to be cannon, then your block is eventually retracted anyhow because you are building on top of an old block, as far as I know. But I am not sure proficient in these topics. Maybe @NikVolf or @tomusdrw can verify as well. |
Not sure how this is related. I'm speaking about |
How I would analyse this: I see only two states in the world: the X that you imported is cannon or not if it is not, then who cares. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pre_dispatch
fix makes sure that the behaviour that @bkch describes won't happen.
If our local solution is shitty, pre_dispatch
will reject it and the transaction will be marked as invalid, removed from the pool and not included in the block. Previously it would be in block, but would reach the error here. So now that we've fixed pre_dispatch
we can safely panic here, since error here would mean that pre_dispatch
does not cover some stuff.
…orce-correct-staking-solution
bot merge |
Waiting for commit status... |
Checks failed; merge cancelled |
bot merge |
Trying merge. |
Closes #5980
This is small change, but has been the consequence of a long period of monitoring.
Context
Validators submit solutions to the staking election via an unsigned transaction that they can place in only the blocks that they author. Technically though, nothing is preventing a validator from placing a wrong solution in the block that they author, forcing all nodes to check the solution, only to realise later that the solution was wrong. It was proposed by Gav here to panic in such cases to prevent such behaviour.
Initially though, I did not implement this, and it turned out to be a good choice.
Previously
The reason for not putting this was that I was not yet confident that our code for generating the solution and checking it is 100% correct. In case we had a bug, I didnd't want to to cause problem for out validators. It turned out in #6106 that we were actually sometimes submitting solutions that are slightly worse, due to an optimisation that led to removing the
pre_dispatch
. The situation was that validators were submitting solutions that were deemed to be validx
blocks before, now, because they skippre_dispatch
, which was obviously wrong. These wrong solutions were actually backed into blocks and got propagated. Absolute waste of time and cpu cycles for everyone.Now
#6173 Fixed the above.
I've been monitoring both Kusama and Polkadot and since this patch, we have not yet had a single solution by validators that were incorrect. Hence, we can apply the panic in the runtime, ensuring that no sane validator would intentionally misbehave here.
Example log from Recent eras in polkadot:
I like to reason about the panic in two cases:
Review ✅
The code needs not any review. Please read the above and approve only if all of it makes sense.