-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reintroduce delegateCall; ofac/audit; merge tips + callbreaker; [wip]…
… existing examples + tests improvements (#37) * reintroduce delegateCall; ofac/audit; merge tips + callbreaker * completed PnP exmaple
- Loading branch information
Showing
21 changed files
with
575 additions
and
98 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ import "../timetravel/CallBreaker.sol"; | |
|
||
contract SmarterContract { | ||
CallBreaker public callbreaker; | ||
mapping(address => bool) public auditedContracts; | ||
mapping(address => bool) public ofacCensoredAddresses; | ||
|
||
/// @dev Selector 0xab63c583 | ||
error FutureCallExpected(); | ||
|
@@ -26,6 +28,12 @@ contract SmarterContract { | |
/// @dev Selector 0xd1cb360d | ||
error IllegalBackrun(); | ||
|
||
/// @dev Selector 0xed32fe28 | ||
error Unaudited(); | ||
|
||
/// @dev Selector 0xc19f17a9 | ||
error NotApproved(); | ||
|
||
/// @dev Constructs a new SmarterContract instance | ||
/// @param _callbreaker The address of the CallBreaker contract | ||
constructor(address _callbreaker) { | ||
|
@@ -53,6 +61,47 @@ contract SmarterContract { | |
_; | ||
} | ||
|
||
modifier onlyAudited(address _address) { | ||
auditedBlocker(_address); | ||
_; | ||
} | ||
|
||
modifier onlyOFACApproved(address _address) { | ||
OFAC_censoredBlocker(_address); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
_; | ||
} | ||
|
||
/// @notice Prevents execution by un-audited contracts | ||
/// @dev This function checks whether the provided address is in the list of audited contracts | ||
/// @param _address The address to check | ||
function auditedBlocker(address _address) public view { | ||
if (!auditedContracts[_address]) { | ||
revert Unaudited(); | ||
} | ||
} | ||
|
||
/// @notice Prevents calls to all addresses in the list | ||
/// @dev This function checks whether the provided address is in the list of OFAC censored addresses | ||
function OFAC_censoredBlocker(address _address) public view { | ||
if (ofacCensoredAddresses[_address]) { | ||
revert NotApproved(); | ||
} | ||
} | ||
|
||
/// @notice Sets a contract as OFAC blocked | ||
/// @dev This function adds the provided address to the list of OFAC censored addresses | ||
/// @param _address The address to be added to the list of OFAC censored addresses | ||
function setOFACBlocked(address _address) public { | ||
ofacCensoredAddresses[_address] = true; | ||
This comment has been minimized.
Sorry, something went wrong.
laudiacay
Contributor
|
||
} | ||
|
||
/// @notice Sets a contract as audited | ||
/// @dev This function adds the provided address to the list of audited contracts | ||
/// @param _address The address to be added to the list of audited contracts | ||
function setAuditedContract(address _address) public { | ||
auditedContracts[_address] = true; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
|
||
/// @notice Returns the call index, callobj, and returnobj of the currently executing call | ||
/// @dev This function allows for time travel by returning the returnobj of the currently executing call | ||
/// @return A pair consisting of the CallObject and ReturnObject of the currently executing call | ||
|
@@ -90,7 +139,7 @@ contract SmarterContract { | |
/// @notice Ensures that there is a future call to the specified callobject after the current call | ||
/// @dev This iterates over all call indices and ensures there's one after the current call. | ||
/// Adding a hintdex makes this cheaper. | ||
/// @param callObj The callobject to check for future calls | ||
/// @param callObj The callobject to check for. This callObject should strictly be a future call | ||
function assertFutureCallTo(CallObject memory callObj) public view { | ||
uint256[] memory cinds = callbreaker.getCallIndex(callObj); | ||
uint256 currentlyExecuting = callbreaker.getCurrentlyExecuting(); | ||
|
@@ -103,7 +152,7 @@ contract SmarterContract { | |
} | ||
|
||
/// @notice Ensures that there is a future call to the specified callobject after the current call | ||
/// @param callObj The callobject to check for future calls | ||
/// @param callObj The callobject to check for. This callObject should strictly be a future call | ||
/// @param hintdex The hint index to start checking for future calls | ||
/// @custom:reverts FutureCallExpected() Hintdexes should always be in the future of the current executing call | ||
/// @custom:reverts CallMismatch() The callobject at the hintdex should match the specified callObject | ||
|
This file was deleted.
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
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
Oops, something went wrong.
this is not how this should work- we need to pair on this to fix it
basically the concept is "scan the entire call stack to make sure it's entirely composed of calls to functions of contracts that are explicitly white/black listed"