From 9a594cb92b2afa9ab379778276a34c69524ad974 Mon Sep 17 00:00:00 2001 From: Karl Floersch Date: Tue, 24 Mar 2020 14:56:11 -0400 Subject: [PATCH 01/18] Attempt to use unsignedEOACall instead of executeCall --- .../execution-manager.call-opcodes.spec.ts | 41 ++++++++++++++----- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts b/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts index 923dc62a1cef..1a741e80a791 100644 --- a/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts +++ b/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts @@ -123,7 +123,7 @@ describe('Execution Manager -- Call opcodes', () => { }) describe('ovmCALL', async () => { - it('properly executes ovmCALL to SLOAD', async () => { + it.only('properly executes ovmCALL to SLOAD', async () => { const result: string = await executeCall([ addressToBytes32Address(callContract2Address), methodIds.staticFriendlySLOAD, @@ -131,7 +131,7 @@ describe('Execution Manager -- Call opcodes', () => { ]) log.debug(`Result: [${result}]`) - remove0x(result).should.equal(unpopultedSLOADResult, 'Result mismatch!') + // remove0x(result).should.equal(unpopultedSLOADResult, 'Result mismatch!') }) it('properly executes ovmCALL to SSTORE', async () => { @@ -526,14 +526,35 @@ describe('Execution Manager -- Call opcodes', () => { }) const executeCall = (args: any[]): Promise => { - return executeOVMCall(executionManager, 'executeCall', [ - encodeRawArguments([ - getCurrentTime(), - 0, - addressToBytes32Address(callContractAddress), - methodIds.makeCall, - ...args, - ]), + const ovmCalldata: string = add0x( + encodeMethodId(methodIds.makeCall) + encodeRawArguments(args) + ) + + const internalCalldata = executionManager.interface.functions[ + 'executeUnsignedEOACall' + ].encode([ + getCurrentTime(), + 0, + callContractAddress, + ovmCalldata, + '0x' + '01'.repeat(20), + true, ]) + + return executionManager.provider.call({ + to: executionManager.address, + data: internalCalldata, + gasLimit: 10_000_000, + }) + + // return executeOVMCall(executionManager, 'executeCall', [ + // encodeRawArguments([ + // 0, + // 0, + // addressToBytes32Address(callContractAddress), + // methodIds.makeCall, + // ...args, + // ]), + // ]) } }) From 7091ec770232582e895fbcca4e80c64611d6660d Mon Sep 17 00:00:00 2001 From: Mason Fischer Date: Tue, 31 Mar 2020 18:24:51 -0400 Subject: [PATCH 02/18] Remove double encoding of `methodIds.makeCall` Other changes * Add allow_revert parameter --- .../execution-manager.call-opcodes.spec.ts | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts b/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts index 1a741e80a791..bbb40202b510 100644 --- a/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts +++ b/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts @@ -131,7 +131,7 @@ describe('Execution Manager -- Call opcodes', () => { ]) log.debug(`Result: [${result}]`) - // remove0x(result).should.equal(unpopultedSLOADResult, 'Result mismatch!') + remove0x(result).should.equal(unpopultedSLOADResult, 'Result mismatch!') }) it('properly executes ovmCALL to SSTORE', async () => { @@ -525,9 +525,9 @@ describe('Execution Manager -- Call opcodes', () => { }) }) - const executeCall = (args: any[]): Promise => { + const executeCall = async (args: any[]): Promise => { const ovmCalldata: string = add0x( - encodeMethodId(methodIds.makeCall) + encodeRawArguments(args) + methodIds.makeCall + encodeRawArguments(args) ) const internalCalldata = executionManager.interface.functions[ @@ -538,23 +538,23 @@ describe('Execution Manager -- Call opcodes', () => { callContractAddress, ovmCalldata, '0x' + '01'.repeat(20), + '0x' + '01'.repeat(20), true, ]) - - return executionManager.provider.call({ + const result = executionManager.provider.call({ to: executionManager.address, data: internalCalldata, gasLimit: 10_000_000, }) - // return executeOVMCall(executionManager, 'executeCall', [ - // encodeRawArguments([ - // 0, - // 0, - // addressToBytes32Address(callContractAddress), - // methodIds.makeCall, - // ...args, - // ]), - // ]) + return executeOVMCall(executionManager, 'executeCall', [ + encodeRawArguments([ + 0, + 0, + addressToBytes32Address(callContractAddress), + methodIds.makeCall, + ...args, + ]), + ]) } }) From c6a2bd493546e5f2b01c15d29f0ec0000b318972 Mon Sep 17 00:00:00 2001 From: Mason Fischer Date: Tue, 31 Mar 2020 18:48:57 -0400 Subject: [PATCH 03/18] rename executeUnsignedEOACall to executeTransaction --- packages/ovm/src/contracts/ExecutionManager.sol | 4 ++-- packages/ovm/src/contracts/L1ToL2MessagePasser.sol | 2 +- packages/ovm/src/contracts/L2ToL1MessageReceiver.sol | 2 +- .../ovm/src/contracts/precompiles/L2ToL1MessagePasser.sol | 2 +- .../test/contracts/execution-manager.call-opcodes.spec.ts | 4 ++-- .../test/contracts/execution-manager.executeCall.spec.ts | 8 ++++---- .../contracts/execution-manager.l1-l2-opcodes.spec.ts | 8 ++++---- packages/ovm/test/contracts/simple-storage.spec.ts | 4 ++-- packages/ovm/test/govm/simple-storage.spec.ts | 4 ++-- packages/ovm/test/helpers.ts | 6 +++--- 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/ovm/src/contracts/ExecutionManager.sol b/packages/ovm/src/contracts/ExecutionManager.sol index 2ba0d0f6c2d8..2b956bb14bd3 100644 --- a/packages/ovm/src/contracts/ExecutionManager.sol +++ b/packages/ovm/src/contracts/ExecutionManager.sol @@ -201,7 +201,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 +214,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( uint _timestamp, uint _queueOrigin, address _ovmEntrypoint, diff --git a/packages/ovm/src/contracts/L1ToL2MessagePasser.sol b/packages/ovm/src/contracts/L1ToL2MessagePasser.sol index 4d6ce5752768..d8ba09d169b2 100644 --- a/packages/ovm/src/contracts/L1ToL2MessagePasser.sol +++ b/packages/ovm/src/contracts/L1ToL2MessagePasser.sol @@ -19,4 +19,4 @@ contract L1ToL2MessagePasser { ovmCalldata ); } -} \ No newline at end of file +} diff --git a/packages/ovm/src/contracts/L2ToL1MessageReceiver.sol b/packages/ovm/src/contracts/L2ToL1MessageReceiver.sol index c864e504b592..4ec76615f764 100644 --- a/packages/ovm/src/contracts/L2ToL1MessageReceiver.sol +++ b/packages/ovm/src/contracts/L2ToL1MessageReceiver.sol @@ -54,4 +54,4 @@ contract L2ToL1MessageReceiver { function getMessageHash(dt.L2ToL1Message memory _message) internal pure returns(bytes32) { return keccak256(abi.encode(_message)); } -} \ No newline at end of file +} diff --git a/packages/ovm/src/contracts/precompiles/L2ToL1MessagePasser.sol b/packages/ovm/src/contracts/precompiles/L2ToL1MessagePasser.sol index 0636e2d86d84..6dfb1f0d8183 100644 --- a/packages/ovm/src/contracts/precompiles/L2ToL1MessagePasser.sol +++ b/packages/ovm/src/contracts/precompiles/L2ToL1MessagePasser.sol @@ -47,4 +47,4 @@ contract L2ToL1MessagePasser { } return theCaller; } -} \ No newline at end of file +} diff --git a/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts b/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts index bbb40202b510..441d8befaaf1 100644 --- a/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts +++ b/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts @@ -123,7 +123,7 @@ describe('Execution Manager -- Call opcodes', () => { }) describe('ovmCALL', async () => { - it.only('properly executes ovmCALL to SLOAD', async () => { + it('properly executes ovmCALL to SLOAD', async () => { const result: string = await executeCall([ addressToBytes32Address(callContract2Address), methodIds.staticFriendlySLOAD, @@ -531,7 +531,7 @@ describe('Execution Manager -- Call opcodes', () => { ) const internalCalldata = executionManager.interface.functions[ - 'executeUnsignedEOACall' + 'executeTransaction' ].encode([ getCurrentTime(), 0, diff --git a/packages/ovm/test/contracts/execution-manager.executeCall.spec.ts b/packages/ovm/test/contracts/execution-manager.executeCall.spec.ts index 577393324a29..48796dd69712 100644 --- a/packages/ovm/test/contracts/execution-manager.executeCall.spec.ts +++ b/packages/ovm/test/contracts/execution-manager.executeCall.spec.ts @@ -40,7 +40,7 @@ const log = getLogger('execution-manager-calls', true) *********/ const unsignedCallMethodId: string = ethereumjsAbi - .methodID('executeUnsignedEOACall', []) + .methodID('executeTransaction', []) .toString('hex') describe('Execution Manager -- Call opcodes', () => { @@ -145,7 +145,7 @@ describe('Execution Manager -- Call opcodes', () => { } // Call using Ethers - const tx = await executionManager.executeUnsignedEOACall( + const tx = await executionManager.executeTransaction( getCurrentTime(), 0, transaction.to, @@ -283,7 +283,7 @@ describe('Execution Manager -- Call opcodes', () => { const calldata = getUnsignedTransactionCalldata( executionManager, - 'executeUnsignedEOACall', + 'executeTransaction', [ ZERO_UINT, ZERO_UINT, @@ -325,7 +325,7 @@ describe('Execution Manager -- Call opcodes', () => { const calldata = getUnsignedTransactionCalldata( executionManager, - 'executeUnsignedEOACall', + 'executeTransaction', [ ZERO_UINT, ZERO_UINT, diff --git a/packages/ovm/test/contracts/execution-manager.l1-l2-opcodes.spec.ts b/packages/ovm/test/contracts/execution-manager.l1-l2-opcodes.spec.ts index 4ac4b23410f9..514740959d36 100644 --- a/packages/ovm/test/contracts/execution-manager.l1-l2-opcodes.spec.ts +++ b/packages/ovm/test/contracts/execution-manager.l1-l2-opcodes.spec.ts @@ -63,9 +63,9 @@ function overrideAbiFunctionData( } /** - * Use executeUnsignedEOACall with `eth_call`. + * Use executeTransaction with `eth_call`. * @param {ethers.Contract} an ExecutionManager contract instance used for it's address & provider. - * @param {Array} an array of parameters which should be fed into `executeUnsignedEOACall(...)`. + * @param {Array} an array of parameters which should be fed into `executeTransaction(...)`. * @param {OutputTypes} an array ABI types which should be used to decode the output of the call. */ function callExecutionManagerExecuteUnsignedEOACall( @@ -74,7 +74,7 @@ function callExecutionManagerExecuteUnsignedEOACall( outputTypes: any[] ): Promise { const modifiedAbi = cloneDeep(ExecutionManager.abi) - overrideAbiFunctionData(modifiedAbi, 'executeUnsignedEOACall', { + overrideAbiFunctionData(modifiedAbi, 'executeTransaction', { constant: true, outputs: outputTypes, }) @@ -83,7 +83,7 @@ function callExecutionManagerExecuteUnsignedEOACall( modifiedAbi, executionManager.provider ) - return callableExecutionManager.executeUnsignedEOACall.apply(null, parameters) + return callableExecutionManager.executeTransaction.apply(null, parameters) } /********* diff --git a/packages/ovm/test/contracts/simple-storage.spec.ts b/packages/ovm/test/contracts/simple-storage.spec.ts index 4e17e337aba0..40df79289ea2 100644 --- a/packages/ovm/test/contracts/simple-storage.spec.ts +++ b/packages/ovm/test/contracts/simple-storage.spec.ts @@ -16,7 +16,7 @@ import * as SimpleStorage from '../../build/contracts/SimpleStorage.json' import { manuallyDeployOvmContract, getUnsignedTransactionCalldata, - executeUnsignedEOACall, + executeTransaction, DEFAULT_ETHNODE_GAS_LIMIT, gasLimit, } from '../helpers' @@ -72,7 +72,7 @@ describe('SimpleStorage', () => { .toString('hex') const innerCallData: string = add0x(`${setStorageMethodId}${slot}${value}`) - return executeUnsignedEOACall( + return executeTransaction( executionManager, wallet, simpleStorageOvmAddress, diff --git a/packages/ovm/test/govm/simple-storage.spec.ts b/packages/ovm/test/govm/simple-storage.spec.ts index 47fb2b38592f..61bff922cbcd 100644 --- a/packages/ovm/test/govm/simple-storage.spec.ts +++ b/packages/ovm/test/govm/simple-storage.spec.ts @@ -17,7 +17,7 @@ import { ensureGovmIsConnected, manuallyDeployOvmContract, getUnsignedTransactionCalldata, - executeUnsignedEOACall, + executeTransaction, } from '../helpers' import { CHAIN_ID, GAS_LIMIT } from '../../src/app' @@ -69,7 +69,7 @@ describe('SimpleStorage', () => { const setStorage = async (slot, value): Promise => { const innerCallData: string = add0x(`${setStorageMethodId}${slot}${value}`) - return executeUnsignedEOACall( + return executeTransaction( executionManager, wallet, simpleStorageOvmAddress, diff --git a/packages/ovm/test/helpers.ts b/packages/ovm/test/helpers.ts index a6eb194a1e11..e0ac8a2cf325 100644 --- a/packages/ovm/test/helpers.ts +++ b/packages/ovm/test/helpers.ts @@ -72,7 +72,7 @@ export const manuallyDeployOvmContractReturnReceipt = async ( contractDefinition.bytecode ).getDeployTransaction(...constructorArguments).data as string - const receipt: TransactionReceipt = await executeUnsignedEOACall( + const receipt: TransactionReceipt = await executeTransaction( executionManager, wallet, undefined, @@ -103,7 +103,7 @@ export const manuallyDeployOvmContract = async ( return receipt.contractAddress } -export const executeUnsignedEOACall = async ( +export const executeTransaction = async ( executionManager: Contract, wallet: Wallet, to: Address, @@ -119,7 +119,7 @@ export const executeUnsignedEOACall = async ( const ovmTo = to === null || to === undefined ? ZERO_ADDRESS : to // Actually make the call - const tx = await executionManager.executeUnsignedEOACall( + const tx = await executionManager.executeTransaction( getCurrentTime(), 0, ovmTo, From 9f05d1a52e397b4d947a3a8a067a7dcaadb17207 Mon Sep 17 00:00:00 2001 From: Mason Fischer Date: Wed, 1 Apr 2020 07:59:00 -0400 Subject: [PATCH 04/18] Refactor `executeCall` test helper method --- .../execution-manager.call-opcodes.spec.ts | 104 ++++++++---------- 1 file changed, 43 insertions(+), 61 deletions(-) diff --git a/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts b/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts index 441d8befaaf1..06351c94a0f7 100644 --- a/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts +++ b/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts @@ -124,11 +124,11 @@ describe('Execution Manager -- Call opcodes', () => { describe('ovmCALL', async () => { it('properly executes ovmCALL to SLOAD', async () => { - const result: string = await executeCall([ - addressToBytes32Address(callContract2Address), + const result: string = await executeCall( + callContractAddress, methodIds.staticFriendlySLOAD, - sloadKey, - ]) + [sloadKey] + ) log.debug(`Result: [${result}]`) remove0x(result).should.equal(unpopultedSLOADResult, 'Result mismatch!') @@ -155,11 +155,11 @@ describe('Execution Manager -- Call opcodes', () => { gasLimit, }) - const result: string = await executeCall([ - addressToBytes32Address(callContract2Address), + const result: string = await executeCall( + callContract2Address, methodIds.staticFriendlySLOAD, - sloadKey, - ]) + [sloadKey] + ) log.debug(`Result: [${result}]`) @@ -168,11 +168,11 @@ describe('Execution Manager -- Call opcodes', () => { }) it('properly executes ovmCALL to CREATE', async () => { - const result: string = await executeCall([ - addressToBytes32Address(callContract2Address), + const result: string = await executeCall( + callContract2Address, methodIds.notStaticFriendlyCREATE, - deployTx.data, - ]) + [deployTx.data] + ) log.debug(`RESULT: ${result}`) @@ -185,12 +185,11 @@ describe('Execution Manager -- Call opcodes', () => { }) it('properly executes ovmCALL to CREATE2', async () => { - const result: string = await executeCall([ - addressToBytes32Address(callContract2Address), + const result: string = await executeCall( + callContract2Address, methodIds.notStaticFriendlyCREATE2, - 0, - deployTx.data, - ]) + [0, deployTx.data] + ) log.debug(`RESULT: ${result}`) @@ -226,11 +225,11 @@ describe('Execution Manager -- Call opcodes', () => { }) // Stored in contract 2 via delegate call but accessed via contract 1 - const result: string = await executeCall([ - addressToBytes32Address(callContractAddress), + const result: string = await executeCall( + callContractAddress, methodIds.staticFriendlySLOAD, - sloadKey, - ]) + [sloadKey] + ) log.debug(`Result: [${result}]`) // Should have stored result @@ -239,11 +238,11 @@ describe('Execution Manager -- Call opcodes', () => { 'SLOAD should yield stored result!' ) - const contract2Result: string = await executeCall([ + const contract2Result: string = await executeCall( addressToBytes32Address(callContract2Address), methodIds.staticFriendlySLOAD, - sloadKey, - ]) + [sloadKey] + ) log.debug(`Result: [${contract2Result}]`) @@ -278,11 +277,11 @@ describe('Execution Manager -- Call opcodes', () => { gasLimit, }) - const contract1Result: string = await executeCall([ - addressToBytes32Address(callContractAddress), + const contract1Result: string = await executeCall( + callContractAddress, methodIds.staticFriendlySLOAD, - sloadKey, - ]) + [sloadKey] + ) log.debug(`Result 1: [${contract1Result}]`) @@ -292,11 +291,11 @@ describe('Execution Manager -- Call opcodes', () => { 'SLOAD should yield stored data!' ) - const contract2Result: string = await executeCall([ - addressToBytes32Address(callContract2Address), + const contract2Result: string = await executeCall( + callContract2Address, methodIds.staticFriendlySLOAD, - sloadKey, - ]) + [sloadKey] + ) log.debug(`Result 2: [${contract2Result}]`) @@ -306,11 +305,11 @@ describe('Execution Manager -- Call opcodes', () => { 'SLOAD should not yield any data (0 x 32 bytes)!' ) - const contract3Result: string = await executeCall([ - addressToBytes32Address(callContract3Address), + const contract3Result: string = await executeCall( + callContract3Address, methodIds.staticFriendlySLOAD, - sloadKey, - ]) + [sloadKey] + ) log.debug(`Result 3: [${contract3Result}]`) @@ -525,34 +524,17 @@ describe('Execution Manager -- Call opcodes', () => { }) }) - const executeCall = async (args: any[]): Promise => { - const ovmCalldata: string = add0x( - methodIds.makeCall + encodeRawArguments(args) - ) - - const internalCalldata = executionManager.interface.functions[ - 'executeTransaction' - ].encode([ - getCurrentTime(), - 0, - callContractAddress, - ovmCalldata, - '0x' + '01'.repeat(20), - '0x' + '01'.repeat(20), - true, - ]) - const result = executionManager.provider.call({ - to: executionManager.address, - data: internalCalldata, - gasLimit: 10_000_000, - }) - + const executeCall = async ( + contractAddress: string, + methodId: string, + args: any[] + ): Promise => { return executeOVMCall(executionManager, 'executeCall', [ encodeRawArguments([ + getCurrentTime(), 0, - 0, - addressToBytes32Address(callContractAddress), - methodIds.makeCall, + addressToBytes32Address(contractAddress), + methodId, ...args, ]), ]) From 4209f922ebbd7fa67ea8129d58154d953f247cd7 Mon Sep 17 00:00:00 2001 From: Mason Fischer Date: Wed, 1 Apr 2020 15:56:45 -0400 Subject: [PATCH 05/18] Remove assembly used for debugging --- .../ovm/src/contracts/ExecutionManager.sol | 131 ++++++++++++++++++ .../execution-manager.call-opcodes.spec.ts | 4 +- 2 files changed, 134 insertions(+), 1 deletion(-) diff --git a/packages/ovm/src/contracts/ExecutionManager.sol b/packages/ovm/src/contracts/ExecutionManager.sol index 2b956bb14bd3..70ac0572745c 100644 --- a/packages/ovm/src/contracts/ExecutionManager.sol +++ b/packages/ovm/src/contracts/ExecutionManager.sol @@ -123,7 +123,10 @@ contract ExecutionManager is FullStateManager { uint _queueOrigin; uint callSize; bytes memory callBytes; + bytes memory callBytes2; + bytes memory callBytes3; bytes32 methodId = ovmCallMethodId; + address _ovmEntrypoint; assembly { // Revert if we don't have methodId, timestamp, queueOrigin, and ovmEntrypointAddress. if lt(calldatasize, 100) { @@ -147,7 +150,35 @@ contract ExecutionManager is FullStateManager { mstore8(add(callBytes, 1), shr(16, methodId)) mstore8(add(callBytes, 2), shr(8, methodId)) mstore8(add(callBytes, 3), methodId) + callBytes2 := mload(0x40) + mstore(callBytes2, callSize) + calldatacopy(add(callBytes2, 32), 0x44, sub(callSize, 4)) + /* mstore(0, callBytes2) */ + /* calldatacopy(_ovmEntrypoint, 0, 32) */ + _ovmEntrypoint := calldataload(0x40) + calldatacopy(add(callBytes3, 32), 100, sub(callSize, 4)) + mstore(callBytes3, sub(callSize, 36)) + + + /* mstore(0, _ovmEntrypoint) */ + /* return(add(callBytes3, 32), sub(callSize,36)) */ + } + +/* uint callSize3 = callBytes3.length; */ +/* assembly{ */ +/* mstore(0, callSize3) */ +/* return(0, 32) */ +/* } */ + return executeTransaction2( + _timestamp, + _queueOrigin, + _ovmEntrypoint, + callBytes3, + ZERO_ADDRESS, + ZERO_ADDRESS, + true + ); // Initialize our context initializeContext(_timestamp, _queueOrigin, ZERO_ADDRESS, ZERO_ADDRESS); @@ -214,6 +245,106 @@ 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 executeTransaction2( + uint _timestamp, + uint _queueOrigin, + address _ovmEntrypoint, + bytes memory _callBytes, + address _fromAddress, + address _l1MsgSenderAddress, + bool _allowRevert + ) public { + uint256 callSize2; + uint256 callSize; + bool isCreate = _ovmEntrypoint == ZERO_ADDRESS; + if (isCreate) { + callSize = _callBytes.length; + } else { + callSize = _callBytes.length + 32; + } + // Set methodId based on whether we're creating a contract + bytes32 methodId; + /* uint256 callSize; */ + // Check if we're creating -- ovmEntrypoint == ZERO_ADDRESS + if (isCreate) { + methodId = ovmCreateMethodId; + /* callSize = _callBytes.length + 4; */ + uint _nonce = getOvmContractNonce(_fromAddress); + // Emit event that we are creating a contract with an EOA + address _newOvmContractAddress = contractAddressGenerator.getAddressFromCREATE(_fromAddress, _nonce); + emit EOACreatedContract(_newOvmContractAddress); + } else { + methodId = ovmCallMethodId; + /* callSize = _callBytes.length + 32 + 4; */ + // Creates will get incremented, but calls need to be as well! + incrementOvmContractNonce(_fromAddress); + } + + assembly { + if eq(isCreate, 0) { + _callBytes := sub(_callBytes, 4) + // And now set the ovmEntrypoint + mstore(add(_callBytes, 4), _ovmEntrypoint) + // assembly { + //} + } + if eq(isCreate, 1) { + _callBytes := add(_callBytes, 28) + } + 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, _fromAddress, _l1MsgSenderAddress); + + // Set the active contract to be our EOA address + assembly { + return(_callBytes, callSize) + } + switchActiveContract(_fromAddress); + assembly { + if eq(isCreate, 0) { + // And now set the ovmEntrypoint + mstore(add(_callBytes, 4), _ovmEntrypoint) + } + } + + + bool success = false; + address addr = address(this); + bytes memory result; + assembly { + /* return(_callBytes, callSize) */ + /* assembly { */ + /* mstore(0, _ovmEntrypoint) */ + /* return(_callBytes, callSize) */ + /* } */ + success := call(gas, addr, 0, _callBytes, callSize, 0, 0) + result := mload(0x40) + let resultData := add(result, 0x20) + returndatacopy(resultData, 0, returndatasize) + + if eq(success, 1) { + return(resultData, returndatasize) + } + if eq(_allowRevert, 1) { + revert(resultData, returndatasize) + } + mstore(result, returndatasize) + mstore(0x40, add(resultData, returndatasize)) + } + + if (!success) { + // We need the tx to succeed even on failure so logs, nonce, etc. are preserved. + // This is how we indicate that the tx "failed." + emit EOACallRevert(result); + assembly { + return(0,0) + } + } + } function executeTransaction( uint _timestamp, uint _queueOrigin, diff --git a/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts b/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts index 06351c94a0f7..ec722f296575 100644 --- a/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts +++ b/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts @@ -123,7 +123,7 @@ describe('Execution Manager -- Call opcodes', () => { }) describe('ovmCALL', async () => { - it('properly executes ovmCALL to SLOAD', async () => { + it.only('properly executes ovmCALL to SLOAD', async () => { const result: string = await executeCall( callContractAddress, methodIds.staticFriendlySLOAD, @@ -529,6 +529,8 @@ describe('Execution Manager -- Call opcodes', () => { methodId: string, args: any[] ): Promise => { + console.log(contractAddress) + console.log(methodId) return executeOVMCall(executionManager, 'executeCall', [ encodeRawArguments([ getCurrentTime(), From 2aec960ac77f6d77c6f7d9cb93007a9367d78cfa Mon Sep 17 00:00:00 2001 From: Mason Fischer Date: Wed, 1 Apr 2020 15:57:27 -0400 Subject: [PATCH 06/18] Run a successful ovmCALL --- .../ovm/src/contracts/ExecutionManager.sol | 53 ++++++------------- 1 file changed, 16 insertions(+), 37 deletions(-) diff --git a/packages/ovm/src/contracts/ExecutionManager.sol b/packages/ovm/src/contracts/ExecutionManager.sol index 70ac0572745c..68f4b5d647d0 100644 --- a/packages/ovm/src/contracts/ExecutionManager.sol +++ b/packages/ovm/src/contracts/ExecutionManager.sol @@ -155,7 +155,7 @@ contract ExecutionManager is FullStateManager { calldatacopy(add(callBytes2, 32), 0x44, sub(callSize, 4)) /* mstore(0, callBytes2) */ /* calldatacopy(_ovmEntrypoint, 0, 32) */ - _ovmEntrypoint := calldataload(0x40) + _ovmEntrypoint := calldataload(68) calldatacopy(add(callBytes3, 32), 100, sub(callSize, 4)) mstore(callBytes3, sub(callSize, 36)) @@ -167,8 +167,8 @@ contract ExecutionManager is FullStateManager { /* uint callSize3 = callBytes3.length; */ /* assembly{ */ -/* mstore(0, callSize3) */ -/* return(0, 32) */ +/* mstore(0, _ovmEntrypoint) */ +/* return(0, 20) */ /* } */ return executeTransaction2( _timestamp, @@ -254,28 +254,27 @@ contract ExecutionManager is FullStateManager { address _l1MsgSenderAddress, bool _allowRevert ) public { - uint256 callSize2; - uint256 callSize; - bool isCreate = _ovmEntrypoint == ZERO_ADDRESS; - if (isCreate) { - callSize = _callBytes.length; - } else { - callSize = _callBytes.length + 32; - } + uint _nonce = getOvmContractNonce(_fromAddress); + // Initialize our context + initializeContext(_timestamp, _queueOrigin, _fromAddress, _l1MsgSenderAddress); + + // Set the active contract to be our EOA address + switchActiveContract(_fromAddress); + // Set methodId based on whether we're creating a contract bytes32 methodId; - /* uint256 callSize; */ + uint256 callSize; + bool isCreate = _ovmEntrypoint == ZERO_ADDRESS; // Check if we're creating -- ovmEntrypoint == ZERO_ADDRESS if (isCreate) { methodId = ovmCreateMethodId; - /* callSize = _callBytes.length + 4; */ - uint _nonce = getOvmContractNonce(_fromAddress); + callSize = _callBytes.length + 4; // Emit event that we are creating a contract with an EOA address _newOvmContractAddress = contractAddressGenerator.getAddressFromCREATE(_fromAddress, _nonce); emit EOACreatedContract(_newOvmContractAddress); } else { methodId = ovmCallMethodId; - /* callSize = _callBytes.length + 32 + 4; */ + callSize = _callBytes.length + 32 + 4; // Creates will get incremented, but calls need to be as well! incrementOvmContractNonce(_fromAddress); } @@ -285,8 +284,6 @@ contract ExecutionManager is FullStateManager { _callBytes := sub(_callBytes, 4) // And now set the ovmEntrypoint mstore(add(_callBytes, 4), _ovmEntrypoint) - // assembly { - //} } if eq(isCreate, 1) { _callBytes := add(_callBytes, 28) @@ -296,32 +293,14 @@ contract ExecutionManager is FullStateManager { mstore8(add(_callBytes, 2), shr(8, methodId)) mstore8(add(_callBytes, 3), methodId) } - // Initialize our context - initializeContext(_timestamp, _queueOrigin, _fromAddress, _l1MsgSenderAddress); - - // Set the active contract to be our EOA address - assembly { - return(_callBytes, callSize) - } - switchActiveContract(_fromAddress); - assembly { - if eq(isCreate, 0) { - // And now set the ovmEntrypoint - mstore(add(_callBytes, 4), _ovmEntrypoint) - } - } - bool success = false; address addr = address(this); bytes memory result; assembly { - /* return(_callBytes, callSize) */ - /* assembly { */ - /* mstore(0, _ovmEntrypoint) */ - /* return(_callBytes, callSize) */ - /* } */ success := call(gas, addr, 0, _callBytes, callSize, 0, 0) + mstore(0, success) + return(0, 32) result := mload(0x40) let resultData := add(result, 0x20) returndatacopy(resultData, 0, returndatasize) From a34a630fdc9f1ad8efbb2cc17bfa75f847b370ae Mon Sep 17 00:00:00 2001 From: Mason Fischer Date: Wed, 1 Apr 2020 16:50:24 -0400 Subject: [PATCH 07/18] Pass all call tests with executeCall using executeTransaction --- packages/ovm/src/contracts/ExecutionManager.sol | 7 +++---- .../test/contracts/execution-manager.call-opcodes.spec.ts | 6 ++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/ovm/src/contracts/ExecutionManager.sol b/packages/ovm/src/contracts/ExecutionManager.sol index 68f4b5d647d0..a8b2d1912d9c 100644 --- a/packages/ovm/src/contracts/ExecutionManager.sol +++ b/packages/ovm/src/contracts/ExecutionManager.sol @@ -299,16 +299,15 @@ contract ExecutionManager is FullStateManager { bytes memory result; assembly { success := call(gas, addr, 0, _callBytes, callSize, 0, 0) - mstore(0, success) - return(0, 32) result := mload(0x40) let resultData := add(result, 0x20) - returndatacopy(resultData, 0, returndatasize) if eq(success, 1) { - return(resultData, returndatasize) + returndatacopy(0, 0, returndatasize) + return(0, returndatasize) } if eq(_allowRevert, 1) { + returndatacopy(resultData, 0, returndatasize) revert(resultData, returndatasize) } mstore(result, returndatasize) diff --git a/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts b/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts index ec722f296575..9e830e67d35f 100644 --- a/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts +++ b/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts @@ -59,7 +59,7 @@ const sloadKey: string = '11'.repeat(32) const unpopultedSLOADResult: string = '00'.repeat(32) const populatedSLOADResult: string = '22'.repeat(32) -describe('Execution Manager -- Call opcodes', () => { +describe.only('Execution Manager -- Call opcodes', () => { const provider = createMockProvider({ gasLimit: DEFAULT_ETHNODE_GAS_LIMIT }) const [wallet] = getWallets(provider) // Create pointers to our execution manager & simple copier contract @@ -123,7 +123,7 @@ describe('Execution Manager -- Call opcodes', () => { }) describe('ovmCALL', async () => { - it.only('properly executes ovmCALL to SLOAD', async () => { + it('properly executes ovmCALL to SLOAD', async () => { const result: string = await executeCall( callContractAddress, methodIds.staticFriendlySLOAD, @@ -529,8 +529,6 @@ describe('Execution Manager -- Call opcodes', () => { methodId: string, args: any[] ): Promise => { - console.log(contractAddress) - console.log(methodId) return executeOVMCall(executionManager, 'executeCall', [ encodeRawArguments([ getCurrentTime(), From 9b760771feb176942987610936d98b4218ebe60b Mon Sep 17 00:00:00 2001 From: Mason Fischer Date: Thu, 2 Apr 2020 07:38:50 -0400 Subject: [PATCH 08/18] Merge executeTransaction an executeTransaction2 --- packages/ovm/src/contracts/ExecutionManager.sol | 5 +++-- .../test/contracts/execution-manager.call-opcodes.spec.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/ovm/src/contracts/ExecutionManager.sol b/packages/ovm/src/contracts/ExecutionManager.sol index a8b2d1912d9c..01da8fd1e502 100644 --- a/packages/ovm/src/contracts/ExecutionManager.sol +++ b/packages/ovm/src/contracts/ExecutionManager.sol @@ -170,7 +170,7 @@ contract ExecutionManager is FullStateManager { /* mstore(0, _ovmEntrypoint) */ /* return(0, 20) */ /* } */ - return executeTransaction2( + return executeTransaction( _timestamp, _queueOrigin, _ovmEntrypoint, @@ -245,7 +245,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 executeTransaction2( + function executeTransaction( uint _timestamp, uint _queueOrigin, address _ovmEntrypoint, @@ -323,6 +323,7 @@ contract ExecutionManager is FullStateManager { } } } + function executeTransaction( uint _timestamp, uint _queueOrigin, diff --git a/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts b/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts index 9e830e67d35f..06351c94a0f7 100644 --- a/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts +++ b/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts @@ -59,7 +59,7 @@ const sloadKey: string = '11'.repeat(32) const unpopultedSLOADResult: string = '00'.repeat(32) const populatedSLOADResult: string = '22'.repeat(32) -describe.only('Execution Manager -- Call opcodes', () => { +describe('Execution Manager -- Call opcodes', () => { const provider = createMockProvider({ gasLimit: DEFAULT_ETHNODE_GAS_LIMIT }) const [wallet] = getWallets(provider) // Create pointers to our execution manager & simple copier contract From cbbdcb32d95f58b4092f35c9a11106701a2b1b06 Mon Sep 17 00:00:00 2001 From: Mason Fischer Date: Thu, 2 Apr 2020 09:02:49 -0400 Subject: [PATCH 09/18] Remove unused components of executeCall --- .../ovm/src/contracts/ExecutionManager.sol | 83 ++++--------------- 1 file changed, 18 insertions(+), 65 deletions(-) diff --git a/packages/ovm/src/contracts/ExecutionManager.sol b/packages/ovm/src/contracts/ExecutionManager.sol index 01da8fd1e502..c3522576be23 100644 --- a/packages/ovm/src/contracts/ExecutionManager.sol +++ b/packages/ovm/src/contracts/ExecutionManager.sol @@ -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; @@ -121,80 +120,34 @@ contract ExecutionManager is FullStateManager { function executeCall() external { uint _timestamp; uint _queueOrigin; - uint callSize; - bytes memory callBytes; - bytes memory callBytes2; - bytes memory callBytes3; - bytes32 methodId = ovmCallMethodId; + uint _callSize; + bytes memory _callBytes; 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) // skip method ID (bytes4) and timestamp (bytes32) - _queueOrigin := calldataload(0x24) + _queueOrigin := calldataload(add(4, 32)) - 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) - callBytes2 := mload(0x40) - mstore(callBytes2, callSize) - calldatacopy(add(callBytes2, 32), 0x44, sub(callSize, 4)) - /* mstore(0, callBytes2) */ - /* calldatacopy(_ovmEntrypoint, 0, 32) */ + _callSize := sub(calldatasize, 0x40) + mstore(0x40, add(_callBytes, _callSize)) + _ovmEntrypoint := calldataload(68) - calldatacopy(add(callBytes3, 32), 100, sub(callSize, 4)) - mstore(callBytes3, sub(callSize, 36)) - - - /* mstore(0, _ovmEntrypoint) */ - /* return(add(callBytes3, 32), sub(callSize,36)) */ - + calldatacopy(add(_callBytes, 32), 100, sub(_callSize, 4)) + mstore(_callBytes, sub(_callSize, 36)) } - -/* uint callSize3 = callBytes3.length; */ -/* assembly{ */ -/* mstore(0, _ovmEntrypoint) */ -/* return(0, 20) */ -/* } */ + return executeTransaction( - _timestamp, - _queueOrigin, - _ovmEntrypoint, - callBytes3, - ZERO_ADDRESS, - ZERO_ADDRESS, - true - ); - - // 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) - } - - return(result, returndatasize) - } + _timestamp, + _queueOrigin, + _ovmEntrypoint, + _callBytes, + ZERO_ADDRESS, + ZERO_ADDRESS, + true + ); } /******************** From 68a21f28ab713c8162fd302e5be8a0433d46f06f Mon Sep 17 00:00:00 2001 From: Mason Fischer Date: Thu, 2 Apr 2020 09:25:14 -0400 Subject: [PATCH 10/18] Rename executeCall to executeTransactionRaw --- .../ovm/src/contracts/ExecutionManager.sol | 2 +- .../execution-manager.call-opcodes.spec.ts | 48 +++++++++---------- .../execution-manager.context-opcodes.spec.ts | 22 ++++----- .../execution-manager.l1-l2-opcodes.spec.ts | 2 +- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/packages/ovm/src/contracts/ExecutionManager.sol b/packages/ovm/src/contracts/ExecutionManager.sol index c3522576be23..8b29b849049a 100644 --- a/packages/ovm/src/contracts/ExecutionManager.sol +++ b/packages/ovm/src/contracts/ExecutionManager.sol @@ -117,7 +117,7 @@ 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; diff --git a/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts b/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts index 06351c94a0f7..ab01f113fcbf 100644 --- a/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts +++ b/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts @@ -42,7 +42,7 @@ const log = getLogger('execution-manager-calls', true) const methodIds = fromPairs( [ - 'executeCall', + 'executeTransactionRaw', 'makeCall', 'makeStaticCall', 'makeStaticCallThenCall', @@ -124,7 +124,7 @@ describe('Execution Manager -- Call opcodes', () => { describe('ovmCALL', async () => { it('properly executes ovmCALL to SLOAD', async () => { - const result: string = await executeCall( + const result: string = await executeTransaction( callContractAddress, methodIds.staticFriendlySLOAD, [sloadKey] @@ -136,7 +136,7 @@ describe('Execution Manager -- Call opcodes', () => { it('properly executes ovmCALL to SSTORE', async () => { const data: string = - encodeMethodId('executeCall') + + encodeMethodId('executeTransactionRaw') + encodeRawArguments([ getCurrentTime(), 0, @@ -155,7 +155,7 @@ describe('Execution Manager -- Call opcodes', () => { gasLimit, }) - const result: string = await executeCall( + const result: string = await executeTransaction( callContract2Address, methodIds.staticFriendlySLOAD, [sloadKey] @@ -168,7 +168,7 @@ describe('Execution Manager -- Call opcodes', () => { }) it('properly executes ovmCALL to CREATE', async () => { - const result: string = await executeCall( + const result: string = await executeTransaction( callContract2Address, methodIds.notStaticFriendlyCREATE, [deployTx.data] @@ -185,7 +185,7 @@ describe('Execution Manager -- Call opcodes', () => { }) it('properly executes ovmCALL to CREATE2', async () => { - const result: string = await executeCall( + const result: string = await executeTransaction( callContract2Address, methodIds.notStaticFriendlyCREATE2, [0, deployTx.data] @@ -205,7 +205,7 @@ describe('Execution Manager -- Call opcodes', () => { describe('ovmDELEGATECALL', async () => { it('properly executes ovmDELEGATECALL to SSTORE', async () => { const data: string = - methodIds.executeCall + + methodIds.executeTransactionRaw + encodeRawArguments([ getCurrentTime(), 0, @@ -225,7 +225,7 @@ describe('Execution Manager -- Call opcodes', () => { }) // Stored in contract 2 via delegate call but accessed via contract 1 - const result: string = await executeCall( + const result: string = await executeTransaction( callContractAddress, methodIds.staticFriendlySLOAD, [sloadKey] @@ -238,7 +238,7 @@ describe('Execution Manager -- Call opcodes', () => { 'SLOAD should yield stored result!' ) - const contract2Result: string = await executeCall( + const contract2Result: string = await executeTransaction( addressToBytes32Address(callContract2Address), methodIds.staticFriendlySLOAD, [sloadKey] @@ -256,7 +256,7 @@ describe('Execution Manager -- Call opcodes', () => { it('properly executes nested ovmDELEGATECALLs to SSTORE', async () => { // contract 1 delegate calls contract 2 delegate calls contract 3 const data: string = - methodIds.executeCall + + methodIds.executeTransactionRaw + encodeRawArguments([ getCurrentTime(), 0, @@ -277,7 +277,7 @@ describe('Execution Manager -- Call opcodes', () => { gasLimit, }) - const contract1Result: string = await executeCall( + const contract1Result: string = await executeTransaction( callContractAddress, methodIds.staticFriendlySLOAD, [sloadKey] @@ -291,7 +291,7 @@ describe('Execution Manager -- Call opcodes', () => { 'SLOAD should yield stored data!' ) - const contract2Result: string = await executeCall( + const contract2Result: string = await executeTransaction( callContract2Address, methodIds.staticFriendlySLOAD, [sloadKey] @@ -305,7 +305,7 @@ describe('Execution Manager -- Call opcodes', () => { 'SLOAD should not yield any data (0 x 32 bytes)!' ) - const contract3Result: string = await executeCall( + const contract3Result: string = await executeTransaction( callContract3Address, methodIds.staticFriendlySLOAD, [sloadKey] @@ -323,7 +323,7 @@ describe('Execution Manager -- Call opcodes', () => { describe('ovmSTATICCALL', async () => { it('properly executes ovmSTATICCALL to SLOAD', async () => { - const result = await executeOVMCall(executionManager, 'executeCall', [ + const result = await executeOVMCall(executionManager, 'executeTransactionRaw', [ 0, 0, addressToBytes32Address(callContractAddress), @@ -339,7 +339,7 @@ describe('Execution Manager -- Call opcodes', () => { }) it('properly executes nested ovmSTATICCALL to SLOAD', async () => { - const result = await executeOVMCall(executionManager, 'executeCall', [ + const result = await executeOVMCall(executionManager, 'executeTransactionRaw', [ 0, 0, addressToBytes32Address(callContractAddress), @@ -358,7 +358,7 @@ describe('Execution Manager -- Call opcodes', () => { it('successfully makes static call then call', async () => { const data: string = - methodIds.executeCall + + methodIds.executeTransactionRaw + encodeRawArguments([ getCurrentTime(), 0, @@ -377,7 +377,7 @@ describe('Execution Manager -- Call opcodes', () => { it('remains in static context when exiting nested static context', async () => { const data: string = - methodIds.executeCall + + methodIds.executeTransactionRaw + encodeRawArguments([ getCurrentTime(), 0, @@ -399,7 +399,7 @@ describe('Execution Manager -- Call opcodes', () => { it('fails on ovmSTATICCALL to SSTORE', async () => { const data: string = - methodIds.executeCall + + methodIds.executeTransactionRaw + encodeRawArguments([ getCurrentTime(), 0, @@ -423,7 +423,7 @@ describe('Execution Manager -- Call opcodes', () => { it('Fails to create on ovmSTATICCALL to CREATE -- tx', async () => { const data: string = - methodIds.executeCall + + methodIds.executeTransactionRaw + encodeRawArguments([ getCurrentTime(), 0, @@ -450,7 +450,7 @@ describe('Execution Manager -- Call opcodes', () => { it('Fails to create on ovmSTATICCALL to CREATE -- call', async () => { const data: string = - methodIds.executeCall + + methodIds.executeTransactionRaw + encodeRawArguments([ getCurrentTime(), 0, @@ -473,7 +473,7 @@ describe('Execution Manager -- Call opcodes', () => { it('fails on ovmSTATICCALL to CREATE2 -- tx', async () => { const data: string = - methodIds.executeCall + + methodIds.executeTransactionRaw + encodeRawArguments([ getCurrentTime(), 0, @@ -501,7 +501,7 @@ describe('Execution Manager -- Call opcodes', () => { it('fails on ovmSTATICCALL to CREATE2 -- call', async () => { const data: string = - methodIds.executeCall + + methodIds.executeTransactionRaw + encodeRawArguments([ getCurrentTime(), 0, @@ -524,12 +524,12 @@ describe('Execution Manager -- Call opcodes', () => { }) }) - const executeCall = async ( + const executeTransaction = async ( contractAddress: string, methodId: string, args: any[] ): Promise => { - return executeOVMCall(executionManager, 'executeCall', [ + return executeOVMCall(executionManager, 'executeTransactionRaw', [ encodeRawArguments([ getCurrentTime(), 0, diff --git a/packages/ovm/test/contracts/execution-manager.context-opcodes.spec.ts b/packages/ovm/test/contracts/execution-manager.context-opcodes.spec.ts index 9aab8f61eb86..eb8a6c77a555 100644 --- a/packages/ovm/test/contracts/execution-manager.context-opcodes.spec.ts +++ b/packages/ovm/test/contracts/execution-manager.context-opcodes.spec.ts @@ -36,7 +36,7 @@ const log = getLogger('execution-manager-context', true) const methodIds = fromPairs( [ 'callThroughExecutionManager', - 'executeCall', + 'executeTransactionRaw', 'getADDRESS', 'getCALLER', 'getGASLIMIT', @@ -112,12 +112,12 @@ describe('Execution Manager -- Context opcodes', () => { describe('ovmCALLER', async () => { it('reverts when CALLER is not set', async () => { await TestUtils.assertThrowsAsync(async () => { - await executeCall([contractAddress32, methodIds.ovmCALLER]) + await executeTransaction([contractAddress32, methodIds.ovmCALLER]) }) }) it('properly retrieves CALLER when caller is set', async () => { - const result = await executeCall([ + const result = await executeTransaction([ contractAddress32, methodIds.callThroughExecutionManager, contract2Address32, @@ -133,12 +133,12 @@ describe('Execution Manager -- Context opcodes', () => { describe('ovmADDRESS', async () => { it('reverts when ADDRESS is not set', async () => { await TestUtils.assertThrowsAsync(async () => { - await executeCall([contractAddress32, methodIds.ovmADDRESS]) + await executeTransaction([contractAddress32, methodIds.ovmADDRESS]) }) }) it('properly retrieves ADDRESS when address is set', async () => { - const result = await executeCall([ + const result = await executeTransaction([ contractAddress32, methodIds.callThroughExecutionManager, contract2Address32, @@ -155,7 +155,7 @@ describe('Execution Manager -- Context opcodes', () => { describe('ovmTIMESTAMP', async () => { it('properly retrieves TIMESTAMP', async () => { const timestamp: number = 1582890922 - const result = await executeOVMCall(executionManager, 'executeCall', [ + const result = await executeOVMCall(executionManager, 'executeTransactionRaw', [ timestamp, 0, contractAddress32, @@ -173,7 +173,7 @@ describe('Execution Manager -- Context opcodes', () => { describe('ovmGASLIMIT', async () => { it('properly retrieves GASLIMIT', async () => { - const result = await executeCall([ + const result = await executeTransaction([ contractAddress32, methodIds.callThroughExecutionManager, contract2Address32, @@ -190,7 +190,7 @@ describe('Execution Manager -- Context opcodes', () => { describe('ovmQueueOrigin', async () => { it('gets Queue Origin when it is 0', async () => { const queueOrigin: string = '00'.repeat(32) - const result = await executeOVMCall(executionManager, 'executeCall', [ + const result = await executeOVMCall(executionManager, 'executeTransactionRaw', [ getCurrentTime(), queueOrigin, contractAddress32, @@ -207,7 +207,7 @@ describe('Execution Manager -- Context opcodes', () => { it('properly retrieves Queue Origin when queue origin is set', async () => { const queueOrigin: string = '00'.repeat(30) + '1111' - const result = await executeOVMCall(executionManager, 'executeCall', [ + const result = await executeOVMCall(executionManager, 'executeTransactionRaw', [ getCurrentTime(), queueOrigin, contractAddress32, @@ -223,8 +223,8 @@ describe('Execution Manager -- Context opcodes', () => { }) }) - const executeCall = (args: any[]): Promise => { - return executeOVMCall(executionManager, 'executeCall', [ + const executeTransaction = (args: any[]): Promise => { + return executeOVMCall(executionManager, 'executeTransactionRaw', [ encodeRawArguments([getCurrentTime(), 0, ...args]), ]) } diff --git a/packages/ovm/test/contracts/execution-manager.l1-l2-opcodes.spec.ts b/packages/ovm/test/contracts/execution-manager.l1-l2-opcodes.spec.ts index 514740959d36..e9b427bbb657 100644 --- a/packages/ovm/test/contracts/execution-manager.l1-l2-opcodes.spec.ts +++ b/packages/ovm/test/contracts/execution-manager.l1-l2-opcodes.spec.ts @@ -124,7 +124,7 @@ describe('Execution Manager -- L1 <-> L2 Opcodes', () => { ethereumjsAbi.methodID('passMessageToL1', ['bytes']) ) const txData: string = - encodeMethodId('executeCall') + + encodeMethodId('executeTransactionRaw') + encodeRawArguments([ 0, 0, From dd97da28a3c667b16f7300b6c17315663a16faf6 Mon Sep 17 00:00:00 2001 From: Mason Fischer Date: Thu, 2 Apr 2020 09:40:43 -0400 Subject: [PATCH 11/18] Revert changes to returndatacopy Other changes: * Remove commented function --- .../ovm/src/contracts/ExecutionManager.sol | 79 ------------------- 1 file changed, 79 deletions(-) diff --git a/packages/ovm/src/contracts/ExecutionManager.sol b/packages/ovm/src/contracts/ExecutionManager.sol index 8b29b849049a..708af2957a06 100644 --- a/packages/ovm/src/contracts/ExecutionManager.sol +++ b/packages/ovm/src/contracts/ExecutionManager.sol @@ -198,85 +198,6 @@ 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 executeTransaction( - uint _timestamp, - uint _queueOrigin, - address _ovmEntrypoint, - bytes memory _callBytes, - address _fromAddress, - address _l1MsgSenderAddress, - bool _allowRevert - ) public { - uint _nonce = getOvmContractNonce(_fromAddress); - // Initialize our context - initializeContext(_timestamp, _queueOrigin, _fromAddress, _l1MsgSenderAddress); - - // Set the active contract to be our EOA address - switchActiveContract(_fromAddress); - - // Set methodId based on whether we're creating a contract - bytes32 methodId; - uint256 callSize; - bool isCreate = _ovmEntrypoint == ZERO_ADDRESS; - // Check if we're creating -- ovmEntrypoint == ZERO_ADDRESS - if (isCreate) { - methodId = ovmCreateMethodId; - callSize = _callBytes.length + 4; - // Emit event that we are creating a contract with an EOA - address _newOvmContractAddress = contractAddressGenerator.getAddressFromCREATE(_fromAddress, _nonce); - emit EOACreatedContract(_newOvmContractAddress); - } else { - methodId = ovmCallMethodId; - callSize = _callBytes.length + 32 + 4; - // Creates will get incremented, but calls need to be as well! - incrementOvmContractNonce(_fromAddress); - } - - assembly { - if eq(isCreate, 0) { - _callBytes := sub(_callBytes, 4) - // And now set the ovmEntrypoint - mstore(add(_callBytes, 4), _ovmEntrypoint) - } - if eq(isCreate, 1) { - _callBytes := add(_callBytes, 28) - } - mstore8(_callBytes, shr(24, methodId)) - mstore8(add(_callBytes, 1), shr(16, methodId)) - mstore8(add(_callBytes, 2), shr(8, methodId)) - mstore8(add(_callBytes, 3), methodId) - } - - bool success = false; - address addr = address(this); - bytes memory result; - assembly { - success := call(gas, addr, 0, _callBytes, callSize, 0, 0) - result := mload(0x40) - let resultData := add(result, 0x20) - - if eq(success, 1) { - returndatacopy(0, 0, returndatasize) - return(0, returndatasize) - } - if eq(_allowRevert, 1) { - returndatacopy(resultData, 0, returndatasize) - revert(resultData, returndatasize) - } - mstore(result, returndatasize) - mstore(0x40, add(resultData, returndatasize)) - } - - if (!success) { - // We need the tx to succeed even on failure so logs, nonce, etc. are preserved. - // This is how we indicate that the tx "failed." - emit EOACallRevert(result); - assembly { - return(0,0) - } - } - } - function executeTransaction( uint _timestamp, uint _queueOrigin, From cf0f73a9d0f24bfbe6a2e303030353cea84c0655 Mon Sep 17 00:00:00 2001 From: Mason Fischer Date: Thu, 2 Apr 2020 09:59:20 -0400 Subject: [PATCH 12/18] Rebase and pass tests --- .../ovm/test/contracts/execution-manager.call-opcodes.spec.ts | 4 ++-- .../test/contracts/execution-manager.l1-l2-opcodes.spec.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts b/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts index ab01f113fcbf..edf17fdf3eb1 100644 --- a/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts +++ b/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts @@ -324,7 +324,7 @@ describe('Execution Manager -- Call opcodes', () => { describe('ovmSTATICCALL', async () => { it('properly executes ovmSTATICCALL to SLOAD', async () => { const result = await executeOVMCall(executionManager, 'executeTransactionRaw', [ - 0, + getCurrentTime(), 0, addressToBytes32Address(callContractAddress), methodIds.makeStaticCall, @@ -340,7 +340,7 @@ describe('Execution Manager -- Call opcodes', () => { it('properly executes nested ovmSTATICCALL to SLOAD', async () => { const result = await executeOVMCall(executionManager, 'executeTransactionRaw', [ - 0, + getCurrentTime(), 0, addressToBytes32Address(callContractAddress), methodIds.makeStaticCall, diff --git a/packages/ovm/test/contracts/execution-manager.l1-l2-opcodes.spec.ts b/packages/ovm/test/contracts/execution-manager.l1-l2-opcodes.spec.ts index e9b427bbb657..f6ef3b2489c1 100644 --- a/packages/ovm/test/contracts/execution-manager.l1-l2-opcodes.spec.ts +++ b/packages/ovm/test/contracts/execution-manager.l1-l2-opcodes.spec.ts @@ -126,7 +126,7 @@ describe('Execution Manager -- L1 <-> L2 Opcodes', () => { const txData: string = encodeMethodId('executeTransactionRaw') + encodeRawArguments([ - 0, + getCurrentTime(), 0, addressToBytes32Address(callContractAddress), encodeMethodId('makeCall'), @@ -164,7 +164,7 @@ describe('Execution Manager -- L1 <-> L2 Opcodes', () => { ethereumjsAbi.methodID('getL1MessageSender', []) ) - it.only('should return the l1 message sender provided', async () => { + it('should return the l1 message sender provided', async () => { const l1MessageSenderPrecompileAddr = '0x4200000000000000000000000000000000000001' const testL1MsgSenderAddress = '0x' + '01'.repeat(20) From 62eee97ba05c074f5dad72aa8586f16bb9b639e7 Mon Sep 17 00:00:00 2001 From: Mason Fischer Date: Thu, 2 Apr 2020 10:01:54 -0400 Subject: [PATCH 13/18] Revert newline changes --- packages/ovm/src/contracts/L1ToL2MessagePasser.sol | 2 +- packages/ovm/src/contracts/L2ToL1MessageReceiver.sol | 2 +- packages/ovm/src/contracts/precompiles/L2ToL1MessagePasser.sol | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/ovm/src/contracts/L1ToL2MessagePasser.sol b/packages/ovm/src/contracts/L1ToL2MessagePasser.sol index d8ba09d169b2..4d6ce5752768 100644 --- a/packages/ovm/src/contracts/L1ToL2MessagePasser.sol +++ b/packages/ovm/src/contracts/L1ToL2MessagePasser.sol @@ -19,4 +19,4 @@ contract L1ToL2MessagePasser { ovmCalldata ); } -} +} \ No newline at end of file diff --git a/packages/ovm/src/contracts/L2ToL1MessageReceiver.sol b/packages/ovm/src/contracts/L2ToL1MessageReceiver.sol index 4ec76615f764..c864e504b592 100644 --- a/packages/ovm/src/contracts/L2ToL1MessageReceiver.sol +++ b/packages/ovm/src/contracts/L2ToL1MessageReceiver.sol @@ -54,4 +54,4 @@ contract L2ToL1MessageReceiver { function getMessageHash(dt.L2ToL1Message memory _message) internal pure returns(bytes32) { return keccak256(abi.encode(_message)); } -} +} \ No newline at end of file diff --git a/packages/ovm/src/contracts/precompiles/L2ToL1MessagePasser.sol b/packages/ovm/src/contracts/precompiles/L2ToL1MessagePasser.sol index 6dfb1f0d8183..0636e2d86d84 100644 --- a/packages/ovm/src/contracts/precompiles/L2ToL1MessagePasser.sol +++ b/packages/ovm/src/contracts/precompiles/L2ToL1MessagePasser.sol @@ -47,4 +47,4 @@ contract L2ToL1MessagePasser { } return theCaller; } -} +} \ No newline at end of file From 0dafb58f439c984a51341d65261096a49138ff3e Mon Sep 17 00:00:00 2001 From: Mason Fischer Date: Thu, 2 Apr 2020 10:13:19 -0400 Subject: [PATCH 14/18] Lint --- .../execution-manager.call-opcodes.spec.ts | 48 ++++++++------- .../execution-manager.context-opcodes.spec.ts | 60 +++++++++++-------- 2 files changed, 64 insertions(+), 44 deletions(-) diff --git a/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts b/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts index edf17fdf3eb1..c964264abac3 100644 --- a/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts +++ b/packages/ovm/test/contracts/execution-manager.call-opcodes.spec.ts @@ -323,15 +323,19 @@ describe('Execution Manager -- Call opcodes', () => { describe('ovmSTATICCALL', async () => { it('properly executes ovmSTATICCALL to SLOAD', async () => { - const result = await executeOVMCall(executionManager, 'executeTransactionRaw', [ - getCurrentTime(), - 0, - addressToBytes32Address(callContractAddress), - methodIds.makeStaticCall, - addressToBytes32Address(callContract2Address), - methodIds.staticFriendlySLOAD, - sloadKey, - ]) + const result = await executeOVMCall( + executionManager, + 'executeTransactionRaw', + [ + getCurrentTime(), + 0, + addressToBytes32Address(callContractAddress), + methodIds.makeStaticCall, + addressToBytes32Address(callContract2Address), + methodIds.staticFriendlySLOAD, + sloadKey, + ] + ) log.debug(`Result: [${result}]`) @@ -339,17 +343,21 @@ describe('Execution Manager -- Call opcodes', () => { }) it('properly executes nested ovmSTATICCALL to SLOAD', async () => { - const result = await executeOVMCall(executionManager, 'executeTransactionRaw', [ - getCurrentTime(), - 0, - addressToBytes32Address(callContractAddress), - methodIds.makeStaticCall, - addressToBytes32Address(callContract2Address), - methodIds.makeStaticCall, - addressToBytes32Address(callContract2Address), - methodIds.staticFriendlySLOAD, - sloadKey, - ]) + const result = await executeOVMCall( + executionManager, + 'executeTransactionRaw', + [ + getCurrentTime(), + 0, + addressToBytes32Address(callContractAddress), + methodIds.makeStaticCall, + addressToBytes32Address(callContract2Address), + methodIds.makeStaticCall, + addressToBytes32Address(callContract2Address), + methodIds.staticFriendlySLOAD, + sloadKey, + ] + ) log.debug(`Result: [${result}]`) diff --git a/packages/ovm/test/contracts/execution-manager.context-opcodes.spec.ts b/packages/ovm/test/contracts/execution-manager.context-opcodes.spec.ts index eb8a6c77a555..49ff7cfb831e 100644 --- a/packages/ovm/test/contracts/execution-manager.context-opcodes.spec.ts +++ b/packages/ovm/test/contracts/execution-manager.context-opcodes.spec.ts @@ -155,14 +155,18 @@ describe('Execution Manager -- Context opcodes', () => { describe('ovmTIMESTAMP', async () => { it('properly retrieves TIMESTAMP', async () => { const timestamp: number = 1582890922 - const result = await executeOVMCall(executionManager, 'executeTransactionRaw', [ - timestamp, - 0, - contractAddress32, - methodIds.callThroughExecutionManager, - contract2Address32, - methodIds.getTIMESTAMP, - ]) + const result = await executeOVMCall( + executionManager, + 'executeTransactionRaw', + [ + timestamp, + 0, + contractAddress32, + methodIds.callThroughExecutionManager, + contract2Address32, + methodIds.getTIMESTAMP, + ] + ) log.debug(`TIMESTAMP result: ${result}`) @@ -190,14 +194,18 @@ describe('Execution Manager -- Context opcodes', () => { describe('ovmQueueOrigin', async () => { it('gets Queue Origin when it is 0', async () => { const queueOrigin: string = '00'.repeat(32) - const result = await executeOVMCall(executionManager, 'executeTransactionRaw', [ - getCurrentTime(), - queueOrigin, - contractAddress32, - methodIds.callThroughExecutionManager, - contract2Address32, - methodIds.getQueueOrigin, - ]) + const result = await executeOVMCall( + executionManager, + 'executeTransactionRaw', + [ + getCurrentTime(), + queueOrigin, + contractAddress32, + methodIds.callThroughExecutionManager, + contract2Address32, + methodIds.getQueueOrigin, + ] + ) log.debug(`QUEUE ORIGIN result: ${result}`) @@ -207,14 +215,18 @@ describe('Execution Manager -- Context opcodes', () => { it('properly retrieves Queue Origin when queue origin is set', async () => { const queueOrigin: string = '00'.repeat(30) + '1111' - const result = await executeOVMCall(executionManager, 'executeTransactionRaw', [ - getCurrentTime(), - queueOrigin, - contractAddress32, - methodIds.callThroughExecutionManager, - contract2Address32, - methodIds.getQueueOrigin, - ]) + const result = await executeOVMCall( + executionManager, + 'executeTransactionRaw', + [ + getCurrentTime(), + queueOrigin, + contractAddress32, + methodIds.callThroughExecutionManager, + contract2Address32, + methodIds.getQueueOrigin, + ] + ) log.debug(`QUEUE ORIGIN result: ${result}`) From 1b5ee7ab1d4fc6c4f1913adcb40cc86fd57df49f Mon Sep 17 00:00:00 2001 From: Mason Fischer Date: Thu, 2 Apr 2020 10:46:15 -0400 Subject: [PATCH 15/18] Rename `executeUnsignedEOACall` to `executeTransaction` ... in rollup full node --- packages/rollup-full-node/src/app/web3-rpc-handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rollup-full-node/src/app/web3-rpc-handler.ts b/packages/rollup-full-node/src/app/web3-rpc-handler.ts index a3ffd359a5fd..6876ebd971d6 100644 --- a/packages/rollup-full-node/src/app/web3-rpc-handler.ts +++ b/packages/rollup-full-node/src/app/web3-rpc-handler.ts @@ -635,7 +635,7 @@ export class DefaultWeb3Handler implements Web3Handler, FullnodeHandler { ovmEntrypoint = ZERO_ADDRESS } return this.context.executionManager.interface.functions[ - 'executeUnsignedEOACall' + 'executeTransaction' ].encode([ timestamp, queueOrigin, From 362532acc832a79b7b5b7403f4c164a3c8e36fcb Mon Sep 17 00:00:00 2001 From: Mason Fischer Date: Thu, 2 Apr 2020 12:23:49 -0400 Subject: [PATCH 16/18] Use hex in assembly Other changes: 1. Rename _callBytes to callBytes --- .../ovm/src/contracts/ExecutionManager.sol | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/ovm/src/contracts/ExecutionManager.sol b/packages/ovm/src/contracts/ExecutionManager.sol index 708af2957a06..c4b2b99428b1 100644 --- a/packages/ovm/src/contracts/ExecutionManager.sol +++ b/packages/ovm/src/contracts/ExecutionManager.sol @@ -121,29 +121,29 @@ contract ExecutionManager is FullStateManager { uint _timestamp; uint _queueOrigin; uint _callSize; - bytes memory _callBytes; + bytes memory callBytes; address _ovmEntrypoint; assembly { // populate timestamp and queue origin from calldata - _timestamp := calldataload(4) + _timestamp := calldataload(0x04) // skip method ID (bytes4) and timestamp (bytes32) - _queueOrigin := calldataload(add(4, 32)) + _queueOrigin := calldataload(0x24) - _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)) + mstore(0x40, add(callBytes, _callSize)) - _ovmEntrypoint := calldataload(68) - calldatacopy(add(_callBytes, 32), 100, sub(_callSize, 4)) - mstore(_callBytes, sub(_callSize, 36)) + _ovmEntrypoint := calldataload(0x44) + calldatacopy(add(callBytes, 0x20), 0x64, sub(_callSize, 0x04)) + mstore(callBytes, sub(_callSize, 0x20)) } return executeTransaction( _timestamp, _queueOrigin, _ovmEntrypoint, - _callBytes, + callBytes, ZERO_ADDRESS, ZERO_ADDRESS, true From f5b346f717351244e35ee4c71fa9caa02312b821 Mon Sep 17 00:00:00 2001 From: Mason Fischer Date: Thu, 2 Apr 2020 12:31:41 -0400 Subject: [PATCH 17/18] Rename callExecutionManagerExecuteUnsignedEOACall ...to callExecutionManagerExecuteTransaction --- .../contracts/execution-manager.l1-l2-opcodes.spec.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/ovm/test/contracts/execution-manager.l1-l2-opcodes.spec.ts b/packages/ovm/test/contracts/execution-manager.l1-l2-opcodes.spec.ts index f6ef3b2489c1..fb7ac45e11b5 100644 --- a/packages/ovm/test/contracts/execution-manager.l1-l2-opcodes.spec.ts +++ b/packages/ovm/test/contracts/execution-manager.l1-l2-opcodes.spec.ts @@ -68,7 +68,7 @@ function overrideAbiFunctionData( * @param {Array} an array of parameters which should be fed into `executeTransaction(...)`. * @param {OutputTypes} an array ABI types which should be used to decode the output of the call. */ -function callExecutionManagerExecuteUnsignedEOACall( +function callExecutionManagerExecuteTransaction( executionManager: Contract, parameters: any[], outputTypes: any[] @@ -169,7 +169,7 @@ describe('Execution Manager -- L1 <-> L2 Opcodes', () => { '0x4200000000000000000000000000000000000001' const testL1MsgSenderAddress = '0x' + '01'.repeat(20) - const callResult = await callExecutionManagerExecuteUnsignedEOACall( + const callResult = await callExecutionManagerExecuteTransaction( executionManager, [ getCurrentTime(), @@ -195,7 +195,7 @@ describe('Execution Manager -- L1 <-> L2 Opcodes', () => { let failed = false try { - const callResult = await callExecutionManagerExecuteUnsignedEOACall( + const callResult = await callExecutionManagerExecuteTransaction( executionManager, [ 0, @@ -222,7 +222,7 @@ describe('Execution Manager -- L1 <-> L2 Opcodes', () => { let failed = false try { - const callResult = await callExecutionManagerExecuteUnsignedEOACall( + const callResult = await callExecutionManagerExecuteTransaction( executionManager, [ 0, From eb219d8041e7fc442fc493000ab52796e1280834 Mon Sep 17 00:00:00 2001 From: Mason Fischer Date: Thu, 2 Apr 2020 12:38:47 -0400 Subject: [PATCH 18/18] Update @notice to reflect changes to the function name --- packages/ovm/src/contracts/ExecutionManager.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/ovm/src/contracts/ExecutionManager.sol b/packages/ovm/src/contracts/ExecutionManager.sol index c4b2b99428b1..03efcfd0d67b 100644 --- a/packages/ovm/src/contracts/ExecutionManager.sol +++ b/packages/ovm/src/contracts/ExecutionManager.sol @@ -105,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: @@ -189,7 +189,7 @@ contract ExecutionManager is FullStateManager { } /** - * @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.