Skip to content

Commit 35e43f5

Browse files
authored
Merge pull request #308 from crytic/echidna-0.8
Use 0.8.0 for echidna exercises
2 parents 9229d4b + 8c4d2ba commit 35e43f5

File tree

27 files changed

+67
-53
lines changed

27 files changed

+67
-53
lines changed

.github/workflows/echidna.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ jobs:
167167
contract: ${{ matrix.contract }}
168168
config: ${{ matrix.config }}
169169
output-file: ${{ matrix.files }}.out
170-
solc-version: ${{ matrix.solc-version || '0.5.11' }}
170+
solc-version: ${{ matrix.solc-version || '0.8.0' }}
171171
echidna-workdir: ${{ matrix.workdir }}
172172
echidna-version: edge
173173
crytic-args: ${{ matrix.crytic-args || '' }}

not-so-smart-contracts/cairo/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ Each _Not So Smart Contract_ consists of a standard set of information:
3030

3131
These examples are developed and maintained by [Trail of Bits](https://www.trailofbits.com/).
3232

33-
If you have any questions, issues, or wish to learn more, join the #ethereum channel on the [Empire Hacking Slack](https://empireslacking.herokuapp.com/) or [contact us](https://www.trailofbits.com/contact/) directly.
33+
If you have any questions, issues, or wish to learn more, join the #ethereum channel on the [Empire Hacking Slack](https://slack.empirehacking.nyc/) or [contact us](https://www.trailofbits.com/contact/) directly.

program-analysis/echidna/basic/assertion-checking.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
## Introduction
1313

14-
In this short tutorial, we will demonstrate how to use Echidna to check assertions in smart contracts. For this example, be sure to use Solidity 0.7.x or older. If you run them with Solidity 0.8.x, the test will never fail.
14+
In this short tutorial, we will demonstrate how to use Echidna to check assertions in smart contracts.
1515

1616
## Write an Assertion
1717

@@ -23,7 +23,9 @@ contract Incrementor {
2323
2424
function inc(uint256 val) public returns (uint256) {
2525
uint256 tmp = counter;
26-
counter += val;
26+
unchecked {
27+
counter += val;
28+
}
2729
// tmp <= counter
2830
return (counter - tmp);
2931
}
@@ -38,7 +40,9 @@ contract Incrementor {
3840
3941
function inc(uint256 val) public returns (uint256) {
4042
uint256 tmp = counter;
41-
counter += val;
43+
unchecked {
44+
counter += val;
45+
}
4246
assert(tmp <= counter);
4347
return (counter - tmp);
4448
}
@@ -55,7 +59,9 @@ contract Incrementor {
5559
5660
function inc(uint256 val) public returns (uint256) {
5761
uint256 tmp = counter;
58-
counter += val;
62+
unchecked {
63+
counter += val;
64+
}
5965
if (tmp > counter) {
6066
emit AssertionFailed(counter);
6167
}

program-analysis/echidna/example/assert.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
// SPDX-License-Identifier: AGPL-3.0
2-
pragma solidity ^0.5.0;
2+
pragma solidity ^0.8.0;
33

44
contract Incrementor {
55
uint256 private counter = 2 ** 200;
66

77
function inc(uint256 val) public returns (uint256) {
88
uint256 tmp = counter;
9-
counter += val;
9+
unchecked {
10+
counter += val;
11+
}
1012
assert(tmp <= counter);
1113
return (counter - tmp);
1214
}

program-analysis/echidna/example/gas.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: AGPL-3.0
2-
pragma solidity ^0.5.0;
2+
pragma solidity ^0.8.0;
33

44
contract C {
55
uint256 state;

program-analysis/echidna/example/multi.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: AGPL-3.0
2-
pragma solidity ^0.5.0;
2+
pragma solidity ^0.8.0;
33

44
contract C {
55
bool state1 = false;

program-analysis/echidna/example/pushpop.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: AGPL-3.0
2-
pragma solidity ^0.5.0;
2+
pragma solidity ^0.8.0;
33

44
contract C {
55
address[] addrs;

program-analysis/echidna/example/testtoken.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: AGPL-3.0
2-
pragma solidity ^0.5.0;
2+
pragma solidity ^0.8.0;
33

44
import "./token.sol";
55

program-analysis/echidna/example/token.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: AGPL-3.0
2-
pragma solidity ^0.5.0;
2+
pragma solidity ^0.8.0;
33

44
contract Token {
55
mapping(address => uint256) public balances;

program-analysis/echidna/exercises/Exercise-1.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Join the team on Slack at: https://slack.empirehacking.nyc/ #ethereum
1515
We will test the following contract _[token.sol](https://github.com/crytic/building-secure-contracts/tree/master/program-analysis/echidna/exercises/exercise1/token.sol)_:
1616

1717
```solidity
18-
pragma solidity ^0.5.0;
18+
pragma solidity ^0.8.0;
1919
2020
contract Ownable {
2121
address public owner = msg.sender;
@@ -67,13 +67,13 @@ contract Token is Ownable, Pausable {
6767
The skeleton for this exercise is (_[template.sol](https://github.com/crytic/building-secure-contracts/tree/master/program-analysis/echidna/exercises/exercise1/template.sol)_):
6868

6969
````solidity
70-
pragma solidity ^0.5.0;
70+
pragma solidity ^0.8.0;
7171
7272
import "./token.sol";
7373
7474
/// @dev Run the template with
7575
/// ```
76-
/// solc-select use 0.5.0
76+
/// solc-select use 0.8.0
7777
/// echidna program-analysis/echidna/exercises/exercise1/template.sol
7878
/// ```
7979
contract TestToken is Token {

0 commit comments

Comments
 (0)