-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into release
- Loading branch information
Showing
14 changed files
with
1,913 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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 @@ | ||
MergeKCFGTest.test_branch_merge(uint256,uint256,bool) |
This file contains 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,14 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity =0.8.13; | ||
|
||
|
||
// CSE challenge: multiple branches that slow down the verification | ||
contract Branches{ | ||
function applyOp(uint256 x, uint256 y, bool z) public returns (uint256) { | ||
if (z) { | ||
return x + y; | ||
} else { | ||
return x * y; | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/tests/integration/test-data/foundry/test/MergeKCFGTest.t.sol
This file contains 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,29 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity =0.8.13; | ||
|
||
import "forge-std/Test.sol"; | ||
import "src/Branches.sol"; | ||
|
||
contract MergeKCFGTest is Test { | ||
Branches c; | ||
|
||
function setUp() external { | ||
c = new Branches(); | ||
} | ||
|
||
function test_branch_merge(uint256 x, uint256 y, bool z) external{ | ||
vm.assume(x <= type(uint256).max - y); | ||
try c.applyOp(x, y, z) returns (uint256 res) { | ||
// This check will fail if the backend cannot recover the preds in the merged postcondition | ||
// If so, assert res == x + y | res == x * y will pass | ||
// If so, we should not always use merge_node, but provide both on need. | ||
if (z) { | ||
assert(res == x + y); | ||
} else { | ||
assert(res == x * y); | ||
} | ||
} catch { | ||
assert(x != 0 && 2 ** 62 / x < y && !z); | ||
} | ||
} | ||
} |
This file contains 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
This file contains 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
Oops, something went wrong.