Skip to content
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

Reorder checks again #248

Merged

Conversation

loredanacirstea
Copy link
Contributor

Fixes the issue from this thread: #47 (comment) stemmed from the fact that the code is less readable when the checks do not follow the implementation logic, but are artificially grouped together.

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.

  • check function inputs
  • check other preconditions to the state changes that will be done
  • perform actions and immediately check if these actions succeeded
  • check all other invariants at the end

This triggered a warning when static analysis tools were used, because emitting an event is considered a state change.
The pattern that was checked for is: make sure all the state changes are made before any external calls (e.g. token transfers).
This triggered a warning when static analysis tools were used, because emitting an event is considered a state change.
The pattern that was checked for is: make sure all the state changes are made before any external calls (e.g. token transfers).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants