Commit 305fff21 authored by Liam Horne's avatar Liam Horne

style: run lint:fix on all code

parent 35c846a5
...@@ -64,7 +64,8 @@ describe('Syncing a verifier', () => { ...@@ -64,7 +64,8 @@ describe('Syncing a verifier', () => {
}) })
it('should sync dummy transaction', async () => { it('should sync dummy transaction', async () => {
const totalElementsBefore = (await env.ctc.getTotalElements()) as BigNumber const totalElementsBefore =
(await env.ctc.getTotalElements()) as BigNumber
const tx = { const tx = {
to: '0x' + '1234'.repeat(10), to: '0x' + '1234'.repeat(10),
......
...@@ -133,9 +133,10 @@ describe('Basic L1<>L2 Communication', async () => { ...@@ -133,9 +133,10 @@ describe('Basic L1<>L2 Communication', async () => {
// This call is fine but will give a status of 0. // This call is fine but will give a status of 0.
const transaction = await env.l1Messenger.sendMessage( const transaction = await env.l1Messenger.sendMessage(
predeploys.Lib_AddressManager, predeploys.Lib_AddressManager,
getContractInterface( getContractInterface('Lib_AddressManager').encodeFunctionData(
'Lib_AddressManager' 'getAddress',
).encodeFunctionData('getAddress', ['whatever']), ['whatever']
),
5000000 5000000
) )
......
...@@ -42,8 +42,10 @@ describe('Fee Payment Integration Tests', async () => { ...@@ -42,8 +42,10 @@ describe('Fee Payment Integration Tests', async () => {
other, other,
utils.parseEther('0.5') utils.parseEther('0.5')
) )
const executionGas = await (env.ovmEth const executionGas = await (env.ovmEth.provider as any).send(
.provider as any).send('eth_estimateExecutionGas', [tx, true]) 'eth_estimateExecutionGas',
[tx, true]
)
const decoded = TxGasLimit.decode(gas) const decoded = TxGasLimit.decode(gas)
expect(BigNumber.from(executionGas)).deep.eq(decoded) expect(BigNumber.from(executionGas)).deep.eq(decoded)
}) })
......
...@@ -118,8 +118,10 @@ describe('Native ETH value integration tests', () => { ...@@ -118,8 +118,10 @@ describe('Native ETH value integration tests', () => {
'geth RPC does not match OVM_ETH.balanceOf' 'geth RPC does not match OVM_ETH.balanceOf'
) )
// query address(this).balance solidity via eth_call as final check // query address(this).balance solidity via eth_call as final check
const ovmAddressThisBalance0 = await ValueCalls0.callStatic.getAddressThisBalance() const ovmAddressThisBalance0 =
const ovmAddressThisBalance01 = await ValueCalls1.callStatic.getAddressThisBalance() await ValueCalls0.callStatic.getAddressThisBalance()
const ovmAddressThisBalance01 =
await ValueCalls1.callStatic.getAddressThisBalance()
expect(ovmAddressThisBalance0).to.deep.eq( expect(ovmAddressThisBalance0).to.deep.eq(
BigNumber.from(expectedBalances[0]), BigNumber.from(expectedBalances[0]),
'geth RPC does not match address(this).balance' 'geth RPC does not match address(this).balance'
...@@ -251,23 +253,19 @@ describe('Native ETH value integration tests', () => { ...@@ -251,23 +253,19 @@ describe('Native ETH value integration tests', () => {
const sendAmount = 10 const sendAmount = 10
const [ const [outerSuccess, outerReturndata] =
outerSuccess, await ValueCalls0.callStatic.sendWithData(
outerReturndata, ValueCalls1.address,
] = await ValueCalls0.callStatic.sendWithData( sendAmount,
ValueCalls1.address, ValueCalls1.interface.encodeFunctionData('delegateCallToCallValue', [
sendAmount, ValueContext.address,
ValueCalls1.interface.encodeFunctionData('delegateCallToCallValue', [ ])
ValueContext.address, )
]) const [innerSuccess, innerReturndata] =
) ValueCalls1.interface.decodeFunctionResult(
const [ 'delegateCallToCallValue',
innerSuccess, outerReturndata
innerReturndata, )
] = ValueCalls1.interface.decodeFunctionResult(
'delegateCallToCallValue',
outerReturndata
)
const delegatedOvmCALLVALUE = ValueContext.interface.decodeFunctionResult( const delegatedOvmCALLVALUE = ValueContext.interface.decodeFunctionResult(
'getCallValue', 'getCallValue',
innerReturndata innerReturndata
...@@ -286,48 +284,41 @@ describe('Native ETH value integration tests', () => { ...@@ -286,48 +284,41 @@ describe('Native ETH value integration tests', () => {
const ValueContext = await Factory__ValueContext.deploy() const ValueContext = await Factory__ValueContext.deploy()
await ValueContext.deployTransaction.wait() await ValueContext.deployTransaction.wait()
const [ const [delegatedSuccess, delegatedReturndata] =
delegatedSuccess, await ValueCalls0.callStatic.delegateCallToAddressThisBalance(
delegatedReturndata, ValueContext.address
] = await ValueCalls0.callStatic.delegateCallToAddressThisBalance( )
ValueContext.address
)
expect(delegatedSuccess).to.be.true expect(delegatedSuccess).to.be.true
expect(delegatedReturndata).to.deep.eq(BigNumber.from(initialBalance0)) expect(delegatedReturndata).to.deep.eq(BigNumber.from(initialBalance0))
}) })
it('should have correct address(this).balance through ovmDELEGATECALLs to same account', async () => { it('should have correct address(this).balance through ovmDELEGATECALLs to same account', async () => {
const [ const [delegatedSuccess, delegatedReturndata] =
delegatedSuccess, await ValueCalls0.callStatic.delegateCallToAddressThisBalance(
delegatedReturndata, ValueCalls0.address
] = await ValueCalls0.callStatic.delegateCallToAddressThisBalance( )
ValueCalls0.address
)
expect(delegatedSuccess).to.be.true expect(delegatedSuccess).to.be.true
expect(delegatedReturndata).to.deep.eq(BigNumber.from(initialBalance0)) expect(delegatedReturndata).to.deep.eq(BigNumber.from(initialBalance0))
}) })
it('should allow delegate calls which preserve msg.value even with no balance going into the inner call', async () => { it('should allow delegate calls which preserve msg.value even with no balance going into the inner call', async () => {
const Factory__SendETHAwayAndDelegateCall: ContractFactory = await ethers.getContractFactory( const Factory__SendETHAwayAndDelegateCall: ContractFactory =
'SendETHAwayAndDelegateCall', await ethers.getContractFactory('SendETHAwayAndDelegateCall', wallet)
wallet const SendETHAwayAndDelegateCall: Contract =
) await Factory__SendETHAwayAndDelegateCall.deploy()
const SendETHAwayAndDelegateCall: Contract = await Factory__SendETHAwayAndDelegateCall.deploy()
await SendETHAwayAndDelegateCall.deployTransaction.wait() await SendETHAwayAndDelegateCall.deployTransaction.wait()
const value = 17 const value = 17
const [ const [delegatedSuccess, delegatedReturndata] =
delegatedSuccess, await SendETHAwayAndDelegateCall.callStatic.emptySelfAndDelegateCall(
delegatedReturndata, ValueCalls0.address,
] = await SendETHAwayAndDelegateCall.callStatic.emptySelfAndDelegateCall( ValueCalls0.interface.encodeFunctionData('getCallValue'),
ValueCalls0.address, {
ValueCalls0.interface.encodeFunctionData('getCallValue'), value,
{ }
value, )
}
)
expect(delegatedSuccess).to.be.true expect(delegatedSuccess).to.be.true
expect(delegatedReturndata).to.deep.eq(BigNumber.from(value)) expect(delegatedReturndata).to.deep.eq(BigNumber.from(value))
...@@ -343,8 +334,10 @@ describe('Native ETH value integration tests', () => { ...@@ -343,8 +334,10 @@ describe('Native ETH value integration tests', () => {
getContractInterface('OVM_ExecutionManager', false), getContractInterface('OVM_ExecutionManager', false),
env.l1Wallet.provider env.l1Wallet.provider
) )
const CALL_WITH_VALUE_INTRINSIC_GAS_BIGNUM = await OVM_ExecutionManager.CALL_WITH_VALUE_INTRINSIC_GAS() const CALL_WITH_VALUE_INTRINSIC_GAS_BIGNUM =
CALL_WITH_VALUE_INTRINSIC_GAS = CALL_WITH_VALUE_INTRINSIC_GAS_BIGNUM.toNumber() await OVM_ExecutionManager.CALL_WITH_VALUE_INTRINSIC_GAS()
CALL_WITH_VALUE_INTRINSIC_GAS =
CALL_WITH_VALUE_INTRINSIC_GAS_BIGNUM.toNumber()
const Factory__ValueGasMeasurer = await ethers.getContractFactory( const Factory__ValueGasMeasurer = await ethers.getContractFactory(
'ValueGasMeasurer', 'ValueGasMeasurer',
...@@ -357,14 +350,15 @@ describe('Native ETH value integration tests', () => { ...@@ -357,14 +350,15 @@ describe('Native ETH value integration tests', () => {
it('a call with value to an empty account consumes <= the intrinsic gas including a buffer', async () => { it('a call with value to an empty account consumes <= the intrinsic gas including a buffer', async () => {
const value = 1 const value = 1
const gasLimit = 1_000_000 const gasLimit = 1_000_000
const minimalSendGas = await ValueGasMeasurer.callStatic.measureGasOfTransferingEthViaCall( const minimalSendGas =
ethers.constants.AddressZero, await ValueGasMeasurer.callStatic.measureGasOfTransferingEthViaCall(
value, ethers.constants.AddressZero,
gasLimit, value,
{ gasLimit,
gasLimit: 2_000_000, {
} gasLimit: 2_000_000,
) }
)
const buffer = 1.2 const buffer = 1.2
expect(minimalSendGas * buffer).to.be.lte(CALL_WITH_VALUE_INTRINSIC_GAS) expect(minimalSendGas * buffer).to.be.lte(CALL_WITH_VALUE_INTRINSIC_GAS)
...@@ -384,67 +378,61 @@ describe('Native ETH value integration tests', () => { ...@@ -384,67 +378,61 @@ describe('Native ETH value integration tests', () => {
const value = 1 const value = 1
const gasLimit = 1_000_000 const gasLimit = 1_000_000
// A revert, causing the ETH to be sent back, should consume the minimal possible gas for a nonzero ETH send // A revert, causing the ETH to be sent back, should consume the minimal possible gas for a nonzero ETH send
const minimalSendGas = await ValueGasMeasurer.callStatic.measureGasOfTransferingEthViaCall( const minimalSendGas =
AutoRevert.address, await ValueGasMeasurer.callStatic.measureGasOfTransferingEthViaCall(
value, AutoRevert.address,
gasLimit, value,
{ gasLimit,
gasLimit: 2_000_000, {
} gasLimit: 2_000_000,
) }
)
const buffer = 1.2 const buffer = 1.2
expect(minimalSendGas * buffer).to.be.lte(CALL_WITH_VALUE_INTRINSIC_GAS) expect(minimalSendGas * buffer).to.be.lte(CALL_WITH_VALUE_INTRINSIC_GAS)
}) })
it('a value call passing less than the intrinsic gas should appear to revert', async () => { it('a value call passing less than the intrinsic gas should appear to revert', async () => {
const Factory__PayableConstant: ContractFactory = await ethers.getContractFactory( const Factory__PayableConstant: ContractFactory =
'PayableConstant', await ethers.getContractFactory('PayableConstant', wallet)
wallet const PayableConstant: Contract =
) await Factory__PayableConstant.deploy()
const PayableConstant: Contract = await Factory__PayableConstant.deploy()
await PayableConstant.deployTransaction.wait() await PayableConstant.deployTransaction.wait()
const sendAmount = 15 const sendAmount = 15
const [ const [success, returndata] =
success, await ValueCalls0.callStatic.sendWithDataAndGas(
returndata, PayableConstant.address,
] = await ValueCalls0.callStatic.sendWithDataAndGas( sendAmount,
PayableConstant.address, PayableConstant.interface.encodeFunctionData('returnValue'),
sendAmount, CALL_WITH_VALUE_INTRINSIC_GAS - 1,
PayableConstant.interface.encodeFunctionData('returnValue'), {
CALL_WITH_VALUE_INTRINSIC_GAS - 1, gasLimit: 2_000_000,
{ }
gasLimit: 2_000_000, )
}
)
expect(success).to.eq(false) expect(success).to.eq(false)
expect(returndata).to.eq('0x') expect(returndata).to.eq('0x')
}) })
it('a value call which runs out of gas does not out-of-gas the parent', async () => { it('a value call which runs out of gas does not out-of-gas the parent', async () => {
const Factory__TestOOG: ContractFactory = await ethers.getContractFactory( const Factory__TestOOG: ContractFactory =
'TestOOG', await ethers.getContractFactory('TestOOG', wallet)
wallet
)
const TestOOG: Contract = await Factory__TestOOG.deploy() const TestOOG: Contract = await Factory__TestOOG.deploy()
await TestOOG.deployTransaction.wait() await TestOOG.deployTransaction.wait()
const sendAmount = 15 const sendAmount = 15
// Implicitly test that this call is not rejected // Implicitly test that this call is not rejected
const [ const [success, returndata] =
success, await ValueCalls0.callStatic.sendWithDataAndGas(
returndata, TestOOG.address,
] = await ValueCalls0.callStatic.sendWithDataAndGas( sendAmount,
TestOOG.address, TestOOG.interface.encodeFunctionData('runOutOfGas'),
sendAmount, CALL_WITH_VALUE_INTRINSIC_GAS * 2,
TestOOG.interface.encodeFunctionData('runOutOfGas'), {
CALL_WITH_VALUE_INTRINSIC_GAS * 2, gasLimit: 2_000_000,
{ }
gasLimit: 2_000_000, )
}
)
expect(success).to.eq(false) expect(success).to.eq(false)
expect(returndata).to.eq('0x') expect(returndata).to.eq('0x')
......
...@@ -325,12 +325,8 @@ describe('Native ETH Integration Tests', async () => { ...@@ -325,12 +325,8 @@ describe('Native ETH Integration Tests', async () => {
expect(receipt.events.length).to.equal(4) expect(receipt.events.length).to.equal(4)
// The first transfer event is fee payment // The first transfer event is fee payment
const [ const [, firstTransferEvent, secondTransferEvent, depositEvent] =
, receipt.events
firstTransferEvent,
secondTransferEvent,
depositEvent,
] = receipt.events
expect(firstTransferEvent.event).to.equal('Transfer') expect(firstTransferEvent.event).to.equal('Transfer')
expect(firstTransferEvent.args.from).to.equal(env.l2Wallet.address) expect(firstTransferEvent.args.from).to.equal(env.l2Wallet.address)
......
...@@ -49,9 +49,8 @@ describe('OVM Context: Layer 2 EVM Context', () => { ...@@ -49,9 +49,8 @@ describe('OVM Context: Layer 2 EVM Context', () => {
'OVM_CanonicalTransactionChain' 'OVM_CanonicalTransactionChain'
) )
CanonicalTransactionChain = CanonicalTransactionChainFactory.connect( CanonicalTransactionChain =
l1Wallet CanonicalTransactionChainFactory.connect(l1Wallet).attach(ctcAddress)
).attach(ctcAddress)
const OVMMulticallFactory = await ethers.getContractFactory( const OVMMulticallFactory = await ethers.getContractFactory(
'OVMMulticall', 'OVMMulticall',
......
...@@ -208,10 +208,8 @@ describe('Basic RPC tests', () => { ...@@ -208,10 +208,8 @@ describe('Basic RPC tests', () => {
it('should allow eth_calls with nonzero value', async () => { it('should allow eth_calls with nonzero value', async () => {
// Deploy a contract to check msg.value of the call // Deploy a contract to check msg.value of the call
const Factory__ValueContext: ContractFactory = await ethers.getContractFactory( const Factory__ValueContext: ContractFactory =
'ValueContext', await ethers.getContractFactory('ValueContext', wallet)
wallet
)
const ValueContext: Contract = await Factory__ValueContext.deploy() const ValueContext: Contract = await Factory__ValueContext.deploy()
await ValueContext.deployTransaction.wait() await ValueContext.deployTransaction.wait()
......
...@@ -152,10 +152,11 @@ describe('BatchSubmitter', () => { ...@@ -152,10 +152,11 @@ describe('BatchSubmitter', () => {
let OVM_StateCommitmentChain: Contract let OVM_StateCommitmentChain: Contract
let l2Provider: MockchainProvider let l2Provider: MockchainProvider
beforeEach(async () => { beforeEach(async () => {
const unwrapped_OVM_CanonicalTransactionChain = await Factory__OVM_CanonicalTransactionChain.deploy( const unwrapped_OVM_CanonicalTransactionChain =
AddressManager.address, await Factory__OVM_CanonicalTransactionChain.deploy(
FORCE_INCLUSION_PERIOD_SECONDS AddressManager.address,
) FORCE_INCLUSION_PERIOD_SECONDS
)
await unwrapped_OVM_CanonicalTransactionChain.init() await unwrapped_OVM_CanonicalTransactionChain.init()
await AddressManager.setAddress( await AddressManager.setAddress(
...@@ -169,11 +170,12 @@ describe('BatchSubmitter', () => { ...@@ -169,11 +170,12 @@ describe('BatchSubmitter', () => {
sequencer sequencer
) )
const unwrapped_OVM_StateCommitmentChain = await Factory__OVM_StateCommitmentChain.deploy( const unwrapped_OVM_StateCommitmentChain =
AddressManager.address, await Factory__OVM_StateCommitmentChain.deploy(
0, // fraudProofWindowSeconds AddressManager.address,
0 // sequencerPublishWindowSeconds 0, // fraudProofWindowSeconds
) 0 // sequencerPublishWindowSeconds
)
await unwrapped_OVM_StateCommitmentChain.init() await unwrapped_OVM_StateCommitmentChain.init()
......
...@@ -31,7 +31,10 @@ const parseEnv = () => { ...@@ -31,7 +31,10 @@ const parseEnv = () => {
return { return {
l1BlockTimeSeconds: ensure('BLOCK_TIME_SECONDS', 'number'), l1BlockTimeSeconds: ensure('BLOCK_TIME_SECONDS', 'number'),
ctcForceInclusionPeriodSeconds: ensure('FORCE_INCLUSION_PERIOD_SECONDS', 'number'), ctcForceInclusionPeriodSeconds: ensure(
'FORCE_INCLUSION_PERIOD_SECONDS',
'number'
),
ctcMaxTransactionGasLimit: ensure('MAX_TRANSACTION_GAS_LIMIT', 'number'), ctcMaxTransactionGasLimit: ensure('MAX_TRANSACTION_GAS_LIMIT', 'number'),
emMinTransactionGasLimit: ensure('MIN_TRANSACTION_GAS_LIMIT', 'number'), emMinTransactionGasLimit: ensure('MIN_TRANSACTION_GAS_LIMIT', 'number'),
emMaxtransactionGasLimit: ensure('MAX_TRANSACTION_GAS_LIMIT', 'number'), emMaxtransactionGasLimit: ensure('MAX_TRANSACTION_GAS_LIMIT', 'number'),
...@@ -39,7 +42,10 @@ const parseEnv = () => { ...@@ -39,7 +42,10 @@ const parseEnv = () => {
emSecondsPerEpoch: ensure('ECONDS_PER_EPOCH', 'number'), emSecondsPerEpoch: ensure('ECONDS_PER_EPOCH', 'number'),
emOvmChainId: ensure('CHAIN_ID', 'number'), emOvmChainId: ensure('CHAIN_ID', 'number'),
sccFraudProofWindow: ensure('FRAUD_PROOF_WINDOW_SECONDS', 'number'), sccFraudProofWindow: ensure('FRAUD_PROOF_WINDOW_SECONDS', 'number'),
sccSequencerPublishWindow: ensure('SEQUENCER_PUBLISH_WINDOW_SECONDS', 'number'), sccSequencerPublishWindow: ensure(
'SEQUENCER_PUBLISH_WINDOW_SECONDS',
'number'
),
} }
} }
...@@ -68,27 +74,33 @@ const main = async () => { ...@@ -68,27 +74,33 @@ const main = async () => {
// update our CI so this is no longer necessary. But I'm adding it for backwards compat so we can // update our CI so this is no longer necessary. But I'm adding it for backwards compat so we can
// get the hardhat-deploy stuff merged. Woot. // get the hardhat-deploy stuff merged. Woot.
const nicknames = { const nicknames = {
'Lib_AddressManager': 'AddressManager', Lib_AddressManager: 'AddressManager',
'mockOVM_BondManager': 'OVM_BondManager' mockOVM_BondManager: 'OVM_BondManager',
} }
const contracts: any = dirtree( const contracts: any = dirtree(
path.resolve(__dirname, `../deployments/custom`) path.resolve(__dirname, `../deployments/custom`)
).children.filter((child) => { )
return child.extension === '.json' .children.filter((child) => {
}).reduce((contractsAccumulator, child) => { return child.extension === '.json'
const contractName = child.name.replace('.json', '') })
// eslint-disable-next-line @typescript-eslint/no-var-requires .reduce((contractsAccumulator, child) => {
const artifact = require(path.resolve(__dirname, `../deployments/custom/${child.name}`)) const contractName = child.name.replace('.json', '')
contractsAccumulator[nicknames[contractName] || contractName] = artifact.address // eslint-disable-next-line @typescript-eslint/no-var-requires
return contractsAccumulator const artifact = require(path.resolve(
}, {}) __dirname,
`../deployments/custom/${child.name}`
))
contractsAccumulator[nicknames[contractName] || contractName] =
artifact.address
return contractsAccumulator
}, {})
contracts.OVM_Sequencer = await sequencer.getAddress() contracts.OVM_Sequencer = await sequencer.getAddress()
contracts.Deployer = await deployer.getAddress() contracts.Deployer = await deployer.getAddress()
const addresses = JSON.stringify(contracts, null, 2) const addresses = JSON.stringify(contracts, null, 2)
const dumpsPath = path.resolve(__dirname, "../dist/dumps") const dumpsPath = path.resolve(__dirname, '../dist/dumps')
if (!fs.existsSync(dumpsPath)) { if (!fs.existsSync(dumpsPath)) {
fs.mkdirSync(dumpsPath) fs.mkdirSync(dumpsPath)
} }
......
...@@ -5,7 +5,8 @@ import * as mkdirp from 'mkdirp' ...@@ -5,7 +5,8 @@ import * as mkdirp from 'mkdirp'
const env = process.env const env = process.env
const CHAIN_ID = env.CHAIN_ID || '420' const CHAIN_ID = env.CHAIN_ID || '420'
const GAS_PRICE_ORACLE_OWNER = env.GAS_PRICE_ORACLE_OWNER || '0x' + 'FF'.repeat(20) const GAS_PRICE_ORACLE_OWNER =
env.GAS_PRICE_ORACLE_OWNER || '0x' + 'FF'.repeat(20)
/* Internal Imports */ /* Internal Imports */
import { makeStateDump } from '../src/state-dump/make-dump' import { makeStateDump } from '../src/state-dump/make-dump'
...@@ -22,7 +23,7 @@ import { RollupDeployConfig } from '../src/contract-deployment' ...@@ -22,7 +23,7 @@ import { RollupDeployConfig } from '../src/contract-deployment'
gasPriceOracleConfig: { gasPriceOracleConfig: {
owner: GAS_PRICE_ORACLE_OWNER, owner: GAS_PRICE_ORACLE_OWNER,
initialGasPrice: 0, initialGasPrice: 0,
} },
} }
const dump = await makeStateDump(config as RollupDeployConfig) const dump = await makeStateDump(config as RollupDeployConfig)
......
...@@ -38,7 +38,8 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -38,7 +38,8 @@ const deployFn: DeployFunction = async (hre) => {
await Proxy__OVM_L1CrossDomainMessenger.initialize(Lib_AddressManager.address) await Proxy__OVM_L1CrossDomainMessenger.initialize(Lib_AddressManager.address)
const libAddressManager = await Proxy__OVM_L1CrossDomainMessenger.libAddressManager() const libAddressManager =
await Proxy__OVM_L1CrossDomainMessenger.libAddressManager()
if (libAddressManager !== Lib_AddressManager.address) { if (libAddressManager !== Lib_AddressManager.address) {
throw new Error( throw new Error(
`\n**FATAL ERROR. THIS SHOULD NEVER HAPPEN. CHECK YOUR DEPLOYMENT.**:\n` + `\n**FATAL ERROR. THIS SHOULD NEVER HAPPEN. CHECK YOUR DEPLOYMENT.**:\n` +
......
...@@ -65,7 +65,8 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -65,7 +65,8 @@ const deployFn: DeployFunction = async (hre) => {
hre.ethers.utils.hexZeroPad(l1MessengerAddress, 32) hre.ethers.utils.hexZeroPad(l1MessengerAddress, 32)
) )
// Verify that the slot was set correctly // Verify that the slot was set correctly
const l1MessengerStored = await Proxy__WithBridgeInterface.callStatic.messenger() const l1MessengerStored =
await Proxy__WithBridgeInterface.callStatic.messenger()
console.log('l1MessengerStored:', l1MessengerStored) console.log('l1MessengerStored:', l1MessengerStored)
if (l1MessengerStored !== l1MessengerAddress) { if (l1MessengerStored !== l1MessengerAddress) {
throw new Error( throw new Error(
...@@ -79,7 +80,8 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -79,7 +80,8 @@ const deployFn: DeployFunction = async (hre) => {
hre.ethers.utils.hexZeroPad(predeploys.OVM_L2StandardBridge, 32) hre.ethers.utils.hexZeroPad(predeploys.OVM_L2StandardBridge, 32)
) )
// Verify that the slot was set correctly // Verify that the slot was set correctly
const l2TokenBridgeStored = await Proxy__WithBridgeInterface.callStatic.l2TokenBridge() const l2TokenBridgeStored =
await Proxy__WithBridgeInterface.callStatic.l2TokenBridge()
console.log('l2TokenBridgeStored:', l2TokenBridgeStored) console.log('l2TokenBridgeStored:', l2TokenBridgeStored)
if (l2TokenBridgeStored !== predeploys.OVM_L2StandardBridge) { if (l2TokenBridgeStored !== predeploys.OVM_L2StandardBridge) {
throw new Error( throw new Error(
......
...@@ -189,8 +189,10 @@ export const makeStateDump = async (cfg: RollupDeployConfig): Promise<any> => { ...@@ -189,8 +189,10 @@ export const makeStateDump = async (cfg: RollupDeployConfig): Promise<any> => {
const contract = deploymentResult.contracts[name] const contract = deploymentResult.contracts[name]
let code: string let code: string
if (ovmCompiled.includes(name)) { if (ovmCompiled.includes(name)) {
const ovmDeployedBytecode = getContractDefinition(name, true) const ovmDeployedBytecode = getContractDefinition(
.deployedBytecode name,
true
).deployedBytecode
// TODO remove: deployedBytecode is missing the find and replace in solidity // TODO remove: deployedBytecode is missing the find and replace in solidity
code = ovmDeployedBytecode code = ovmDeployedBytecode
.split( .split(
......
...@@ -197,7 +197,9 @@ describe('OVM_L2StandardBridge', () => { ...@@ -197,7 +197,9 @@ describe('OVM_L2StandardBridge', () => {
let SmoddedL2Token: ModifiableContract let SmoddedL2Token: ModifiableContract
beforeEach(async () => { beforeEach(async () => {
// Deploy a smodded gateway so we can give some balances to withdraw // Deploy a smodded gateway so we can give some balances to withdraw
SmoddedL2Token = await (await smoddit('L2StandardERC20', alice)).deploy( SmoddedL2Token = await (
await smoddit('L2StandardERC20', alice)
).deploy(
OVM_L2StandardBridge.address, OVM_L2StandardBridge.address,
DUMMY_L1TOKEN_ADDRESS, DUMMY_L1TOKEN_ADDRESS,
'L2Token', 'L2Token',
......
...@@ -93,12 +93,13 @@ describe('OVM_L1CrossDomainMessenger', () => { ...@@ -93,12 +93,13 @@ describe('OVM_L1CrossDomainMessenger', () => {
Factory__OVM_L1CrossDomainMessenger = await ethers.getContractFactory( Factory__OVM_L1CrossDomainMessenger = await ethers.getContractFactory(
'OVM_L1CrossDomainMessenger' 'OVM_L1CrossDomainMessenger'
) )
OVM_CanonicalTransactionChain = await Factory__OVM_CanonicalTransactionChain.deploy( OVM_CanonicalTransactionChain =
AddressManager.address, await Factory__OVM_CanonicalTransactionChain.deploy(
FORCE_INCLUSION_PERIOD_SECONDS, AddressManager.address,
FORCE_INCLUSION_PERIOD_BLOCKS, FORCE_INCLUSION_PERIOD_SECONDS,
MAX_GAS_LIMIT FORCE_INCLUSION_PERIOD_BLOCKS,
) MAX_GAS_LIMIT
)
const batches = await Factory__OVM_ChainStorageContainer.deploy( const batches = await Factory__OVM_ChainStorageContainer.deploy(
AddressManager.address, AddressManager.address,
...@@ -127,7 +128,8 @@ describe('OVM_L1CrossDomainMessenger', () => { ...@@ -127,7 +128,8 @@ describe('OVM_L1CrossDomainMessenger', () => {
let OVM_L1CrossDomainMessenger: Contract let OVM_L1CrossDomainMessenger: Contract
beforeEach(async () => { beforeEach(async () => {
const xDomainMessengerImpl = await Factory__OVM_L1CrossDomainMessenger.deploy() const xDomainMessengerImpl =
await Factory__OVM_L1CrossDomainMessenger.deploy()
// We use an upgradable proxy for the XDomainMessenger--deploy & set up the proxy. // We use an upgradable proxy for the XDomainMessenger--deploy & set up the proxy.
OVM_L1CrossDomainMessenger = await deployProxyXDomainMessenger( OVM_L1CrossDomainMessenger = await deployProxyXDomainMessenger(
AddressManager, AddressManager,
...@@ -469,9 +471,8 @@ describe('OVM_L1CrossDomainMessenger', () => { ...@@ -469,9 +471,8 @@ describe('OVM_L1CrossDomainMessenger', () => {
describe('blockMessage and allowMessage', () => { describe('blockMessage and allowMessage', () => {
it('should revert if called by an account other than the owner', async () => { it('should revert if called by an account other than the owner', async () => {
const OVM_L1CrossDomainMessenger2 = OVM_L1CrossDomainMessenger.connect( const OVM_L1CrossDomainMessenger2 =
signer2 OVM_L1CrossDomainMessenger.connect(signer2)
)
await expect( await expect(
OVM_L1CrossDomainMessenger2.blockMessage(keccak256(calldata)) OVM_L1CrossDomainMessenger2.blockMessage(keccak256(calldata))
).to.be.revertedWith('Ownable: caller is not the owner') ).to.be.revertedWith('Ownable: caller is not the owner')
......
...@@ -71,9 +71,8 @@ describe('OVM_L2CrossDomainMessenger', () => { ...@@ -71,9 +71,8 @@ describe('OVM_L2CrossDomainMessenger', () => {
let OVM_L2CrossDomainMessenger: Contract let OVM_L2CrossDomainMessenger: Contract
beforeEach(async () => { beforeEach(async () => {
OVM_L2CrossDomainMessenger = await Factory__OVM_L2CrossDomainMessenger.deploy( OVM_L2CrossDomainMessenger =
AddressManager.address await Factory__OVM_L2CrossDomainMessenger.deploy(AddressManager.address)
)
}) })
describe('sendMessage', () => { describe('sendMessage', () => {
...@@ -183,7 +182,9 @@ describe('OVM_L2CrossDomainMessenger', () => { ...@@ -183,7 +182,9 @@ describe('OVM_L2CrossDomainMessenger', () => {
// There should be no 'relayedMessage' event logged in the receipt. // There should be no 'relayedMessage' event logged in the receipt.
const logs = ( const logs = (
await Mock__OVM_L2ToL1MessagePasser.provider.getTransactionReceipt( await Mock__OVM_L2ToL1MessagePasser.provider.getTransactionReceipt(
(await resProm).hash (
await resProm
).hash
) )
).logs ).logs
expect(logs).to.deep.equal([]) expect(logs).to.deep.equal([])
...@@ -204,10 +205,11 @@ describe('OVM_L2CrossDomainMessenger', () => { ...@@ -204,10 +205,11 @@ describe('OVM_L2CrossDomainMessenger', () => {
Mock__OVM_L1CrossDomainMessenger.address Mock__OVM_L1CrossDomainMessenger.address
) )
const reentrantMessage = OVM_L2CrossDomainMessenger.interface.encodeFunctionData( const reentrantMessage =
'relayMessage', OVM_L2CrossDomainMessenger.interface.encodeFunctionData(
[target, sender, message, 1] 'relayMessage',
) [target, sender, message, 1]
)
// Calculate xDomainCallData used for indexing // Calculate xDomainCallData used for indexing
// (within the first call to the L2 Messenger). // (within the first call to the L2 Messenger).
......
...@@ -98,12 +98,13 @@ describe('[GAS BENCHMARK] OVM_CanonicalTransactionChain', () => { ...@@ -98,12 +98,13 @@ describe('[GAS BENCHMARK] OVM_CanonicalTransactionChain', () => {
let OVM_CanonicalTransactionChain: Contract let OVM_CanonicalTransactionChain: Contract
beforeEach(async () => { beforeEach(async () => {
OVM_CanonicalTransactionChain = await Factory__OVM_CanonicalTransactionChain.deploy( OVM_CanonicalTransactionChain =
AddressManager.address, await Factory__OVM_CanonicalTransactionChain.deploy(
FORCE_INCLUSION_PERIOD_SECONDS, AddressManager.address,
FORCE_INCLUSION_PERIOD_BLOCKS, FORCE_INCLUSION_PERIOD_SECONDS,
MAX_GAS_LIMIT FORCE_INCLUSION_PERIOD_BLOCKS,
) MAX_GAS_LIMIT
)
const batches = await Factory__OVM_ChainStorageContainer.deploy( const batches = await Factory__OVM_ChainStorageContainer.deploy(
AddressManager.address, AddressManager.address,
...@@ -132,9 +133,8 @@ describe('[GAS BENCHMARK] OVM_CanonicalTransactionChain', () => { ...@@ -132,9 +133,8 @@ describe('[GAS BENCHMARK] OVM_CanonicalTransactionChain', () => {
describe('appendSequencerBatch [ @skip-on-coverage ]', () => { describe('appendSequencerBatch [ @skip-on-coverage ]', () => {
beforeEach(() => { beforeEach(() => {
OVM_CanonicalTransactionChain = OVM_CanonicalTransactionChain.connect( OVM_CanonicalTransactionChain =
sequencer OVM_CanonicalTransactionChain.connect(sequencer)
)
}) })
it('200 transactions in a single context', async () => { it('200 transactions in a single context', async () => {
......
...@@ -147,12 +147,13 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -147,12 +147,13 @@ describe('OVM_CanonicalTransactionChain', () => {
let OVM_CanonicalTransactionChain: Contract let OVM_CanonicalTransactionChain: Contract
beforeEach(async () => { beforeEach(async () => {
OVM_CanonicalTransactionChain = await Factory__OVM_CanonicalTransactionChain.deploy( OVM_CanonicalTransactionChain =
AddressManager.address, await Factory__OVM_CanonicalTransactionChain.deploy(
FORCE_INCLUSION_PERIOD_SECONDS, AddressManager.address,
FORCE_INCLUSION_PERIOD_BLOCKS, FORCE_INCLUSION_PERIOD_SECONDS,
MAX_GAS_LIMIT FORCE_INCLUSION_PERIOD_BLOCKS,
) MAX_GAS_LIMIT
)
const batches = await Factory__OVM_ChainStorageContainer.deploy( const batches = await Factory__OVM_ChainStorageContainer.deploy(
AddressManager.address, AddressManager.address,
...@@ -184,7 +185,8 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -184,7 +185,8 @@ describe('OVM_CanonicalTransactionChain', () => {
const gasLimit = 500_000 const gasLimit = 500_000
it('should revert when trying to input more data than the max data size', async () => { it('should revert when trying to input more data than the max data size', async () => {
const MAX_ROLLUP_TX_SIZE = await OVM_CanonicalTransactionChain.MAX_ROLLUP_TX_SIZE() const MAX_ROLLUP_TX_SIZE =
await OVM_CanonicalTransactionChain.MAX_ROLLUP_TX_SIZE()
const data = '0x' + '12'.repeat(MAX_ROLLUP_TX_SIZE + 1) const data = '0x' + '12'.repeat(MAX_ROLLUP_TX_SIZE + 1)
await expect( await expect(
...@@ -207,7 +209,8 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -207,7 +209,8 @@ describe('OVM_CanonicalTransactionChain', () => {
}) })
it('should revert if gas limit parameter is not at least MIN_ROLLUP_TX_GAS', async () => { it('should revert if gas limit parameter is not at least MIN_ROLLUP_TX_GAS', async () => {
const MIN_ROLLUP_TX_GAS = await OVM_CanonicalTransactionChain.MIN_ROLLUP_TX_GAS() const MIN_ROLLUP_TX_GAS =
await OVM_CanonicalTransactionChain.MIN_ROLLUP_TX_GAS()
const customGasLimit = MIN_ROLLUP_TX_GAS / 2 const customGasLimit = MIN_ROLLUP_TX_GAS / 2
const data = '0x' + '12'.repeat(1234) const data = '0x' + '12'.repeat(1234)
...@@ -217,7 +220,8 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -217,7 +220,8 @@ describe('OVM_CanonicalTransactionChain', () => {
}) })
it('should revert if transaction gas limit does not cover rollup burn', async () => { it('should revert if transaction gas limit does not cover rollup burn', async () => {
const L2_GAS_DISCOUNT_DIVISOR = await OVM_CanonicalTransactionChain.L2_GAS_DISCOUNT_DIVISOR() const L2_GAS_DISCOUNT_DIVISOR =
await OVM_CanonicalTransactionChain.L2_GAS_DISCOUNT_DIVISOR()
const data = '0x' + '12'.repeat(1234) const data = '0x' + '12'.repeat(1234)
await expect( await expect(
...@@ -663,9 +667,8 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -663,9 +667,8 @@ describe('OVM_CanonicalTransactionChain', () => {
describe('appendSequencerBatch', () => { describe('appendSequencerBatch', () => {
beforeEach(() => { beforeEach(() => {
OVM_CanonicalTransactionChain = OVM_CanonicalTransactionChain.connect( OVM_CanonicalTransactionChain =
sequencer OVM_CanonicalTransactionChain.connect(sequencer)
)
}) })
it('should revert if expected start does not match current total batches', async () => { it('should revert if expected start does not match current total batches', async () => {
...@@ -757,7 +760,8 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -757,7 +760,8 @@ describe('OVM_CanonicalTransactionChain', () => {
}) })
it('should revert when trying to input more data than the max data size', async () => { it('should revert when trying to input more data than the max data size', async () => {
const MAX_ROLLUP_TX_SIZE = await OVM_CanonicalTransactionChain.MAX_ROLLUP_TX_SIZE() const MAX_ROLLUP_TX_SIZE =
await OVM_CanonicalTransactionChain.MAX_ROLLUP_TX_SIZE()
const data = '0x' + '12'.repeat(MAX_ROLLUP_TX_SIZE + 1) const data = '0x' + '12'.repeat(MAX_ROLLUP_TX_SIZE + 1)
const timestamp = await getEthTime(ethers.provider) const timestamp = await getEthTime(ethers.provider)
...@@ -965,9 +969,8 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -965,9 +969,8 @@ describe('OVM_CanonicalTransactionChain', () => {
gasLimit, gasLimit,
data data
) )
queueElements[ queueElements[i] =
i await OVM_CanonicalTransactionChain.getQueueElement(i)
] = await OVM_CanonicalTransactionChain.getQueueElement(i)
// this is a valid context for this TX // this is a valid context for this TX
validContexts[i] = { validContexts[i] = {
numSequencedTransactions: 1, numSequencedTransactions: 1,
......
...@@ -170,7 +170,8 @@ describe('OVM_StateCommitmentChain', () => { ...@@ -170,7 +170,8 @@ describe('OVM_StateCommitmentChain', () => {
describe('when outside sequencer publish window', () => { describe('when outside sequencer publish window', () => {
beforeEach(async () => { beforeEach(async () => {
const SEQUENCER_PUBLISH_WINDOW = await OVM_StateCommitmentChain.SEQUENCER_PUBLISH_WINDOW() const SEQUENCER_PUBLISH_WINDOW =
await OVM_StateCommitmentChain.SEQUENCER_PUBLISH_WINDOW()
await increaseEthTime( await increaseEthTime(
ethers.provider, ethers.provider,
SEQUENCER_PUBLISH_WINDOW.toNumber() + 1 SEQUENCER_PUBLISH_WINDOW.toNumber() + 1
......
...@@ -68,9 +68,9 @@ describe('OVM_ExecutionManager gas consumption', () => { ...@@ -68,9 +68,9 @@ describe('OVM_ExecutionManager gas consumption', () => {
// deploy the state manager and mock it for the state transitioner // deploy the state manager and mock it for the state transitioner
MOCK__STATE_MANAGER = await smockit( MOCK__STATE_MANAGER = await smockit(
await (await ethers.getContractFactory('OVM_StateManager')).deploy( await (
NON_ZERO_ADDRESS await ethers.getContractFactory('OVM_StateManager')
) ).deploy(NON_ZERO_ADDRESS)
) )
// Setup the SM to satisfy all the checks executed during EM.run() // Setup the SM to satisfy all the checks executed during EM.run()
......
...@@ -51,8 +51,7 @@ const test_nuisanceGas: TestDefinition = { ...@@ -51,8 +51,7 @@ const test_nuisanceGas: TestDefinition = {
}, },
subTests: [ subTests: [
{ {
name: name: 'ovmCALL consumes nuisance gas of CODESIZE * NUISANCE_GAS_PER_CONTRACT_BYTE',
'ovmCALL consumes nuisance gas of CODESIZE * NUISANCE_GAS_PER_CONTRACT_BYTE',
postState: { postState: {
ExecutionManager: { ExecutionManager: {
messageRecord: { messageRecord: {
...@@ -88,8 +87,7 @@ const test_nuisanceGas: TestDefinition = { ...@@ -88,8 +87,7 @@ const test_nuisanceGas: TestDefinition = {
], ],
}, },
{ {
name: name: 'ovmCALL consumes nuisance gas of CODESIZE * NUISANCE_GAS_PER_CONTRACT_BYTE twice for two unique ovmCALLS',
'ovmCALL consumes nuisance gas of CODESIZE * NUISANCE_GAS_PER_CONTRACT_BYTE twice for two unique ovmCALLS',
postState: { postState: {
ExecutionManager: { ExecutionManager: {
messageRecord: { messageRecord: {
...@@ -140,8 +138,7 @@ const test_nuisanceGas: TestDefinition = { ...@@ -140,8 +138,7 @@ const test_nuisanceGas: TestDefinition = {
], ],
}, },
{ {
name: name: 'ovmCALL consumes all allotted nuisance gas if code contract throws unknown exception',
'ovmCALL consumes all allotted nuisance gas if code contract throws unknown exception',
postState: { postState: {
ExecutionManager: { ExecutionManager: {
messageRecord: { messageRecord: {
...@@ -178,8 +175,7 @@ const test_nuisanceGas: TestDefinition = { ...@@ -178,8 +175,7 @@ const test_nuisanceGas: TestDefinition = {
], ],
}, },
{ {
name: name: 'ovmCREATE consumes all allotted nuisance gas if creation code throws data-less exception',
'ovmCREATE consumes all allotted nuisance gas if creation code throws data-less exception',
parameters: [ parameters: [
{ {
name: 'give 1/2 gas to ovmCALL => ovmCREATE, evmINVALID', name: 'give 1/2 gas to ovmCALL => ovmCREATE, evmINVALID',
......
...@@ -90,8 +90,7 @@ const test_ovmCALL: TestDefinition = { ...@@ -90,8 +90,7 @@ const test_ovmCALL: TestDefinition = {
], ],
}, },
{ {
name: name: 'ovmCALL(ADDRESS_1) => ovmSSTORE + ovmSLOAD, ovmCALL(ADDRESS_1) => ovmSLOAD',
'ovmCALL(ADDRESS_1) => ovmSSTORE + ovmSLOAD, ovmCALL(ADDRESS_1) => ovmSLOAD',
steps: [ steps: [
{ {
functionName: 'ovmCALL', functionName: 'ovmCALL',
...@@ -140,8 +139,7 @@ const test_ovmCALL: TestDefinition = { ...@@ -140,8 +139,7 @@ const test_ovmCALL: TestDefinition = {
], ],
}, },
{ {
name: name: 'ovmCALL(ADDRESS_1) => ovmCALL(ADDRESS_2) => ovmADDRESS + ovmCALLER',
'ovmCALL(ADDRESS_1) => ovmCALL(ADDRESS_2) => ovmADDRESS + ovmCALLER',
steps: [ steps: [
{ {
functionName: 'ovmCALL', functionName: 'ovmCALL',
......
...@@ -401,8 +401,7 @@ const test_ovmCREATE: TestDefinition = { ...@@ -401,8 +401,7 @@ const test_ovmCREATE: TestDefinition = {
], ],
}, },
{ {
name: name: 'ovmCREATE => ovmSSTORE, ovmCALL(CREATED) => ovmSLOAD(EXIST) + ovmSLOAD(NONEXIST)',
'ovmCREATE => ovmSSTORE, ovmCALL(CREATED) => ovmSLOAD(EXIST) + ovmSLOAD(NONEXIST)',
steps: [ steps: [
{ {
functionName: 'ovmCREATE', functionName: 'ovmCREATE',
...@@ -450,8 +449,7 @@ const test_ovmCREATE: TestDefinition = { ...@@ -450,8 +449,7 @@ const test_ovmCREATE: TestDefinition = {
], ],
}, },
{ {
name: name: 'ovmCREATE => ovmCALL(ADDRESS_1) => ovmSSTORE, ovmCALL(ADDRESS_1) => ovmSLOAD',
'ovmCREATE => ovmCALL(ADDRESS_1) => ovmSSTORE, ovmCALL(ADDRESS_1) => ovmSLOAD',
steps: [ steps: [
{ {
functionName: 'ovmCREATE', functionName: 'ovmCREATE',
...@@ -503,8 +501,7 @@ const test_ovmCREATE: TestDefinition = { ...@@ -503,8 +501,7 @@ const test_ovmCREATE: TestDefinition = {
{ {
// TODO: appears to be failing due to a smoddit issue // TODO: appears to be failing due to a smoddit issue
skip: true, skip: true,
name: name: 'ovmCREATE => (ovmCALL(ADDRESS_2) => ovmSSTORE) + ovmREVERT, ovmCALL(ADDRESS_2) => ovmSLOAD',
'ovmCREATE => (ovmCALL(ADDRESS_2) => ovmSSTORE) + ovmREVERT, ovmCALL(ADDRESS_2) => ovmSLOAD',
steps: [ steps: [
{ {
functionName: 'ovmCREATE', functionName: 'ovmCREATE',
...@@ -775,9 +772,10 @@ const test_ovmCREATE: TestDefinition = { ...@@ -775,9 +772,10 @@ const test_ovmCREATE: TestDefinition = {
contractStorage: { contractStorage: {
[predeploys.OVM_DeployerWhitelist]: { [predeploys.OVM_DeployerWhitelist]: {
// initialized? true, allowArbitraryDeployment? false // initialized? true, allowArbitraryDeployment? false
'0x0000000000000000000000000000000000000000000000000000000000000000': getStorageXOR( '0x0000000000000000000000000000000000000000000000000000000000000000':
'0x0000000000000000000000000000000000000000000000000000000000000001' getStorageXOR(
), '0x0000000000000000000000000000000000000000000000000000000000000001'
),
// non-whitelisted deployer is whitelisted? false // non-whitelisted deployer is whitelisted? false
[NON_WHITELISTED_DEPLOYER_KEY]: getStorageXOR( [NON_WHITELISTED_DEPLOYER_KEY]: getStorageXOR(
ethers.constants.HashZero ethers.constants.HashZero
...@@ -905,9 +903,10 @@ const test_ovmCREATE: TestDefinition = { ...@@ -905,9 +903,10 @@ const test_ovmCREATE: TestDefinition = {
contractStorage: { contractStorage: {
[predeploys.OVM_DeployerWhitelist]: { [predeploys.OVM_DeployerWhitelist]: {
// initialized? true, allowArbitraryDeployment? true // initialized? true, allowArbitraryDeployment? true
'0x0000000000000000000000000000000000000000000000000000000000000000': getStorageXOR( '0x0000000000000000000000000000000000000000000000000000000000000000':
'0x0000000000000000000000000000000000000000000000000000000000000101' getStorageXOR(
), '0x0000000000000000000000000000000000000000000000000000000000000101'
),
// non-whitelisted deployer is whitelisted? false // non-whitelisted deployer is whitelisted? false
[NON_WHITELISTED_DEPLOYER_KEY]: getStorageXOR( [NON_WHITELISTED_DEPLOYER_KEY]: getStorageXOR(
ethers.constants.HashZero ethers.constants.HashZero
...@@ -946,7 +945,8 @@ const test_ovmCREATE: TestDefinition = { ...@@ -946,7 +945,8 @@ const test_ovmCREATE: TestDefinition = {
subSteps: [], subSteps: [],
}, },
expectedReturnStatus: true, expectedReturnStatus: true,
expectedReturnValue: CREATED_BY_NON_WHITELISTED_DEPLOYER, expectedReturnValue:
CREATED_BY_NON_WHITELISTED_DEPLOYER,
}, },
], ],
}, },
......
...@@ -54,10 +54,8 @@ const test_ovmCREATEEOA: TestDefinition = { ...@@ -54,10 +54,8 @@ const test_ovmCREATEEOA: TestDefinition = {
_messageHash: _messageHash:
'0x92d658d25f963af824e9d4bd533c165773d4a694a67d88135d119d5bca97c001', '0x92d658d25f963af824e9d4bd533c165773d4a694a67d88135d119d5bca97c001',
_v: 1, _v: 1,
_r: _r: '0x73757c671fae2c3fb6825766c724b7715720bda4b309d3612f2c623364556967',
'0x73757c671fae2c3fb6825766c724b7715720bda4b309d3612f2c623364556967', _s: '0x2fc9b7222783390b9f10e22e92a52871beaff2613193d6e2dbf18d0e2d2eb8ff',
_s:
'0x2fc9b7222783390b9f10e22e92a52871beaff2613193d6e2dbf18d0e2d2eb8ff',
}, },
expectedReturnStatus: true, expectedReturnStatus: true,
expectedReturnValue: undefined, expectedReturnValue: undefined,
......
...@@ -87,8 +87,7 @@ const test_ovmDELEGATECALL: TestDefinition = { ...@@ -87,8 +87,7 @@ const test_ovmDELEGATECALL: TestDefinition = {
], ],
}, },
{ {
name: name: 'ovmCALL(ADDRESS_1) => ovmCALL(ADDRESS_2) => ovmDELEGATECALL(ADDRESS_3) => ovmCALLER',
'ovmCALL(ADDRESS_1) => ovmCALL(ADDRESS_2) => ovmDELEGATECALL(ADDRESS_3) => ovmCALLER',
steps: [ steps: [
{ {
functionName: 'ovmCALL', functionName: 'ovmCALL',
...@@ -127,8 +126,7 @@ const test_ovmDELEGATECALL: TestDefinition = { ...@@ -127,8 +126,7 @@ const test_ovmDELEGATECALL: TestDefinition = {
], ],
}, },
{ {
name: name: 'ovmCALL(ADDRESS_1) => (ovmDELEGATECALL(ADDRESS_2) => ovmSSTORE) + ovmSLOAD',
'ovmCALL(ADDRESS_1) => (ovmDELEGATECALL(ADDRESS_2) => ovmSSTORE) + ovmSLOAD',
steps: [ steps: [
{ {
functionName: 'ovmCALL', functionName: 'ovmCALL',
...@@ -202,8 +200,7 @@ const test_ovmDELEGATECALL: TestDefinition = { ...@@ -202,8 +200,7 @@ const test_ovmDELEGATECALL: TestDefinition = {
], ],
}, },
{ {
name: name: 'ovmCALL(ADDRESS_1) => ovmCALL(ADDRESS_2) => ovmDELEGATECALL(ADDRESS_3) => ovmDELEGATECALL(ADDRESS_4) => ovmCALLER',
'ovmCALL(ADDRESS_1) => ovmCALL(ADDRESS_2) => ovmDELEGATECALL(ADDRESS_3) => ovmDELEGATECALL(ADDRESS_4) => ovmCALLER',
steps: [ steps: [
{ {
functionName: 'ovmCALL', functionName: 'ovmCALL',
...@@ -252,8 +249,7 @@ const test_ovmDELEGATECALL: TestDefinition = { ...@@ -252,8 +249,7 @@ const test_ovmDELEGATECALL: TestDefinition = {
], ],
}, },
{ {
name: name: 'ovmCALL(ADDRESS_1) => ovmCALL(ADDRESS_2) => ovmDELEGATECALL(ADDRESS_3) => ovmDELEGATECALL(ADDRESS_4) => ovmADDRESS',
'ovmCALL(ADDRESS_1) => ovmCALL(ADDRESS_2) => ovmDELEGATECALL(ADDRESS_3) => ovmDELEGATECALL(ADDRESS_4) => ovmADDRESS',
steps: [ steps: [
{ {
functionName: 'ovmCALL', functionName: 'ovmCALL',
...@@ -302,8 +298,7 @@ const test_ovmDELEGATECALL: TestDefinition = { ...@@ -302,8 +298,7 @@ const test_ovmDELEGATECALL: TestDefinition = {
], ],
}, },
{ {
name: name: 'ovmCALL(ADDRESS_1) => ovmCALL(ADDRESS_2) => ovmDELEGATECALL(ADDRESS_3) => ovmDELEGATECALL(ADDRESS_4) => ovmCREATE',
'ovmCALL(ADDRESS_1) => ovmCALL(ADDRESS_2) => ovmDELEGATECALL(ADDRESS_3) => ovmDELEGATECALL(ADDRESS_4) => ovmCREATE',
steps: [ steps: [
{ {
functionName: 'ovmCALL', functionName: 'ovmCALL',
......
...@@ -192,8 +192,7 @@ const test_ovmSTATICCALL: TestDefinition = { ...@@ -192,8 +192,7 @@ const test_ovmSTATICCALL: TestDefinition = {
], ],
}, },
{ {
name: name: 'ovmCALL(ADDRESS_1) => ovmSTATICCALL(ADDRESS_2) => ovmCALL(ADDRESS_3) => ovmSSTORE',
'ovmCALL(ADDRESS_1) => ovmSTATICCALL(ADDRESS_2) => ovmCALL(ADDRESS_3) => ovmSSTORE',
steps: [ steps: [
{ {
functionName: 'ovmCALL', functionName: 'ovmCALL',
...@@ -240,8 +239,7 @@ const test_ovmSTATICCALL: TestDefinition = { ...@@ -240,8 +239,7 @@ const test_ovmSTATICCALL: TestDefinition = {
], ],
}, },
{ {
name: name: 'ovmCALL(ADDRESS_1) => ovmSTATICCALL(ADDRESS_2) => ovmCALL(ADDRESS_3) => ovmSLOAD',
'ovmCALL(ADDRESS_1) => ovmSTATICCALL(ADDRESS_2) => ovmCALL(ADDRESS_3) => ovmSLOAD',
steps: [ steps: [
{ {
functionName: 'ovmCALL', functionName: 'ovmCALL',
...@@ -284,8 +282,7 @@ const test_ovmSTATICCALL: TestDefinition = { ...@@ -284,8 +282,7 @@ const test_ovmSTATICCALL: TestDefinition = {
], ],
}, },
{ {
name: name: 'ovmCALL(ADDRESS_1) => ovmSTATICCALL(ADDRESS_2) => ovmCALL(ADDRESS_3) => ovmCREATE',
'ovmCALL(ADDRESS_1) => ovmSTATICCALL(ADDRESS_2) => ovmCALL(ADDRESS_3) => ovmCREATE',
steps: [ steps: [
{ {
functionName: 'ovmCALL', functionName: 'ovmCALL',
......
...@@ -67,10 +67,9 @@ describe('OVM_BondManager', () => { ...@@ -67,10 +67,9 @@ describe('OVM_BondManager', () => {
token = await (await deployer.getContractFactory('TestERC20')).deploy() token = await (await deployer.getContractFactory('TestERC20')).deploy()
await token.mint(sender, ethers.utils.parseEther('100')) await token.mint(sender, ethers.utils.parseEther('100'))
bondManager = await (await smoddit('OVM_BondManager')).deploy( bondManager = await (
token.address, await smoddit('OVM_BondManager')
manager.address ).deploy(token.address, manager.address)
)
await manager.setAddress('OVM_BondManager', bondManager.address) await manager.setAddress('OVM_BondManager', bondManager.address)
await fraudVerifier.setBondManager(bondManager.address) await fraudVerifier.setBondManager(bondManager.address)
}) })
......
...@@ -35,9 +35,8 @@ describe('OVM_StateTransitionerFactory', () => { ...@@ -35,9 +35,8 @@ describe('OVM_StateTransitionerFactory', () => {
let OVM_StateTransitionerFactory: Contract let OVM_StateTransitionerFactory: Contract
let Mock__OVM_StateManagerFactory: MockContract let Mock__OVM_StateManagerFactory: MockContract
beforeEach(async () => { beforeEach(async () => {
OVM_StateTransitionerFactory = await Factory__OVM_StateTransitionerFactory.deploy( OVM_StateTransitionerFactory =
AddressManager.address await Factory__OVM_StateTransitionerFactory.deploy(AddressManager.address)
)
Mock__OVM_StateManagerFactory = await smockit('OVM_StateManagerFactory') Mock__OVM_StateManagerFactory = await smockit('OVM_StateManagerFactory')
Mock__OVM_StateManagerFactory.smocked.create.will.return.with( Mock__OVM_StateManagerFactory.smocked.create.will.return.with(
......
...@@ -44,9 +44,10 @@ describe('Lib_RLPWriter', () => { ...@@ -44,9 +44,10 @@ describe('Lib_RLPWriter', () => {
const randomAddress = '0x1234123412341234123412341234123412341234' const randomAddress = '0x1234123412341234123412341234123412341234'
const rlpEncodedRandomAddress = const rlpEncodedRandomAddress =
'0x941234123412341234123412341234123412341234' '0x941234123412341234123412341234123412341234'
const encoded = await Lib_RLPWriter.callStatic.writeAddressWithTaintedMemory( const encoded =
randomAddress await Lib_RLPWriter.callStatic.writeAddressWithTaintedMemory(
) randomAddress
)
expect(encoded).to.eq(rlpEncodedRandomAddress) expect(encoded).to.eq(rlpEncodedRandomAddress)
}) })
}) })
......
...@@ -10,20 +10,7 @@ import { fromHexString, toHexString } from '@eth-optimism/core-utils' ...@@ -10,20 +10,7 @@ import { fromHexString, toHexString } from '@eth-optimism/core-utils'
import { NON_NULL_BYTES32 } from '../../../helpers' import { NON_NULL_BYTES32 } from '../../../helpers'
const NODE_COUNTS = [ const NODE_COUNTS = [
2, 2, 3, 7, 9, 13, 63, 64, 123, 128, 129, 255, 1021, 1023, 1024,
3,
7,
9,
13,
63,
64,
123,
128,
129,
255,
1021,
1023,
1024,
] ]
const hash = (el: Buffer | string): Buffer => { const hash = (el: Buffer | string): Buffer => {
......
...@@ -6,7 +6,8 @@ export const encodeXDomainCalldata = ( ...@@ -6,7 +6,8 @@ export const encodeXDomainCalldata = (
message: string, message: string,
messageNonce: number messageNonce: number
): string => { ): string => {
return getContractInterface( return getContractInterface('OVM_L2CrossDomainMessenger').encodeFunctionData(
'OVM_L2CrossDomainMessenger' 'relayMessage',
).encodeFunctionData('relayMessage', [target, sender, message, messageNonce]) [target, sender, message, messageNonce]
)
} }
...@@ -16,10 +16,11 @@ export class GasMeasurement { ...@@ -16,10 +16,11 @@ export class GasMeasurement {
methodName: string, methodName: string,
methodArgs: Array<any> = [] methodArgs: Array<any> = []
): Promise<number> { ): Promise<number> {
const gasCost: number = await this.GasMeasurementContract.callStatic.measureCallGas( const gasCost: number =
targetContract.address, await this.GasMeasurementContract.callStatic.measureCallGas(
targetContract.interface.encodeFunctionData(methodName, methodArgs) targetContract.address,
) targetContract.interface.encodeFunctionData(methodName, methodArgs)
)
return gasCost return gasCost
} }
......
...@@ -83,15 +83,17 @@ export class ExecutionManagerTestRunner { ...@@ -83,15 +83,17 @@ export class ExecutionManagerTestRunner {
}, },
contractStorage: { contractStorage: {
[predeploys.OVM_DeployerWhitelist]: { [predeploys.OVM_DeployerWhitelist]: {
'0x0000000000000000000000000000000000000000000000000000000000000000': { '0x0000000000000000000000000000000000000000000000000000000000000000':
getStorageXOR: true, {
value: ethers.constants.HashZero, getStorageXOR: true,
}, value: ethers.constants.HashZero,
},
}, },
}, },
verifiedContractStorage: { verifiedContractStorage: {
[predeploys.OVM_DeployerWhitelist]: { [predeploys.OVM_DeployerWhitelist]: {
'0x0000000000000000000000000000000000000000000000000000000000000000': true, '0x0000000000000000000000000000000000000000000000000000000000000000':
true,
}, },
}, },
}, },
...@@ -275,9 +277,8 @@ export class ExecutionManagerTestRunner { ...@@ -275,9 +277,8 @@ export class ExecutionManagerTestRunner {
await ethers.getContractFactory('Helper_TestRunner') await ethers.getContractFactory('Helper_TestRunner')
).deploy() ).deploy()
this.contracts.Factory__Helper_TestRunner_CREATE = await ethers.getContractFactory( this.contracts.Factory__Helper_TestRunner_CREATE =
'Helper_TestRunner_CREATE' await ethers.getContractFactory('Helper_TestRunner_CREATE')
)
this.snapshot = await ethers.provider.send('evm_snapshot', []) this.snapshot = await ethers.provider.send('evm_snapshot', [])
} }
......
...@@ -22,7 +22,7 @@ export class Watcher { ...@@ -22,7 +22,7 @@ export class Watcher {
constructor(opts: WatcherOptions) { constructor(opts: WatcherOptions) {
this.l1 = opts.l1 this.l1 = opts.l1
this.l2 = opts.l2 this.l2 = opts.l2
if(opts.pollInterval) { if (opts.pollInterval) {
this.pollInterval = opts.pollInterval this.pollInterval = opts.pollInterval
} }
} }
...@@ -105,7 +105,7 @@ export class Watcher { ...@@ -105,7 +105,7 @@ export class Watcher {
} }
// pause awhile before trying again // pause awhile before trying again
await new Promise(r => setTimeout(r, this.pollInterval)) await new Promise((r) => setTimeout(r, this.pollInterval))
} }
// Message was relayed in the past // Message was relayed in the past
......
...@@ -46,7 +46,7 @@ const registerMetrics = ({ ...@@ -46,7 +46,7 @@ const registerMetrics = ({
name: 'data_transport_layer_l1_unhandled_error_count', name: 'data_transport_layer_l1_unhandled_error_count',
help: 'Number of times recovered from unhandled errors', help: 'Number of times recovered from unhandled errors',
registers: [registry], registers: [registry],
}) }),
}) })
export interface L1IngestionServiceOptions export interface L1IngestionServiceOptions
...@@ -168,7 +168,8 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> { ...@@ -168,7 +168,8 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> {
// Store the total number of submitted transactions so the server can tell clients if we're // Store the total number of submitted transactions so the server can tell clients if we're
// done syncing or not // done syncing or not
const totalElements = await this.state.contracts.OVM_CanonicalTransactionChain.getTotalElements() const totalElements =
await this.state.contracts.OVM_CanonicalTransactionChain.getTotalElements()
if (totalElements > 0) { if (totalElements > 0) {
await this.state.db.putHighestL2BlockNumber(totalElements - 1) await this.state.db.putHighestL2BlockNumber(totalElements - 1)
} }
...@@ -246,9 +247,14 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> { ...@@ -246,9 +247,14 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> {
// Different functions for getting the last good element depending on the event type. // Different functions for getting the last good element depending on the event type.
const handlers = { const handlers = {
SequencerBatchAppended: this.state.db.getLatestTransactionBatch.bind(this.state.db), SequencerBatchAppended:
StateBatchAppended: this.state.db.getLatestStateRootBatch.bind(this.state.db), this.state.db.getLatestTransactionBatch.bind(this.state.db),
TransactionEnqueued: this.state.db.getLatestEnqueue.bind(this.state.db), StateBatchAppended: this.state.db.getLatestStateRootBatch.bind(
this.state.db
),
TransactionEnqueued: this.state.db.getLatestEnqueue.bind(
this.state.db
),
} }
// Find the last good element and reset the highest synced L1 block to go back to the // Find the last good element and reset the highest synced L1 block to go back to the
...@@ -325,11 +331,14 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> { ...@@ -325,11 +331,14 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> {
// We need to figure out how to make this work without Infura. Mark and I think that infura is // We need to figure out how to make this work without Infura. Mark and I think that infura is
// doing some indexing of events beyond Geth's native capabilities, meaning some event logic // doing some indexing of events beyond Geth's native capabilities, meaning some event logic
// will only work on Infura and not on a local geth instance. Not great. // will only work on Infura and not on a local geth instance. Not great.
const addressSetEvents = await this.state.contracts.Lib_AddressManager.queryFilter( const addressSetEvents =
this.state.contracts.Lib_AddressManager.filters.AddressSet(contractName), await this.state.contracts.Lib_AddressManager.queryFilter(
fromL1Block, this.state.contracts.Lib_AddressManager.filters.AddressSet(
toL1Block contractName
) ),
fromL1Block,
toL1Block
)
// We're going to parse things out in ranges because the address of a given contract may have // We're going to parse things out in ranges because the address of a given contract may have
// changed in the range provided by the user. // changed in the range provided by the user.
......
...@@ -229,7 +229,8 @@ export class L1TransportServer extends BaseService<L1TransportServerOptions> { ...@@ -229,7 +229,8 @@ export class L1TransportServer extends BaseService<L1TransportServerOptions> {
highestL2BlockNumber = await this.state.db.getHighestL2BlockNumber() highestL2BlockNumber = await this.state.db.getHighestL2BlockNumber()
break break
case 'l2': case 'l2':
currentL2Block = await this.state.db.getLatestUnconfirmedTransaction() currentL2Block =
await this.state.db.getLatestUnconfirmedTransaction()
highestL2BlockNumber = highestL2BlockNumber =
(await this.state.db.getHighestSyncedUnconfirmedBlock()) - 1 (await this.state.db.getHighestSyncedUnconfirmedBlock()) - 1
break break
...@@ -472,11 +473,12 @@ export class L1TransportServer extends BaseService<L1TransportServerOptions> { ...@@ -472,11 +473,12 @@ export class L1TransportServer extends BaseService<L1TransportServerOptions> {
} }
} }
const transactions = await this.state.db.getFullTransactionsByIndexRange( const transactions =
BigNumber.from(batch.prevTotalElements).toNumber(), await this.state.db.getFullTransactionsByIndexRange(
BigNumber.from(batch.prevTotalElements).toNumber() + BigNumber.from(batch.prevTotalElements).toNumber(),
BigNumber.from(batch.size).toNumber() BigNumber.from(batch.prevTotalElements).toNumber() +
) BigNumber.from(batch.size).toNumber()
)
return { return {
batch, batch,
...@@ -500,11 +502,12 @@ export class L1TransportServer extends BaseService<L1TransportServerOptions> { ...@@ -500,11 +502,12 @@ export class L1TransportServer extends BaseService<L1TransportServerOptions> {
} }
} }
const transactions = await this.state.db.getFullTransactionsByIndexRange( const transactions =
BigNumber.from(batch.prevTotalElements).toNumber(), await this.state.db.getFullTransactionsByIndexRange(
BigNumber.from(batch.prevTotalElements).toNumber() + BigNumber.from(batch.prevTotalElements).toNumber(),
BigNumber.from(batch.size).toNumber() BigNumber.from(batch.prevTotalElements).toNumber() +
) BigNumber.from(batch.size).toNumber()
)
return { return {
batch, batch,
......
...@@ -14,8 +14,7 @@ describe('Event Handlers: OVM_CanonicalTransactionChain.StateBatchAppended', () ...@@ -14,8 +14,7 @@ describe('Event Handlers: OVM_CanonicalTransactionChain.StateBatchAppended', ()
it('should return event block and transaction', async () => { it('should return event block and transaction', async () => {
// Source: https://etherscan.io/tx/0x4ca72484e93cdb50fe1089984db152258c2bbffc2534dcafbfe032b596bd5b49 // Source: https://etherscan.io/tx/0x4ca72484e93cdb50fe1089984db152258c2bbffc2534dcafbfe032b596bd5b49
const l1Transaction = { const l1Transaction = {
hash: hash: '0x4ca72484e93cdb50fe1089984db152258c2bbffc2534dcafbfe032b596bd5b49',
'0x4ca72484e93cdb50fe1089984db152258c2bbffc2534dcafbfe032b596bd5b49',
from: '0xfd7d4de366850c08ee2cba32d851385a3071ec8d', from: '0xfd7d4de366850c08ee2cba32d851385a3071ec8d',
data: l1StateBatchData, data: l1StateBatchData,
} }
...@@ -23,8 +22,7 @@ describe('Event Handlers: OVM_CanonicalTransactionChain.StateBatchAppended', () ...@@ -23,8 +22,7 @@ describe('Event Handlers: OVM_CanonicalTransactionChain.StateBatchAppended', ()
const eventBlock: Block = { const eventBlock: Block = {
timestamp: 1616680530, timestamp: 1616680530,
number: 12106615, number: 12106615,
hash: hash: '0x9c40310e19e943ad38e170329465c4489f6aba5895e9cacdac236be181aea31f',
'0x9c40310e19e943ad38e170329465c4489f6aba5895e9cacdac236be181aea31f',
parentHash: parentHash:
'0xc7707a04c287a22ff4e43e5d9316e45ab342dcd405e7e0284eb51ce71a3a29ac', '0xc7707a04c287a22ff4e43e5d9316e45ab342dcd405e7e0284eb51ce71a3a29ac',
miner: '0xea674fdde714fd979de3edf0f56aa9716b898ec8', miner: '0xea674fdde714fd979de3edf0f56aa9716b898ec8',
......
...@@ -116,14 +116,10 @@ export const getMessagesByTransactionHash = async ( ...@@ -116,14 +116,10 @@ export const getMessagesByTransactionHash = async (
* @returns Encoded message. * @returns Encoded message.
*/ */
const encodeCrossDomainMessage = (message: CrossDomainMessage): string => { const encodeCrossDomainMessage = (message: CrossDomainMessage): string => {
return getContractInterface( return getContractInterface('OVM_L2CrossDomainMessenger').encodeFunctionData(
'OVM_L2CrossDomainMessenger' 'relayMessage',
).encodeFunctionData('relayMessage', [ [message.target, message.sender, message.message, message.messageNonce]
message.target, )
message.sender,
message.message,
message.messageNonce,
])
} }
/** /**
...@@ -169,16 +165,16 @@ export const getStateBatchAppendedEventByTransactionIndex = async ( ...@@ -169,16 +165,16 @@ export const getStateBatchAppendedEventByTransactionIndex = async (
return index >= prevTotalElements + batchSize return index >= prevTotalElements + batchSize
} }
const totalBatches: ethers.BigNumber = await l1StateCommitmentChain.getTotalBatches() const totalBatches: ethers.BigNumber =
await l1StateCommitmentChain.getTotalBatches()
if (totalBatches.eq(0)) { if (totalBatches.eq(0)) {
return null return null
} }
let lowerBound = 0 let lowerBound = 0
let upperBound = totalBatches.toNumber() - 1 let upperBound = totalBatches.toNumber() - 1
let batchEvent: ethers.Event | null = await getStateBatchAppendedEventByBatchIndex( let batchEvent: ethers.Event | null =
upperBound await getStateBatchAppendedEventByBatchIndex(upperBound)
)
if (isEventLo(batchEvent, l2TransactionIndex)) { if (isEventLo(batchEvent, l2TransactionIndex)) {
// Upper bound is too low, means this transaction doesn't have a corresponding state batch yet. // Upper bound is too low, means this transaction doesn't have a corresponding state batch yet.
...@@ -227,11 +223,12 @@ export const getStateRootBatchByTransactionIndex = async ( ...@@ -227,11 +223,12 @@ export const getStateRootBatchByTransactionIndex = async (
l1RpcProvider l1RpcProvider
) )
const stateBatchAppendedEvent = await getStateBatchAppendedEventByTransactionIndex( const stateBatchAppendedEvent =
l1RpcProvider, await getStateBatchAppendedEventByTransactionIndex(
l1StateCommitmentChainAddress, l1RpcProvider,
l2TransactionIndex l1StateCommitmentChainAddress,
) l2TransactionIndex
)
if (stateBatchAppendedEvent === null) { if (stateBatchAppendedEvent === null) {
return null return null
} }
...@@ -277,12 +274,9 @@ const getMerkleTreeProof = (leaves: string[], index: number): string[] => { ...@@ -277,12 +274,9 @@ const getMerkleTreeProof = (leaves: string[], index: number): string[] => {
// merkletreejs prefers things to be Buffers. // merkletreejs prefers things to be Buffers.
const bufLeaves = parsedLeaves.map(fromHexString) const bufLeaves = parsedLeaves.map(fromHexString)
const tree = new MerkleTree( const tree = new MerkleTree(bufLeaves, (el: Buffer | string): Buffer => {
bufLeaves, return fromHexString(ethers.utils.keccak256(el))
(el: Buffer | string): Buffer => { })
return fromHexString(ethers.utils.keccak256(el))
}
)
const proof = tree.getProof(bufLeaves[index], index).map((element: any) => { const proof = tree.getProof(bufLeaves[index], index).map((element: any) => {
return toHexString(element.data) return toHexString(element.data)
......
...@@ -274,9 +274,7 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> { ...@@ -274,9 +274,7 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> {
} }
} }
private async _getStateBatchHeader( private async _getStateBatchHeader(height: number): Promise<
height: number
): Promise<
| { | {
batch: StateRootBatchHeader batch: StateRootBatchHeader
stateRoots: string[] stateRoots: string[]
...@@ -308,11 +306,12 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> { ...@@ -308,11 +306,12 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> {
endBlock: startingBlock + this.options.getLogsInterval, endBlock: startingBlock + this.options.getLogsInterval,
}) })
const events: ethers.Event[] = await this.state.OVM_StateCommitmentChain.queryFilter( const events: ethers.Event[] =
this.state.OVM_StateCommitmentChain.filters.StateBatchAppended(), await this.state.OVM_StateCommitmentChain.queryFilter(
startingBlock, this.state.OVM_StateCommitmentChain.filters.StateBatchAppended(),
startingBlock + this.options.getLogsInterval startingBlock,
) startingBlock + this.options.getLogsInterval
)
this.state.eventCache = this.state.eventCache.concat(events) this.state.eventCache = this.state.eventCache.concat(events)
startingBlock += this.options.getLogsInterval startingBlock += this.options.getLogsInterval
...@@ -333,12 +332,11 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> { ...@@ -333,12 +332,11 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> {
event.transactionHash event.transactionHash
) )
const [ const [stateRoots] =
stateRoots, this.state.OVM_StateCommitmentChain.interface.decodeFunctionData(
] = this.state.OVM_StateCommitmentChain.interface.decodeFunctionData( 'appendStateBatch',
'appendStateBatch', transaction.data
transaction.data )
)
return { return {
batch: { batch: {
...@@ -390,10 +388,11 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> { ...@@ -390,10 +388,11 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> {
const messages = events.map((event) => { const messages = events.map((event) => {
const message = event.args.message const message = event.args.message
const decoded = this.state.OVM_L2CrossDomainMessenger.interface.decodeFunctionData( const decoded =
'relayMessage', this.state.OVM_L2CrossDomainMessenger.interface.decodeFunctionData(
message 'relayMessage',
) message
)
return { return {
target: decoded._target, target: decoded._target,
......
...@@ -7,8 +7,8 @@ import BN from 'bn.js' ...@@ -7,8 +7,8 @@ import BN from 'bn.js'
// Handle hardhat ^2.4.0 // Handle hardhat ^2.4.0
let decodeRevertReason: (value: Buffer) => string let decodeRevertReason: (value: Buffer) => string
try { try {
decodeRevertReason = require('hardhat/internal/hardhat-network/stack-traces/revert-reasons') decodeRevertReason =
.decodeRevertReason require('hardhat/internal/hardhat-network/stack-traces/revert-reasons').decodeRevertReason
} catch (err) { } catch (err) {
const { const {
ReturnData, ReturnData,
...@@ -20,11 +20,11 @@ try { ...@@ -20,11 +20,11 @@ try {
// Handle hardhat ^2.2.0 // Handle hardhat ^2.2.0
let TransactionExecutionError: any let TransactionExecutionError: any
try { try {
TransactionExecutionError = require('hardhat/internal/hardhat-network/provider/errors') TransactionExecutionError =
.TransactionExecutionError require('hardhat/internal/hardhat-network/provider/errors').TransactionExecutionError
} catch (err) { } catch (err) {
TransactionExecutionError = require('hardhat/internal/core/providers/errors') TransactionExecutionError =
.TransactionExecutionError require('hardhat/internal/core/providers/errors').TransactionExecutionError
} }
/* eslint-enable @typescript-eslint/no-var-requires */ /* eslint-enable @typescript-eslint/no-var-requires */
...@@ -137,13 +137,8 @@ const initializeSmock = (provider: HardhatNetworkProvider): void => { ...@@ -137,13 +137,8 @@ const initializeSmock = (provider: HardhatNetworkProvider): void => {
// Compute the mock return data. // Compute the mock return data.
const mock: MockContract = vm._smockState.mocks[target] const mock: MockContract = vm._smockState.mocks[target]
const { const { resolve, functionName, rawReturnValue, returnValue, gasUsed } =
resolve, await mock._smockit(message.data)
functionName,
rawReturnValue,
returnValue,
gasUsed,
} = await mock._smockit(message.data)
// Set the mock return data, potentially set the `exceptionError` field if the user requested // Set the mock return data, potentially set the `exceptionError` field if the user requested
// a revert. // a revert.
......
...@@ -200,9 +200,7 @@ export const smockit = async ( ...@@ -200,9 +200,7 @@ export const smockit = async (
} }
// TODO: Make this less of a hack. // TODO: Make this less of a hack.
;(contract as any)._smockit = async function ( ;(contract as any)._smockit = async function (data: Buffer): Promise<{
data: Buffer
): Promise<{
resolve: 'return' | 'revert' resolve: 'return' | 'revert'
functionName: string functionName: string
rawReturnValue: any rawReturnValue: any
......
...@@ -328,7 +328,7 @@ function parseSequencerBatchAppendedEvent( ...@@ -328,7 +328,7 @@ function parseSequencerBatchAppendedEvent(
l1TxOrigin: 0x0000000000000000000000000000000000000000, l1TxOrigin: 0x0000000000000000000000000000000000000000,
entrypoint: 0x4200000000000000000000000000000000000005, entrypoint: 0x4200000000000000000000000000000000000005,
gasLimit: OVM_ExecutionManager.getMaxTransactionGasLimit(), gasLimit: OVM_ExecutionManager.getMaxTransactionGasLimit(),
data: params.transactions[sequencerTransactionCount] data: params.transactions[sequencerTransactionCount],
}); });
sequencerTransactionCount = sequencerTransactionCount + 1; sequencerTransactionCount = sequencerTransactionCount + 1;
...@@ -338,9 +338,10 @@ function parseSequencerBatchAppendedEvent( ...@@ -338,9 +338,10 @@ function parseSequencerBatchAppendedEvent(
// Note that this places an assumption on how events are parsed. This // Note that this places an assumption on how events are parsed. This
// only works if enqueued transactions are parsed before // only works if enqueued transactions are parsed before
// `appendQueueBatch` events. // `appendQueueBatch` events.
const enqueuedTransaction: EnqueuedTransaction = getEnqueuedTransactionByIndex( const enqueuedTransaction: EnqueuedTransaction =
event.startingQueueIndex + queueTransactionCount getEnqueuedTransactionByIndex(
); event.startingQueueIndex + queueTransactionCount
);
transactions.push({ transactions.push({
l1QueueOrigin: QueueOrigin.L1TOL2_QUEUE, l1QueueOrigin: QueueOrigin.L1TOL2_QUEUE,
...@@ -349,7 +350,7 @@ function parseSequencerBatchAppendedEvent( ...@@ -349,7 +350,7 @@ function parseSequencerBatchAppendedEvent(
l1TxOrigin: enqueuedTransaction.l1TxOrigin, l1TxOrigin: enqueuedTransaction.l1TxOrigin,
entrypoint: enqueuedTransaction.entrypoint, entrypoint: enqueuedTransaction.entrypoint,
gasLimit: enqueuedTransaction.gasLimit, gasLimit: enqueuedTransaction.gasLimit,
data: enqueuedTransaction.data data: enqueuedTransaction.data,
}); });
queueTransactionCount = queueTransactionCount + 1; queueTransactionCount = queueTransactionCount + 1;
......
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