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

Missing range constraints for TIMESTAMP_CELL symbolic variable #315

Closed
lucasmt opened this issue Jan 25, 2024 · 3 comments · Fixed by runtimeverification/evm-semantics#2277
Assignees

Comments

@lucasmt
Copy link
Contributor

lucasmt commented Jan 25, 2024

Kontrol uses the symbolic variable TIMESTAMP_CELL to represent the value block.timestamp in Solidity, but it doesn't introduce range constraints for this variable (0 <=Int TIMESTAMP_CELL and TIMESTAMP_CELL <Int pow256). This means, for example, that the following test will fail in Kontrol:

function testTimestamp() public {
    assertLe(block.timestamp, type(uint256).max);
}

It will also prevent expressions that use TIMESTAMP_CELL from simplifying. For example, #asWord ( #range ( #padToWidth ( 32 , #asByteStack ( TIMESTAMP_CELL:Int ) ) , 0 , 32 ) ) should simplify to just TIMESTAMP_CELL, but only if its range is constrained.

@lucasmt
Copy link
Contributor Author

lucasmt commented Jan 25, 2024

I'd be happy to submit a PR fixing this, but I don't actually know where these constraints get added

@anvacaru
Copy link
Contributor

Constraints like this are added in evm-semantics, in KEVM.add_invariant method.

@anvacaru
Copy link
Contributor

Closing this as it is a duplicate of runtimeverification/evm-semantics#2143.

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 a pull request may close this issue.

2 participants