Commit 6aa9220e authored by Maurelian's avatar Maurelian Committed by GitHub

Rename OVM precompiles to predeploys (#332)

* Rename OVM precompiles to predeploys

* Appease linter
Co-authored-by: default avatarsmartcontracts <kelvinfichter@gmail.com>
Co-authored-by: default avatarben-chain <ben@pseudonym.party>
parent cf78c786
...@@ -258,7 +258,7 @@ contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, Abs_BaseCros ...@@ -258,7 +258,7 @@ contract OVM_L1CrossDomainMessenger is iOVM_L1CrossDomainMessenger, Abs_BaseCros
require( require(
exists == true, exists == true,
"Message passing precompile has not been initialized or invalid proof provided." "Message passing predeploy has not been initialized or invalid proof provided."
); );
Lib_OVMCodec.EVMAccount memory account = Lib_OVMCodec.decodeEVMAccount( Lib_OVMCodec.EVMAccount memory account = Lib_OVMCodec.decodeEVMAccount(
......
...@@ -8,8 +8,8 @@ import { Lib_ReentrancyGuard } from "../../../libraries/utils/Lib_ReentrancyGuar ...@@ -8,8 +8,8 @@ import { Lib_ReentrancyGuard } from "../../../libraries/utils/Lib_ReentrancyGuar
/* Interface Imports */ /* Interface Imports */
import { iOVM_L2CrossDomainMessenger } from "../../../iOVM/bridge/messaging/iOVM_L2CrossDomainMessenger.sol"; import { iOVM_L2CrossDomainMessenger } from "../../../iOVM/bridge/messaging/iOVM_L2CrossDomainMessenger.sol";
import { iOVM_L1MessageSender } from "../../../iOVM/precompiles/iOVM_L1MessageSender.sol"; import { iOVM_L1MessageSender } from "../../../iOVM/predeploys/iOVM_L1MessageSender.sol";
import { iOVM_L2ToL1MessagePasser } from "../../../iOVM/precompiles/iOVM_L2ToL1MessagePasser.sol"; import { iOVM_L2ToL1MessagePasser } from "../../../iOVM/predeploys/iOVM_L2ToL1MessagePasser.sol";
/* Contract Imports */ /* Contract Imports */
import { Abs_BaseCrossDomainMessenger } from "./Abs_BaseCrossDomainMessenger.sol"; import { Abs_BaseCrossDomainMessenger } from "./Abs_BaseCrossDomainMessenger.sol";
......
...@@ -6,7 +6,7 @@ pragma experimental ABIEncoderV2; ...@@ -6,7 +6,7 @@ pragma experimental ABIEncoderV2;
/* Interface Imports */ /* Interface Imports */
import { iOVM_L1TokenGateway } from "../../../iOVM/bridge/tokens/iOVM_L1TokenGateway.sol"; import { iOVM_L1TokenGateway } from "../../../iOVM/bridge/tokens/iOVM_L1TokenGateway.sol";
import { Abs_L1TokenGateway } from "./Abs_L1TokenGateway.sol"; import { Abs_L1TokenGateway } from "./Abs_L1TokenGateway.sol";
import { iOVM_ERC20 } from "../../../iOVM/precompiles/iOVM_ERC20.sol"; import { iOVM_ERC20 } from "../../../iOVM/predeploys/iOVM_ERC20.sol";
/** /**
* @title OVM_L1ERC20Gateway * @title OVM_L1ERC20Gateway
......
...@@ -17,7 +17,7 @@ import { iOVM_SafetyChecker } from "../../iOVM/execution/iOVM_SafetyChecker.sol" ...@@ -17,7 +17,7 @@ import { iOVM_SafetyChecker } from "../../iOVM/execution/iOVM_SafetyChecker.sol"
/* Contract Imports */ /* Contract Imports */
import { OVM_ECDSAContractAccount } from "../accounts/OVM_ECDSAContractAccount.sol"; import { OVM_ECDSAContractAccount } from "../accounts/OVM_ECDSAContractAccount.sol";
import { OVM_ProxyEOA } from "../accounts/OVM_ProxyEOA.sol"; import { OVM_ProxyEOA } from "../accounts/OVM_ProxyEOA.sol";
import { OVM_DeployerWhitelist } from "../precompiles/OVM_DeployerWhitelist.sol"; import { OVM_DeployerWhitelist } from "../predeploys/OVM_DeployerWhitelist.sol";
/** /**
* @title OVM_ExecutionManager * @title OVM_ExecutionManager
......
...@@ -5,7 +5,7 @@ pragma solidity >0.5.0 <0.8.0; ...@@ -5,7 +5,7 @@ pragma solidity >0.5.0 <0.8.0;
import { Lib_Bytes32Utils } from "../../libraries/utils/Lib_Bytes32Utils.sol"; import { Lib_Bytes32Utils } from "../../libraries/utils/Lib_Bytes32Utils.sol";
/* Interface Imports */ /* Interface Imports */
import { iOVM_DeployerWhitelist } from "../../iOVM/precompiles/iOVM_DeployerWhitelist.sol"; import { iOVM_DeployerWhitelist } from "../../iOVM/predeploys/iOVM_DeployerWhitelist.sol";
import { Lib_SafeExecutionManagerWrapper } from "../../libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol"; import { Lib_SafeExecutionManagerWrapper } from "../../libraries/wrappers/Lib_SafeExecutionManagerWrapper.sol";
/** /**
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
pragma solidity >0.5.0 <0.8.0; pragma solidity >0.5.0 <0.8.0;
/* Interface Imports */ /* Interface Imports */
import { iOVM_L1MessageSender } from "../../iOVM/precompiles/iOVM_L1MessageSender.sol"; import { iOVM_L1MessageSender } from "../../iOVM/predeploys/iOVM_L1MessageSender.sol";
import { iOVM_ExecutionManager } from "../../iOVM/execution/iOVM_ExecutionManager.sol"; import { iOVM_ExecutionManager } from "../../iOVM/execution/iOVM_ExecutionManager.sol";
/** /**
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
pragma solidity >0.5.0 <0.8.0; pragma solidity >0.5.0 <0.8.0;
/* Interface Imports */ /* Interface Imports */
import { iOVM_L2ToL1MessagePasser } from "../../iOVM/precompiles/iOVM_L2ToL1MessagePasser.sol"; import { iOVM_L2ToL1MessagePasser } from "../../iOVM/predeploys/iOVM_L2ToL1MessagePasser.sol";
/** /**
* @title OVM_L2ToL1MessagePasser * @title OVM_L2ToL1MessagePasser
......
...@@ -3,22 +3,22 @@ pragma solidity >0.5.0 <0.8.0; ...@@ -3,22 +3,22 @@ pragma solidity >0.5.0 <0.8.0;
import { Helper_SimpleProxy } from "./Helper_SimpleProxy.sol"; import { Helper_SimpleProxy } from "./Helper_SimpleProxy.sol";
contract Helper_PrecompileCaller is Helper_SimpleProxy { contract Helper_PredeployCaller is Helper_SimpleProxy {
function callPrecompile( function callPredeploy(
address _precompile, address _predeploy,
bytes memory _data bytes memory _data
) )
public public
{ {
if (msg.sender == owner) { if (msg.sender == owner) {
makeExternalCall(_precompile, _data); makeExternalCall(_predeploy, _data);
} else { } else {
makeExternalCall(target, msg.data); makeExternalCall(target, msg.data);
} }
} }
function callPrecompileAbi( function callPredeployAbi(
address _precompile, address _predeploy,
bytes memory _data bytes memory _data
) )
public public
...@@ -30,16 +30,16 @@ contract Helper_PrecompileCaller is Helper_SimpleProxy { ...@@ -30,16 +30,16 @@ contract Helper_PrecompileCaller is Helper_SimpleProxy {
bool success; bool success;
bytes memory returndata; bytes memory returndata;
if (msg.sender == owner) { if (msg.sender == owner) {
(success, returndata) = _precompile.call(_data); (success, returndata) = _predeploy.call(_data);
} else { } else {
(success, returndata) = target.call(msg.data); (success, returndata) = target.call(msg.data);
} }
require(success, "Precompile call reverted"); require(success, "Predeploy call reverted");
return returndata; return returndata;
} }
function getL1MessageSender( function getL1MessageSender(
address _precompile, address _predeploy,
bytes memory _data bytes memory _data
) )
public public
...@@ -47,7 +47,7 @@ contract Helper_PrecompileCaller is Helper_SimpleProxy { ...@@ -47,7 +47,7 @@ contract Helper_PrecompileCaller is Helper_SimpleProxy {
address address
) )
{ {
callPrecompile(_precompile, _data); callPredeploy(_predeploy, _data);
return address(0); // unused: silence compiler return address(0); // unused: silence compiler
} }
} }
...@@ -160,7 +160,7 @@ export const makeStateDump = async (cfg: RollupDeployConfig): Promise<any> => { ...@@ -160,7 +160,7 @@ export const makeStateDump = async (cfg: RollupDeployConfig): Promise<any> => {
config = { ...config, ...cfg } config = { ...config, ...cfg }
const precompiles = { const predeploys = {
OVM_L2ToL1MessagePasser: '0x4200000000000000000000000000000000000000', OVM_L2ToL1MessagePasser: '0x4200000000000000000000000000000000000000',
OVM_L1MessageSender: '0x4200000000000000000000000000000000000001', OVM_L1MessageSender: '0x4200000000000000000000000000000000000001',
OVM_DeployerWhitelist: '0x4200000000000000000000000000000000000002', OVM_DeployerWhitelist: '0x4200000000000000000000000000000000000002',
...@@ -220,7 +220,7 @@ export const makeStateDump = async (cfg: RollupDeployConfig): Promise<any> => { ...@@ -220,7 +220,7 @@ export const makeStateDump = async (cfg: RollupDeployConfig): Promise<any> => {
} }
const deadAddress = const deadAddress =
precompiles[name] || predeploys[name] ||
`0xdeaddeaddeaddeaddeaddeaddeaddeaddead${i.toString(16).padStart(4, '0')}` `0xdeaddeaddeaddeaddeaddeaddeaddeaddead${i.toString(16).padStart(4, '0')}`
dump.accounts[name] = { dump.accounts[name] = {
......
...@@ -16,26 +16,26 @@ import { ...@@ -16,26 +16,26 @@ import {
decodeSolidityError, decodeSolidityError,
} from '../../../helpers' } from '../../../helpers'
const callPrecompile = async ( const callPredeploy = async (
Helper_PrecompileCaller: Contract, Helper_PredeployCaller: Contract,
precompile: Contract, predeploy: Contract,
functionName: string, functionName: string,
functionParams?: any[], functionParams?: any[],
gasLimit?: number gasLimit?: number
): Promise<any> => { ): Promise<any> => {
if (gasLimit) { if (gasLimit) {
return Helper_PrecompileCaller.callPrecompile( return Helper_PredeployCaller.callPredeploy(
precompile.address, predeploy.address,
precompile.interface.encodeFunctionData( predeploy.interface.encodeFunctionData(
functionName, functionName,
functionParams || [] functionParams || []
), ),
{ gasLimit } { gasLimit }
) )
} }
return Helper_PrecompileCaller.callPrecompile( return Helper_PredeployCaller.callPredeploy(
precompile.address, predeploy.address,
precompile.interface.encodeFunctionData(functionName, functionParams || []) predeploy.interface.encodeFunctionData(functionName, functionParams || [])
) )
} }
...@@ -48,16 +48,16 @@ describe('OVM_ECDSAContractAccount', () => { ...@@ -48,16 +48,16 @@ describe('OVM_ECDSAContractAccount', () => {
}) })
let Mock__OVM_ExecutionManager: MockContract let Mock__OVM_ExecutionManager: MockContract
let Helper_PrecompileCaller: Contract let Helper_PredeployCaller: Contract
before(async () => { before(async () => {
Mock__OVM_ExecutionManager = await smockit( Mock__OVM_ExecutionManager = await smockit(
await ethers.getContractFactory('OVM_ExecutionManager') await ethers.getContractFactory('OVM_ExecutionManager')
) )
Helper_PrecompileCaller = await ( Helper_PredeployCaller = await (
await ethers.getContractFactory('Helper_PrecompileCaller') await ethers.getContractFactory('Helper_PredeployCaller')
).deploy() ).deploy()
Helper_PrecompileCaller.setTarget(Mock__OVM_ExecutionManager.address) Helper_PredeployCaller.setTarget(Mock__OVM_ExecutionManager.address)
}) })
let Factory__OVM_ECDSAContractAccount: ContractFactory let Factory__OVM_ECDSAContractAccount: ContractFactory
...@@ -91,8 +91,8 @@ describe('OVM_ECDSAContractAccount', () => { ...@@ -91,8 +91,8 @@ describe('OVM_ECDSAContractAccount', () => {
const message = serializeNativeTransaction(DEFAULT_EIP155_TX) const message = serializeNativeTransaction(DEFAULT_EIP155_TX)
const sig = await signNativeTransaction(wallet, DEFAULT_EIP155_TX) const sig = await signNativeTransaction(wallet, DEFAULT_EIP155_TX)
await callPrecompile( await callPredeploy(
Helper_PrecompileCaller, Helper_PredeployCaller,
OVM_ECDSAContractAccount, OVM_ECDSAContractAccount,
'execute', 'execute',
[ [
...@@ -119,8 +119,8 @@ describe('OVM_ECDSAContractAccount', () => { ...@@ -119,8 +119,8 @@ describe('OVM_ECDSAContractAccount', () => {
const message = serializeEthSignTransaction(DEFAULT_EIP155_TX) const message = serializeEthSignTransaction(DEFAULT_EIP155_TX)
const sig = await signEthSignMessage(wallet, DEFAULT_EIP155_TX) const sig = await signEthSignMessage(wallet, DEFAULT_EIP155_TX)
await callPrecompile( await callPredeploy(
Helper_PrecompileCaller, Helper_PredeployCaller,
OVM_ECDSAContractAccount, OVM_ECDSAContractAccount,
'execute', 'execute',
[ [
...@@ -148,8 +148,8 @@ describe('OVM_ECDSAContractAccount', () => { ...@@ -148,8 +148,8 @@ describe('OVM_ECDSAContractAccount', () => {
const message = serializeNativeTransaction(createTx) const message = serializeNativeTransaction(createTx)
const sig = await signNativeTransaction(wallet, createTx) const sig = await signNativeTransaction(wallet, createTx)
await callPrecompile( await callPredeploy(
Helper_PrecompileCaller, Helper_PredeployCaller,
OVM_ECDSAContractAccount, OVM_ECDSAContractAccount,
'execute', 'execute',
[ [
...@@ -170,8 +170,8 @@ describe('OVM_ECDSAContractAccount', () => { ...@@ -170,8 +170,8 @@ describe('OVM_ECDSAContractAccount', () => {
const message = serializeNativeTransaction(DEFAULT_EIP155_TX) const message = serializeNativeTransaction(DEFAULT_EIP155_TX)
const sig = await signNativeTransaction(badWallet, DEFAULT_EIP155_TX) const sig = await signNativeTransaction(badWallet, DEFAULT_EIP155_TX)
await callPrecompile( await callPredeploy(
Helper_PrecompileCaller, Helper_PredeployCaller,
OVM_ECDSAContractAccount, OVM_ECDSAContractAccount,
'execute', 'execute',
[ [
...@@ -197,8 +197,8 @@ describe('OVM_ECDSAContractAccount', () => { ...@@ -197,8 +197,8 @@ describe('OVM_ECDSAContractAccount', () => {
const message = serializeNativeTransaction(alteredNonceTx) const message = serializeNativeTransaction(alteredNonceTx)
const sig = await signNativeTransaction(wallet, alteredNonceTx) const sig = await signNativeTransaction(wallet, alteredNonceTx)
await callPrecompile( await callPredeploy(
Helper_PrecompileCaller, Helper_PredeployCaller,
OVM_ECDSAContractAccount, OVM_ECDSAContractAccount,
'execute', 'execute',
[ [
...@@ -224,8 +224,8 @@ describe('OVM_ECDSAContractAccount', () => { ...@@ -224,8 +224,8 @@ describe('OVM_ECDSAContractAccount', () => {
const message = serializeNativeTransaction(alteredChainIdTx) const message = serializeNativeTransaction(alteredChainIdTx)
const sig = await signNativeTransaction(wallet, alteredChainIdTx) const sig = await signNativeTransaction(wallet, alteredChainIdTx)
await callPrecompile( await callPredeploy(
Helper_PrecompileCaller, Helper_PredeployCaller,
OVM_ECDSAContractAccount, OVM_ECDSAContractAccount,
'execute', 'execute',
[ [
...@@ -252,8 +252,8 @@ describe('OVM_ECDSAContractAccount', () => { ...@@ -252,8 +252,8 @@ describe('OVM_ECDSAContractAccount', () => {
const message = serializeNativeTransaction(alteredInsufficientGasTx) const message = serializeNativeTransaction(alteredInsufficientGasTx)
const sig = await signNativeTransaction(wallet, alteredInsufficientGasTx) const sig = await signNativeTransaction(wallet, alteredInsufficientGasTx)
await callPrecompile( await callPredeploy(
Helper_PrecompileCaller, Helper_PredeployCaller,
OVM_ECDSAContractAccount, OVM_ECDSAContractAccount,
'execute', 'execute',
[ [
...@@ -278,8 +278,8 @@ describe('OVM_ECDSAContractAccount', () => { ...@@ -278,8 +278,8 @@ describe('OVM_ECDSAContractAccount', () => {
const sig = await signNativeTransaction(wallet, DEFAULT_EIP155_TX) const sig = await signNativeTransaction(wallet, DEFAULT_EIP155_TX)
Mock__OVM_ExecutionManager.smocked.ovmCALL.will.return.with([false, '0x']) Mock__OVM_ExecutionManager.smocked.ovmCALL.will.return.with([false, '0x'])
await callPrecompile( await callPredeploy(
Helper_PrecompileCaller, Helper_PredeployCaller,
OVM_ECDSAContractAccount, OVM_ECDSAContractAccount,
'execute', 'execute',
[ [
......
...@@ -9,25 +9,22 @@ import { remove0x } from '@eth-optimism/core-utils' ...@@ -9,25 +9,22 @@ import { remove0x } from '@eth-optimism/core-utils'
/* Internal Imports */ /* Internal Imports */
import { decodeSolidityError } from '../../../helpers' import { decodeSolidityError } from '../../../helpers'
const callPrecompile = async ( const callPredeploy = async (
Helper_PrecompileCaller: Contract, Helper_PredeployCaller: Contract,
precompile: Contract, predeploy: Contract,
functionName: string, functionName: string,
functionParams?: any[], functionParams?: any[],
ethCall: boolean = false ethCall: boolean = false
): Promise<any> => { ): Promise<any> => {
if (ethCall) { if (ethCall) {
return Helper_PrecompileCaller.callStatic.callPrecompileAbi( return Helper_PredeployCaller.callStatic.callPredeployAbi(
precompile.address, predeploy.address,
precompile.interface.encodeFunctionData( predeploy.interface.encodeFunctionData(functionName, functionParams || [])
functionName,
functionParams || []
)
) )
} }
return Helper_PrecompileCaller.callPrecompile( return Helper_PredeployCaller.callPredeploy(
precompile.address, predeploy.address,
precompile.interface.encodeFunctionData(functionName, functionParams || []) predeploy.interface.encodeFunctionData(functionName, functionParams || [])
) )
} }
...@@ -44,17 +41,17 @@ describe('OVM_ProxyEOA', () => { ...@@ -44,17 +41,17 @@ describe('OVM_ProxyEOA', () => {
let Mock__OVM_ExecutionManager: MockContract let Mock__OVM_ExecutionManager: MockContract
let Mock__OVM_ECDSAContractAccount: MockContract let Mock__OVM_ECDSAContractAccount: MockContract
let Helper_PrecompileCaller: Contract let Helper_PredeployCaller: Contract
before(async () => { before(async () => {
Mock__OVM_ExecutionManager = await smockit( Mock__OVM_ExecutionManager = await smockit(
await ethers.getContractFactory('OVM_ExecutionManager') await ethers.getContractFactory('OVM_ExecutionManager')
) )
Helper_PrecompileCaller = await ( Helper_PredeployCaller = await (
await ethers.getContractFactory('Helper_PrecompileCaller') await ethers.getContractFactory('Helper_PredeployCaller')
).deploy() ).deploy()
Helper_PrecompileCaller.setTarget(Mock__OVM_ExecutionManager.address) Helper_PredeployCaller.setTarget(Mock__OVM_ExecutionManager.address)
Mock__OVM_ECDSAContractAccount = await smockit( Mock__OVM_ECDSAContractAccount = await smockit(
await ethers.getContractFactory('OVM_ECDSAContractAccount') await ethers.getContractFactory('OVM_ECDSAContractAccount')
...@@ -79,13 +76,13 @@ describe('OVM_ProxyEOA', () => { ...@@ -79,13 +76,13 @@ describe('OVM_ProxyEOA', () => {
}) })
describe('getImplementation()', () => { describe('getImplementation()', () => {
it(`should be created with implementation at precompile address`, async () => { it(`should be created with implementation at predeploy address`, async () => {
const eoaDefaultAddrBytes32 = addrToBytes32(eoaDefaultAddr) const eoaDefaultAddrBytes32 = addrToBytes32(eoaDefaultAddr)
Mock__OVM_ExecutionManager.smocked.ovmSLOAD.will.return.with( Mock__OVM_ExecutionManager.smocked.ovmSLOAD.will.return.with(
eoaDefaultAddrBytes32 eoaDefaultAddrBytes32
) )
const implAddrBytes32 = await callPrecompile( const implAddrBytes32 = await callPredeploy(
Helper_PrecompileCaller, Helper_PredeployCaller,
OVM_ProxyEOA, OVM_ProxyEOA,
'getImplementation', 'getImplementation',
[], [],
...@@ -100,7 +97,7 @@ describe('OVM_ProxyEOA', () => { ...@@ -100,7 +97,7 @@ describe('OVM_ProxyEOA', () => {
it(`should upgrade the proxy implementation`, async () => { it(`should upgrade the proxy implementation`, async () => {
const newImpl = `0x${'81'.repeat(20)}` const newImpl = `0x${'81'.repeat(20)}`
const newImplBytes32 = addrToBytes32(newImpl) const newImplBytes32 = addrToBytes32(newImpl)
await callPrecompile(Helper_PrecompileCaller, OVM_ProxyEOA, 'upgrade', [ await callPredeploy(Helper_PredeployCaller, OVM_ProxyEOA, 'upgrade', [
newImpl, newImpl,
]) ])
const ovmSSTORE: any = const ovmSSTORE: any =
...@@ -113,7 +110,7 @@ describe('OVM_ProxyEOA', () => { ...@@ -113,7 +110,7 @@ describe('OVM_ProxyEOA', () => {
await wallet.getAddress() await wallet.getAddress()
) )
const newImpl = `0x${'81'.repeat(20)}` const newImpl = `0x${'81'.repeat(20)}`
await callPrecompile(Helper_PrecompileCaller, OVM_ProxyEOA, 'upgrade', [ await callPredeploy(Helper_PredeployCaller, OVM_ProxyEOA, 'upgrade', [
newImpl, newImpl,
]) ])
const ovmREVERT: any = const ovmREVERT: any =
...@@ -133,10 +130,7 @@ describe('OVM_ProxyEOA', () => { ...@@ -133,10 +130,7 @@ describe('OVM_ProxyEOA', () => {
'0x1234', '0x1234',
]) ])
const calldata = '0xdeadbeef' const calldata = '0xdeadbeef'
await Helper_PrecompileCaller.callPrecompile( await Helper_PredeployCaller.callPredeploy(OVM_ProxyEOA.address, calldata)
OVM_ProxyEOA.address,
calldata
)
const ovmDELEGATECALL: any = const ovmDELEGATECALL: any =
Mock__OVM_ExecutionManager.smocked.ovmDELEGATECALL.calls[0] Mock__OVM_ExecutionManager.smocked.ovmDELEGATECALL.calls[0]
......
...@@ -6,15 +6,15 @@ import { ContractFactory, Contract } from 'ethers' ...@@ -6,15 +6,15 @@ import { ContractFactory, Contract } from 'ethers'
import { MockContract, smockit } from '@eth-optimism/smock' import { MockContract, smockit } from '@eth-optimism/smock'
import { NON_ZERO_ADDRESS } from '../../../helpers/constants' import { NON_ZERO_ADDRESS } from '../../../helpers/constants'
const callPrecompileStatic = async ( const callPredeployStatic = async (
Helper_PrecompileCaller: Contract, Helper_PredeployCaller: Contract,
precompile: Contract, predeploy: Contract,
functionName: string, functionName: string,
functionParams?: any[] functionParams?: any[]
): Promise<any> => { ): Promise<any> => {
return Helper_PrecompileCaller.callStatic[functionName]( return Helper_PredeployCaller.callStatic[functionName](
precompile.address, predeploy.address,
precompile.interface.encodeFunctionData(functionName, functionParams || []) predeploy.interface.encodeFunctionData(functionName, functionParams || [])
) )
} }
...@@ -26,13 +26,13 @@ describe('OVM_L1MessageSender', () => { ...@@ -26,13 +26,13 @@ describe('OVM_L1MessageSender', () => {
) )
}) })
let Helper_PrecompileCaller: Contract let Helper_PredeployCaller: Contract
before(async () => { before(async () => {
Helper_PrecompileCaller = await ( Helper_PredeployCaller = await (
await ethers.getContractFactory('Helper_PrecompileCaller') await ethers.getContractFactory('Helper_PredeployCaller')
).deploy() ).deploy()
Helper_PrecompileCaller.setTarget(Mock__OVM_ExecutionManager.address) Helper_PredeployCaller.setTarget(Mock__OVM_ExecutionManager.address)
}) })
let Factory__OVM_L1MessageSender: ContractFactory let Factory__OVM_L1MessageSender: ContractFactory
...@@ -56,8 +56,8 @@ describe('OVM_L1MessageSender', () => { ...@@ -56,8 +56,8 @@ describe('OVM_L1MessageSender', () => {
it('should return the L1 message sender', async () => { it('should return the L1 message sender', async () => {
expect( expect(
await callPrecompileStatic( await callPredeployStatic(
Helper_PrecompileCaller, Helper_PredeployCaller,
OVM_L1MessageSender, OVM_L1MessageSender,
'getL1MessageSender' 'getL1MessageSender'
) )
......
...@@ -12,15 +12,15 @@ import { NON_ZERO_ADDRESS } from '../../../helpers/constants' ...@@ -12,15 +12,15 @@ import { NON_ZERO_ADDRESS } from '../../../helpers/constants'
const ELEMENT_TEST_SIZES = [1, 2, 4, 8, 16] const ELEMENT_TEST_SIZES = [1, 2, 4, 8, 16]
const callPrecompile = async ( const callPredeploy = async (
Helper_PrecompileCaller: Contract, Helper_PredeployCaller: Contract,
precompile: Contract, predeploy: Contract,
functionName: string, functionName: string,
functionParams?: any[] functionParams?: any[]
): Promise<any> => { ): Promise<any> => {
return Helper_PrecompileCaller.callPrecompile( return Helper_PredeployCaller.callPredeploy(
precompile.address, predeploy.address,
precompile.interface.encodeFunctionData(functionName, functionParams || []) predeploy.interface.encodeFunctionData(functionName, functionParams || [])
) )
} }
...@@ -32,13 +32,13 @@ describe('OVM_L2ToL1MessagePasser', () => { ...@@ -32,13 +32,13 @@ describe('OVM_L2ToL1MessagePasser', () => {
) )
}) })
let Helper_PrecompileCaller: Contract let Helper_PredeployCaller: Contract
before(async () => { before(async () => {
Helper_PrecompileCaller = await ( Helper_PredeployCaller = await (
await ethers.getContractFactory('Helper_PrecompileCaller') await ethers.getContractFactory('Helper_PredeployCaller')
).deploy() ).deploy()
Helper_PrecompileCaller.setTarget(Mock__OVM_ExecutionManager.address) Helper_PredeployCaller.setTarget(Mock__OVM_ExecutionManager.address)
}) })
let Factory__OVM_L2ToL1MessagePasser: ContractFactory let Factory__OVM_L2ToL1MessagePasser: ContractFactory
...@@ -65,8 +65,8 @@ describe('OVM_L2ToL1MessagePasser', () => { ...@@ -65,8 +65,8 @@ describe('OVM_L2ToL1MessagePasser', () => {
for (let i = 0; i < size; i++) { for (let i = 0; i < size; i++) {
const message = '0x' + '12' + '34'.repeat(i) const message = '0x' + '12' + '34'.repeat(i)
await callPrecompile( await callPredeploy(
Helper_PrecompileCaller, Helper_PredeployCaller,
OVM_L2ToL1MessagePasser, OVM_L2ToL1MessagePasser,
'passMessageToL1', 'passMessageToL1',
[message] [message]
...@@ -74,7 +74,7 @@ describe('OVM_L2ToL1MessagePasser', () => { ...@@ -74,7 +74,7 @@ describe('OVM_L2ToL1MessagePasser', () => {
expect( expect(
await OVM_L2ToL1MessagePasser.sentMessages( await OVM_L2ToL1MessagePasser.sentMessages(
keccak256(message + remove0x(Helper_PrecompileCaller.address)) keccak256(message + remove0x(Helper_PredeployCaller.address))
) )
).to.equal(true) ).to.equal(true)
} }
......
...@@ -9,15 +9,15 @@ import { remove0x } from '@eth-optimism/core-utils' ...@@ -9,15 +9,15 @@ import { remove0x } from '@eth-optimism/core-utils'
/* Internal Imports */ /* Internal Imports */
import { decodeSolidityError } from '../../../helpers' import { decodeSolidityError } from '../../../helpers'
const callPrecompile = async ( const callPredeploy = async (
Helper_PrecompileCaller: Contract, Helper_PredeployCaller: Contract,
precompile: Contract, predeploy: Contract,
functionName: string, functionName: string,
functionParams?: any[] functionParams?: any[]
): Promise<any> => { ): Promise<any> => {
return Helper_PrecompileCaller.callPrecompile( return Helper_PredeployCaller.callPredeploy(
precompile.address, predeploy.address,
precompile.interface.encodeFunctionData(functionName, functionParams || []) predeploy.interface.encodeFunctionData(functionName, functionParams || [])
) )
} }
...@@ -39,7 +39,7 @@ describe('OVM_ProxySequencerEntrypoint', () => { ...@@ -39,7 +39,7 @@ describe('OVM_ProxySequencerEntrypoint', () => {
}) })
let Mock__OVM_ExecutionManager: MockContract let Mock__OVM_ExecutionManager: MockContract
let Helper_PrecompileCaller: Contract let Helper_PredeployCaller: Contract
let OVM_SequencerEntrypoint: Contract let OVM_SequencerEntrypoint: Contract
before(async () => { before(async () => {
Mock__OVM_ExecutionManager = await smockit( Mock__OVM_ExecutionManager = await smockit(
...@@ -53,11 +53,11 @@ describe('OVM_ProxySequencerEntrypoint', () => { ...@@ -53,11 +53,11 @@ describe('OVM_ProxySequencerEntrypoint', () => {
Mock__OVM_ExecutionManager.smocked.ovmEXTCODESIZE.will.return.with(0) Mock__OVM_ExecutionManager.smocked.ovmEXTCODESIZE.will.return.with(0)
Mock__OVM_ExecutionManager.smocked.ovmCHAINID.will.return.with(420) Mock__OVM_ExecutionManager.smocked.ovmCHAINID.will.return.with(420)
Helper_PrecompileCaller = await ( Helper_PredeployCaller = await (
await ethers.getContractFactory('Helper_PrecompileCaller') await ethers.getContractFactory('Helper_PredeployCaller')
).deploy() ).deploy()
Helper_PrecompileCaller.setTarget(Mock__OVM_ExecutionManager.address) Helper_PredeployCaller.setTarget(Mock__OVM_ExecutionManager.address)
OVM_SequencerEntrypoint = await ( OVM_SequencerEntrypoint = await (
await ethers.getContractFactory('OVM_SequencerEntrypoint') await ethers.getContractFactory('OVM_SequencerEntrypoint')
...@@ -72,8 +72,8 @@ describe('OVM_ProxySequencerEntrypoint', () => { ...@@ -72,8 +72,8 @@ describe('OVM_ProxySequencerEntrypoint', () => {
Mock__OVM_ExecutionManager.smocked.ovmSLOAD.will.return.with( Mock__OVM_ExecutionManager.smocked.ovmSLOAD.will.return.with(
`0x${'00'.repeat(32)}` `0x${'00'.repeat(32)}`
) )
await callPrecompile( await callPredeploy(
Helper_PrecompileCaller, Helper_PredeployCaller,
OVM_ProxySequencerEntrypoint, OVM_ProxySequencerEntrypoint,
'init', 'init',
[OVM_SequencerEntrypoint.address, await wallet.getAddress()] [OVM_SequencerEntrypoint.address, await wallet.getAddress()]
...@@ -98,8 +98,8 @@ describe('OVM_ProxySequencerEntrypoint', () => { ...@@ -98,8 +98,8 @@ describe('OVM_ProxySequencerEntrypoint', () => {
Mock__OVM_ExecutionManager.smocked.ovmSLOAD.will.return.with( Mock__OVM_ExecutionManager.smocked.ovmSLOAD.will.return.with(
addrToBytes32(await wallet.getAddress()) addrToBytes32(await wallet.getAddress())
) )
await callPrecompile( await callPredeploy(
Helper_PrecompileCaller, Helper_PredeployCaller,
OVM_ProxySequencerEntrypoint, OVM_ProxySequencerEntrypoint,
'init', 'init',
[constants.AddressZero, constants.AddressZero] [constants.AddressZero, constants.AddressZero]
...@@ -115,8 +115,8 @@ describe('OVM_ProxySequencerEntrypoint', () => { ...@@ -115,8 +115,8 @@ describe('OVM_ProxySequencerEntrypoint', () => {
Mock__OVM_ExecutionManager.smocked.ovmSLOAD.will.return.with( Mock__OVM_ExecutionManager.smocked.ovmSLOAD.will.return.with(
addrToBytes32(await wallet.getAddress()) addrToBytes32(await wallet.getAddress())
) )
await callPrecompile( await callPredeploy(
Helper_PrecompileCaller, Helper_PredeployCaller,
OVM_ProxySequencerEntrypoint, OVM_ProxySequencerEntrypoint,
'upgrade', 'upgrade',
[`0x${'12'.repeat(20)}`] [`0x${'12'.repeat(20)}`]
...@@ -131,8 +131,8 @@ describe('OVM_ProxySequencerEntrypoint', () => { ...@@ -131,8 +131,8 @@ describe('OVM_ProxySequencerEntrypoint', () => {
Mock__OVM_ExecutionManager.smocked.ovmSLOAD.will.return.with( Mock__OVM_ExecutionManager.smocked.ovmSLOAD.will.return.with(
`0x${'00'.repeat(32)}` `0x${'00'.repeat(32)}`
) )
await callPrecompile( await callPredeploy(
Helper_PrecompileCaller, Helper_PredeployCaller,
OVM_ProxySequencerEntrypoint, OVM_ProxySequencerEntrypoint,
'upgrade', 'upgrade',
[`0x${'12'.repeat(20)}`] [`0x${'12'.repeat(20)}`]
...@@ -152,7 +152,7 @@ describe('OVM_ProxySequencerEntrypoint', () => { ...@@ -152,7 +152,7 @@ describe('OVM_ProxySequencerEntrypoint', () => {
'0x', '0x',
]) ])
const calldata = '0xdeadbeef' const calldata = '0xdeadbeef'
await Helper_PrecompileCaller.callPrecompile( await Helper_PredeployCaller.callPredeploy(
OVM_ProxySequencerEntrypoint.address, OVM_ProxySequencerEntrypoint.address,
calldata calldata
) )
......
...@@ -24,7 +24,7 @@ describe('OVM_SequencerEntrypoint', () => { ...@@ -24,7 +24,7 @@ describe('OVM_SequencerEntrypoint', () => {
}) })
let Mock__OVM_ExecutionManager: MockContract let Mock__OVM_ExecutionManager: MockContract
let Helper_PrecompileCaller: Contract let Helper_PredeployCaller: Contract
before(async () => { before(async () => {
Mock__OVM_ExecutionManager = await smockit( Mock__OVM_ExecutionManager = await smockit(
await ethers.getContractFactory('OVM_ExecutionManager') await ethers.getContractFactory('OVM_ExecutionManager')
...@@ -33,11 +33,11 @@ describe('OVM_SequencerEntrypoint', () => { ...@@ -33,11 +33,11 @@ describe('OVM_SequencerEntrypoint', () => {
Mock__OVM_ExecutionManager.smocked.ovmCHAINID.will.return.with(420) Mock__OVM_ExecutionManager.smocked.ovmCHAINID.will.return.with(420)
Mock__OVM_ExecutionManager.smocked.ovmCALL.will.return.with([true, '0x']) Mock__OVM_ExecutionManager.smocked.ovmCALL.will.return.with([true, '0x'])
Helper_PrecompileCaller = await ( Helper_PredeployCaller = await (
await ethers.getContractFactory('Helper_PrecompileCaller') await ethers.getContractFactory('Helper_PredeployCaller')
).deploy() ).deploy()
Helper_PrecompileCaller.setTarget(Mock__OVM_ExecutionManager.address) Helper_PredeployCaller.setTarget(Mock__OVM_ExecutionManager.address)
}) })
let OVM_SequencerEntrypointFactory: ContractFactory let OVM_SequencerEntrypointFactory: ContractFactory
...@@ -61,7 +61,7 @@ describe('OVM_SequencerEntrypoint', () => { ...@@ -61,7 +61,7 @@ describe('OVM_SequencerEntrypoint', () => {
DEFAULT_EIP155_TX, DEFAULT_EIP155_TX,
0 0
) )
await Helper_PrecompileCaller.callPrecompile( await Helper_PredeployCaller.callPredeploy(
OVM_SequencerEntrypoint.address, OVM_SequencerEntrypoint.address,
calldata calldata
) )
...@@ -86,7 +86,7 @@ describe('OVM_SequencerEntrypoint', () => { ...@@ -86,7 +86,7 @@ describe('OVM_SequencerEntrypoint', () => {
it('should send correct calldata if tx is a create and the transaction type is 0', async () => { it('should send correct calldata if tx is a create and the transaction type is 0', async () => {
const createTx = { ...DEFAULT_EIP155_TX, to: '' } const createTx = { ...DEFAULT_EIP155_TX, to: '' }
const calldata = await encodeSequencerCalldata(wallet, createTx, 0) const calldata = await encodeSequencerCalldata(wallet, createTx, 0)
await Helper_PrecompileCaller.callPrecompile( await Helper_PredeployCaller.callPredeploy(
OVM_SequencerEntrypoint.address, OVM_SequencerEntrypoint.address,
calldata calldata
) )
...@@ -116,7 +116,7 @@ describe('OVM_SequencerEntrypoint', () => { ...@@ -116,7 +116,7 @@ describe('OVM_SequencerEntrypoint', () => {
DEFAULT_EIP155_TX, DEFAULT_EIP155_TX,
i i
) )
await Helper_PrecompileCaller.callPrecompile( await Helper_PredeployCaller.callPredeploy(
OVM_SequencerEntrypoint.address, OVM_SequencerEntrypoint.address,
calldata calldata
) )
...@@ -137,7 +137,7 @@ describe('OVM_SequencerEntrypoint', () => { ...@@ -137,7 +137,7 @@ describe('OVM_SequencerEntrypoint', () => {
DEFAULT_EIP155_TX, DEFAULT_EIP155_TX,
2 2
) )
await Helper_PrecompileCaller.callPrecompile( await Helper_PredeployCaller.callPredeploy(
OVM_SequencerEntrypoint.address, OVM_SequencerEntrypoint.address,
calldata calldata
) )
...@@ -162,7 +162,7 @@ describe('OVM_SequencerEntrypoint', () => { ...@@ -162,7 +162,7 @@ describe('OVM_SequencerEntrypoint', () => {
it('should revert if TransactionType is >2', async () => { it('should revert if TransactionType is >2', async () => {
const calldata = '0x03' const calldata = '0x03'
await expect( await expect(
Helper_PrecompileCaller.callPrecompile( Helper_PredeployCaller.callPredeploy(
OVM_SequencerEntrypoint.address, OVM_SequencerEntrypoint.address,
calldata calldata
) )
...@@ -172,7 +172,7 @@ describe('OVM_SequencerEntrypoint', () => { ...@@ -172,7 +172,7 @@ describe('OVM_SequencerEntrypoint', () => {
it('should revert if TransactionType is 1', async () => { it('should revert if TransactionType is 1', async () => {
const calldata = '0x01' const calldata = '0x01'
await expect( await expect(
Helper_PrecompileCaller.callPrecompile( Helper_PredeployCaller.callPredeploy(
OVM_SequencerEntrypoint.address, OVM_SequencerEntrypoint.address,
calldata calldata
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment