-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Zero Value Enforcers #31
base: main
Are you sure you want to change the base?
Conversation
/** | ||
* @title NoValueEnforcer | ||
* @dev This contract enforces that the execution has no value. | ||
* @dev This caveat enforcer only works when the execution is in single mode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @dev This caveat enforcer only works when the execution is in single mode. | |
* @dev This caveat enforcer only works in single and batch modes |
/** | ||
* @title NoCalldataEnforcer | ||
* @dev This contract enforces that the execution has no calldata. | ||
* @dev This caveat enforcer only works when the execution is in single mode. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @dev This caveat enforcer only works when the execution is in single mode. | |
* @dev This caveat enforcer only works in single and batch modes. |
require(callData_.length == 0, "NoCalldataEnforcer:calldata-not-allowed"); | ||
} else if (ModeLib.getCallType(_mode) == CALLTYPE_BATCH) { | ||
(Execution[] calldata executions_) = _executionCallData.decodeBatch(); | ||
for (uint256 i = 0; i < executions_.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (uint256 i = 0; i < executions_.length; i++) { | |
for (uint256 i = 0; i < executions_.length; ++i) { |
{ | ||
if (ModeLib.getCallType(_mode) == CALLTYPE_SINGLE) { | ||
(,, bytes calldata callData_) = _executionCallData.decodeSingle(); | ||
require(callData_.length == 0, "NoCalldataEnforcer:calldata-not-allowed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit concerned about the errors being exactly the same, it might help to differentiate them
please add the new enforcers to the deployment script |
import { CALLTYPE_SINGLE, CALLTYPE_BATCH } from "../utils/Constants.sol"; | ||
|
||
/** | ||
* @title NoCalldataEnforcer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see some places inside our contracts where calldata
is lowercase but in others it is callData
|
||
////////////////////////////// State ////////////////////////////// | ||
NoCalldataEnforcer public noCalldataEnforcer; | ||
DummyContract public c; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe DummyContract public dummy
; instead
require(value_ == 0, "NoValueEnforcer:value-not-allowed"); | ||
} else if (ModeLib.getCallType(_mode) == CALLTYPE_BATCH) { | ||
(Execution[] calldata executions_) = _executionCallData.decodeBatch(); | ||
for (uint256 i = 0; i < executions_.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (uint256 i = 0; i < executions_.length; i++) { | |
for (uint256 i = 0; i < executions_.length; ++i) { |
// should allow an execution in single mode with no calldata | ||
function test_singleMethodNoCalldataIsAllowed() public { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename tests, these are value tests not calldata
What?
NoValueEnforcer
restricts thevalue
field of theExecution
to0
for both single and batch execution modes. Noterms
are required.NoCalldataEnforcer
restricts thecalldata
field of theExecution
to `` (ie empty bytes array, no data) for both single and batch execution modes. Noterms
are required.