-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Changes from 14 commits
9a594cb
7091ec7
c6a2bd4
9f05d1a
4209f92
2aec960
a34a630
9b76077
cbbdcb3
68a21f2
dd97da2
cf0f73a
62eee97
0dafb58
1b5ee7a
362532a
f5b346f
eb219d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
|
@@ -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; | ||
bytes memory callBytes; | ||
bytes32 methodId = ovmCallMethodId; | ||
uint _callSize; | ||
bytes memory _callBytes; | ||
address _ovmEntrypoint; | ||
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. I had been going with the convention of |
||
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) | ||
// skip method ID (bytes4) and timestamp (bytes32) | ||
_queueOrigin := calldataload(0x24) | ||
_queueOrigin := calldataload(add(4, 32)) | ||
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. I think we should either be all hex or all decimal. Also, any reason for adding the extra |
||
|
||
callBytes := mload(0x40) | ||
_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(68) | ||
calldatacopy(add(_callBytes, 32), 100, sub(_callSize, 4)) | ||
mstore(_callBytes, sub(_callSize, 36)) | ||
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 with all hex or all decimal. I'm cool whichever route, though. |
||
} | ||
|
||
return executeTransaction( | ||
_timestamp, | ||
_queueOrigin, | ||
_ovmEntrypoint, | ||
_callBytes, | ||
ZERO_ADDRESS, | ||
ZERO_ADDRESS, | ||
true | ||
); | ||
} | ||
|
||
/******************** | ||
|
@@ -201,7 +185,7 @@ 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); | ||
} | ||
|
||
/** | ||
|
@@ -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, | ||
|
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