-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
R4R: Runtime-assertable invariants #2807
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2807 +/- ##
===========================================
+ Coverage 56.73% 56.75% +0.02%
===========================================
Files 131 131
Lines 8554 8554
===========================================
+ Hits 4853 4855 +2
+ Misses 3368 3366 -2
Partials 333 333 |
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.
Love the code re-use from the simulator.
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.
I was able to pull down this branch and run a testnet, as well as the simulator successfully.
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.
LGTM. Changes are clean and minimal 👌
I would be nice if we could revert this somehow w/o a hard fork, although it's not directly clear to me why it would cause one? So my vote would be for a parameter proposal. In either case, this can be done post GoS/pre-launch.
It doesn't require a hard fork in the sense that the state transition machine is incompatible (it would be compatible), but rather that if some nodes dropped the invariants and others did not, if any were ever violated the network would diverge, since the nodes continuing to check the invariants would panic and halt. |
Mhmmm yes, good point. Although I'd hope none would be violated. So it sounds more like a soft fork. Ultimately, validators could still run this if they wanted to, no? |
Closes #2663
This PR adds code to Gaia to assert an invariant set at the end of processing every block (right before returning
abci.ResponseEndBlock
). Currently, these invariants are the following:int => uint
change @alexanderbez is working on)O(n)
wheren
is the number of validator distribution infos, which I believe is capped atMaxValidators
.O(a + d + v + i)
, wherea
is the number of accounts,d
is the number of unbonding delegations,v
is the number of validators (not just bonded, all candidates), andi
is the number of validator distribution infos.O(v)
wherev
is the number of validators.These invariants will obviously become too expensive in the long run to run on each block, but I think this may be a nice bit of defense-in-depth in the short run. This is written so removing the invariant checks will required a hard fork (which might end up being the hard fork to enable transfers, or might be a later fork).
Up for debate:
ParamChangeProposal
?To-do:
EndBlock
is correctStandard checklist:
docs/
)PENDING.md
with issue #Files changed
in the github PR explorerFor Admin Use: