-
Notifications
You must be signed in to change notification settings - Fork 45
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
Assess keeping invariants grouped #47
Comments
Just my 2 cents. I also would really like to have all the require invariants somewhere. This would make each function so much easier to read and reason about. |
Yes, I thought about this and I think I went too far with making sure the gas cost is minimal. |
Grouping the invariants is fine but you should only use asserts for internal errors and things that should never ever happen. I am commenting on #64 about it. Docs which help us understand the different between |
Just to clarify my point, code should be written to be readable first. I don't have a hard rule for how to format code for readability, specially because of solidity's constraints on the number of variables in a stack, which require intermediary functions to be introduced, which may hide validation inside these functions. But I would strive for a contract-based approach, where the beginning of a function starts with the requirements, first validating/requiring the value inputs, then the code is followed by the pure computation, which is followed by the validation of the computation and side-effects, and the code finishes with the asserts/invariants that must be true after the execution of the code. |
I fully agree with this. I think @berndbohmeier also agrees with this. |
I reopened the issue. The checks should follow the above proposed format:
This issue will be closed when the above format is implemented. |
as described in raiden-network#238. Additionally, the function was refactored to be more clear and readable, as discussed in raiden-network#47.
as described in raiden-network#238. Additionally, the function was refactored to be more clear and readable, as discussed in raiden-network#47.
#248 implements the agreed changes. |
(must be updated with a proper description)
As mentioned in this thread: #39 (comment)
The text was updated successfully, but these errors were encountered: