Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
8b70a0f3
Unverified
Commit
8b70a0f3
authored
Dec 08, 2022
by
Maurelian
Committed by
GitHub
Dec 08, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4166 from ethereum-optimism/jm/echidna-burn
parents
400d81fb
1c631750
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
94 additions
and
2 deletions
+94
-2
pretty-chicken-rest.md
.changeset/pretty-chicken-rest.md
+6
-0
config.yml
.circleci/config.yml
+15
-1
FuzzBurn.sol
packages/contracts-bedrock/contracts/echidna/FuzzBurn.sol
+71
-0
package.json
packages/contracts-bedrock/package.json
+2
-1
No files found.
.changeset/pretty-chicken-rest.md
0 → 100644
View file @
8b70a0f3
---
'
@eth-optimism/ci-builder'
:
patch
'
@eth-optimism/contracts-bedrock'
:
patch
---
Add echidna tests for Burn
.circleci/config.yml
View file @
8b70a0f3
...
@@ -290,11 +290,16 @@ jobs:
...
@@ -290,11 +290,16 @@ jobs:
bedrock-echidna-run
:
bedrock-echidna-run
:
docker
:
docker
:
-
image
:
ethereumoptimism/ci-builder:latest
-
image
:
ethereumoptimism/ci-builder:latest
parameters
:
parameters
:
echidna_target
:
echidna_target
:
description
:
Which echidna fuzz contract to run
description
:
Which echidna fuzz contract to run
type
:
string
type
:
string
size
:
description
:
Custom resource class size for the run
type
:
string
default
:
large
resource_class
:
<<parameters.size>>
steps
:
steps
:
-
checkout
-
checkout
-
attach_workspace
:
{
at
:
"
."
}
-
attach_workspace
:
{
at
:
"
."
}
...
@@ -817,6 +822,15 @@ workflows:
...
@@ -817,6 +822,15 @@ workflows:
echidna_target
:
aliasing
echidna_target
:
aliasing
requires
:
requires
:
-
bedrock-echidna-build
-
bedrock-echidna-build
-
bedrock-echidna-run
:
echidna_target
:
"
burn:eth"
requires
:
-
bedrock-echidna-build
-
bedrock-echidna-run
:
echidna_target
:
"
burn:gas"
size
:
2xlarge
requires
:
-
bedrock-echidna-build
-
op-bindings-build
:
-
op-bindings-build
:
requires
:
requires
:
-
yarn-monorepo
-
yarn-monorepo
...
...
packages/contracts-bedrock/contracts/echidna/FuzzBurn.sol
0 → 100644
View file @
8b70a0f3
pragma solidity 0.8.15;
import { Burn } from "../libraries/Burn.sol";
import { StdUtils } from "forge-std/Test.sol";
contract EchidnaFuzzBurnEth is StdUtils {
bool failedEthBurn;
/**
* @notice Takes an integer amount of eth to burn through the Burn library and
* updates the contract state if an incorrect amount of eth moved from the contract
*/
function testBurn(uint256 _value) public {
// cache the contract's eth balance
uint256 preBurnBalance = address(this).balance;
uint256 value = bound(_value, 0, preBurnBalance);
// execute a burn of _value eth
Burn.eth(value);
// check that exactly value eth was transfered from the contract
unchecked {
if (address(this).balance != preBurnBalance - value) {
failedEthBurn = true;
}
}
}
function echidna_burn_eth() public view returns (bool) {
// ASSERTION: The amount burned should always match the amount passed exactly
return !failedEthBurn;
}
}
contract EchidnaFuzzBurnGas is StdUtils {
bool failedGasBurn;
/**
* @notice Takes an integer amount of gas to burn through the Burn library and
* updates the contract state if at least that amount of gas was not burned
* by the library
*/
function testGas(uint256 _value) public {
// cap the value to the max resource limit
uint256 MAX_RESOURCE_LIMIT = 8_000_000;
uint256 value = bound(_value, 0, MAX_RESOURCE_LIMIT);
// cache the contract's current remaining gas
uint256 preBurnGas = gasleft();
// execute the gas burn
Burn.gas(value);
// cache the remaining gas post burn
uint256 postBurnGas = gasleft();
// check that at least value gas was burnt (and that there was no underflow)
unchecked {
if (postBurnGas - preBurnGas > value || preBurnGas - value > preBurnGas) {
failedGasBurn = true;
}
}
}
function echidna_burn_gas() public view returns (bool) {
// ASSERTION: The amount of gas burned should be strictly greater than the
// the amount passed as _value (minimum _value + whatever minor overhead to
// the value after the call)
return !failedGasBurn;
}
}
packages/contracts-bedrock/package.json
View file @
8b70a0f3
...
@@ -40,7 +40,8 @@
...
@@ -40,7 +40,8 @@
"lint"
:
"yarn lint:fix && yarn lint:check"
,
"lint"
:
"yarn lint:fix && yarn lint:check"
,
"typechain"
:
"typechain --target ethers-v5 --out-dir dist/types --glob 'artifacts/!(build-info)/**/+([a-zA-Z0-9_]).json'"
,
"typechain"
:
"typechain --target ethers-v5 --out-dir dist/types --glob 'artifacts/!(build-info)/**/+([a-zA-Z0-9_]).json'"
,
"echidna:aliasing"
:
"echidna-test --contract EchidnaFuzzAddressAliasing --config ./echidna.yaml ."
,
"echidna:aliasing"
:
"echidna-test --contract EchidnaFuzzAddressAliasing --config ./echidna.yaml ."
,
"echidna:burn"
:
"echidna-test --contract EchidnaFuzzBurn --config ./echidna.yaml ."
,
"echidna:burn:gas"
:
"echidna-test --contract EchidnaFuzzBurnGas --config ./echidna.yaml ."
,
"echidna:burn:eth"
:
"echidna-test --contract EchidnaFuzzBurnEth --config ./echidna.yaml ."
,
"echidna:encoding"
:
"echidna-test --contract EchidnaFuzzEncoding --config ./echidna.yaml ."
,
"echidna:encoding"
:
"echidna-test --contract EchidnaFuzzEncoding --config ./echidna.yaml ."
,
"echidna:portal"
:
"echidna-test --contract EchidnaFuzzOptimismPortal --config ./echidna.yaml ."
,
"echidna:portal"
:
"echidna-test --contract EchidnaFuzzOptimismPortal --config ./echidna.yaml ."
,
"echidna:hashing"
:
"echidna-test --contract EchidnaFuzzHashing --config ./echidna.yaml ."
,
"echidna:hashing"
:
"echidna-test --contract EchidnaFuzzHashing --config ./echidna.yaml ."
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment