-
Notifications
You must be signed in to change notification settings - Fork 47
Add an example on how to reason about events in CVL #174
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bcb3c7d
7.26.0 Release (#163)
yoav-el-certora 33b87b9
Bug fixed
otakar-trunda d61ec6e
Add an example on how to reason about events in CVL
johspaeth 601b174
Addressing code reviews
johspaeth a62177a
Addressing Christiane's CR
johspaeth 0816b23
Issue with merge resolution
johspaeth 214c068
Revert "Bug fixed"
johspaeth b981ec8
Reverse incorrect change after merge
johspaeth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Reasoning about Solidity events | ||
|
|
||
| This directory demonstrates how to reason about Solidity events with the Prover. | ||
| The Prover cannot natively reason about events, therefore a workaround is needed. | ||
|
|
||
| The workaround is to wrap the `emits` of Solidity `events` into an internal function and then apply internal summarization to reason about the emitted event. | ||
|
|
||
| See `contracts/Auction.sol` for the original code that uses an event and take a look at `contract/AuctionFixed.sol` for code that uses the workaround. | ||
|
|
||
| - | ||
| Run this configuration via: | ||
|
|
||
| ```certoraRun runAuctionFixed.conf``` | ||
|
|
||
| [A report of this run](https://prover.certora.com/output/53900/4ffdad0c20094a729d830bfb1b460f3e?anonymousKey=b345ea4d1fe4b3631442c0f110e926a58f47ee9b) | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /** | ||
| * @title Reasoning about Solidity events example | ||
| * | ||
| * This is an example specification for reasoning about events in CVL. | ||
| */ | ||
|
|
||
| methods { | ||
| function emitBidEvent(address from) internal => cvlEmitBidEvent(from); | ||
| } | ||
|
|
||
| persistent ghost bool isEventEmitted; | ||
| persistent ghost address emittedEventAddress; | ||
|
|
||
| function cvlEmitBidEvent(address from){ | ||
| isEventEmitted = true; | ||
| emittedEventAddress = from; | ||
| } | ||
|
|
||
| /** | ||
| * This rule checks that an event is emitted | ||
| */ | ||
| rule eventIsEmitted() { | ||
| env e; | ||
| isEventEmitted = false; | ||
| bid(e); | ||
| assert isEventEmitted; | ||
| } | ||
|
|
||
| /** | ||
| * This rule checks that the emitted event address is the one | ||
| * that initiated the bid operation. | ||
| */ | ||
| rule eventEmitsMsgSender() { | ||
| env e; | ||
| bid(e); | ||
| assert emittedEventAddress == e.msg.sender; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| contract Auction | ||
| { | ||
| event BidEvent(address from); | ||
| function bid() public | ||
| { | ||
| emit BidEvent(msg.sender); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| contract AuctionFixed | ||
| { | ||
| event BidEvent(address from); | ||
| function bid() public | ||
| { | ||
| emitBidEvent(msg.sender); | ||
| } | ||
|
|
||
| function emitBidEvent(address from) internal | ||
| { | ||
| emit BidEvent(from); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "files": [ | ||
| "contracts/AuctionFixed.sol", | ||
| ], | ||
| "verify": "AuctionFixed:certora/specs/Auction.spec", | ||
| "msg": "Reasoning about Solidity events", | ||
| "rule_sanity" : "basic" // check there is a trace satisfying the rule. | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.