-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
AL
committed
Apr 17, 2024
1 parent
39af7cd
commit b7bea8d
Showing
11 changed files
with
4,785 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Fuzzing VoteWeighting | ||
|
||
## Prepare contracts for fuzzing | ||
contracts/test/VoteWeightingFuzzing.sol <br> | ||
contracts/test/EchidnaVoteWeightingAssert.sol <br> | ||
|
||
## Fuzzing | ||
```sh | ||
# Move the script to the root of the project | ||
cp start_echidna.sh ../../../ | ||
# Move config file to the root of the project | ||
cp echidna_assert.yaml ../../../ | ||
cd ../../../ | ||
# Run | ||
./start_echidna.sh | ||
``` | ||
result overflow: [fuzzing-overflow.PNG](fuzzing-overflow.PNG) <br> | ||
result assert: [fuzzing-assert.PNG](fuzzing-assert.PNG) |
2,072 changes: 2,072 additions & 0 deletions
2,072
audits/internal11/fuzzing/corpusEchidna/covered.1713373564.html
Large diffs are not rendered by default.
Oops, something went wrong.
2,073 changes: 2,073 additions & 0 deletions
2,073
audits/internal11/fuzzing/corpusEchidna/covered.1713373572.html
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,10 @@ | ||
#testMode: overflow | ||
testMode: assertion | ||
coverage: true | ||
corpusDir: corpusEchidna | ||
coverageFormats: ["html"] | ||
# maxBlockDelay: 12 | ||
# provide solc remappings to crytic-compile | ||
# https://www.justinsilver.com/technology/programming/slither-echidna-remappings/ | ||
cryticArgs: ['--solc-remaps', '@=node_modules/@'] | ||
|
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,10 @@ | ||
testMode: overflow | ||
#testMode: assertion | ||
coverage: true | ||
corpusDir: corpusEchidna | ||
coverageFormats: ["html"] | ||
# maxBlockDelay: 12 | ||
# provide solc remappings to crytic-compile | ||
# https://www.justinsilver.com/technology/programming/slither-echidna-remappings/ | ||
cryticArgs: ['--solc-remaps', '@=node_modules/@'] | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,4 @@ | ||
#!/bin/bash | ||
|
||
rm -rf corpusEchidna/ | ||
echidna contracts/test/EchidnaVoteWeightingAssert.sol --contract EchidnaVoteWeightingAssert --config echidna_assert.yaml |
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,74 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.23; | ||
|
||
import "../OLAS.sol"; | ||
import "../veOLAS.sol"; | ||
import "./VoteWeightingFuzzing.sol"; | ||
|
||
|
||
contract EchidnaVoteWeightingAssert { | ||
OLAS olas; | ||
veOLAS ve; | ||
VoteWeightingFuzzing vw; | ||
uint160 constant FAKE_OLAS = 7; | ||
|
||
uint256 constant oneOLASBalance = 1 ether; | ||
uint256 constant fourYear = 4 * 365 * 86400; | ||
uint256 constant oneYear = 1 * 365 * 86400; | ||
uint256 constant maxVoteWeight = 10000; | ||
uint64 constant WEEK = 1 weeks; | ||
uint256 constant oneOLAS = 1 ether; | ||
uint256 constant oneMLN = 1_000_000; | ||
uint256 ts; | ||
|
||
// msg.sender in Echidna | ||
address[3] private senders = [ address(0x10000), address(0x20000), address(0x30000) ]; | ||
|
||
constructor() payable { | ||
olas = new OLAS(); | ||
address aolas = address(olas); | ||
ve = new veOLAS(aolas, "Voting Escrow OLAS", "veOLAS"); | ||
address ave = address(ve); | ||
vw = new VoteWeightingFuzzing(ave); | ||
olas.mint(address(this),oneOLAS*oneMLN); | ||
} | ||
|
||
// voteForNomineeWeights_assert(0xdeadbeef,1,0,4495678220902361,1124857) | ||
function voteForNomineeWeights_assert(address nominee, uint32 chainId, uint16 weight, uint256 amount, uint32 unlockTime) external { | ||
require(block.timestamp > 0); | ||
require(block.timestamp > ts); | ||
require(unlockTime < fourYear); | ||
require(weight < maxVoteWeight); | ||
require(amount < 100 * oneOLAS); | ||
uint256 balanceOf = olas.balanceOf(address(this)); | ||
assert(balanceOf > amount); | ||
(uint128 initialAmount,) = ve.mapLockedBalances(address(this)); | ||
if (initialAmount == 0) { | ||
olas.approve(address(ve), amount); | ||
ve.createLock(amount, unlockTime); | ||
(uint128 lockedAmount,) = ve.mapLockedBalances(address(this)); | ||
assert(lockedAmount > 0); | ||
} else { | ||
(uint128 lockedAmount,) = ve.mapLockedBalances(address(this)); | ||
assert(lockedAmount > 0); | ||
} | ||
vw.addNominee(nominee, chainId); | ||
uint256 id = vw.getNomineeId(nominee, chainId); | ||
uint256 num = vw.getNumNominees(); | ||
assert(id > 0); | ||
assert(num > 0); | ||
vw.setCallVoteForNomineeWeights(false); | ||
bool beforeAfterCall = vw.callVoteForNomineeWeights(); | ||
assert(beforeAfterCall == false); | ||
vw.voteForNomineeWeights(nominee, chainId, weight); | ||
bool stateAfterCall = vw.callVoteForNomineeWeights(); | ||
if(stateAfterCall == true) { | ||
uint256 lts = vw.getlastUserVote(nominee,chainId); | ||
assert(lts > 0); | ||
} | ||
ts = block.timestamp; // next timestamp > timestamp | ||
vw.checkpointNominee(nominee, chainId); | ||
} | ||
|
||
} | ||
|
Oops, something went wrong.