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