forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ctb: Add echidna test for AddressAliasing
ctb: Used a config file for echidna
- Loading branch information
Showing
8 changed files
with
83 additions
and
31 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,6 @@ | ||
--- | ||
'@eth-optimism/ci-builder': patch | ||
'@eth-optimism/contracts-bedrock': patch | ||
--- | ||
|
||
Add echidna test for AliasHelper |
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 |
---|---|---|
|
@@ -56,3 +56,6 @@ op-exporter | |
|
||
|
||
__pycache__ | ||
|
||
# Ignore echidna artifacts | ||
crytic-export |
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
33 changes: 33 additions & 0 deletions
33
packages/contracts-bedrock/contracts/echidna/FuzzAddressAliasing.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,33 @@ | ||
pragma solidity 0.8.15; | ||
|
||
import { AddressAliasHelper } from "../vendor/AddressAliasHelper.sol"; | ||
|
||
contract EchidnaFuzzAddressAliasing { | ||
bool failedRoundtrip; | ||
|
||
/** | ||
* @notice Takes an address to be aliased with AddressAliasHelper and then unaliased | ||
* and updates the test contract's state indicating if the round trip encoding | ||
* failed. | ||
*/ | ||
function testRoundTrip(address addr) public { | ||
// Alias our address | ||
address aliasedAddr = AddressAliasHelper.applyL1ToL2Alias(addr); | ||
|
||
// Unalias our address | ||
address undoneAliasAddr = AddressAliasHelper.undoL1ToL2Alias(aliasedAddr); | ||
|
||
// If our round trip aliasing did not return the original result, set our state. | ||
if (addr != undoneAliasAddr) { | ||
failedRoundtrip = true; | ||
} | ||
} | ||
|
||
/** | ||
* @notice Verifies that testRoundTrip(...) did not ever fail. | ||
*/ | ||
function echidna_round_trip_aliasing() public view returns (bool) { | ||
// ASSERTION: The round trip aliasing done in testRoundTrip(...) should never fail. | ||
return !failedRoundtrip; | ||
} | ||
} |
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,6 @@ | ||
cryticArgs: ["--hardhat-ignore-compile"] | ||
format: text | ||
|
||
# Set the timeout to 3 minutes to keep CI from getting too long. | ||
# The tool also adds 2 or 3 minutes before/after the actual timeout window. | ||
timeout: 180 |
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