-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Refactor executeCall to use executeUnsignedEOACall #65
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
9a594cb
Attempt to use unsignedEOACall instead of executeCall
karlfloersch 7091ec7
Remove double encoding of `methodIds.makeCall`
masonforest c6a2bd4
rename executeUnsignedEOACall to executeTransaction
masonforest 9f05d1a
Refactor `executeCall` test helper method
masonforest 4209f92
Remove assembly used for debugging
masonforest 2aec960
Run a successful ovmCALL
masonforest a34a630
Pass all call tests with executeCall using executeTransaction
masonforest 9b76077
Merge executeTransaction an executeTransaction2
masonforest cbbdcb3
Remove unused components of executeCall
masonforest 68a21f2
Rename executeCall to executeTransactionRaw
masonforest dd97da2
Revert changes to returndatacopy
masonforest cf0f73a
Rebase and pass tests
masonforest 62eee97
Revert newline changes
masonforest 0dafb58
Lint
masonforest 1b5ee7a
Rename `executeUnsignedEOACall` to `executeTransaction`
masonforest 362532a
Use hex in assembly
masonforest f5b346f
Rename callExecutionManagerExecuteUnsignedEOACall
masonforest eb219d8
Update @notice to reflect changes to the function name
masonforest File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -24,7 +24,6 @@ contract ExecutionManager is FullStateManager { | |
// bitwise right shift 28 * 8 bits so the 4 method ID bytes are in the right-most bytes | ||
bytes32 constant ovmCallMethodId = keccak256("ovmCALL()") >> 224; | ||
bytes32 constant ovmCreateMethodId = keccak256("ovmCREATE()") >> 224; | ||
bytes32 constant executeCallMethodId = keccak256("executeCall()") >> 224; | ||
|
||
// Precompile addresses | ||
address constant l2ToL1MessagePasserOvmAddress = 0x4200000000000000000000000000000000000000; | ||
|
@@ -106,7 +105,7 @@ contract ExecutionManager is FullStateManager { | |
} | ||
|
||
/** | ||
* @notice Execute a call which will return the result of the call instead of the updated storage. | ||
* @notice Execute a transaction which will return the result of the call instead of the updated storage. | ||
* Note: This should only be used with a Web3 `call` operation, otherwise you may accidentally save changes to the state. | ||
* Note: This is a raw function, so there are no listed (ABI-encoded) inputs / outputs. | ||
* Below format of the bytes expected as input and written as output: | ||
|
@@ -118,52 +117,37 @@ contract ExecutionManager is FullStateManager { | |
* [callBytes (bytes (variable length))] | ||
* returndata: [variable-length bytes returned from call] | ||
*/ | ||
function executeCall() external { | ||
function executeTransactionRaw() external { | ||
uint _timestamp; | ||
uint _queueOrigin; | ||
uint callSize; | ||
uint _callSize; | ||
bytes memory callBytes; | ||
bytes32 methodId = ovmCallMethodId; | ||
address _ovmEntrypoint; | ||
assembly { | ||
// Revert if we don't have methodId, timestamp, queueOrigin, and ovmEntrypointAddress. | ||
if lt(calldatasize, 100) { | ||
revert(0,0) | ||
} | ||
|
||
// populate timestamp and queue origin from calldata | ||
_timestamp := calldataload(4) | ||
_timestamp := calldataload(0x04) | ||
// skip method ID (bytes4) and timestamp (bytes32) | ||
_queueOrigin := calldataload(0x24) | ||
|
||
callBytes := mload(0x40) | ||
// set callsize: total param size minus 2 uints (methodId bytes are repurposed) | ||
callSize := sub(calldatasize, 0x40) | ||
mstore(0x40, add(callBytes, callSize)) | ||
|
||
// leave room for method ID, skip ahead in calldata methodID(4), timestamp(32), queueOrigin(32) | ||
calldatacopy(add(callBytes, 4), 0x44, sub(callSize, 4)) | ||
|
||
mstore8(callBytes, shr(24, methodId)) | ||
mstore8(add(callBytes, 1), shr(16, methodId)) | ||
mstore8(add(callBytes, 2), shr(8, methodId)) | ||
mstore8(add(callBytes, 3), methodId) | ||
} | ||
|
||
// Initialize our context | ||
initializeContext(_timestamp, _queueOrigin, ZERO_ADDRESS, ZERO_ADDRESS); | ||
|
||
address addr = address(this); | ||
assembly { | ||
let success := call(gas, addr, 0, callBytes, callSize, 0, 0) | ||
let result := mload(0x40) | ||
returndatacopy(result, 0, returndatasize) | ||
|
||
if eq(success, 0) { | ||
revert(result, returndatasize) | ||
} | ||
_callSize := sub(calldatasize, 0x40) | ||
mstore(0x40, add(callBytes, _callSize)) | ||
|
||
return(result, returndatasize) | ||
_ovmEntrypoint := calldataload(0x44) | ||
calldatacopy(add(callBytes, 0x20), 0x64, sub(_callSize, 0x04)) | ||
mstore(callBytes, sub(_callSize, 0x20)) | ||
} | ||
|
||
return executeTransaction( | ||
_timestamp, | ||
_queueOrigin, | ||
_ovmEntrypoint, | ||
callBytes, | ||
ZERO_ADDRESS, | ||
ZERO_ADDRESS, | ||
true | ||
); | ||
} | ||
|
||
/******************** | ||
|
@@ -201,11 +185,11 @@ contract ExecutionManager is FullStateManager { | |
require(_nonce == getOvmContractNonce(eoaAddress), "Incorrect nonce!"); | ||
emit CallingWithEOA(eoaAddress); | ||
// Make the EOA call for the account | ||
executeUnsignedEOACall(_timestamp, _queueOrigin, _ovmEntrypoint, _callBytes, eoaAddress, ZERO_ADDRESS, false); | ||
executeTransaction(_timestamp, _queueOrigin, _ovmEntrypoint, _callBytes, eoaAddress, ZERO_ADDRESS, false); | ||
} | ||
|
||
/** | ||
* @notice Execute an unsigned EOA call. Note that unsigned EOA calls are unauthenticated. | ||
* @notice Execute an unsigned EOA transaction. Note that unsigned EOA calls are unauthenticated. | ||
* This means that they should not be allowed for normal execution. | ||
* @param _timestamp The timestamp which should be used for this call's context. | ||
* @param _queueOrigin The parent-chain queue from which this call originated. | ||
|
@@ -214,7 +198,7 @@ contract ExecutionManager is FullStateManager { | |
* @param _fromAddress The address which this call should originate from--the msg.sender. | ||
* @param _allowRevert Flag which controls whether or not to revert in the case of failure. | ||
*/ | ||
function executeUnsignedEOACall( | ||
function executeTransaction( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above WRT |
||
uint _timestamp, | ||
uint _queueOrigin, | ||
address _ovmEntrypoint, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Would consider massaging the
@notice
above here for clarity as it currently says "Execute a call" and we are renaming the function fromexecuteCall