Add option(s) to override provable relationships
See original GitHub issueIn my contract I have a relationship where each user is storing their proportion of a total quantity. Due to a provable mathematical relationship between the quantities (I increase total every time I increase mine, and I decrease total every time I decrease mine), I can maintain an invariant in my code with more minimal input validation.
How would I add comments to my code to request mythril ignore specific violations that I could provable demonstrate are invariant?
Example contract:
contract A {
uint total;
mapping (address => uint) mine;
function add()
public
{
require( total + 1 > total ); // Overflow protection
// require( mine[msg.sender] <= total ); // This should be necessary to avoid integer overflow
total += 1;
mine[msg.sender] += 1; // Curiously, no integer overflow raised here...
}
function subtract()
public
{
require( mine[msg.sender] > 0 ); // Underflow protection
// require( mine[msg.sender] <= total ); // This avoids throwing integer underflow
total -= 1; // mythril throws an integer underflow here
mine[msg.sender] -= 1; // @myth-ignore UNDERFLOW - Example of syntax
}
}
Some tools have a @ignore CHECK_NAME
comment that can be added to a line to ignore a specific check. I could save a bit of gas by just being able to avoid having a assert(mine <= total)
in my code in two spots
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:12 (8 by maintainers)
Top Results From Across the Web
Relationship options settings - IBM
Use this page to specify relationship options for deployable or composition units in an asset deployed as part of a business-level application.
Read more >Chapter 1: the Nature of Economics Flashcards | Quizlet
A direct relationship occurs when: A) the two variables being compared change in opposite directions, or when one goes up the other goes...
Read more >SOLID: The First 5 Principles of Object Oriented Design
SOLID stands for: S - Single-responsiblity Principle; O - Open-closed Principle; L - Liskov Substitution Principle; I - Interface Segregation ...
Read more >How to Create a real one-to-one relationship in SQL Server
First, store all the data in a single table. Then you'll have no issues in EF. Or Secondly, your entity must be smart...
Read more >9-27.000 - Principles of Federal Prosecution | JM
Among the options are: taking no position regarding the sentence; not opposing ... Second, federal prosecutors may drop readily provable charges with the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Adding invariants and statements to be proved is discussed in #405
Adding constraints to inform Mythril of possible invariants in order to prune & resolve false positives is not necessary anymore as Mythril now has a constrained memory model (vs the old unconstrained one)
Therefore I’m closing this issue if there is anything that isn’t captured in the other issue yet. Please open another issue so we can look at that separately
A very good idea, I think. I recently noticed in one of Suhabe’s benchmarks this:
How do people feel about this variation: in a front-end wrapper, look for comments of the form:
And add that as a constraint to the z3 solver. Presumably this would previent Mythril from triggering the violation.
Outside of a wrapper a
--constraint
option could be supplied.