Commit a94779d4 authored by elenadimitrova's avatar elenadimitrova Committed by Kelvin Fichter

Rename L1/rollup contracts to remove the OVM prefix

parent f817d4c3
...@@ -83,9 +83,9 @@ export class OptimismEnv { ...@@ -83,9 +83,9 @@ export class OptimismEnv {
.attach(watcher.l2.messengerAddress) .attach(watcher.l2.messengerAddress)
const ctcAddress = await addressManager.getAddress( const ctcAddress = await addressManager.getAddress(
'OVM_CanonicalTransactionChain' 'CanonicalTransactionChain'
) )
const ctc = getContractFactory('OVM_CanonicalTransactionChain') const ctc = getContractFactory('CanonicalTransactionChain')
.connect(l1Wallet) .connect(l1Wallet)
.attach(ctcAddress) .attach(ctcAddress)
...@@ -94,9 +94,9 @@ export class OptimismEnv { ...@@ -94,9 +94,9 @@ export class OptimismEnv {
.attach(predeploys.OVM_GasPriceOracle) .attach(predeploys.OVM_GasPriceOracle)
const sccAddress = await addressManager.getAddress( const sccAddress = await addressManager.getAddress(
'OVM_StateCommitmentChain' 'StateCommitmentChain'
) )
const scc = getContractFactory('OVM_StateCommitmentChain') const scc = getContractFactory('StateCommitmentChain')
.connect(l1Wallet) .connect(l1Wallet)
.attach(sccAddress) .attach(sccAddress)
......
...@@ -138,10 +138,10 @@ export abstract class BatchSubmitter { ...@@ -138,10 +138,10 @@ export abstract class BatchSubmitter {
await getContractFactory('Lib_AddressManager', this.signer) await getContractFactory('Lib_AddressManager', this.signer)
).attach(this.addressManagerAddress) ).attach(this.addressManagerAddress)
const sccAddress = await addressManager.getAddress( const sccAddress = await addressManager.getAddress(
'OVM_StateCommitmentChain' 'StateCommitmentChain'
) )
const ctcAddress = await addressManager.getAddress( const ctcAddress = await addressManager.getAddress(
'OVM_CanonicalTransactionChain' 'CanonicalTransactionChain'
) )
return { return {
ctcAddress, ctcAddress,
......
...@@ -94,10 +94,10 @@ export class StateBatchSubmitter extends BatchSubmitter { ...@@ -94,10 +94,10 @@ export class StateBatchSubmitter extends BatchSubmitter {
} }
this.chainContract = ( this.chainContract = (
await getContractFactory('OVM_StateCommitmentChain', this.signer) await getContractFactory('StateCommitmentChain', this.signer)
).attach(sccAddress) ).attach(sccAddress)
this.ctcContract = ( this.ctcContract = (
await getContractFactory('OVM_CanonicalTransactionChain', this.signer) await getContractFactory('CanonicalTransactionChain', this.signer)
).attach(ctcAddress) ).attach(ctcAddress)
this.logger.info('Connected Optimism contracts', { this.logger.info('Connected Optimism contracts', {
......
...@@ -107,13 +107,13 @@ export class TransactionBatchSubmitter extends BatchSubmitter { ...@@ -107,13 +107,13 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
return return
} }
const unwrapped_OVM_CanonicalTransactionChain = ( const unwrapped_CanonicalTransactionChain = (
await getContractFactory('OVM_CanonicalTransactionChain', this.signer) await getContractFactory('CanonicalTransactionChain', this.signer)
).attach(ctcAddress) ).attach(ctcAddress)
this.chainContract = new CanonicalTransactionChainContract( this.chainContract = new CanonicalTransactionChainContract(
unwrapped_OVM_CanonicalTransactionChain.address, unwrapped_CanonicalTransactionChain.address,
getContractInterface('OVM_CanonicalTransactionChain'), getContractInterface('CanonicalTransactionChain'),
this.signer this.signer
) )
this.logger.info('Initialized new CTC', { this.logger.info('Initialized new CTC', {
...@@ -573,11 +573,12 @@ export class TransactionBatchSubmitter extends BatchSubmitter { ...@@ -573,11 +573,12 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
) )
const addr = await manager.getAddress( const addr = await manager.getAddress(
'OVM_ChainStorageContainer-CTC-batches' 'ChainStorageContainer-CTC-batches'
) )
const container = new Contract( const container = new Contract(
addr, addr,
getNewContractInterface('iOVM_ChainStorageContainer'), getNewContractInterface('IChainStorageContainer'),
this.signer.provider this.signer.provider
) )
......
...@@ -15,7 +15,7 @@ import { ...@@ -15,7 +15,7 @@ import {
export { encodeAppendSequencerBatch, BatchContext, AppendSequencerBatchParams } export { encodeAppendSequencerBatch, BatchContext, AppendSequencerBatchParams }
/* /*
* OVM_CanonicalTransactionChainContract is a wrapper around a normal Ethers contract * CanonicalTransactionChainContract is a wrapper around a normal Ethers contract
* where the `appendSequencerBatch(...)` function uses a specialized encoding for improved efficiency. * where the `appendSequencerBatch(...)` function uses a specialized encoding for improved efficiency.
*/ */
export class CanonicalTransactionChainContract extends Contract { export class CanonicalTransactionChainContract extends Contract {
...@@ -57,12 +57,12 @@ const APPEND_SEQUENCER_BATCH_METHOD_ID = keccak256( ...@@ -57,12 +57,12 @@ const APPEND_SEQUENCER_BATCH_METHOD_ID = keccak256(
).slice(2, 10) ).slice(2, 10)
const appendSequencerBatch = async ( const appendSequencerBatch = async (
OVM_CanonicalTransactionChain: Contract, CanonicalTransactionChain: Contract,
batch: AppendSequencerBatchParams, batch: AppendSequencerBatchParams,
options?: TransactionRequest options?: TransactionRequest
): Promise<TransactionResponse> => { ): Promise<TransactionResponse> => {
return OVM_CanonicalTransactionChain.signer.sendTransaction({ return CanonicalTransactionChain.signer.sendTransaction({
to: OVM_CanonicalTransactionChain.address, to: CanonicalTransactionChain.address,
data: getEncodedCalldata(batch), data: getEncodedCalldata(batch),
...options, ...options,
}) })
......
...@@ -8,7 +8,7 @@ import ganache from 'ganache-core' ...@@ -8,7 +8,7 @@ import ganache from 'ganache-core'
import sinon from 'sinon' import sinon from 'sinon'
import { Web3Provider } from '@ethersproject/providers' import { Web3Provider } from '@ethersproject/providers'
import scc from '@eth-optimism/contracts/artifacts/contracts/L1/rollup/OVM_StateCommitmentChain.sol/OVM_StateCommitmentChain.json' import scc from '@eth-optimism/contracts/artifacts/contracts/L1/rollup/StateCommitmentChain.sol/StateCommitmentChain.json'
import { getContractInterface, predeploys } from '@eth-optimism/contracts' import { getContractInterface, predeploys } from '@eth-optimism/contracts'
import { smockit, MockContract } from '@eth-optimism/smock' import { smockit, MockContract } from '@eth-optimism/smock'
...@@ -89,7 +89,7 @@ describe('BatchSubmitter', () => { ...@@ -89,7 +89,7 @@ describe('BatchSubmitter', () => {
let AddressManager: Contract let AddressManager: Contract
let Mock__OVM_ExecutionManager: MockContract let Mock__OVM_ExecutionManager: MockContract
let Mock__OVM_BondManager: MockContract let Mock__OVM_BondManager: MockContract
let Mock__OVM_StateCommitmentChain: MockContract let Mock__StateCommitmentChain: MockContract
before(async () => { before(async () => {
AddressManager = await makeAddressManager() AddressManager = await makeAddressManager()
await AddressManager.setAddress( await AddressManager.setAddress(
...@@ -105,8 +105,8 @@ describe('BatchSubmitter', () => { ...@@ -105,8 +105,8 @@ describe('BatchSubmitter', () => {
await getContractFactory('OVM_BondManager') await getContractFactory('OVM_BondManager')
) )
Mock__OVM_StateCommitmentChain = await smockit( Mock__StateCommitmentChain = await smockit(
await getContractFactory('OVM_StateCommitmentChain') await getContractFactory('StateCommitmentChain')
) )
await setProxyTarget( await setProxyTarget(
...@@ -123,74 +123,76 @@ describe('BatchSubmitter', () => { ...@@ -123,74 +123,76 @@ describe('BatchSubmitter', () => {
await setProxyTarget( await setProxyTarget(
AddressManager, AddressManager,
'OVM_StateCommitmentChain', 'StateCommitmentChain',
Mock__OVM_StateCommitmentChain Mock__StateCommitmentChain
) )
Mock__OVM_StateCommitmentChain.smocked.canOverwrite.will.return.with(false) Mock__StateCommitmentChain.smocked.canOverwrite.will.return.with(false)
Mock__OVM_ExecutionManager.smocked.getMaxTransactionGasLimit.will.return.with( Mock__OVM_ExecutionManager.smocked.getMaxTransactionGasLimit.will.return.with(
MAX_GAS_LIMIT MAX_GAS_LIMIT
) )
Mock__OVM_BondManager.smocked.isCollateralized.will.return.with(true) Mock__OVM_BondManager.smocked.isCollateralized.will.return.with(true)
}) })
let Factory__OVM_CanonicalTransactionChain: ContractFactory let Factory__CanonicalTransactionChain: ContractFactory
let Factory__OVM_StateCommitmentChain: ContractFactory let Factory__StateCommitmentChain: ContractFactory
before(async () => { before(async () => {
Factory__OVM_CanonicalTransactionChain = await getContractFactory( Factory__CanonicalTransactionChain = await getContractFactory(
'OVM_CanonicalTransactionChain' 'CanonicalTransactionChain'
) )
Factory__OVM_StateCommitmentChain = await getContractFactory( Factory__StateCommitmentChain = await getContractFactory(
'OVM_StateCommitmentChain' 'StateCommitmentChain'
) )
Factory__StateCommitmentChain = Factory__StateCommitmentChain.connect(signer)
}) })
let OVM_CanonicalTransactionChain: CanonicalTransactionChainContract let CanonicalTransactionChain: CanonicalTransactionChainContract
let OVM_StateCommitmentChain: Contract let StateCommitmentChain: Contract
let l2Provider: MockchainProvider let l2Provider: MockchainProvider
beforeEach(async () => { beforeEach(async () => {
const unwrapped_OVM_CanonicalTransactionChain = const unwrapped_CanonicalTransactionChain =
await Factory__OVM_CanonicalTransactionChain.deploy( await Factory__CanonicalTransactionChain.deploy(
AddressManager.address, AddressManager.address,
FORCE_INCLUSION_PERIOD_SECONDS FORCE_INCLUSION_PERIOD_SECONDS
) )
await unwrapped_OVM_CanonicalTransactionChain.init() await unwrapped_CanonicalTransactionChain.init()
await AddressManager.setAddress( await AddressManager.setAddress(
'OVM_CanonicalTransactionChain', 'CanonicalTransactionChain',
unwrapped_OVM_CanonicalTransactionChain.address unwrapped_CanonicalTransactionChain.address
) )
OVM_CanonicalTransactionChain = new CanonicalTransactionChainContract( CanonicalTransactionChain = new CanonicalTransactionChainContract(
unwrapped_OVM_CanonicalTransactionChain.address, unwrapped_CanonicalTransactionChain.address,
getContractInterface('OVM_CanonicalTransactionChain'), getContractInterface('CanonicalTransactionChain'),
sequencer sequencer
) )
const unwrapped_OVM_StateCommitmentChain = const unwrapped_StateCommitmentChain =
await Factory__OVM_StateCommitmentChain.deploy( await Factory__StateCommitmentChain.deploy(
AddressManager.address, AddressManager.address,
0, // fraudProofWindowSeconds 0, // fraudProofWindowSeconds
0 // sequencerPublishWindowSeconds 0 // sequencerPublishWindowSeconds
) )
await unwrapped_OVM_StateCommitmentChain.init() await unwrapped_StateCommitmentChain.init()
await AddressManager.setAddress( await AddressManager.setAddress(
'OVM_StateCommitmentChain', 'StateCommitmentChain',
unwrapped_OVM_StateCommitmentChain.address unwrapped_StateCommitmentChain.address
) )
OVM_StateCommitmentChain = new Contract( StateCommitmentChain = new Contract(
unwrapped_OVM_StateCommitmentChain.address, unwrapped_StateCommitmentChain.address,
getContractInterface('OVM_StateCommitmentChain'), getContractInterface('StateCommitmentChain'),
sequencer sequencer
) )
l2Provider = new MockchainProvider( l2Provider = new MockchainProvider(
OVM_CanonicalTransactionChain.address, CanonicalTransactionChain.address,
OVM_StateCommitmentChain.address StateCommitmentChain.address
) )
}) })
...@@ -239,7 +241,7 @@ describe('BatchSubmitter', () => { ...@@ -239,7 +241,7 @@ describe('BatchSubmitter', () => {
let batchSubmitter let batchSubmitter
beforeEach(async () => { beforeEach(async () => {
for (let i = 1; i < 15; i++) { for (let i = 1; i < 15; i++) {
await OVM_CanonicalTransactionChain.enqueue( await CanonicalTransactionChain.enqueue(
'0x' + '01'.repeat(20), '0x' + '01'.repeat(20),
50_000, 50_000,
'0x' + i.toString().repeat(64), '0x' + i.toString().repeat(64),
...@@ -254,7 +256,7 @@ describe('BatchSubmitter', () => { ...@@ -254,7 +256,7 @@ describe('BatchSubmitter', () => {
it('should submit a sequencer batch correctly', async () => { it('should submit a sequencer batch correctly', async () => {
l2Provider.setNumBlocksToReturn(5) l2Provider.setNumBlocksToReturn(5)
const nextQueueElement = await getQueueElement( const nextQueueElement = await getQueueElement(
OVM_CanonicalTransactionChain CanonicalTransactionChain
) )
l2Provider.setL2BlockData( l2Provider.setL2BlockData(
{ {
...@@ -302,7 +304,7 @@ describe('BatchSubmitter', () => { ...@@ -302,7 +304,7 @@ describe('BatchSubmitter', () => {
} as any) } as any)
// Turn blocks 3-5 into sequencer txs // Turn blocks 3-5 into sequencer txs
const nextQueueElement = await getQueueElement( const nextQueueElement = await getQueueElement(
OVM_CanonicalTransactionChain, CanonicalTransactionChain,
2 2
) )
l2Provider.setL2BlockData( l2Provider.setL2BlockData(
...@@ -393,7 +395,7 @@ describe('BatchSubmitter', () => { ...@@ -393,7 +395,7 @@ describe('BatchSubmitter', () => {
let stateBatchSubmitter let stateBatchSubmitter
beforeEach(async () => { beforeEach(async () => {
for (let i = 1; i < 15; i++) { for (let i = 1; i < 15; i++) {
await OVM_CanonicalTransactionChain.enqueue( await CanonicalTransactionChain.enqueue(
'0x' + '01'.repeat(20), '0x' + '01'.repeat(20),
50_000, 50_000,
'0x' + i.toString().repeat(64), '0x' + i.toString().repeat(64),
...@@ -407,7 +409,7 @@ describe('BatchSubmitter', () => { ...@@ -407,7 +409,7 @@ describe('BatchSubmitter', () => {
l2Provider.setNumBlocksToReturn(5) l2Provider.setNumBlocksToReturn(5)
const nextQueueElement = await getQueueElement( const nextQueueElement = await getQueueElement(
OVM_CanonicalTransactionChain CanonicalTransactionChain
) )
l2Provider.setL2BlockData( l2Provider.setL2BlockData(
{ {
......
...@@ -13,8 +13,8 @@ import { Lib_CrossDomainUtils } from "../../libraries/bridge/Lib_CrossDomainUtil ...@@ -13,8 +13,8 @@ import { Lib_CrossDomainUtils } from "../../libraries/bridge/Lib_CrossDomainUtil
/* Interface Imports */ /* Interface Imports */
import { IL1CrossDomainMessenger } from "./IL1CrossDomainMessenger.sol"; import { IL1CrossDomainMessenger } from "./IL1CrossDomainMessenger.sol";
import { iOVM_CanonicalTransactionChain } from "../rollup/iOVM_CanonicalTransactionChain.sol"; import { ICanonicalTransactionChain } from "../rollup/ICanonicalTransactionChain.sol";
import { iOVM_StateCommitmentChain } from "../rollup/iOVM_StateCommitmentChain.sol"; import { IStateCommitmentChain } from "../rollup/IStateCommitmentChain.sol";
/* External Imports */ /* External Imports */
import { OwnableUpgradeable } from import { OwnableUpgradeable } from
...@@ -187,10 +187,10 @@ contract L1CrossDomainMessenger is ...@@ -187,10 +187,10 @@ contract L1CrossDomainMessenger is
override override
public public
{ {
address ovmCanonicalTransactionChain = resolve("OVM_CanonicalTransactionChain"); address ovmCanonicalTransactionChain = resolve("CanonicalTransactionChain");
// Use the CTC queue length as nonce // Use the CTC queue length as nonce
uint40 nonce = uint40 nonce =
iOVM_CanonicalTransactionChain(ovmCanonicalTransactionChain).getQueueLength(); ICanonicalTransactionChain(ovmCanonicalTransactionChain).getQueueLength();
bytes memory xDomainCalldata = Lib_CrossDomainUtils.encodeXDomainCalldata( bytes memory xDomainCalldata = Lib_CrossDomainUtils.encodeXDomainCalldata(
_target, _target,
...@@ -253,7 +253,7 @@ contract L1CrossDomainMessenger is ...@@ -253,7 +253,7 @@ contract L1CrossDomainMessenger is
); );
require( require(
_target != resolve("OVM_CanonicalTransactionChain"), _target != resolve("CanonicalTransactionChain"),
"Cannot send L2->L1 messages to L1 system contracts." "Cannot send L2->L1 messages to L1 system contracts."
); );
...@@ -297,9 +297,9 @@ contract L1CrossDomainMessenger is ...@@ -297,9 +297,9 @@ contract L1CrossDomainMessenger is
public public
{ {
// Verify that the message is in the queue: // Verify that the message is in the queue:
address canonicalTransactionChain = resolve("OVM_CanonicalTransactionChain"); address canonicalTransactionChain = resolve("CanonicalTransactionChain");
Lib_OVMCodec.QueueElement memory element = Lib_OVMCodec.QueueElement memory element =
iOVM_CanonicalTransactionChain(canonicalTransactionChain).getQueueElement(_queueIndex); ICanonicalTransactionChain(canonicalTransactionChain).getQueueElement(_queueIndex);
// Compute the transactionHash // Compute the transactionHash
bytes32 transactionHash = keccak256( bytes32 transactionHash = keccak256(
...@@ -371,8 +371,8 @@ contract L1CrossDomainMessenger is ...@@ -371,8 +371,8 @@ contract L1CrossDomainMessenger is
bool bool
) )
{ {
iOVM_StateCommitmentChain ovmStateCommitmentChain = iOVM_StateCommitmentChain( IStateCommitmentChain ovmStateCommitmentChain = IStateCommitmentChain(
resolve("OVM_StateCommitmentChain") resolve("StateCommitmentChain")
); );
return ( return (
...@@ -441,7 +441,7 @@ contract L1CrossDomainMessenger is ...@@ -441,7 +441,7 @@ contract L1CrossDomainMessenger is
/** /**
* Sends a cross domain message. * Sends a cross domain message.
* @param _canonicalTransactionChain Address of the OVM_CanonicalTransactionChain instance. * @param _canonicalTransactionChain Address of the CanonicalTransactionChain instance.
* @param _message Message to send. * @param _message Message to send.
* @param _gasLimit OVM gas limit for the message. * @param _gasLimit OVM gas limit for the message.
*/ */
...@@ -452,7 +452,7 @@ contract L1CrossDomainMessenger is ...@@ -452,7 +452,7 @@ contract L1CrossDomainMessenger is
) )
internal internal
{ {
iOVM_CanonicalTransactionChain(_canonicalTransactionChain).enqueue( ICanonicalTransactionChain(_canonicalTransactionChain).enqueue(
Lib_PredeployAddresses.L2_CROSS_DOMAIN_MESSENGER, Lib_PredeployAddresses.L2_CROSS_DOMAIN_MESSENGER,
_gasLimit, _gasLimit,
_message _message
......
...@@ -9,14 +9,14 @@ import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolve ...@@ -9,14 +9,14 @@ import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolve
import { Lib_MerkleTree } from "../../libraries/utils/Lib_MerkleTree.sol"; import { Lib_MerkleTree } from "../../libraries/utils/Lib_MerkleTree.sol";
/* Interface Imports */ /* Interface Imports */
import { iOVM_CanonicalTransactionChain } from "./iOVM_CanonicalTransactionChain.sol"; import { ICanonicalTransactionChain } from "./ICanonicalTransactionChain.sol";
import { iOVM_ChainStorageContainer } from "./iOVM_ChainStorageContainer.sol"; import { IChainStorageContainer } from "./IChainStorageContainer.sol";
/* External Imports */ /* External Imports */
import { Math } from "@openzeppelin/contracts/math/Math.sol"; import { Math } from "@openzeppelin/contracts/math/Math.sol";
/** /**
* @title OVM_CanonicalTransactionChain * @title CanonicalTransactionChain
* @dev The Canonical Transaction Chain (CTC) contract is an append-only log of transactions * @dev The Canonical Transaction Chain (CTC) contract is an append-only log of transactions
* which must be applied to the rollup state. It defines the ordering of rollup transactions by * which must be applied to the rollup state. It defines the ordering of rollup transactions by
* writing them to the 'CTC:batches' instance of the Chain Storage Container. * writing them to the 'CTC:batches' instance of the Chain Storage Container.
...@@ -27,7 +27,7 @@ import { Math } from "@openzeppelin/contracts/math/Math.sol"; ...@@ -27,7 +27,7 @@ import { Math } from "@openzeppelin/contracts/math/Math.sol";
* *
* Runtime target: EVM * Runtime target: EVM
*/ */
contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_AddressResolver { contract CanonicalTransactionChain is ICanonicalTransactionChain, Lib_AddressResolver {
/************* /*************
* Constants * * Constants *
...@@ -88,11 +88,11 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -88,11 +88,11 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
public public
view view
returns ( returns (
iOVM_ChainStorageContainer IChainStorageContainer
) )
{ {
return iOVM_ChainStorageContainer( return IChainStorageContainer(
resolve("OVM_ChainStorageContainer-CTC-batches") resolve("ChainStorageContainer-CTC-batches")
); );
} }
...@@ -105,11 +105,11 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -105,11 +105,11 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
public public
view view
returns ( returns (
iOVM_ChainStorageContainer IChainStorageContainer
) )
{ {
return iOVM_ChainStorageContainer( return IChainStorageContainer(
resolve("OVM_ChainStorageContainer-CTC-queue") resolve("ChainStorageContainer-CTC-queue")
); );
} }
...@@ -314,7 +314,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -314,7 +314,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
timestampAndBlockNumber := or(timestampAndBlockNumber, shl(40, number())) timestampAndBlockNumber := or(timestampAndBlockNumber, shl(40, number()))
} }
iOVM_ChainStorageContainer queueRef = queue(); IChainStorageContainer queueRef = queue();
queueRef.push(transactionHash); queueRef.push(transactionHash);
queueRef.push(timestampAndBlockNumber); queueRef.push(timestampAndBlockNumber);
...@@ -430,7 +430,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -430,7 +430,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
// Take a reference to the queue and its length so we don't have to keep resolving it. // Take a reference to the queue and its length so we don't have to keep resolving it.
// Length isn't going to change during the course of execution, so it's fine to simply // Length isn't going to change during the course of execution, so it's fine to simply
// resolve this once at the start. Saves gas. // resolve this once at the start. Saves gas.
iOVM_ChainStorageContainer queueRef = queue(); IChainStorageContainer queueRef = queue();
uint40 queueLength = _getQueueLength(queueRef); uint40 queueLength = _getQueueLength(queueRef);
// Reserve some memory to save gas on hashing later on. This is a relatively safe estimate // Reserve some memory to save gas on hashing later on. This is a relatively safe estimate
...@@ -718,7 +718,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -718,7 +718,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
*/ */
function _getQueueElement( function _getQueueElement(
uint256 _index, uint256 _index,
iOVM_ChainStorageContainer _queueRef IChainStorageContainer _queueRef
) )
internal internal
view view
...@@ -754,7 +754,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -754,7 +754,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
* @return Length of the queue. * @return Length of the queue.
*/ */
function _getQueueLength( function _getQueueLength(
iOVM_ChainStorageContainer _queueRef IChainStorageContainer _queueRef
) )
internal internal
view view
...@@ -875,7 +875,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad ...@@ -875,7 +875,7 @@ contract OVM_CanonicalTransactionChain is iOVM_CanonicalTransactionChain, Lib_Ad
) )
internal internal
{ {
iOVM_ChainStorageContainer batchesRef = batches(); IChainStorageContainer batchesRef = batches();
(uint40 totalElements, uint40 nextQueueIndex,,) = _getBatchExtraData(); (uint40 totalElements, uint40 nextQueueIndex,,) = _getBatchExtraData();
Lib_OVMCodec.ChainBatchHeader memory header = Lib_OVMCodec.ChainBatchHeader({ Lib_OVMCodec.ChainBatchHeader memory header = Lib_OVMCodec.ChainBatchHeader({
......
...@@ -6,10 +6,10 @@ import { Lib_Buffer } from "../../libraries/utils/Lib_Buffer.sol"; ...@@ -6,10 +6,10 @@ import { Lib_Buffer } from "../../libraries/utils/Lib_Buffer.sol";
import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol"; import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolver.sol";
/* Interface Imports */ /* Interface Imports */
import { iOVM_ChainStorageContainer } from "./iOVM_ChainStorageContainer.sol"; import { IChainStorageContainer } from "./IChainStorageContainer.sol";
/** /**
* @title OVM_ChainStorageContainer * @title ChainStorageContainer
* @dev The Chain Storage Container provides its owner contract with read, write and delete * @dev The Chain Storage Container provides its owner contract with read, write and delete
* functionality. This provides gas efficiency gains by enabling it to overwrite storage slots which * functionality. This provides gas efficiency gains by enabling it to overwrite storage slots which
* can no longer be used in a fraud proof due to the fraud window having passed, and the associated * can no longer be used in a fraud proof due to the fraud window having passed, and the associated
...@@ -21,7 +21,7 @@ import { iOVM_ChainStorageContainer } from "./iOVM_ChainStorageContainer.sol"; ...@@ -21,7 +21,7 @@ import { iOVM_ChainStorageContainer } from "./iOVM_ChainStorageContainer.sol";
* *
* Runtime target: EVM * Runtime target: EVM
*/ */
contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressResolver { contract ChainStorageContainer is IChainStorageContainer, Lib_AddressResolver {
/************* /*************
* Libraries * * Libraries *
...@@ -63,7 +63,7 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes ...@@ -63,7 +63,7 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes
modifier onlyOwner() { modifier onlyOwner() {
require( require(
msg.sender == resolve(owner), msg.sender == resolve(owner),
"OVM_ChainStorageContainer: Function can only be called by the owner." "ChainStorageContainer: Function can only be called by the owner."
); );
_; _;
} }
...@@ -74,7 +74,7 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes ...@@ -74,7 +74,7 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes
********************/ ********************/
/** /**
* @inheritdoc iOVM_ChainStorageContainer * @inheritdoc IChainStorageContainer
*/ */
function setGlobalMetadata( function setGlobalMetadata(
bytes27 _globalMetadata bytes27 _globalMetadata
...@@ -87,7 +87,7 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes ...@@ -87,7 +87,7 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes
} }
/** /**
* @inheritdoc iOVM_ChainStorageContainer * @inheritdoc IChainStorageContainer
*/ */
function getGlobalMetadata() function getGlobalMetadata()
override override
...@@ -101,7 +101,7 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes ...@@ -101,7 +101,7 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes
} }
/** /**
* @inheritdoc iOVM_ChainStorageContainer * @inheritdoc IChainStorageContainer
*/ */
function length() function length()
override override
...@@ -115,7 +115,7 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes ...@@ -115,7 +115,7 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes
} }
/** /**
* @inheritdoc iOVM_ChainStorageContainer * @inheritdoc IChainStorageContainer
*/ */
function push( function push(
bytes32 _object bytes32 _object
...@@ -128,7 +128,7 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes ...@@ -128,7 +128,7 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes
} }
/** /**
* @inheritdoc iOVM_ChainStorageContainer * @inheritdoc IChainStorageContainer
*/ */
function push( function push(
bytes32 _object, bytes32 _object,
...@@ -142,7 +142,7 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes ...@@ -142,7 +142,7 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes
} }
/** /**
* @inheritdoc iOVM_ChainStorageContainer * @inheritdoc IChainStorageContainer
*/ */
function get( function get(
uint256 _index uint256 _index
...@@ -158,7 +158,7 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes ...@@ -158,7 +158,7 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes
} }
/** /**
* @inheritdoc iOVM_ChainStorageContainer * @inheritdoc IChainStorageContainer
*/ */
function deleteElementsAfterInclusive( function deleteElementsAfterInclusive(
uint256 _index uint256 _index
...@@ -173,7 +173,7 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes ...@@ -173,7 +173,7 @@ contract OVM_ChainStorageContainer is iOVM_ChainStorageContainer, Lib_AddressRes
} }
/** /**
* @inheritdoc iOVM_ChainStorageContainer * @inheritdoc IChainStorageContainer
*/ */
function deleteElementsAfterInclusive( function deleteElementsAfterInclusive(
uint256 _index, uint256 _index,
......
...@@ -6,12 +6,12 @@ pragma experimental ABIEncoderV2; ...@@ -6,12 +6,12 @@ pragma experimental ABIEncoderV2;
import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol";
/* Interface Imports */ /* Interface Imports */
import { iOVM_ChainStorageContainer } from "./iOVM_ChainStorageContainer.sol"; import { IChainStorageContainer } from "./IChainStorageContainer.sol";
/** /**
* @title iOVM_CanonicalTransactionChain * @title ICanonicalTransactionChain
*/ */
interface iOVM_CanonicalTransactionChain { interface ICanonicalTransactionChain {
/********** /**********
* Events * * Events *
...@@ -72,7 +72,7 @@ interface iOVM_CanonicalTransactionChain { ...@@ -72,7 +72,7 @@ interface iOVM_CanonicalTransactionChain {
external external
view view
returns ( returns (
iOVM_ChainStorageContainer IChainStorageContainer
); );
/** /**
...@@ -83,7 +83,7 @@ interface iOVM_CanonicalTransactionChain { ...@@ -83,7 +83,7 @@ interface iOVM_CanonicalTransactionChain {
external external
view view
returns ( returns (
iOVM_ChainStorageContainer IChainStorageContainer
); );
/** /**
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
pragma solidity >0.5.0 <0.8.0; pragma solidity >0.5.0 <0.8.0;
/** /**
* @title iOVM_ChainStorageContainer * @title IChainStorageContainer
*/ */
interface iOVM_ChainStorageContainer { interface IChainStorageContainer {
/******************** /********************
* Public Functions * * Public Functions *
......
...@@ -6,9 +6,9 @@ pragma experimental ABIEncoderV2; ...@@ -6,9 +6,9 @@ pragma experimental ABIEncoderV2;
import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol"; import { Lib_OVMCodec } from "../../libraries/codec/Lib_OVMCodec.sol";
/** /**
* @title iOVM_StateCommitmentChain * @title IStateCommitmentChain
*/ */
interface iOVM_StateCommitmentChain { interface IStateCommitmentChain {
/********** /**********
* Events * * Events *
......
...@@ -8,16 +8,16 @@ import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolve ...@@ -8,16 +8,16 @@ import { Lib_AddressResolver } from "../../libraries/resolver/Lib_AddressResolve
import { Lib_MerkleTree } from "../../libraries/utils/Lib_MerkleTree.sol"; import { Lib_MerkleTree } from "../../libraries/utils/Lib_MerkleTree.sol";
/* Interface Imports */ /* Interface Imports */
import { iOVM_StateCommitmentChain } from "./iOVM_StateCommitmentChain.sol"; import { IStateCommitmentChain } from "./IStateCommitmentChain.sol";
import { iOVM_CanonicalTransactionChain } from "./iOVM_CanonicalTransactionChain.sol"; import { ICanonicalTransactionChain } from "./ICanonicalTransactionChain.sol";
import { iOVM_BondManager } from "../verification/iOVM_BondManager.sol"; import { iOVM_BondManager } from "../verification/iOVM_BondManager.sol";
import { iOVM_ChainStorageContainer } from "./iOVM_ChainStorageContainer.sol"; import { IChainStorageContainer } from "./IChainStorageContainer.sol";
/* External Imports */ /* External Imports */
import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/math/SafeMath.sol";
/** /**
* @title OVM_StateCommitmentChain * @title StateCommitmentChain
* @dev The State Commitment Chain (SCC) contract contains a list of proposed state roots which * @dev The State Commitment Chain (SCC) contract contains a list of proposed state roots which
* Proposers assert to be a result of each transaction in the Canonical Transaction Chain (CTC). * Proposers assert to be a result of each transaction in the Canonical Transaction Chain (CTC).
* Elements here have a 1:1 correspondence with transactions in the CTC, and should be the unique * Elements here have a 1:1 correspondence with transactions in the CTC, and should be the unique
...@@ -25,7 +25,7 @@ import "@openzeppelin/contracts/math/SafeMath.sol"; ...@@ -25,7 +25,7 @@ import "@openzeppelin/contracts/math/SafeMath.sol";
* *
* Runtime target: EVM * Runtime target: EVM
*/ */
contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, Lib_AddressResolver { contract StateCommitmentChain is IStateCommitmentChain, Lib_AddressResolver {
/************* /*************
* Constants * * Constants *
...@@ -66,16 +66,16 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, Lib_AddressResol ...@@ -66,16 +66,16 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, Lib_AddressResol
public public
view view
returns ( returns (
iOVM_ChainStorageContainer IChainStorageContainer
) )
{ {
return iOVM_ChainStorageContainer( return IChainStorageContainer(
resolve("OVM_ChainStorageContainer-SCC-batches") resolve("ChainStorageContainer-SCC-batches")
); );
} }
/** /**
* @inheritdoc iOVM_StateCommitmentChain * @inheritdoc IStateCommitmentChain
*/ */
function getTotalElements() function getTotalElements()
override override
...@@ -90,7 +90,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, Lib_AddressResol ...@@ -90,7 +90,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, Lib_AddressResol
} }
/** /**
* @inheritdoc iOVM_StateCommitmentChain * @inheritdoc IStateCommitmentChain
*/ */
function getTotalBatches() function getTotalBatches()
override override
...@@ -104,7 +104,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, Lib_AddressResol ...@@ -104,7 +104,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, Lib_AddressResol
} }
/** /**
* @inheritdoc iOVM_StateCommitmentChain * @inheritdoc IStateCommitmentChain
*/ */
function getLastSequencerTimestamp() function getLastSequencerTimestamp()
override override
...@@ -119,7 +119,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, Lib_AddressResol ...@@ -119,7 +119,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, Lib_AddressResol
} }
/** /**
* @inheritdoc iOVM_StateCommitmentChain * @inheritdoc IStateCommitmentChain
*/ */
function appendStateBatch( function appendStateBatch(
bytes32[] memory _batch, bytes32[] memory _batch,
...@@ -148,7 +148,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, Lib_AddressResol ...@@ -148,7 +148,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, Lib_AddressResol
require( require(
getTotalElements() + _batch.length <= getTotalElements() + _batch.length <=
iOVM_CanonicalTransactionChain(resolve("OVM_CanonicalTransactionChain")) ICanonicalTransactionChain(resolve("CanonicalTransactionChain"))
.getTotalElements(), .getTotalElements(),
"Number of state roots cannot exceed the number of canonical transactions." "Number of state roots cannot exceed the number of canonical transactions."
); );
...@@ -162,7 +162,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, Lib_AddressResol ...@@ -162,7 +162,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, Lib_AddressResol
} }
/** /**
* @inheritdoc iOVM_StateCommitmentChain * @inheritdoc IStateCommitmentChain
*/ */
function deleteStateBatch( function deleteStateBatch(
Lib_OVMCodec.ChainBatchHeader memory _batchHeader Lib_OVMCodec.ChainBatchHeader memory _batchHeader
...@@ -189,7 +189,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, Lib_AddressResol ...@@ -189,7 +189,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, Lib_AddressResol
} }
/** /**
* @inheritdoc iOVM_StateCommitmentChain * @inheritdoc IStateCommitmentChain
*/ */
function verifyStateCommitment( function verifyStateCommitment(
bytes32 _element, bytes32 _element,
...@@ -223,7 +223,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, Lib_AddressResol ...@@ -223,7 +223,7 @@ contract OVM_StateCommitmentChain is iOVM_StateCommitmentChain, Lib_AddressResol
} }
/** /**
* @inheritdoc iOVM_StateCommitmentChain * @inheritdoc IStateCommitmentChain
*/ */
function insideFraudProofWindow( function insideFraudProofWindow(
Lib_OVMCodec.ChainBatchHeader memory _batchHeader Lib_OVMCodec.ChainBatchHeader memory _batchHeader
......
...@@ -15,13 +15,13 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -15,13 +15,13 @@ const deployFn: DeployFunction = async (hre) => {
await deployAndRegister({ await deployAndRegister({
hre, hre,
name: 'OVM_ChainStorageContainer-CTC-batches', name: 'ChainStorageContainer-CTC-batches',
contract: 'OVM_ChainStorageContainer', contract: 'ChainStorageContainer',
args: [Lib_AddressManager.address, 'OVM_CanonicalTransactionChain'], args: [Lib_AddressManager.address, 'CanonicalTransactionChain'],
}) })
} }
deployFn.dependencies = ['Lib_AddressManager'] deployFn.dependencies = ['Lib_AddressManager']
deployFn.tags = ['OVM_ChainStorageContainer_ctc_batches'] deployFn.tags = ['ChainStorageContainer_ctc_batches']
export default deployFn export default deployFn
...@@ -15,13 +15,13 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -15,13 +15,13 @@ const deployFn: DeployFunction = async (hre) => {
await deployAndRegister({ await deployAndRegister({
hre, hre,
name: 'OVM_ChainStorageContainer-CTC-queue', name: 'ChainStorageContainer-CTC-queue',
contract: 'OVM_ChainStorageContainer', contract: 'ChainStorageContainer',
args: [Lib_AddressManager.address, 'OVM_CanonicalTransactionChain'], args: [Lib_AddressManager.address, 'CanonicalTransactionChain'],
}) })
} }
deployFn.dependencies = ['Lib_AddressManager'] deployFn.dependencies = ['Lib_AddressManager']
deployFn.tags = ['OVM_ChainStorageContainer_ctc_queue'] deployFn.tags = ['ChainStorageContainer_ctc_queue']
export default deployFn export default deployFn
...@@ -15,13 +15,13 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -15,13 +15,13 @@ const deployFn: DeployFunction = async (hre) => {
await deployAndRegister({ await deployAndRegister({
hre, hre,
name: 'OVM_ChainStorageContainer-SCC-batches', name: 'ChainStorageContainer-SCC-batches',
contract: 'OVM_ChainStorageContainer', contract: 'ChainStorageContainer',
args: [Lib_AddressManager.address, 'OVM_StateCommitmentChain'], args: [Lib_AddressManager.address, 'StateCommitmentChain'],
}) })
} }
deployFn.dependencies = ['Lib_AddressManager'] deployFn.dependencies = ['Lib_AddressManager']
deployFn.tags = ['OVM_ChainStorageContainer_scc_batches'] deployFn.tags = ['ChainStorageContainer_scc_batches']
export default deployFn export default deployFn
...@@ -15,7 +15,7 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -15,7 +15,7 @@ const deployFn: DeployFunction = async (hre) => {
await deployAndRegister({ await deployAndRegister({
hre, hre,
name: 'OVM_CanonicalTransactionChain', name: 'CanonicalTransactionChain',
args: [ args: [
Lib_AddressManager.address, Lib_AddressManager.address,
(hre as any).deployConfig.ctcForceInclusionPeriodSeconds, (hre as any).deployConfig.ctcForceInclusionPeriodSeconds,
...@@ -26,6 +26,6 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -26,6 +26,6 @@ const deployFn: DeployFunction = async (hre) => {
} }
deployFn.dependencies = ['Lib_AddressManager'] deployFn.dependencies = ['Lib_AddressManager']
deployFn.tags = ['OVM_CanonicalTransactionChain'] deployFn.tags = ['CanonicalTransactionChain']
export default deployFn export default deployFn
...@@ -15,7 +15,7 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -15,7 +15,7 @@ const deployFn: DeployFunction = async (hre) => {
await deployAndRegister({ await deployAndRegister({
hre, hre,
name: 'OVM_StateCommitmentChain', name: 'StateCommitmentChain',
args: [ args: [
Lib_AddressManager.address, Lib_AddressManager.address,
(hre as any).deployConfig.sccFraudProofWindow, (hre as any).deployConfig.sccFraudProofWindow,
...@@ -25,6 +25,6 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -25,6 +25,6 @@ const deployFn: DeployFunction = async (hre) => {
} }
deployFn.dependencies = ['Lib_AddressManager'] deployFn.dependencies = ['Lib_AddressManager']
deployFn.tags = ['OVM_StateCommitmentChain'] deployFn.tags = ['StateCommitmentChain']
export default deployFn export default deployFn
...@@ -63,9 +63,9 @@ export const connectL1Contracts = async ( ...@@ -63,9 +63,9 @@ export const connectL1Contracts = async (
return { return {
addressManager: getEthersContract('Lib_AddressManager'), addressManager: getEthersContract('Lib_AddressManager'),
canonicalTransactionChain: getEthersContract( canonicalTransactionChain: getEthersContract(
'OVM_CanonicalTransactionChain' 'CanonicalTransactionChain'
), ),
stateCommitmentChain: getEthersContract('OVM_StateCommitmentChain'), stateCommitmentChain: getEthersContract('StateCommitmentChain'),
xDomainMessengerProxy: getEthersContract( xDomainMessengerProxy: getEthersContract(
'Proxy__OVM_L1CrossDomainMessenger' 'Proxy__OVM_L1CrossDomainMessenger'
), ),
......
...@@ -9,23 +9,23 @@ import { Network } from './connect-contracts' ...@@ -9,23 +9,23 @@ import { Network } from './connect-contracts'
*/ */
const Mainnet__Lib_AddressManager = require('../deployments/mainnet/Lib_AddressManager.json') const Mainnet__Lib_AddressManager = require('../deployments/mainnet/Lib_AddressManager.json')
const Mainnet__OVM_CanonicalTransactionChain = require('../deployments/mainnet/OVM_CanonicalTransactionChain.json') const Mainnet__CanonicalTransactionChain = require('../deployments/mainnet/CanonicalTransactionChain.json')
const Mainnet__OVM_L1CrossDomainMessenger = require('../deployments/mainnet/L1CrossDomainMessenger.json') const Mainnet__OVM_L1CrossDomainMessenger = require('../deployments/mainnet/L1CrossDomainMessenger.json')
const Mainnet__OVM_StateCommitmentChain = require('../deployments/mainnet/OVM_StateCommitmentChain.json') const Mainnet__StateCommitmentChain = require('../deployments/mainnet/StateCommitmentChain.json')
const Mainnet__Proxy__OVM_L1CrossDomainMessenger = require('../deployments/mainnet/Proxy__OVM_L1CrossDomainMessenger.json') const Mainnet__Proxy__OVM_L1CrossDomainMessenger = require('../deployments/mainnet/Proxy__OVM_L1CrossDomainMessenger.json')
const Mainnet__OVM_BondManager = require('../deployments/mainnet/mockOVM_BondManager.json') const Mainnet__OVM_BondManager = require('../deployments/mainnet/mockOVM_BondManager.json')
const Kovan__Lib_AddressManager = require('../deployments/kovan/Lib_AddressManager.json') const Kovan__Lib_AddressManager = require('../deployments/kovan/Lib_AddressManager.json')
const Kovan__OVM_CanonicalTransactionChain = require('../deployments/kovan/OVM_CanonicalTransactionChain.json') const Kovan__CanonicalTransactionChain = require('../deployments/kovan/CanonicalTransactionChain.json')
const Kovan__OVM_L1CrossDomainMessenger = require('../deployments/kovan/L1CrossDomainMessenger.json') const Kovan__OVM_L1CrossDomainMessenger = require('../deployments/kovan/L1CrossDomainMessenger.json')
const Kovan__OVM_StateCommitmentChain = require('../deployments/kovan/OVM_StateCommitmentChain.json') const Kovan__StateCommitmentChain = require('../deployments/kovan/StateCommitmentChain.json')
const Kovan__Proxy__OVM_L1CrossDomainMessenger = require('../deployments/kovan/Proxy__OVM_L1CrossDomainMessenger.json') const Kovan__Proxy__OVM_L1CrossDomainMessenger = require('../deployments/kovan/Proxy__OVM_L1CrossDomainMessenger.json')
const Kovan__OVM_BondManager = require('../deployments/kovan/mockOVM_BondManager.json') const Kovan__OVM_BondManager = require('../deployments/kovan/mockOVM_BondManager.json')
const Goerli__Lib_AddressManager = require('../deployments/goerli/Lib_AddressManager.json') const Goerli__Lib_AddressManager = require('../deployments/goerli/Lib_AddressManager.json')
const Goerli__OVM_CanonicalTransactionChain = require('../deployments/goerli/OVM_CanonicalTransactionChain.json') const Goerli__CanonicalTransactionChain = require('../deployments/goerli/CanonicalTransactionChain.json')
const Goerli__OVM_L1CrossDomainMessenger = require('../deployments/goerli/L1CrossDomainMessenger.json') const Goerli__OVM_L1CrossDomainMessenger = require('../deployments/goerli/L1CrossDomainMessenger.json')
const Goerli__OVM_StateCommitmentChain = require('../deployments/goerli/OVM_StateCommitmentChain.json') const Goerli__StateCommitmentChain = require('../deployments/goerli/StateCommitmentChain.json')
const Goerli__Proxy__OVM_L1CrossDomainMessenger = require('../deployments/goerli/Proxy__OVM_L1CrossDomainMessenger.json') const Goerli__Proxy__OVM_L1CrossDomainMessenger = require('../deployments/goerli/Proxy__OVM_L1CrossDomainMessenger.json')
const Goerli__OVM_BondManager = require('../deployments/goerli/mockOVM_BondManager.json') const Goerli__OVM_BondManager = require('../deployments/goerli/mockOVM_BondManager.json')
...@@ -36,20 +36,20 @@ export const getL1ContractData = (network: Network) => { ...@@ -36,20 +36,20 @@ export const getL1ContractData = (network: Network) => {
kovan: Kovan__Lib_AddressManager, kovan: Kovan__Lib_AddressManager,
goerli: Goerli__Lib_AddressManager, goerli: Goerli__Lib_AddressManager,
}[network], }[network],
OVM_CanonicalTransactionChain: { CanonicalTransactionChain: {
mainnet: Mainnet__OVM_CanonicalTransactionChain, mainnet: Mainnet__CanonicalTransactionChain,
kovan: Kovan__OVM_CanonicalTransactionChain, kovan: Kovan__CanonicalTransactionChain,
goerli: Goerli__OVM_CanonicalTransactionChain, goerli: Goerli__CanonicalTransactionChain,
}[network], }[network],
L1CrossDomainMessenger: { L1CrossDomainMessenger: {
mainnet: Mainnet__OVM_L1CrossDomainMessenger, mainnet: Mainnet__OVM_L1CrossDomainMessenger,
kovan: Kovan__OVM_L1CrossDomainMessenger, kovan: Kovan__OVM_L1CrossDomainMessenger,
goerli: Goerli__OVM_L1CrossDomainMessenger, goerli: Goerli__OVM_L1CrossDomainMessenger,
}[network], }[network],
OVM_StateCommitmentChain: { StateCommitmentChain: {
mainnet: Mainnet__OVM_StateCommitmentChain, mainnet: Mainnet__StateCommitmentChain,
kovan: Kovan__OVM_StateCommitmentChain, kovan: Kovan__StateCommitmentChain,
goerli: Goerli__OVM_StateCommitmentChain, goerli: Goerli__StateCommitmentChain,
}[network], }[network],
Proxy__OVM_L1CrossDomainMessenger: { Proxy__OVM_L1CrossDomainMessenger: {
mainnet: Mainnet__Proxy__OVM_L1CrossDomainMessenger, mainnet: Mainnet__Proxy__OVM_L1CrossDomainMessenger,
......
...@@ -53,13 +53,13 @@ describe('L1CrossDomainMessenger', () => { ...@@ -53,13 +53,13 @@ describe('L1CrossDomainMessenger', () => {
let Mock__TargetContract: MockContract let Mock__TargetContract: MockContract
let Mock__L2CrossDomainMessenger: MockContract let Mock__L2CrossDomainMessenger: MockContract
let Mock__OVM_StateCommitmentChain: MockContract let Mock__StateCommitmentChain: MockContract
let Factory__OVM_CanonicalTransactionChain: ContractFactory let Factory__CanonicalTransactionChain: ContractFactory
let Factory__OVM_ChainStorageContainer: ContractFactory let Factory__ChainStorageContainer: ContractFactory
let Factory__OVM_L1CrossDomainMessenger: ContractFactory let Factory__OVM_L1CrossDomainMessenger: ContractFactory
let OVM_CanonicalTransactionChain: Contract let CanonicalTransactionChain: Contract
before(async () => { before(async () => {
Mock__TargetContract = await smockit( Mock__TargetContract = await smockit(
await ethers.getContractFactory('Helper_SimpleProxy') await ethers.getContractFactory('Helper_SimpleProxy')
...@@ -70,8 +70,8 @@ describe('L1CrossDomainMessenger', () => { ...@@ -70,8 +70,8 @@ describe('L1CrossDomainMessenger', () => {
address: predeploys.L2CrossDomainMessenger, address: predeploys.L2CrossDomainMessenger,
} }
) )
Mock__OVM_StateCommitmentChain = await smockit( Mock__StateCommitmentChain = await smockit(
await ethers.getContractFactory('OVM_StateCommitmentChain') await ethers.getContractFactory('StateCommitmentChain')
) )
await AddressManager.setAddress( await AddressManager.setAddress(
...@@ -81,51 +81,51 @@ describe('L1CrossDomainMessenger', () => { ...@@ -81,51 +81,51 @@ describe('L1CrossDomainMessenger', () => {
await setProxyTarget( await setProxyTarget(
AddressManager, AddressManager,
'OVM_StateCommitmentChain', 'StateCommitmentChain',
Mock__OVM_StateCommitmentChain Mock__StateCommitmentChain
) )
Factory__OVM_CanonicalTransactionChain = await ethers.getContractFactory( Factory__CanonicalTransactionChain = await ethers.getContractFactory(
'OVM_CanonicalTransactionChain' 'CanonicalTransactionChain'
) )
Factory__OVM_ChainStorageContainer = await ethers.getContractFactory( Factory__ChainStorageContainer = await ethers.getContractFactory(
'OVM_ChainStorageContainer' 'ChainStorageContainer'
) )
Factory__OVM_L1CrossDomainMessenger = await ethers.getContractFactory( Factory__OVM_L1CrossDomainMessenger = await ethers.getContractFactory(
'L1CrossDomainMessenger' 'L1CrossDomainMessenger'
) )
OVM_CanonicalTransactionChain = CanonicalTransactionChain =
await Factory__OVM_CanonicalTransactionChain.deploy( await Factory__CanonicalTransactionChain.deploy(
AddressManager.address, AddressManager.address,
FORCE_INCLUSION_PERIOD_SECONDS, FORCE_INCLUSION_PERIOD_SECONDS,
FORCE_INCLUSION_PERIOD_BLOCKS, FORCE_INCLUSION_PERIOD_BLOCKS,
MAX_GAS_LIMIT MAX_GAS_LIMIT
) )
const batches = await Factory__OVM_ChainStorageContainer.deploy( const batches = await Factory__ChainStorageContainer.deploy(
AddressManager.address, AddressManager.address,
'OVM_CanonicalTransactionChain' 'CanonicalTransactionChain'
) )
const queue = await Factory__OVM_ChainStorageContainer.deploy( const queue = await Factory__ChainStorageContainer.deploy(
AddressManager.address, AddressManager.address,
'OVM_CanonicalTransactionChain' 'CanonicalTransactionChain'
) )
await AddressManager.setAddress( await AddressManager.setAddress(
'OVM_ChainStorageContainer-CTC-batches', 'ChainStorageContainer-CTC-batches',
batches.address batches.address
) )
await AddressManager.setAddress( await AddressManager.setAddress(
'OVM_ChainStorageContainer-CTC-queue', 'ChainStorageContainer-CTC-queue',
queue.address queue.address
) )
await AddressManager.setAddress( await AddressManager.setAddress(
'OVM_CanonicalTransactionChain', 'CanonicalTransactionChain',
OVM_CanonicalTransactionChain.address CanonicalTransactionChain.address
) )
}) })
...@@ -202,8 +202,8 @@ describe('L1CrossDomainMessenger', () => { ...@@ -202,8 +202,8 @@ describe('L1CrossDomainMessenger', () => {
calldata calldata
) )
const queueLength = await OVM_CanonicalTransactionChain.getQueueLength() const queueLength = await CanonicalTransactionChain.getQueueLength()
const queueElement = await OVM_CanonicalTransactionChain.getQueueElement( const queueElement = await CanonicalTransactionChain.getQueueElement(
queueLength - 1 queueLength - 1
) )
expect(queueElement[0]).to.equal(transactionHash) expect(queueElement[0]).to.equal(transactionHash)
...@@ -226,7 +226,7 @@ describe('L1CrossDomainMessenger', () => { ...@@ -226,7 +226,7 @@ describe('L1CrossDomainMessenger', () => {
it('should revert if given the wrong queue index', async () => { it('should revert if given the wrong queue index', async () => {
await L1CrossDomainMessenger.sendMessage(target, message, 100_001) await L1CrossDomainMessenger.sendMessage(target, message, 100_001)
const queueLength = await OVM_CanonicalTransactionChain.getQueueLength() const queueLength = await CanonicalTransactionChain.getQueueLength()
await expect( await expect(
L1CrossDomainMessenger.replayMessage( L1CrossDomainMessenger.replayMessage(
target, target,
...@@ -240,7 +240,7 @@ describe('L1CrossDomainMessenger', () => { ...@@ -240,7 +240,7 @@ describe('L1CrossDomainMessenger', () => {
it('should succeed if the message exists', async () => { it('should succeed if the message exists', async () => {
await L1CrossDomainMessenger.sendMessage(target, message, gasLimit) await L1CrossDomainMessenger.sendMessage(target, message, gasLimit)
const queueLength = await OVM_CanonicalTransactionChain.getQueueLength() const queueLength = await CanonicalTransactionChain.getQueueLength()
const calldata = encodeXDomainCalldata( const calldata = encodeXDomainCalldata(
target, target,
...@@ -344,16 +344,16 @@ describe('L1CrossDomainMessenger', () => { ...@@ -344,16 +344,16 @@ describe('L1CrossDomainMessenger', () => {
}) })
beforeEach(async () => { beforeEach(async () => {
Mock__OVM_StateCommitmentChain.smocked.verifyStateCommitment.will.return.with( Mock__StateCommitmentChain.smocked.verifyStateCommitment.will.return.with(
true true
) )
Mock__OVM_StateCommitmentChain.smocked.insideFraudProofWindow.will.return.with( Mock__StateCommitmentChain.smocked.insideFraudProofWindow.will.return.with(
false false
) )
}) })
it('should revert if still inside the fraud proof window', async () => { it('should revert if still inside the fraud proof window', async () => {
Mock__OVM_StateCommitmentChain.smocked.insideFraudProofWindow.will.return.with( Mock__StateCommitmentChain.smocked.insideFraudProofWindow.will.return.with(
true true
) )
...@@ -378,14 +378,14 @@ describe('L1CrossDomainMessenger', () => { ...@@ -378,14 +378,14 @@ describe('L1CrossDomainMessenger', () => {
it('should revert if attempting to relay a message sent to an L1 system contract', async () => { it('should revert if attempting to relay a message sent to an L1 system contract', async () => {
const maliciousProof = await generateMockRelayMessageProof( const maliciousProof = await generateMockRelayMessageProof(
OVM_CanonicalTransactionChain.address, CanonicalTransactionChain.address,
sender, sender,
message message
) )
await expect( await expect(
L1CrossDomainMessenger.relayMessage( L1CrossDomainMessenger.relayMessage(
OVM_CanonicalTransactionChain.address, CanonicalTransactionChain.address,
sender, sender,
message, message,
0, 0,
...@@ -397,7 +397,7 @@ describe('L1CrossDomainMessenger', () => { ...@@ -397,7 +397,7 @@ describe('L1CrossDomainMessenger', () => {
}) })
it('should revert if provided an invalid state root proof', async () => { it('should revert if provided an invalid state root proof', async () => {
Mock__OVM_StateCommitmentChain.smocked.verifyStateCommitment.will.return.with( Mock__StateCommitmentChain.smocked.verifyStateCommitment.will.return.with(
false false
) )
......
...@@ -21,31 +21,31 @@ import { ...@@ -21,31 +21,31 @@ import {
NON_ZERO_ADDRESS, NON_ZERO_ADDRESS,
} from '../../../helpers' } from '../../../helpers'
// Still have some duplication from OVM_CanonicalTransactionChain.spec.ts, but it's so minimal that // Still have some duplication from CanonicalTransactionChain.spec.ts, but it's so minimal that
// this is probably cleaner for now. Particularly since we're planning to move all of this out into // this is probably cleaner for now. Particularly since we're planning to move all of this out into
// core-utils soon anyway. // core-utils soon anyway.
const MAX_GAS_LIMIT = 8_000_000 const MAX_GAS_LIMIT = 8_000_000
const appendSequencerBatch = async ( const appendSequencerBatch = async (
OVM_CanonicalTransactionChain: Contract, CanonicalTransactionChain: Contract,
batch: AppendSequencerBatchParams batch: AppendSequencerBatchParams
): Promise<TransactionResponse> => { ): Promise<TransactionResponse> => {
const methodId = keccak256(Buffer.from('appendSequencerBatch()')).slice(2, 10) const methodId = keccak256(Buffer.from('appendSequencerBatch()')).slice(2, 10)
const calldata = encodeAppendSequencerBatch(batch) const calldata = encodeAppendSequencerBatch(batch)
return OVM_CanonicalTransactionChain.signer.sendTransaction({ return CanonicalTransactionChain.signer.sendTransaction({
to: OVM_CanonicalTransactionChain.address, to: CanonicalTransactionChain.address,
data: '0x' + methodId + calldata, data: '0x' + methodId + calldata,
}) })
} }
describe('[GAS BENCHMARK] OVM_CanonicalTransactionChain', () => { describe('[GAS BENCHMARK] CanonicalTransactionChain', () => {
let sequencer: Signer let sequencer: Signer
before(async () => { before(async () => {
;[sequencer] = await ethers.getSigners() ;[sequencer] = await ethers.getSigners()
}) })
let AddressManager: Contract let AddressManager: Contract
let Mock__OVM_StateCommitmentChain: MockContract let Mock__StateCommitmentChain: MockContract
before(async () => { before(async () => {
AddressManager = await makeAddressManager() AddressManager = await makeAddressManager()
await AddressManager.setAddress( await AddressManager.setAddress(
...@@ -53,71 +53,71 @@ describe('[GAS BENCHMARK] OVM_CanonicalTransactionChain', () => { ...@@ -53,71 +53,71 @@ describe('[GAS BENCHMARK] OVM_CanonicalTransactionChain', () => {
await sequencer.getAddress() await sequencer.getAddress()
) )
Mock__OVM_StateCommitmentChain = await smockit( Mock__StateCommitmentChain = await smockit(
await ethers.getContractFactory('OVM_StateCommitmentChain') await ethers.getContractFactory('StateCommitmentChain')
) )
await setProxyTarget( await setProxyTarget(
AddressManager, AddressManager,
'OVM_StateCommitmentChain', 'StateCommitmentChain',
Mock__OVM_StateCommitmentChain Mock__StateCommitmentChain
) )
}) })
let Factory__OVM_CanonicalTransactionChain: ContractFactory let Factory__CanonicalTransactionChain: ContractFactory
let Factory__OVM_ChainStorageContainer: ContractFactory let Factory__ChainStorageContainer: ContractFactory
before(async () => { before(async () => {
Factory__OVM_CanonicalTransactionChain = await ethers.getContractFactory( Factory__CanonicalTransactionChain = await ethers.getContractFactory(
'OVM_CanonicalTransactionChain' 'CanonicalTransactionChain'
) )
Factory__OVM_ChainStorageContainer = await ethers.getContractFactory( Factory__ChainStorageContainer = await ethers.getContractFactory(
'OVM_ChainStorageContainer' 'ChainStorageContainer'
) )
}) })
let OVM_CanonicalTransactionChain: Contract let CanonicalTransactionChain: Contract
beforeEach(async () => { beforeEach(async () => {
// Use a larger FIP for blocks so that we can send a large number of // Use a larger FIP for blocks so that we can send a large number of
// enqueue() transactions without having to manipulate the block number. // enqueue() transactions without having to manipulate the block number.
const forceInclusionPeriodBlocks = 101 const forceInclusionPeriodBlocks = 101
OVM_CanonicalTransactionChain = CanonicalTransactionChain =
await Factory__OVM_CanonicalTransactionChain.deploy( await Factory__CanonicalTransactionChain.deploy(
AddressManager.address, AddressManager.address,
FORCE_INCLUSION_PERIOD_SECONDS, FORCE_INCLUSION_PERIOD_SECONDS,
forceInclusionPeriodBlocks, forceInclusionPeriodBlocks,
MAX_GAS_LIMIT MAX_GAS_LIMIT
) )
const batches = await Factory__OVM_ChainStorageContainer.deploy( const batches = await Factory__ChainStorageContainer.deploy(
AddressManager.address, AddressManager.address,
'OVM_CanonicalTransactionChain' 'CanonicalTransactionChain'
) )
const queue = await Factory__OVM_ChainStorageContainer.deploy( const queue = await Factory__ChainStorageContainer.deploy(
AddressManager.address, AddressManager.address,
'OVM_CanonicalTransactionChain' 'CanonicalTransactionChain'
) )
await AddressManager.setAddress( await AddressManager.setAddress(
'OVM_ChainStorageContainer-CTC-batches', 'ChainStorageContainer-CTC-batches',
batches.address batches.address
) )
await AddressManager.setAddress( await AddressManager.setAddress(
'OVM_ChainStorageContainer-CTC-queue', 'ChainStorageContainer-CTC-queue',
queue.address queue.address
) )
await AddressManager.setAddress( await AddressManager.setAddress(
'OVM_CanonicalTransactionChain', 'CanonicalTransactionChain',
OVM_CanonicalTransactionChain.address CanonicalTransactionChain.address
) )
}) })
describe('appendSequencerBatch [ @skip-on-coverage ]', () => { describe('appendSequencerBatch [ @skip-on-coverage ]', () => {
beforeEach(() => { beforeEach(() => {
OVM_CanonicalTransactionChain = CanonicalTransactionChain =
OVM_CanonicalTransactionChain.connect(sequencer) CanonicalTransactionChain.connect(sequencer)
}) })
it('200 transactions in a single context', async () => { it('200 transactions in a single context', async () => {
...@@ -135,7 +135,7 @@ describe('[GAS BENCHMARK] OVM_CanonicalTransactionChain', () => { ...@@ -135,7 +135,7 @@ describe('[GAS BENCHMARK] OVM_CanonicalTransactionChain', () => {
const fixedCalldataCost = const fixedCalldataCost =
(transactionTemplate.slice(2).length / 2) * 16 * numTxs (transactionTemplate.slice(2).length / 2) * 16 * numTxs
const res = await appendSequencerBatch(OVM_CanonicalTransactionChain, { const res = await appendSequencerBatch(CanonicalTransactionChain, {
shouldStartAtElement: 0, shouldStartAtElement: 0,
totalElementsToAppend: numTxs, totalElementsToAppend: numTxs,
contexts: [ contexts: [
...@@ -175,7 +175,7 @@ describe('[GAS BENCHMARK] OVM_CanonicalTransactionChain', () => { ...@@ -175,7 +175,7 @@ describe('[GAS BENCHMARK] OVM_CanonicalTransactionChain', () => {
const fixedCalldataCost = const fixedCalldataCost =
(transactionTemplate.slice(2).length / 2) * 16 * numTxs (transactionTemplate.slice(2).length / 2) * 16 * numTxs
const res = await appendSequencerBatch(OVM_CanonicalTransactionChain, { const res = await appendSequencerBatch(CanonicalTransactionChain, {
shouldStartAtElement: 0, shouldStartAtElement: 0,
totalElementsToAppend: numTxs, totalElementsToAppend: numTxs,
contexts: [...Array(numTxs)].map(() => { contexts: [...Array(numTxs)].map(() => {
......
...@@ -76,18 +76,18 @@ const encodeQueueTransaction = ( ...@@ -76,18 +76,18 @@ const encodeQueueTransaction = (
} }
const appendSequencerBatch = async ( const appendSequencerBatch = async (
OVM_CanonicalTransactionChain: Contract, CanonicalTransactionChain: Contract,
batch: AppendSequencerBatchParams batch: AppendSequencerBatchParams
): Promise<TransactionResponse> => { ): Promise<TransactionResponse> => {
const methodId = keccak256(Buffer.from('appendSequencerBatch()')).slice(2, 10) const methodId = keccak256(Buffer.from('appendSequencerBatch()')).slice(2, 10)
const calldata = encodeAppendSequencerBatch(batch) const calldata = encodeAppendSequencerBatch(batch)
return OVM_CanonicalTransactionChain.signer.sendTransaction({ return CanonicalTransactionChain.signer.sendTransaction({
to: OVM_CanonicalTransactionChain.address, to: CanonicalTransactionChain.address,
data: '0x' + methodId + calldata, data: '0x' + methodId + calldata,
}) })
} }
describe('OVM_CanonicalTransactionChain', () => { describe('CanonicalTransactionChain', () => {
let signer: Signer let signer: Signer
let sequencer: Signer let sequencer: Signer
before(async () => { before(async () => {
...@@ -95,7 +95,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -95,7 +95,7 @@ describe('OVM_CanonicalTransactionChain', () => {
}) })
let AddressManager: Contract let AddressManager: Contract
let Mock__OVM_StateCommitmentChain: MockContract let Mock__StateCommitmentChain: MockContract
before(async () => { before(async () => {
AddressManager = await makeAddressManager() AddressManager = await makeAddressManager()
await AddressManager.setAddress( await AddressManager.setAddress(
...@@ -103,61 +103,61 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -103,61 +103,61 @@ describe('OVM_CanonicalTransactionChain', () => {
await sequencer.getAddress() await sequencer.getAddress()
) )
Mock__OVM_StateCommitmentChain = await smockit( Mock__StateCommitmentChain = await smockit(
await ethers.getContractFactory('OVM_StateCommitmentChain') await ethers.getContractFactory('StateCommitmentChain')
) )
await setProxyTarget( await setProxyTarget(
AddressManager, AddressManager,
'OVM_StateCommitmentChain', 'StateCommitmentChain',
Mock__OVM_StateCommitmentChain Mock__StateCommitmentChain
) )
}) })
let Factory__OVM_CanonicalTransactionChain: ContractFactory let Factory__CanonicalTransactionChain: ContractFactory
let Factory__OVM_ChainStorageContainer: ContractFactory let Factory__ChainStorageContainer: ContractFactory
before(async () => { before(async () => {
Factory__OVM_CanonicalTransactionChain = await ethers.getContractFactory( Factory__CanonicalTransactionChain = await ethers.getContractFactory(
'OVM_CanonicalTransactionChain' 'CanonicalTransactionChain'
) )
Factory__OVM_ChainStorageContainer = await ethers.getContractFactory( Factory__ChainStorageContainer = await ethers.getContractFactory(
'OVM_ChainStorageContainer' 'ChainStorageContainer'
) )
}) })
let OVM_CanonicalTransactionChain: Contract let CanonicalTransactionChain: Contract
beforeEach(async () => { beforeEach(async () => {
OVM_CanonicalTransactionChain = CanonicalTransactionChain =
await Factory__OVM_CanonicalTransactionChain.deploy( await Factory__CanonicalTransactionChain.deploy(
AddressManager.address, AddressManager.address,
FORCE_INCLUSION_PERIOD_SECONDS, FORCE_INCLUSION_PERIOD_SECONDS,
FORCE_INCLUSION_PERIOD_BLOCKS, FORCE_INCLUSION_PERIOD_BLOCKS,
MAX_GAS_LIMIT MAX_GAS_LIMIT
) )
const batches = await Factory__OVM_ChainStorageContainer.deploy( const batches = await Factory__ChainStorageContainer.deploy(
AddressManager.address, AddressManager.address,
'OVM_CanonicalTransactionChain' 'CanonicalTransactionChain'
) )
const queue = await Factory__OVM_ChainStorageContainer.deploy( const queue = await Factory__ChainStorageContainer.deploy(
AddressManager.address, AddressManager.address,
'OVM_CanonicalTransactionChain' 'CanonicalTransactionChain'
) )
await AddressManager.setAddress( await AddressManager.setAddress(
'OVM_ChainStorageContainer-CTC-batches', 'ChainStorageContainer-CTC-batches',
batches.address batches.address
) )
await AddressManager.setAddress( await AddressManager.setAddress(
'OVM_ChainStorageContainer-CTC-queue', 'ChainStorageContainer-CTC-queue',
queue.address queue.address
) )
await AddressManager.setAddress( await AddressManager.setAddress(
'OVM_CanonicalTransactionChain', 'CanonicalTransactionChain',
OVM_CanonicalTransactionChain.address CanonicalTransactionChain.address
) )
}) })
...@@ -167,11 +167,11 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -167,11 +167,11 @@ 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 = const MAX_ROLLUP_TX_SIZE =
await OVM_CanonicalTransactionChain.MAX_ROLLUP_TX_SIZE() await 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(
OVM_CanonicalTransactionChain.enqueue(target, gasLimit, data, { CanonicalTransactionChain.enqueue(target, gasLimit, data, {
gasLimit: 40000000, gasLimit: 40000000,
}) })
).to.be.revertedWith( ).to.be.revertedWith(
...@@ -183,7 +183,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -183,7 +183,7 @@ describe('OVM_CanonicalTransactionChain', () => {
const data = '0x1234567890' const data = '0x1234567890'
await expect( await expect(
OVM_CanonicalTransactionChain.enqueue(target, MAX_GAS_LIMIT + 1, data) CanonicalTransactionChain.enqueue(target, MAX_GAS_LIMIT + 1, data)
).to.be.revertedWith( ).to.be.revertedWith(
'Transaction gas limit exceeds maximum for rollup transaction.' 'Transaction gas limit exceeds maximum for rollup transaction.'
) )
...@@ -191,20 +191,20 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -191,20 +191,20 @@ 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 = const MIN_ROLLUP_TX_GAS =
await OVM_CanonicalTransactionChain.MIN_ROLLUP_TX_GAS() await 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)
await expect( await expect(
OVM_CanonicalTransactionChain.enqueue(target, customGasLimit, data) CanonicalTransactionChain.enqueue(target, customGasLimit, data)
).to.be.revertedWith('Transaction gas limit too low to enqueue.') ).to.be.revertedWith('Transaction gas limit too low to enqueue.')
}) })
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 ENQUEUE_L2_GAS_PREPAID = const ENQUEUE_L2_GAS_PREPAID =
await OVM_CanonicalTransactionChain.ENQUEUE_L2_GAS_PREPAID() await CanonicalTransactionChain.ENQUEUE_L2_GAS_PREPAID()
const L2_GAS_DISCOUNT_DIVISOR = const L2_GAS_DISCOUNT_DIVISOR =
await OVM_CanonicalTransactionChain.L2_GAS_DISCOUNT_DIVISOR() await CanonicalTransactionChain.L2_GAS_DISCOUNT_DIVISOR()
const data = '0x' + '12'.repeat(1234) const data = '0x' + '12'.repeat(1234)
// Create a tx with high L2 gas limit, but insufficient L1 gas limit to cover burn. // Create a tx with high L2 gas limit, but insufficient L1 gas limit to cover burn.
...@@ -216,7 +216,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -216,7 +216,7 @@ describe('OVM_CanonicalTransactionChain', () => {
(l2GasLimit - ENQUEUE_L2_GAS_PREPAID) / L2_GAS_DISCOUNT_DIVISOR (l2GasLimit - ENQUEUE_L2_GAS_PREPAID) / L2_GAS_DISCOUNT_DIVISOR
await expect( await expect(
OVM_CanonicalTransactionChain.enqueue(target, l2GasLimit, data, { CanonicalTransactionChain.enqueue(target, l2GasLimit, data, {
gasLimit: l1GasLimit, gasLimit: l1GasLimit,
}) })
).to.be.revertedWith('Insufficient gas for L2 rate limiting burn.') ).to.be.revertedWith('Insufficient gas for L2 rate limiting burn.')
...@@ -230,8 +230,8 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -230,8 +230,8 @@ describe('OVM_CanonicalTransactionChain', () => {
await setEthTime(ethers.provider, timestamp) await setEthTime(ethers.provider, timestamp)
await expect( await expect(
OVM_CanonicalTransactionChain.enqueue(target, gasLimit, data) CanonicalTransactionChain.enqueue(target, gasLimit, data)
).to.emit(OVM_CanonicalTransactionChain, 'TransactionEnqueued') ).to.emit(CanonicalTransactionChain, 'TransactionEnqueued')
}) })
describe('when enqueing multiple times', () => { describe('when enqueing multiple times', () => {
...@@ -241,7 +241,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -241,7 +241,7 @@ describe('OVM_CanonicalTransactionChain', () => {
it(`should be able to enqueue ${size} elements`, async () => { it(`should be able to enqueue ${size} elements`, async () => {
for (let i = 0; i < size; i++) { for (let i = 0; i < size; i++) {
await expect( await expect(
OVM_CanonicalTransactionChain.enqueue(target, gasLimit, data) CanonicalTransactionChain.enqueue(target, gasLimit, data)
).to.not.be.reverted ).to.not.be.reverted
} }
}) })
...@@ -286,7 +286,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -286,7 +286,7 @@ describe('OVM_CanonicalTransactionChain', () => {
describe('getQueueElement', () => { describe('getQueueElement', () => {
it('should revert when accessing a non-existent element', async () => { it('should revert when accessing a non-existent element', async () => {
await expect( await expect(
OVM_CanonicalTransactionChain.getQueueElement(0) CanonicalTransactionChain.getQueueElement(0)
).to.be.revertedWith('Index out of bounds.') ).to.be.revertedWith('Index out of bounds.')
}) })
...@@ -309,10 +309,10 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -309,10 +309,10 @@ describe('OVM_CanonicalTransactionChain', () => {
data data
) )
await OVM_CanonicalTransactionChain.enqueue(target, gasLimit, data) await CanonicalTransactionChain.enqueue(target, gasLimit, data)
for (let i = 0; i < size; i++) { for (let i = 0; i < size; i++) {
await OVM_CanonicalTransactionChain.enqueue( await CanonicalTransactionChain.enqueue(
target, target,
gasLimit, gasLimit,
'0x' + '12'.repeat(i + 1) '0x' + '12'.repeat(i + 1)
...@@ -321,7 +321,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -321,7 +321,7 @@ describe('OVM_CanonicalTransactionChain', () => {
expect( expect(
_.toPlainObject( _.toPlainObject(
await OVM_CanonicalTransactionChain.getQueueElement(0) await CanonicalTransactionChain.getQueueElement(0)
) )
).to.deep.include({ ).to.deep.include({
transactionHash, transactionHash,
...@@ -353,13 +353,13 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -353,13 +353,13 @@ describe('OVM_CanonicalTransactionChain', () => {
data data
) )
await OVM_CanonicalTransactionChain.enqueue( await CanonicalTransactionChain.enqueue(
target, target,
gasLimit, gasLimit,
data data
) )
} else { } else {
await OVM_CanonicalTransactionChain.enqueue( await CanonicalTransactionChain.enqueue(
target, target,
gasLimit, gasLimit,
'0x' + '12'.repeat(i + 1) '0x' + '12'.repeat(i + 1)
...@@ -369,7 +369,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -369,7 +369,7 @@ describe('OVM_CanonicalTransactionChain', () => {
expect( expect(
_.toPlainObject( _.toPlainObject(
await OVM_CanonicalTransactionChain.getQueueElement(middleIndex) await CanonicalTransactionChain.getQueueElement(middleIndex)
) )
).to.deep.include({ ).to.deep.include({
transactionHash, transactionHash,
...@@ -400,13 +400,13 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -400,13 +400,13 @@ describe('OVM_CanonicalTransactionChain', () => {
data data
) )
await OVM_CanonicalTransactionChain.enqueue( await CanonicalTransactionChain.enqueue(
target, target,
gasLimit, gasLimit,
data data
) )
} else { } else {
await OVM_CanonicalTransactionChain.enqueue( await CanonicalTransactionChain.enqueue(
target, target,
gasLimit, gasLimit,
'0x' + '12'.repeat(i + 1) '0x' + '12'.repeat(i + 1)
...@@ -416,7 +416,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -416,7 +416,7 @@ describe('OVM_CanonicalTransactionChain', () => {
expect( expect(
_.toPlainObject( _.toPlainObject(
await OVM_CanonicalTransactionChain.getQueueElement(size - 1) await CanonicalTransactionChain.getQueueElement(size - 1)
) )
).to.deep.include({ ).to.deep.include({
transactionHash, transactionHash,
...@@ -432,7 +432,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -432,7 +432,7 @@ describe('OVM_CanonicalTransactionChain', () => {
describe('appendQueueBatch disabled', () => { describe('appendQueueBatch disabled', () => {
it('should revert', async () => { it('should revert', async () => {
await expect( await expect(
OVM_CanonicalTransactionChain.appendQueueBatch(0) CanonicalTransactionChain.appendQueueBatch(0)
).to.be.revertedWith('appendQueueBatch is currently disabled.') ).to.be.revertedWith('appendQueueBatch is currently disabled.')
}) })
}) })
...@@ -440,13 +440,13 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -440,13 +440,13 @@ describe('OVM_CanonicalTransactionChain', () => {
describe.skip('appendQueueBatch', () => { describe.skip('appendQueueBatch', () => {
it('should revert if trying to append zero transactions', async () => { it('should revert if trying to append zero transactions', async () => {
await expect( await expect(
OVM_CanonicalTransactionChain.appendQueueBatch(0) CanonicalTransactionChain.appendQueueBatch(0)
).to.be.revertedWith('Must append more than zero transactions.') ).to.be.revertedWith('Must append more than zero transactions.')
}) })
it('should revert if the queue is empty', async () => { it('should revert if the queue is empty', async () => {
await expect( await expect(
OVM_CanonicalTransactionChain.appendQueueBatch(1) CanonicalTransactionChain.appendQueueBatch(1)
).to.be.revertedWith('Must append more than zero transactions.') ).to.be.revertedWith('Must append more than zero transactions.')
}) })
...@@ -459,7 +459,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -459,7 +459,7 @@ describe('OVM_CanonicalTransactionChain', () => {
describe(`when the queue has ${size} elements`, () => { describe(`when the queue has ${size} elements`, () => {
beforeEach(async () => { beforeEach(async () => {
for (let i = 0; i < size; i++) { for (let i = 0; i < size; i++) {
await OVM_CanonicalTransactionChain.enqueue( await CanonicalTransactionChain.enqueue(
target, target,
gasLimit, gasLimit,
data data
...@@ -470,7 +470,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -470,7 +470,7 @@ describe('OVM_CanonicalTransactionChain', () => {
describe('when the sequencer inclusion period has not passed', () => { describe('when the sequencer inclusion period has not passed', () => {
it('should revert if not called by the sequencer', async () => { it('should revert if not called by the sequencer', async () => {
await expect( await expect(
OVM_CanonicalTransactionChain.connect(signer).appendQueueBatch( CanonicalTransactionChain.connect(signer).appendQueueBatch(
1 1
) )
).to.be.revertedWith( ).to.be.revertedWith(
...@@ -480,11 +480,11 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -480,11 +480,11 @@ describe('OVM_CanonicalTransactionChain', () => {
it('should succeed if called by the sequencer', async () => { it('should succeed if called by the sequencer', async () => {
await expect( await expect(
OVM_CanonicalTransactionChain.connect( CanonicalTransactionChain.connect(
sequencer sequencer
).appendQueueBatch(1) ).appendQueueBatch(1)
) )
.to.emit(OVM_CanonicalTransactionChain, 'QueueBatchAppended') .to.emit(CanonicalTransactionChain, 'QueueBatchAppended')
.withArgs(0, 1, 1) .withArgs(0, 1, 1)
}) })
}) })
...@@ -498,22 +498,22 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -498,22 +498,22 @@ describe('OVM_CanonicalTransactionChain', () => {
}) })
it('should be able to append a single element', async () => { it('should be able to append a single element', async () => {
await expect(OVM_CanonicalTransactionChain.appendQueueBatch(1)) await expect(CanonicalTransactionChain.appendQueueBatch(1))
.to.emit(OVM_CanonicalTransactionChain, 'QueueBatchAppended') .to.emit(CanonicalTransactionChain, 'QueueBatchAppended')
.withArgs(0, 1, 1) .withArgs(0, 1, 1)
}) })
it(`should be able to append ${size} elements`, async () => { it(`should be able to append ${size} elements`, async () => {
await expect(OVM_CanonicalTransactionChain.appendQueueBatch(size)) await expect(CanonicalTransactionChain.appendQueueBatch(size))
.to.emit(OVM_CanonicalTransactionChain, 'QueueBatchAppended') .to.emit(CanonicalTransactionChain, 'QueueBatchAppended')
.withArgs(0, size, size) .withArgs(0, size, size)
}) })
it(`should be able to append ${size} elements even if attempting to append ${size} + 1 elements`, async () => { it(`should be able to append ${size} elements even if attempting to append ${size} + 1 elements`, async () => {
await expect( await expect(
OVM_CanonicalTransactionChain.appendQueueBatch(size + 1) CanonicalTransactionChain.appendQueueBatch(size + 1)
) )
.to.emit(OVM_CanonicalTransactionChain, 'QueueBatchAppended') .to.emit(CanonicalTransactionChain, 'QueueBatchAppended')
.withArgs(0, size, size) .withArgs(0, size, size)
}) })
}) })
...@@ -530,12 +530,12 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -530,12 +530,12 @@ describe('OVM_CanonicalTransactionChain', () => {
const timestamp = (await getEthTime(ethers.provider)) + 100 const timestamp = (await getEthTime(ethers.provider)) + 100
await setEthTime(ethers.provider, timestamp) await setEthTime(ethers.provider, timestamp)
await OVM_CanonicalTransactionChain.enqueue(entrypoint, gasLimit, data) await CanonicalTransactionChain.enqueue(entrypoint, gasLimit, data)
const blockNumber = await ethers.provider.getBlockNumber() const blockNumber = await ethers.provider.getBlockNumber()
await appendSequencerBatch( await appendSequencerBatch(
OVM_CanonicalTransactionChain.connect(sequencer), CanonicalTransactionChain.connect(sequencer),
{ {
shouldStartAtElement: 0, shouldStartAtElement: 0,
totalElementsToAppend: 1, totalElementsToAppend: 1,
...@@ -552,12 +552,12 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -552,12 +552,12 @@ describe('OVM_CanonicalTransactionChain', () => {
) )
expect( expect(
await OVM_CanonicalTransactionChain.verifyTransaction( await CanonicalTransactionChain.verifyTransaction(
{ {
timestamp, timestamp,
blockNumber, blockNumber,
l1QueueOrigin: 1, l1QueueOrigin: 1,
l1TxOrigin: await OVM_CanonicalTransactionChain.signer.getAddress(), l1TxOrigin: await CanonicalTransactionChain.signer.getAddress(),
entrypoint, entrypoint,
gasLimit, gasLimit,
data, data,
...@@ -591,20 +591,20 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -591,20 +591,20 @@ describe('OVM_CanonicalTransactionChain', () => {
const timestamp = (await getEthTime(ethers.provider)) + 100 const timestamp = (await getEthTime(ethers.provider)) + 100
await setEthTime(ethers.provider, timestamp) await setEthTime(ethers.provider, timestamp)
await OVM_CanonicalTransactionChain.enqueue(entrypoint, gasLimit, data) await CanonicalTransactionChain.enqueue(entrypoint, gasLimit, data)
const blockNumber = await ethers.provider.getBlockNumber() const blockNumber = await ethers.provider.getBlockNumber()
await increaseEthTime(ethers.provider, FORCE_INCLUSION_PERIOD_SECONDS * 2) await increaseEthTime(ethers.provider, FORCE_INCLUSION_PERIOD_SECONDS * 2)
await OVM_CanonicalTransactionChain.appendQueueBatch(1) await CanonicalTransactionChain.appendQueueBatch(1)
expect( expect(
await OVM_CanonicalTransactionChain.verifyTransaction( await CanonicalTransactionChain.verifyTransaction(
{ {
timestamp, timestamp,
blockNumber, blockNumber,
l1QueueOrigin: 1, l1QueueOrigin: 1,
l1TxOrigin: await OVM_CanonicalTransactionChain.signer.getAddress(), l1TxOrigin: await CanonicalTransactionChain.signer.getAddress(),
entrypoint, entrypoint,
gasLimit, gasLimit,
data, data,
...@@ -639,7 +639,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -639,7 +639,7 @@ describe('OVM_CanonicalTransactionChain', () => {
const blockNumber = (await ethers.provider.getBlockNumber()) - 1 const blockNumber = (await ethers.provider.getBlockNumber()) - 1
await appendSequencerBatch( await appendSequencerBatch(
OVM_CanonicalTransactionChain.connect(sequencer), CanonicalTransactionChain.connect(sequencer),
{ {
shouldStartAtElement: 0, shouldStartAtElement: 0,
totalElementsToAppend: 1, totalElementsToAppend: 1,
...@@ -656,7 +656,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -656,7 +656,7 @@ describe('OVM_CanonicalTransactionChain', () => {
) )
expect( expect(
await OVM_CanonicalTransactionChain.verifyTransaction( await CanonicalTransactionChain.verifyTransaction(
{ {
timestamp, timestamp,
blockNumber, blockNumber,
...@@ -691,13 +691,13 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -691,13 +691,13 @@ describe('OVM_CanonicalTransactionChain', () => {
describe('appendSequencerBatch', () => { describe('appendSequencerBatch', () => {
beforeEach(() => { beforeEach(() => {
OVM_CanonicalTransactionChain = CanonicalTransactionChain =
OVM_CanonicalTransactionChain.connect(sequencer) 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 () => {
await expect( await expect(
appendSequencerBatch(OVM_CanonicalTransactionChain, { appendSequencerBatch(CanonicalTransactionChain, {
transactions: ['0x1234'], transactions: ['0x1234'],
contexts: [ contexts: [
{ {
...@@ -717,7 +717,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -717,7 +717,7 @@ describe('OVM_CanonicalTransactionChain', () => {
it('should revert if not called by the sequencer', async () => { it('should revert if not called by the sequencer', async () => {
await expect( await expect(
appendSequencerBatch(OVM_CanonicalTransactionChain.connect(signer), { appendSequencerBatch(CanonicalTransactionChain.connect(signer), {
transactions: ['0x1234'], transactions: ['0x1234'],
contexts: [ contexts: [
{ {
...@@ -735,14 +735,14 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -735,14 +735,14 @@ 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 = const MAX_ROLLUP_TX_SIZE =
await OVM_CanonicalTransactionChain.MAX_ROLLUP_TX_SIZE() await 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)
const blockNumber = (await getNextBlockNumber(ethers.provider)) - 1 const blockNumber = (await getNextBlockNumber(ethers.provider)) - 1
await expect( await expect(
appendSequencerBatch(OVM_CanonicalTransactionChain, { appendSequencerBatch(CanonicalTransactionChain, {
transactions: [data], transactions: [data],
contexts: [ contexts: [
{ {
...@@ -771,7 +771,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -771,7 +771,7 @@ describe('OVM_CanonicalTransactionChain', () => {
const blockNumber = (await getNextBlockNumber(ethers.provider)) - 1 const blockNumber = (await getNextBlockNumber(ethers.provider)) - 1
await expect( await expect(
appendSequencerBatch(OVM_CanonicalTransactionChain, { appendSequencerBatch(CanonicalTransactionChain, {
transactions: ['0x1234'], transactions: ['0x1234'],
contexts: [ contexts: [
{ {
...@@ -793,11 +793,11 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -793,11 +793,11 @@ describe('OVM_CanonicalTransactionChain', () => {
const numEnqueues = 7 const numEnqueues = 7
for (let i = 0; i < numEnqueues; i++) { for (let i = 0; i < numEnqueues; i++) {
await OVM_CanonicalTransactionChain.enqueue(target, gasLimit, data) await CanonicalTransactionChain.enqueue(target, gasLimit, data)
} }
await expect( await expect(
appendSequencerBatch(OVM_CanonicalTransactionChain, { appendSequencerBatch(CanonicalTransactionChain, {
transactions: ['0x1234'], transactions: ['0x1234'],
contexts: [ contexts: [
{ {
...@@ -846,7 +846,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -846,7 +846,7 @@ describe('OVM_CanonicalTransactionChain', () => {
it('should append the given number of transactions', async () => { it('should append the given number of transactions', async () => {
await expect( await expect(
appendSequencerBatch(OVM_CanonicalTransactionChain, { appendSequencerBatch(CanonicalTransactionChain, {
transactions, transactions,
contexts, contexts,
shouldStartAtElement: 0, shouldStartAtElement: 0,
...@@ -854,7 +854,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -854,7 +854,7 @@ describe('OVM_CanonicalTransactionChain', () => {
}) })
) )
.to.emit( .to.emit(
OVM_CanonicalTransactionChain, CanonicalTransactionChain,
'SequencerBatchAppended' 'SequencerBatchAppended'
) )
.withArgs(0, 0, size) .withArgs(0, 0, size)
...@@ -865,7 +865,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -865,7 +865,7 @@ describe('OVM_CanonicalTransactionChain', () => {
describe('when inserting queue elements in between', () => { describe('when inserting queue elements in between', () => {
beforeEach(async () => { beforeEach(async () => {
for (let i = 0; i < size; i++) { for (let i = 0; i < size; i++) {
await OVM_CanonicalTransactionChain.enqueue( await CanonicalTransactionChain.enqueue(
target, target,
gasLimit, gasLimit,
data data
...@@ -897,7 +897,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -897,7 +897,7 @@ describe('OVM_CanonicalTransactionChain', () => {
it('should append the batch', async () => { it('should append the batch', async () => {
await expect( await expect(
appendSequencerBatch(OVM_CanonicalTransactionChain, { appendSequencerBatch(CanonicalTransactionChain, {
transactions, transactions,
contexts, contexts,
shouldStartAtElement: 0, shouldStartAtElement: 0,
...@@ -905,7 +905,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -905,7 +905,7 @@ describe('OVM_CanonicalTransactionChain', () => {
}) })
) )
.to.emit( .to.emit(
OVM_CanonicalTransactionChain, CanonicalTransactionChain,
'SequencerBatchAppended' 'SequencerBatchAppended'
) )
.withArgs(0, size, size * 2) .withArgs(0, size, size * 2)
...@@ -937,7 +937,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -937,7 +937,7 @@ describe('OVM_CanonicalTransactionChain', () => {
it('should append the batch', async () => { it('should append the batch', async () => {
await expect( await expect(
appendSequencerBatch(OVM_CanonicalTransactionChain, { appendSequencerBatch(CanonicalTransactionChain, {
transactions, transactions,
contexts, contexts,
shouldStartAtElement: 0, shouldStartAtElement: 0,
...@@ -945,7 +945,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -945,7 +945,7 @@ describe('OVM_CanonicalTransactionChain', () => {
}) })
) )
.to.emit( .to.emit(
OVM_CanonicalTransactionChain, CanonicalTransactionChain,
'SequencerBatchAppended' 'SequencerBatchAppended'
) )
.withArgs(0, spacing, size + spacing) .withArgs(0, spacing, size + spacing)
...@@ -958,7 +958,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -958,7 +958,7 @@ describe('OVM_CanonicalTransactionChain', () => {
describe('getTotalElements', () => { describe('getTotalElements', () => {
it('should return zero when no elements exist', async () => { it('should return zero when no elements exist', async () => {
expect(await OVM_CanonicalTransactionChain.getTotalElements()).to.equal(0) expect(await CanonicalTransactionChain.getTotalElements()).to.equal(0)
}) })
for (const size of ELEMENT_TEST_SIZES) { for (const size of ELEMENT_TEST_SIZES) {
...@@ -981,7 +981,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -981,7 +981,7 @@ describe('OVM_CanonicalTransactionChain', () => {
}) })
const res = await appendSequencerBatch( const res = await appendSequencerBatch(
OVM_CanonicalTransactionChain.connect(sequencer), CanonicalTransactionChain.connect(sequencer),
{ {
transactions, transactions,
contexts, contexts,
...@@ -994,7 +994,7 @@ describe('OVM_CanonicalTransactionChain', () => { ...@@ -994,7 +994,7 @@ describe('OVM_CanonicalTransactionChain', () => {
it(`should return ${size}`, async () => { it(`should return ${size}`, async () => {
expect( expect(
await OVM_CanonicalTransactionChain.getTotalElements() await CanonicalTransactionChain.getTotalElements()
).to.equal(size) ).to.equal(size)
}) })
}) })
......
...@@ -14,7 +14,7 @@ import { ...@@ -14,7 +14,7 @@ import {
increaseEthTime, increaseEthTime,
} from '../../../helpers' } from '../../../helpers'
describe('OVM_StateCommitmentChain', () => { describe('StateCommitmentChain', () => {
let sequencer: Signer let sequencer: Signer
let user: Signer let user: Signer
before(async () => { before(async () => {
...@@ -26,17 +26,17 @@ describe('OVM_StateCommitmentChain', () => { ...@@ -26,17 +26,17 @@ describe('OVM_StateCommitmentChain', () => {
AddressManager = await makeAddressManager() AddressManager = await makeAddressManager()
}) })
let Mock__OVM_CanonicalTransactionChain: MockContract let Mock__CanonicalTransactionChain: MockContract
let Mock__OVM_BondManager: MockContract let Mock__OVM_BondManager: MockContract
before(async () => { before(async () => {
Mock__OVM_CanonicalTransactionChain = await smockit( Mock__CanonicalTransactionChain = await smockit(
await ethers.getContractFactory('OVM_CanonicalTransactionChain') await ethers.getContractFactory('CanonicalTransactionChain')
) )
await setProxyTarget( await setProxyTarget(
AddressManager, AddressManager,
'OVM_CanonicalTransactionChain', 'CanonicalTransactionChain',
Mock__OVM_CanonicalTransactionChain Mock__CanonicalTransactionChain
) )
Mock__OVM_BondManager = await smockit( Mock__OVM_BondManager = await smockit(
...@@ -57,39 +57,39 @@ describe('OVM_StateCommitmentChain', () => { ...@@ -57,39 +57,39 @@ describe('OVM_StateCommitmentChain', () => {
) )
}) })
let Factory__OVM_StateCommitmentChain: ContractFactory let Factory__StateCommitmentChain: ContractFactory
let Factory__OVM_ChainStorageContainer: ContractFactory let Factory__ChainStorageContainer: ContractFactory
before(async () => { before(async () => {
Factory__OVM_StateCommitmentChain = await ethers.getContractFactory( Factory__StateCommitmentChain = await ethers.getContractFactory(
'OVM_StateCommitmentChain' 'StateCommitmentChain'
) )
Factory__OVM_ChainStorageContainer = await ethers.getContractFactory( Factory__ChainStorageContainer = await ethers.getContractFactory(
'OVM_ChainStorageContainer' 'ChainStorageContainer'
) )
}) })
let OVM_StateCommitmentChain: Contract let StateCommitmentChain: Contract
beforeEach(async () => { beforeEach(async () => {
OVM_StateCommitmentChain = await Factory__OVM_StateCommitmentChain.deploy( StateCommitmentChain = await Factory__StateCommitmentChain.deploy(
AddressManager.address, AddressManager.address,
60 * 60 * 24 * 7, // 1 week fraud proof window 60 * 60 * 24 * 7, // 1 week fraud proof window
60 * 30 // 30 minute sequencer publish window 60 * 30 // 30 minute sequencer publish window
) )
const batches = await Factory__OVM_ChainStorageContainer.deploy( const batches = await Factory__ChainStorageContainer.deploy(
AddressManager.address, AddressManager.address,
'OVM_StateCommitmentChain' 'StateCommitmentChain'
) )
await AddressManager.setAddress( await AddressManager.setAddress(
'OVM_ChainStorageContainer-SCC-batches', 'ChainStorageContainer-SCC-batches',
batches.address batches.address
) )
await AddressManager.setAddress( await AddressManager.setAddress(
'OVM_StateCommitmentChain', 'StateCommitmentChain',
OVM_StateCommitmentChain.address StateCommitmentChain.address
) )
}) })
...@@ -99,7 +99,7 @@ describe('OVM_StateCommitmentChain', () => { ...@@ -99,7 +99,7 @@ describe('OVM_StateCommitmentChain', () => {
it('should revert', async () => { it('should revert', async () => {
await expect( await expect(
OVM_StateCommitmentChain.appendStateBatch(batch, 0) StateCommitmentChain.appendStateBatch(batch, 0)
).to.be.revertedWith('Cannot submit an empty state batch.') ).to.be.revertedWith('Cannot submit an empty state batch.')
}) })
}) })
...@@ -110,49 +110,49 @@ describe('OVM_StateCommitmentChain', () => { ...@@ -110,49 +110,49 @@ describe('OVM_StateCommitmentChain', () => {
describe('when start index does not match total elements', () => { describe('when start index does not match total elements', () => {
it('should revert', async () => { it('should revert', async () => {
await expect( await expect(
OVM_StateCommitmentChain.appendStateBatch(batch, 1) StateCommitmentChain.appendStateBatch(batch, 1)
).to.be.revertedWith( ).to.be.revertedWith(
'Actual batch start index does not match expected start index.' 'Actual batch start index does not match expected start index.'
) )
}) })
}) })
describe('when submitting more elements than present in the OVM_CanonicalTransactionChain', () => { describe('when submitting more elements than present in the CanonicalTransactionChain', () => {
before(() => { before(() => {
Mock__OVM_CanonicalTransactionChain.smocked.getTotalElements.will.return.with( Mock__CanonicalTransactionChain.smocked.getTotalElements.will.return.with(
batch.length - 1 batch.length - 1
) )
}) })
it('should revert', async () => { it('should revert', async () => {
await expect( await expect(
OVM_StateCommitmentChain.appendStateBatch(batch, 0) StateCommitmentChain.appendStateBatch(batch, 0)
).to.be.revertedWith( ).to.be.revertedWith(
'Number of state roots cannot exceed the number of canonical transactions.' 'Number of state roots cannot exceed the number of canonical transactions.'
) )
}) })
}) })
describe('when not submitting more elements than present in the OVM_CanonicalTransactionChain', () => { describe('when not submitting more elements than present in the CanonicalTransactionChain', () => {
before(() => { before(() => {
Mock__OVM_CanonicalTransactionChain.smocked.getTotalElements.will.return.with( Mock__CanonicalTransactionChain.smocked.getTotalElements.will.return.with(
batch.length batch.length
) )
}) })
it('should append the state batch', async () => { it('should append the state batch', async () => {
await expect(OVM_StateCommitmentChain.appendStateBatch(batch, 0)).to await expect(StateCommitmentChain.appendStateBatch(batch, 0)).to
.not.be.reverted .not.be.reverted
}) })
}) })
describe('when a sequencer submits ', () => { describe('when a sequencer submits ', () => {
beforeEach(async () => { beforeEach(async () => {
Mock__OVM_CanonicalTransactionChain.smocked.getTotalElements.will.return.with( Mock__CanonicalTransactionChain.smocked.getTotalElements.will.return.with(
batch.length * 2 batch.length * 2
) )
await OVM_StateCommitmentChain.connect(sequencer).appendStateBatch( await StateCommitmentChain.connect(sequencer).appendStateBatch(
batch, batch,
0 0
) )
...@@ -161,7 +161,7 @@ describe('OVM_StateCommitmentChain', () => { ...@@ -161,7 +161,7 @@ describe('OVM_StateCommitmentChain', () => {
describe('when inside sequencer publish window', () => { describe('when inside sequencer publish window', () => {
it('should revert', async () => { it('should revert', async () => {
await expect( await expect(
OVM_StateCommitmentChain.connect(user).appendStateBatch(batch, 1) StateCommitmentChain.connect(user).appendStateBatch(batch, 1)
).to.be.revertedWith( ).to.be.revertedWith(
'Cannot publish state roots within the sequencer publication window.' 'Cannot publish state roots within the sequencer publication window.'
) )
...@@ -171,7 +171,7 @@ describe('OVM_StateCommitmentChain', () => { ...@@ -171,7 +171,7 @@ describe('OVM_StateCommitmentChain', () => {
describe('when outside sequencer publish window', () => { describe('when outside sequencer publish window', () => {
beforeEach(async () => { beforeEach(async () => {
const SEQUENCER_PUBLISH_WINDOW = const SEQUENCER_PUBLISH_WINDOW =
await OVM_StateCommitmentChain.SEQUENCER_PUBLISH_WINDOW() await StateCommitmentChain.SEQUENCER_PUBLISH_WINDOW()
await increaseEthTime( await increaseEthTime(
ethers.provider, ethers.provider,
SEQUENCER_PUBLISH_WINDOW.toNumber() + 1 SEQUENCER_PUBLISH_WINDOW.toNumber() + 1
...@@ -180,7 +180,7 @@ describe('OVM_StateCommitmentChain', () => { ...@@ -180,7 +180,7 @@ describe('OVM_StateCommitmentChain', () => {
it('should succeed', async () => { it('should succeed', async () => {
await expect( await expect(
OVM_StateCommitmentChain.connect(user).appendStateBatch(batch, 1) StateCommitmentChain.connect(user).appendStateBatch(batch, 1)
).to.not.be.reverted ).to.not.be.reverted
}) })
}) })
...@@ -199,10 +199,10 @@ describe('OVM_StateCommitmentChain', () => { ...@@ -199,10 +199,10 @@ describe('OVM_StateCommitmentChain', () => {
} }
beforeEach(async () => { beforeEach(async () => {
Mock__OVM_CanonicalTransactionChain.smocked.getTotalElements.will.return.with( Mock__CanonicalTransactionChain.smocked.getTotalElements.will.return.with(
batch.length batch.length
) )
await OVM_StateCommitmentChain.appendStateBatch(batch, 0) await StateCommitmentChain.appendStateBatch(batch, 0)
batchHeader.extraData = ethers.utils.defaultAbiCoder.encode( batchHeader.extraData = ethers.utils.defaultAbiCoder.encode(
['uint256', 'address'], ['uint256', 'address'],
[await getEthTime(ethers.provider), await sequencer.getAddress()] [await getEthTime(ethers.provider), await sequencer.getAddress()]
...@@ -219,7 +219,7 @@ describe('OVM_StateCommitmentChain', () => { ...@@ -219,7 +219,7 @@ describe('OVM_StateCommitmentChain', () => {
it('should revert', async () => { it('should revert', async () => {
await expect( await expect(
OVM_StateCommitmentChain.deleteStateBatch(batchHeader) StateCommitmentChain.deleteStateBatch(batchHeader)
).to.be.revertedWith( ).to.be.revertedWith(
'State batches can only be deleted by the OVM_FraudVerifier.' 'State batches can only be deleted by the OVM_FraudVerifier.'
) )
...@@ -237,7 +237,7 @@ describe('OVM_StateCommitmentChain', () => { ...@@ -237,7 +237,7 @@ describe('OVM_StateCommitmentChain', () => {
describe('when the provided batch index is greater than the total submitted', () => { describe('when the provided batch index is greater than the total submitted', () => {
it('should revert', async () => { it('should revert', async () => {
await expect( await expect(
OVM_StateCommitmentChain.deleteStateBatch({ StateCommitmentChain.deleteStateBatch({
...batchHeader, ...batchHeader,
batchIndex: 1, batchIndex: 1,
}) })
...@@ -249,7 +249,7 @@ describe('OVM_StateCommitmentChain', () => { ...@@ -249,7 +249,7 @@ describe('OVM_StateCommitmentChain', () => {
describe('when the provided batch header is invalid', () => { describe('when the provided batch header is invalid', () => {
it('should revert', async () => { it('should revert', async () => {
await expect( await expect(
OVM_StateCommitmentChain.deleteStateBatch({ StateCommitmentChain.deleteStateBatch({
...batchHeader, ...batchHeader,
extraData: '0x' + '22'.repeat(32), extraData: '0x' + '22'.repeat(32),
}) })
...@@ -259,7 +259,7 @@ describe('OVM_StateCommitmentChain', () => { ...@@ -259,7 +259,7 @@ describe('OVM_StateCommitmentChain', () => {
describe('when the provided batch header is valid', () => { describe('when the provided batch header is valid', () => {
it('should remove the batch and all following batches', async () => { it('should remove the batch and all following batches', async () => {
await expect(OVM_StateCommitmentChain.deleteStateBatch(batchHeader)) await expect(StateCommitmentChain.deleteStateBatch(batchHeader))
.to.not.be.reverted .to.not.be.reverted
}) })
}) })
...@@ -270,50 +270,50 @@ describe('OVM_StateCommitmentChain', () => { ...@@ -270,50 +270,50 @@ describe('OVM_StateCommitmentChain', () => {
describe('getTotalElements', () => { describe('getTotalElements', () => {
describe('when no batch elements have been inserted', () => { describe('when no batch elements have been inserted', () => {
it('should return zero', async () => { it('should return zero', async () => {
expect(await OVM_StateCommitmentChain.getTotalElements()).to.equal(0) expect(await StateCommitmentChain.getTotalElements()).to.equal(0)
}) })
}) })
describe('when one batch element has been inserted', () => { describe('when one batch element has been inserted', () => {
beforeEach(async () => { beforeEach(async () => {
const batch = [NON_NULL_BYTES32] const batch = [NON_NULL_BYTES32]
Mock__OVM_CanonicalTransactionChain.smocked.getTotalElements.will.return.with( Mock__CanonicalTransactionChain.smocked.getTotalElements.will.return.with(
batch.length batch.length
) )
await OVM_StateCommitmentChain.appendStateBatch(batch, 0) await StateCommitmentChain.appendStateBatch(batch, 0)
}) })
it('should return the number of inserted batch elements', async () => { it('should return the number of inserted batch elements', async () => {
expect(await OVM_StateCommitmentChain.getTotalElements()).to.equal(1) expect(await StateCommitmentChain.getTotalElements()).to.equal(1)
}) })
}) })
describe('when 64 batch elements have been inserted in one batch', () => { describe('when 64 batch elements have been inserted in one batch', () => {
beforeEach(async () => { beforeEach(async () => {
const batch = Array(64).fill(NON_NULL_BYTES32) const batch = Array(64).fill(NON_NULL_BYTES32)
Mock__OVM_CanonicalTransactionChain.smocked.getTotalElements.will.return.with( Mock__CanonicalTransactionChain.smocked.getTotalElements.will.return.with(
batch.length batch.length
) )
await OVM_StateCommitmentChain.appendStateBatch(batch, 0) await StateCommitmentChain.appendStateBatch(batch, 0)
}) })
it('should return the number of inserted batch elements', async () => { it('should return the number of inserted batch elements', async () => {
expect(await OVM_StateCommitmentChain.getTotalElements()).to.equal(64) expect(await StateCommitmentChain.getTotalElements()).to.equal(64)
}) })
}) })
describe('when 32 batch elements have been inserted in each of two batches', () => { describe('when 32 batch elements have been inserted in each of two batches', () => {
beforeEach(async () => { beforeEach(async () => {
const batch = Array(32).fill(NON_NULL_BYTES32) const batch = Array(32).fill(NON_NULL_BYTES32)
Mock__OVM_CanonicalTransactionChain.smocked.getTotalElements.will.return.with( Mock__CanonicalTransactionChain.smocked.getTotalElements.will.return.with(
batch.length * 2 batch.length * 2
) )
await OVM_StateCommitmentChain.appendStateBatch(batch, 0) await StateCommitmentChain.appendStateBatch(batch, 0)
await OVM_StateCommitmentChain.appendStateBatch(batch, 32) await StateCommitmentChain.appendStateBatch(batch, 32)
}) })
it('should return the number of inserted batch elements', async () => { it('should return the number of inserted batch elements', async () => {
expect(await OVM_StateCommitmentChain.getTotalElements()).to.equal(64) expect(await StateCommitmentChain.getTotalElements()).to.equal(64)
}) })
}) })
}) })
...@@ -321,38 +321,38 @@ describe('OVM_StateCommitmentChain', () => { ...@@ -321,38 +321,38 @@ describe('OVM_StateCommitmentChain', () => {
describe('getTotalBatches()', () => { describe('getTotalBatches()', () => {
describe('when no batches have been inserted', () => { describe('when no batches have been inserted', () => {
it('should return zero', async () => { it('should return zero', async () => {
expect(await OVM_StateCommitmentChain.getTotalBatches()).to.equal(0) expect(await StateCommitmentChain.getTotalBatches()).to.equal(0)
}) })
}) })
describe('when one batch has been inserted', () => { describe('when one batch has been inserted', () => {
beforeEach(async () => { beforeEach(async () => {
const batch = [NON_NULL_BYTES32] const batch = [NON_NULL_BYTES32]
Mock__OVM_CanonicalTransactionChain.smocked.getTotalElements.will.return.with( Mock__CanonicalTransactionChain.smocked.getTotalElements.will.return.with(
batch.length batch.length
) )
await OVM_StateCommitmentChain.appendStateBatch(batch, 0) await StateCommitmentChain.appendStateBatch(batch, 0)
}) })
it('should return the number of inserted batch elements', async () => { it('should return the number of inserted batch elements', async () => {
expect(await OVM_StateCommitmentChain.getTotalBatches()).to.equal(1) expect(await StateCommitmentChain.getTotalBatches()).to.equal(1)
}) })
}) })
describe('when 8 batches have been inserted', () => { describe('when 8 batches have been inserted', () => {
beforeEach(async () => { beforeEach(async () => {
const batch = [NON_NULL_BYTES32] const batch = [NON_NULL_BYTES32]
Mock__OVM_CanonicalTransactionChain.smocked.getTotalElements.will.return.with( Mock__CanonicalTransactionChain.smocked.getTotalElements.will.return.with(
batch.length * 8 batch.length * 8
) )
for (let i = 0; i < 8; i++) { for (let i = 0; i < 8; i++) {
await OVM_StateCommitmentChain.appendStateBatch(batch, i) await StateCommitmentChain.appendStateBatch(batch, i)
} }
}) })
it('should return the number of inserted batch elements', async () => { it('should return the number of inserted batch elements', async () => {
expect(await OVM_StateCommitmentChain.getTotalBatches()).to.equal(8) expect(await StateCommitmentChain.getTotalBatches()).to.equal(8)
}) })
}) })
}) })
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
The Optimistic Ethereum Data Transport Layer is a long-running software service (written in TypeScript) designed to reliably index Optimistic Ethereum transaction data from Layer 1 (Ethereum). Specifically, this service indexes: The Optimistic Ethereum Data Transport Layer is a long-running software service (written in TypeScript) designed to reliably index Optimistic Ethereum transaction data from Layer 1 (Ethereum). Specifically, this service indexes:
* Transactions that have been enqueued for submission to the CanonicalTransactionChain via [`enqueue`](https://github.com/ethereum-optimism/contracts-v2/blob/13b7deef60f773241723ea874fc6e81b4003b164/contracts/optimistic-ethereum/OVM/chain/OVM_CanonicalTransactionChain.sol#L225-L231). * Transactions that have been enqueued for submission to the CanonicalTransactionChain via [`enqueue`](https://github.com/ethereum-optimism/contracts-v2/blob/13b7deef60f773241723ea874fc6e81b4003b164/contracts/optimistic-ethereum/OVM/chain/CanonicalTransactionChain.sol#L225-L231).
* Transactions that have been included in the CanonicalTransactionChain via [`appendQueueBatch`](https://github.com/ethereum-optimism/contracts-v2/blob/13b7deef60f773241723ea874fc6e81b4003b164/contracts/optimistic-ethereum/OVM/chain/OVM_CanonicalTransactionChain.sol#L302-L306) or [`appendSequencerBatch`](https://github.com/ethereum-optimism/contracts-v2/blob/13b7deef60f773241723ea874fc6e81b4003b164/contracts/optimistic-ethereum/OVM/chain/OVM_CanonicalTransactionChain.sol#L352-L354). * Transactions that have been included in the CanonicalTransactionChain via [`appendQueueBatch`](https://github.com/ethereum-optimism/contracts-v2/blob/13b7deef60f773241723ea874fc6e81b4003b164/contracts/optimistic-ethereum/OVM/chain/CanonicalTransactionChain.sol#L302-L306) or [`appendSequencerBatch`](https://github.com/ethereum-optimism/contracts-v2/blob/13b7deef60f773241723ea874fc6e81b4003b164/contracts/optimistic-ethereum/OVM/chain/CanonicalTransactionChain.sol#L352-L354).
* State roots (transaction results) that have been published to the StateCommitmentChain via [`appendStateBatch`](https://github.com/ethereum-optimism/contracts-v2/blob/13b7deef60f773241723ea874fc6e81b4003b164/contracts/optimistic-ethereum/OVM/chain/OVM_StateCommitmentChain.sol#L127-L132). * State roots (transaction results) that have been published to the StateCommitmentChain via [`appendStateBatch`](https://github.com/ethereum-optimism/contracts-v2/blob/13b7deef60f773241723ea874fc6e81b4003b164/contracts/optimistic-ethereum/OVM/chain/OVM_StateCommitmentChain.sol#L127-L132).
## How does it work? ## How does it work?
......
...@@ -36,15 +36,15 @@ export const handleEventsSequencerBatchAppended: EventHandlerSet< ...@@ -36,15 +36,15 @@ export const handleEventsSequencerBatchAppended: EventHandlerSet<
// TODO: We need to update our events so that we actually have enough information to parse this // TODO: We need to update our events so that we actually have enough information to parse this
// batch without having to pull out this extra event. For the meantime, we need to find this // batch without having to pull out this extra event. For the meantime, we need to find this
// "TransactonBatchAppended" event to get the rest of the data. // "TransactonBatchAppended" event to get the rest of the data.
const OVM_CanonicalTransactionChain = getContractFactory( const CanonicalTransactionChain = getContractFactory(
'OVM_CanonicalTransactionChain' 'CanonicalTransactionChain'
) )
.attach(event.address) .attach(event.address)
.connect(l1RpcProvider) .connect(l1RpcProvider)
const batchSubmissionEvent = ( const batchSubmissionEvent = (
await OVM_CanonicalTransactionChain.queryFilter( await CanonicalTransactionChain.queryFilter(
OVM_CanonicalTransactionChain.filters.TransactionBatchAppended(), CanonicalTransactionChain.filters.TransactionBatchAppended(),
eventBlock.number, eventBlock.number,
eventBlock.number eventBlock.number
) )
......
...@@ -32,7 +32,7 @@ export const handleEventsStateBatchAppended: EventHandlerSet< ...@@ -32,7 +32,7 @@ export const handleEventsStateBatchAppended: EventHandlerSet<
}, },
parseEvent: (event, extraData) => { parseEvent: (event, extraData) => {
const stateRoots = getContractFactory( const stateRoots = getContractFactory(
'OVM_StateCommitmentChain' 'StateCommitmentChain'
).interface.decodeFunctionData( ).interface.decodeFunctionData(
'appendStateBatch', 'appendStateBatch',
extraData.l1TransactionData extraData.l1TransactionData
......
...@@ -170,7 +170,7 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> { ...@@ -170,7 +170,7 @@ 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 = const totalElements =
await this.state.contracts.OVM_CanonicalTransactionChain.getTotalElements() await this.state.contracts.CanonicalTransactionChain.getTotalElements()
if (totalElements > 0) { if (totalElements > 0) {
await this.state.db.putHighestL2BlockNumber(totalElements - 1) await this.state.db.putHighestL2BlockNumber(totalElements - 1)
} }
...@@ -207,7 +207,7 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> { ...@@ -207,7 +207,7 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> {
// using Promise.all if necessary, but I don't see a good reason to do so unless parsing is // using Promise.all if necessary, but I don't see a good reason to do so unless parsing is
// really, really slow for all event types. // really, really slow for all event types.
await this._syncEvents( await this._syncEvents(
'OVM_CanonicalTransactionChain', 'CanonicalTransactionChain',
'TransactionEnqueued', 'TransactionEnqueued',
highestSyncedL1Block, highestSyncedL1Block,
targetL1Block, targetL1Block,
...@@ -215,7 +215,7 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> { ...@@ -215,7 +215,7 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> {
) )
await this._syncEvents( await this._syncEvents(
'OVM_CanonicalTransactionChain', 'CanonicalTransactionChain',
'SequencerBatchAppended', 'SequencerBatchAppended',
highestSyncedL1Block, highestSyncedL1Block,
targetL1Block, targetL1Block,
...@@ -223,7 +223,7 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> { ...@@ -223,7 +223,7 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> {
) )
await this._syncEvents( await this._syncEvents(
'OVM_StateCommitmentChain', 'StateCommitmentChain',
'StateBatchAppended', 'StateBatchAppended',
highestSyncedL1Block, highestSyncedL1Block,
targetL1Block, targetL1Block,
......
...@@ -30,8 +30,8 @@ export const loadProxyFromManager = async ( ...@@ -30,8 +30,8 @@ export const loadProxyFromManager = async (
export interface OptimismContracts { export interface OptimismContracts {
Lib_AddressManager: Contract Lib_AddressManager: Contract
OVM_StateCommitmentChain: Contract StateCommitmentChain: Contract
OVM_CanonicalTransactionChain: Contract CanonicalTransactionChain: Contract
} }
export const loadOptimismContracts = async ( export const loadOptimismContracts = async (
...@@ -47,12 +47,12 @@ export const loadOptimismContracts = async ( ...@@ -47,12 +47,12 @@ export const loadOptimismContracts = async (
const inputs = [ const inputs = [
{ {
name: 'OVM_StateCommitmentChain', name: 'StateCommitmentChain',
interface: 'iOVM_StateCommitmentChain', interface: 'IStateCommitmentChain',
}, },
{ {
name: 'OVM_CanonicalTransactionChain', name: 'CanonicalTransactionChain',
interface: 'iOVM_CanonicalTransactionChain', interface: 'ICanonicalTransactionChain',
}, },
] ]
......
...@@ -5,7 +5,7 @@ import { expect } from '../../../../setup' ...@@ -5,7 +5,7 @@ import { expect } from '../../../../setup'
import { handleEventsSequencerBatchAppended } from '../../../../../src/services/l1-ingestion/handlers/sequencer-batch-appended' import { handleEventsSequencerBatchAppended } from '../../../../../src/services/l1-ingestion/handlers/sequencer-batch-appended'
import { SequencerBatchAppendedExtraData } from '../../../../../src/types' import { SequencerBatchAppendedExtraData } from '../../../../../src/types'
describe('Event Handlers: OVM_CanonicalTransactionChain.SequencerBatchAppended', () => { describe('Event Handlers: CanonicalTransactionChain.SequencerBatchAppended', () => {
describe('handleEventsSequencerBatchAppended.parseEvent', () => { describe('handleEventsSequencerBatchAppended.parseEvent', () => {
// This tests the behavior of parsing a real mainnet transaction, // This tests the behavior of parsing a real mainnet transaction,
// so it will break if the encoding scheme changes. // so it will break if the encoding scheme changes.
......
...@@ -9,7 +9,7 @@ import { handleEventsStateBatchAppended } from '../../../../../src/services/l1-i ...@@ -9,7 +9,7 @@ import { handleEventsStateBatchAppended } from '../../../../../src/services/l1-i
import { StateBatchAppendedExtraData } from '../../../../../src/types' import { StateBatchAppendedExtraData } from '../../../../../src/types'
import { l1StateBatchData } from '../../../examples/l1-data' import { l1StateBatchData } from '../../../examples/l1-data'
describe('Event Handlers: OVM_CanonicalTransactionChain.StateBatchAppended', () => { describe('Event Handlers: CanonicalTransactionChain.StateBatchAppended', () => {
describe('getExtraData', () => { describe('getExtraData', () => {
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
......
...@@ -8,7 +8,7 @@ import { handleEventsTransactionEnqueued } from '../../../../../src/services/l1- ...@@ -8,7 +8,7 @@ import { handleEventsTransactionEnqueued } from '../../../../../src/services/l1-
const MAX_ITERATIONS = 128 const MAX_ITERATIONS = 128
describe('Event Handlers: OVM_CanonicalTransactionChain.TransactionEnqueued', () => { describe('Event Handlers: CanonicalTransactionChain.TransactionEnqueued', () => {
describe('getExtraData', () => { describe('getExtraData', () => {
it('should return null', async () => { it('should return null', async () => {
const output1 = await handleEventsTransactionEnqueued.getExtraData() const output1 = await handleEventsTransactionEnqueued.getExtraData()
......
...@@ -26,7 +26,7 @@ import { getMessagesAndProofsForL2Transaction } from '@eth-optimism/message-rela ...@@ -26,7 +26,7 @@ import { getMessagesAndProofsForL2Transaction } from '@eth-optimism/message-rela
const main = async () => { const main = async () => {
const l1RpcProviderUrl = 'https://layer1.endpoint' const l1RpcProviderUrl = 'https://layer1.endpoint'
const l2RpcProviderUrl = 'https://layer2.endpoint' const l2RpcProviderUrl = 'https://layer2.endpoint'
const l1StateCommitmentChainAddress = 'address of OVM_StateCommitmentChain from deployments page' const l1StateCommitmentChainAddress = 'address of StateCommitmentChain from deployments page'
const l2CrossDomainMessengerAddress = 'address of L2CrossDomainMessenger from deployments page' const l2CrossDomainMessengerAddress = 'address of L2CrossDomainMessenger from deployments page'
const l2TransactionHash = 'hash of the transaction with messages to relay' const l2TransactionHash = 'hash of the transaction with messages to relay'
......
...@@ -131,7 +131,7 @@ export const getStateBatchAppendedEventByTransactionIndex = async ( ...@@ -131,7 +131,7 @@ export const getStateBatchAppendedEventByTransactionIndex = async (
): Promise<ethers.Event | null> => { ): Promise<ethers.Event | null> => {
const l1StateCommitmentChain = new ethers.Contract( const l1StateCommitmentChain = new ethers.Contract(
l1StateCommitmentChainAddress, l1StateCommitmentChainAddress,
getContractInterface('OVM_StateCommitmentChain'), getContractInterface('StateCommitmentChain'),
l1RpcProvider l1RpcProvider
) )
...@@ -213,7 +213,7 @@ export const getStateRootBatchByTransactionIndex = async ( ...@@ -213,7 +213,7 @@ export const getStateRootBatchByTransactionIndex = async (
): Promise<StateRootBatch | null> => { ): Promise<StateRootBatch | null> => {
const l1StateCommitmentChain = new ethers.Contract( const l1StateCommitmentChain = new ethers.Contract(
l1StateCommitmentChainAddress, l1StateCommitmentChainAddress,
getContractInterface('OVM_StateCommitmentChain'), getContractInterface('StateCommitmentChain'),
l1RpcProvider l1RpcProvider
) )
......
...@@ -72,7 +72,7 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> { ...@@ -72,7 +72,7 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> {
lastQueriedL1Block: number lastQueriedL1Block: number
eventCache: ethers.Event[] eventCache: ethers.Event[]
Lib_AddressManager: Contract Lib_AddressManager: Contract
OVM_StateCommitmentChain: Contract StateCommitmentChain: Contract
L1CrossDomainMessenger: Contract L1CrossDomainMessenger: Contract
L2CrossDomainMessenger: Contract L2CrossDomainMessenger: Contract
OVM_L2ToL1MessagePasser: Contract OVM_L2ToL1MessagePasser: Contract
...@@ -98,14 +98,14 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> { ...@@ -98,14 +98,14 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> {
this.options.l1RpcProvider this.options.l1RpcProvider
) )
this.logger.info('Connecting to OVM_StateCommitmentChain...') this.logger.info('Connecting to StateCommitmentChain...')
this.state.OVM_StateCommitmentChain = await loadContractFromManager({ this.state.StateCommitmentChain = await loadContractFromManager({
name: 'OVM_StateCommitmentChain', name: 'StateCommitmentChain',
Lib_AddressManager: this.state.Lib_AddressManager, Lib_AddressManager: this.state.Lib_AddressManager,
provider: this.options.l1RpcProvider, provider: this.options.l1RpcProvider,
}) })
this.logger.info('Connected to OVM_StateCommitmentChain', { this.logger.info('Connected to StateCommitmentChain', {
address: this.state.OVM_StateCommitmentChain.address, address: this.state.StateCommitmentChain.address,
}) })
this.logger.info('Connecting to L1CrossDomainMessenger...') this.logger.info('Connecting to L1CrossDomainMessenger...')
...@@ -307,8 +307,8 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> { ...@@ -307,8 +307,8 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> {
}) })
const events: ethers.Event[] = const events: ethers.Event[] =
await this.state.OVM_StateCommitmentChain.queryFilter( await this.state.StateCommitmentChain.queryFilter(
this.state.OVM_StateCommitmentChain.filters.StateBatchAppended(), this.state.StateCommitmentChain.filters.StateBatchAppended(),
startingBlock, startingBlock,
startingBlock + this.options.getLogsInterval startingBlock + this.options.getLogsInterval
) )
...@@ -333,7 +333,7 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> { ...@@ -333,7 +333,7 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> {
) )
const [stateRoots] = const [stateRoots] =
this.state.OVM_StateCommitmentChain.interface.decodeFunctionData( this.state.StateCommitmentChain.interface.decodeFunctionData(
'appendStateBatch', 'appendStateBatch',
transaction.data transaction.data
) )
...@@ -361,7 +361,7 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> { ...@@ -361,7 +361,7 @@ export class MessageRelayerService extends BaseService<MessageRelayerOptions> {
this.logger.info('Got state batch header', { header }) this.logger.info('Got state batch header', { header })
} }
return !(await this.state.OVM_StateCommitmentChain.insideFraudProofWindow( return !(await this.state.StateCommitmentChain.insideFraudProofWindow(
header.batch header.batch
)) ))
} }
......
...@@ -37,12 +37,12 @@ describe('relay transaction generation functions', () => { ...@@ -37,12 +37,12 @@ describe('relay transaction generation functions', () => {
let StateCommitmentChain: Contract let StateCommitmentChain: Contract
beforeEach(async () => { beforeEach(async () => {
const factory1 = getContractFactory('Lib_AddressManager') const factory1 = getContractFactory('Lib_AddressManager')
const factory2 = getContractFactory('OVM_ChainStorageContainer') const factory2 = getContractFactory('ChainStorageContainer')
const factory3 = getContractFactory('OVM_StateCommitmentChain') const factory3 = getContractFactory('StateCommitmentChain')
const mockBondManager = await smockit(getContractFactory('OVM_BondManager')) const mockBondManager = await smockit(getContractFactory('OVM_BondManager'))
const mockCanonicalTransactionChain = await smockit( const mockCanonicalTransactionChain = await smockit(
getContractFactory('OVM_CanonicalTransactionChain') getContractFactory('CanonicalTransactionChain')
) )
mockBondManager.smocked.isCollateralized.will.return.with(true) mockBondManager.smocked.isCollateralized.will.return.with(true)
...@@ -53,25 +53,25 @@ describe('relay transaction generation functions', () => { ...@@ -53,25 +53,25 @@ describe('relay transaction generation functions', () => {
const AddressManager = await factory1.connect(signer1).deploy() const AddressManager = await factory1.connect(signer1).deploy()
const ChainStorageContainer = await factory2 const ChainStorageContainer = await factory2
.connect(signer1) .connect(signer1)
.deploy(AddressManager.address, 'OVM_StateCommitmentChain') .deploy(AddressManager.address, 'StateCommitmentChain')
StateCommitmentChain = await factory3 StateCommitmentChain = await factory3
.connect(signer1) .connect(signer1)
.deploy(AddressManager.address, 0, 0) .deploy(AddressManager.address, 0, 0)
await AddressManager.setAddress( await AddressManager.setAddress(
'OVM_ChainStorageContainer-SCC-batches', 'ChainStorageContainer-SCC-batches',
ChainStorageContainer.address ChainStorageContainer.address
) )
await AddressManager.setAddress( await AddressManager.setAddress(
'OVM_StateCommitmentChain', 'StateCommitmentChain',
StateCommitmentChain.address StateCommitmentChain.address
) )
await AddressManager.setAddress('OVM_BondManager', mockBondManager.address) await AddressManager.setAddress('OVM_BondManager', mockBondManager.address)
await AddressManager.setAddress( await AddressManager.setAddress(
'OVM_CanonicalTransactionChain', 'CanonicalTransactionChain',
mockCanonicalTransactionChain.address mockCanonicalTransactionChain.address
) )
}) })
......
...@@ -65,14 +65,14 @@ We need to retrieve the following information reliably: ...@@ -65,14 +65,14 @@ We need to retrieve the following information reliably:
All relevant data can be retrieved by parsing data from the following functions: All relevant data can be retrieved by parsing data from the following functions:
- `OVM_CanonicalTransactionChain.enqueue` - `CanonicalTransactionChain.enqueue`
- `OVM_CanonicalTransactionChain.appendQueueBatch` - `CanonicalTransactionChain.appendQueueBatch`
- `OVM_CanonicalTransactionChain.appendSequencerBatch` - `CanonicalTransactionChain.appendSequencerBatch`
- `OVM_StateCommitmentChain.appendStateBatch` - `StateCommitmentChain.appendStateBatch`
#### Enqueued Transactions #### Enqueued Transactions
Transactions are "enqueued" when users make calls to `OVM_CanonicalTransactionChain.enqueue`. Transactions are "enqueued" when users make calls to `CanonicalTransactionChain.enqueue`.
Calls to this function can be detected by searching for [`TransactionEnqueued`](#transactionenqueued) events. Calls to this function can be detected by searching for [`TransactionEnqueued`](#transactionenqueued) events.
All relevant transaction data can be pulled out of the event, here's a pseudocode function for doing so: All relevant transaction data can be pulled out of the event, here's a pseudocode function for doing so:
......
...@@ -28,7 +28,7 @@ There are two 'low level' bridge contracts (the L1 and L2 Cross Domain Messenger ...@@ -28,7 +28,7 @@ There are two 'low level' bridge contracts (the L1 and L2 Cross Domain Messenger
- The validity of the message is confirmed by the following functions: - The validity of the message is confirmed by the following functions:
- `_verifyStateRootProof()`: - `_verifyStateRootProof()`:
- checks that the fraud proof window has closed for the batch to which the transaction belongs. - checks that the fraud proof window has closed for the batch to which the transaction belongs.
- checks that the batch is stored in the `OVM_ChainStorageContainer`. - checks that the batch is stored in the `ChainStorageContainer`.
- `_verifyStorageProof()`: - `_verifyStorageProof()`:
- checks the proof to confirm that the message data provided is in the `OVM_L2ToL1MessagePasser.sentMessages` mapping - checks the proof to confirm that the message data provided is in the `OVM_L2ToL1MessagePasser.sentMessages` mapping
- checks that this transaction has not already been written to the `successfulMessages` mapping. - checks that this transaction has not already been written to the `successfulMessages` mapping.
......
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