-
Notifications
You must be signed in to change notification settings - Fork 998
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
Use of assert
to validate method arguments
#1797
Comments
I think that is just a misinterpretation of the "assert" statement as used in the spec. When translated into client code, it should just become an exception or a similar thing that flags something invalid has happened during the state transition, and the whole transition should therefore be rejected. Since the spec is not a program that is run in a production environment, the flagged suggestions don't really apply to it. And if not done using assertions, it would make tracking down bugs while testing the spec itself harder. So I'm not sure if there is a better solution, unless you can suggest one? |
Thanks for your feedback @dankrad
I interpreted the
I am not so sure. Again most of the specs are written in Python, so the only semantics I can see to apply is the semantics of the Python language.
Yes I have a suggestion. For writing specifications and for instance constraints on the input parameters of a function, it is common to use pre conditions. The semantics is that the function can be called only if the parameters satisfy the pre-condition(s). This allows for a modular reasoning on the validity of functions calls (we can check that a caller satisfies the pre-conditions of a callee for instance using a static analyser). If you want some examples of the use of pre/post-conditions, we are currently writing a formal specification of the Eth2.0 specs in order to prove that it is |
@franck44 Maybe you can take a few functions of the beacon spec, and change them how you would like them to look like without asserts? Can you please open a PR to show your approach? If we can agree on those as example, and share that with client implementers for feedback, we can change the other parts of the spec to not have any asserts. |
@protolambda This is what we have done in our Dafny specs. |
The spec clearly states how to interpret
consensus-specs/specs/phase0/beacon-chain.md Line 1249 in bf09b9a
I don't see the added semantic value of switching to something other than |
The Eth2 specs frequently use
assert
statements to validate methods arguments.This is a known source of security vulnerabilities and may result in insecure implementations:
The specs, as guidelines for implementers, may benefit from following standard coding practices to limit the number of security vulnerabilities. After all, the Beacon Chain is a critical component of the Eth2 infrastructure, and critical software components may be coded/specified following the highest coding standards.
Note: this issue is a follow-up of issue 1789.
The text was updated successfully, but these errors were encountered: