diff --git a/src/lib/message/L2ToL1Message.ts b/src/lib/message/L2ToL1Message.ts index d9a1651bdc..882ed0dfa1 100644 --- a/src/lib/message/L2ToL1Message.ts +++ b/src/lib/message/L2ToL1Message.ts @@ -177,7 +177,7 @@ export class ChildToParentMessage { } if (nitroFilter.fromBlock !== nitroFilter.toBlock) { logQueries.push( - nitro.L2ToL1MessageNitro.getL2ToL1Events( + nitro.ChildToParentChainMessageNitro.getChildToParentChainEvents( childChainProvider, nitroFilter, position, @@ -196,7 +196,7 @@ export class ChildToParentMessage { */ export class ChildToParentMessageReader extends ChildToParentMessage { private readonly classicReader?: classic.L2ToL1MessageReaderClassic - private readonly nitroReader?: nitro.L2ToL1MessageReaderNitro + private readonly nitroReader?: nitro.ChildToParentChainMessageReaderNitro constructor( protected readonly parentChainProvider: Provider, @@ -210,7 +210,7 @@ export class ChildToParentMessageReader extends ChildToParentMessage { event.indexInBatch ) } else { - this.nitroReader = new nitro.L2ToL1MessageReaderNitro( + this.nitroReader = new nitro.ChildToParentChainMessageReaderNitro( parentChainProvider, event ) @@ -282,7 +282,7 @@ export class ChildToParentMessageReader extends ChildToParentMessage { */ export class ChildToParentMessageWriter extends ChildToParentMessageReader { private readonly classicWriter?: classic.L2ToL1MessageWriterClassic - private readonly nitroWriter?: nitro.L2ToL1MessageWriterNitro + private readonly nitroWriter?: nitro.ChildToParentChainMessageWriterNitro /** * Instantiates a new `ChildToParentMessageWriter` object. @@ -306,7 +306,7 @@ export class ChildToParentMessageWriter extends ChildToParentMessageReader { parentChainProvider ) } else { - this.nitroWriter = new nitro.L2ToL1MessageWriterNitro( + this.nitroWriter = new nitro.ChildToParentChainMessageWriterNitro( parentChainSigner, event, parentChainProvider diff --git a/src/lib/message/L2ToL1MessageNitro.ts b/src/lib/message/L2ToL1MessageNitro.ts index e1651e284a..d6e082ea1f 100644 --- a/src/lib/message/L2ToL1MessageNitro.ts +++ b/src/lib/message/L2ToL1MessageNitro.ts @@ -30,7 +30,7 @@ import { RollupUserLogic__factory } from '../abi/factories/RollupUserLogic__fact import { Outbox__factory } from '../abi/factories/Outbox__factory' import { NodeInterface__factory } from '../abi/factories/NodeInterface__factory' -import { L2ToL1TxEvent } from '../abi/ArbSys' +import { L2ToL1TxEvent as ChildToParentChainTxEvent } from '../abi/ArbSys' import { ContractTransaction, Overrides } from 'ethers' import { Mutex } from 'async-mutex' import { EventFetcher, FetchedEvent } from '../utils/eventFetcher' @@ -46,116 +46,133 @@ import { ArbitrumProvider } from '../utils/arbProvider' import { ArbBlock } from '../dataEntities/rpc' import { JsonRpcProvider } from '@ethersproject/providers' import { EventArgs } from '../dataEntities/event' -import { L2ToL1MessageStatus } from '../dataEntities/message' +import { L2ToL1MessageStatus as ChildToParentChainMessageStatus } from '../dataEntities/message' /** * Conditional type for Signer or Provider. If T is of type Provider - * then L2ToL1MessageReaderOrWriter will be of type L2ToL1MessageReader. - * If T is of type Signer then L2ToL1MessageReaderOrWriter will be of - * type L2ToL1MessageWriter. + * then ChildToParentChainMessageReaderOrWriter will be of type ChildToParentChainMessageReader. + * If T is of type Signer then ChildToParentChainMessageReaderOrWriter will be of + * type ChildToParentChainMessageWriter. */ -export type L2ToL1MessageReaderOrWriterNitro = - T extends Provider ? L2ToL1MessageReaderNitro : L2ToL1MessageWriterNitro +export type ChildToParentChainMessageReaderOrWriterNitro< + T extends SignerOrProvider +> = T extends Provider + ? ChildToParentChainMessageReaderNitro + : ChildToParentChainMessageWriterNitro -// expected number of L1 blocks that it takes for an L2 tx to be included in a L1 assertion +// expected number of parent chain blocks that it takes for a Child chain tx to be included in a parent chain assertion const ASSERTION_CREATED_PADDING = 50 -// expected number of L1 blocks that it takes for a validator to confirm an L1 block after the node deadline is passed +// expected number of parent chain blocks that it takes for a validator to confirm an parent chain block after the node deadline is passed const ASSERTION_CONFIRMED_PADDING = 20 -const l2BlockRangeCache: { [key in string]: (number | undefined)[] } = {} +const childChainBlockRangeCache: { [key in string]: (number | undefined)[] } = + {} const mutex = new Mutex() -function getL2BlockRangeCacheKey({ - l2ChainId, - l1BlockNumber, +function getChildChainBlockRangeCacheKey({ + childChainId, + parentChainBlockNumber, }: { - l2ChainId: number - l1BlockNumber: number + childChainId: number + parentChainBlockNumber: number }) { - return `${l2ChainId}-${l1BlockNumber}` + return `${childChainId}-${parentChainBlockNumber}` } -function setL2BlockRangeCache(key: string, value: (number | undefined)[]) { - l2BlockRangeCache[key] = value +function setChildChainBlockRangeCache( + key: string, + value: (number | undefined)[] +) { + childChainBlockRangeCache[key] = value } async function getBlockRangesForL1BlockWithCache({ - l1Provider, - l2Provider, - forL1Block, + parentProvider, + childProvider, + forParentChainBlock, }: { - l1Provider: JsonRpcProvider - l2Provider: JsonRpcProvider - forL1Block: number + parentProvider: JsonRpcProvider + childProvider: JsonRpcProvider + forParentChainBlock: number }) { - const l2ChainId = (await l2Provider.getNetwork()).chainId - const key = getL2BlockRangeCacheKey({ - l2ChainId, - l1BlockNumber: forL1Block, + const childChainId = (await childProvider.getNetwork()).chainId + const key = getChildChainBlockRangeCacheKey({ + childChainId, + parentChainBlockNumber: forParentChainBlock, }) - if (l2BlockRangeCache[key]) { - return l2BlockRangeCache[key] + if (childChainBlockRangeCache[key]) { + return childChainBlockRangeCache[key] } // implements a lock that only fetches cache once const release = await mutex.acquire() // if cache has been acquired while awaiting the lock - if (l2BlockRangeCache[key]) { + if (childChainBlockRangeCache[key]) { release() - return l2BlockRangeCache[key] + return childChainBlockRangeCache[key] } try { - const l2BlockRange = await getBlockRangesForL1Block({ - forL1Block, - provider: l1Provider, + const childChainBlockRange = await getBlockRangesForL1Block({ + forL1Block: forParentChainBlock, + provider: parentProvider, }) - setL2BlockRangeCache(key, l2BlockRange) + setChildChainBlockRangeCache(key, childChainBlockRange) } finally { release() } - return l2BlockRangeCache[key] + return childChainBlockRangeCache[key] } /** - * Base functionality for nitro L2->L1 messages + * Base functionality for nitro Child->Parent messages */ -export class L2ToL1MessageNitro { - protected constructor(public readonly event: EventArgs) {} +export class ChildToParentChainMessageNitro { + protected constructor( + public readonly event: EventArgs + ) {} /** - * Instantiates a new `L2ToL1MessageWriterNitro` or `L2ToL1MessageReaderNitro` object. + * Instantiates a new `ChildToParentChainMessageWriterNitro` or `ChildToParentChainMessageReaderNitro` object. * - * @param {SignerOrProvider} l1SignerOrProvider Signer or provider to be used for executing or reading the L2-to-L1 message. - * @param {EventArgs} event The event containing the data of the L2-to-L1 message. - * @param {Provider} [l1Provider] Optional. Used to override the Provider which is attached to `l1SignerOrProvider` in case you need more control. This will be a required parameter in a future major version update. + * @param {SignerOrProvider} parentSignerOrProvider Signer or provider to be used for executing or reading the Child-to-Parent message. + * @param {EventArgs} event The event containing the data of the Child-to-Parent message. + * @param {Provider} [parentProvider] Optional. Used to override the Provider which is attached to `parentSignerOrProvider` in case you need more control. This will be a required parameter in a future major version update. */ public static fromEvent( - l1SignerOrProvider: T, - event: EventArgs, - l1Provider?: Provider - ): L2ToL1MessageReaderOrWriterNitro + parentSignerOrProvider: T, + event: EventArgs, + parentProvider?: Provider + ): ChildToParentChainMessageReaderOrWriterNitro public static fromEvent( - l1SignerOrProvider: T, - event: EventArgs, - l1Provider?: Provider - ): L2ToL1MessageReaderNitro | L2ToL1MessageWriterNitro { - return SignerProviderUtils.isSigner(l1SignerOrProvider) - ? new L2ToL1MessageWriterNitro(l1SignerOrProvider, event, l1Provider) - : new L2ToL1MessageReaderNitro(l1SignerOrProvider, event) + parentSignerOrProvider: T, + event: EventArgs, + parentProvider?: Provider + ): + | ChildToParentChainMessageReaderNitro + | ChildToParentChainMessageWriterNitro { + return SignerProviderUtils.isSigner(parentSignerOrProvider) + ? new ChildToParentChainMessageWriterNitro( + parentSignerOrProvider, + event, + parentProvider + ) + : new ChildToParentChainMessageReaderNitro(parentSignerOrProvider, event) } - public static async getL2ToL1Events( - l2Provider: Provider, + public static async getChildToParentChainEvents( + childProvider: Provider, filter: { fromBlock: BlockTag; toBlock: BlockTag }, position?: BigNumber, destination?: string, hash?: BigNumber - ): Promise<(EventArgs & { transactionHash: string })[]> { - const eventFetcher = new EventFetcher(l2Provider) + ): Promise< + (EventArgs & { transactionHash: string })[] + > { + const eventFetcher = new EventFetcher(childProvider) return ( await eventFetcher.getEvents( ArbSys__factory, @@ -167,9 +184,9 @@ export class L2ToL1MessageNitro { } /** - * Provides read-only access nitro for l2-to-l1-messages + * Provides read-only access nitro for child-to-parent-messages */ -export class L2ToL1MessageReaderNitro extends L2ToL1MessageNitro { +export class ChildToParentChainMessageReaderNitro extends ChildToParentChainMessageNitro { protected sendRootHash?: string protected sendRootSize?: BigNumber protected sendRootConfirmed?: boolean @@ -177,19 +194,19 @@ export class L2ToL1MessageReaderNitro extends L2ToL1MessageNitro { protected l1BatchNumber?: number constructor( - protected readonly l1Provider: Provider, - event: EventArgs + protected readonly parentProvider: Provider, + event: EventArgs ) { super(event) } - public async getOutboxProof(l2Provider: Provider) { - const { sendRootSize } = await this.getSendProps(l2Provider) + public async getOutboxProof(childProvider: Provider) { + const { sendRootSize } = await this.getSendProps(childProvider) if (!sendRootSize) throw new ArbSdkError('Node not yet created, cannot get proof.') const nodeInterface = NodeInterface__factory.connect( NODE_INTERFACE_ADDRESS, - l2Provider + childProvider ) const outboxProofParams = @@ -204,11 +221,11 @@ export class L2ToL1MessageReaderNitro extends L2ToL1MessageNitro { /** * Check if this message has already been executed in the Outbox */ - protected async hasExecuted(l2Provider: Provider): Promise { - const l2Network = await getChildChain(l2Provider) + protected async hasExecuted(childProvider: Provider): Promise { + const childChain = await getChildChain(childProvider) const outbox = Outbox__factory.connect( - l2Network.ethBridge.outbox, - this.l1Provider + childChain.ethBridge.outbox, + this.parentProvider ) return outbox.callStatic.isSpent(this.event.position) @@ -219,12 +236,14 @@ export class L2ToL1MessageReaderNitro extends L2ToL1MessageNitro { * In order to check if the message has been executed proof info must be provided. * @returns */ - public async status(l2Provider: Provider): Promise { - const { sendRootConfirmed } = await this.getSendProps(l2Provider) - if (!sendRootConfirmed) return L2ToL1MessageStatus.UNCONFIRMED - return (await this.hasExecuted(l2Provider)) - ? L2ToL1MessageStatus.EXECUTED - : L2ToL1MessageStatus.CONFIRMED + public async status( + childProvider: Provider + ): Promise { + const { sendRootConfirmed } = await this.getSendProps(childProvider) + if (!sendRootConfirmed) return ChildToParentChainMessageStatus.UNCONFIRMED + return (await this.hasExecuted(childProvider)) + ? ChildToParentChainMessageStatus.EXECUTED + : ChildToParentChainMessageStatus.CONFIRMED } private parseNodeCreatedAssertion(event: FetchedEvent) { @@ -237,10 +256,10 @@ export class L2ToL1MessageReaderNitro extends L2ToL1MessageNitro { } private async getBlockFromNodeLog( - l2Provider: JsonRpcProvider, + childProvider: JsonRpcProvider, log: FetchedEvent | undefined ) { - const arbitrumProvider = new ArbitrumProvider(l2Provider) + const arbitrumProvider = new ArbitrumProvider(childProvider) if (!log) { console.warn('No NodeCreated events found, defaulting to block 0') @@ -248,42 +267,42 @@ export class L2ToL1MessageReaderNitro extends L2ToL1MessageNitro { } const parsedLog = this.parseNodeCreatedAssertion(log) - const l2Block = await arbitrumProvider.getBlock( + const childChainBlock = await arbitrumProvider.getBlock( parsedLog.afterState.blockHash ) - if (!l2Block) { + if (!childChainBlock) { throw new ArbSdkError( `Block not found. ${parsedLog.afterState.blockHash}` ) } - if (l2Block.sendRoot !== parsedLog.afterState.sendRoot) { + if (childChainBlock.sendRoot !== parsedLog.afterState.sendRoot) { throw new ArbSdkError( - `L2 block send root doesn't match parsed log. ${l2Block.sendRoot} ${parsedLog.afterState.sendRoot}` + `Child chain block send root doesn't match parsed log. ${childChainBlock.sendRoot} ${parsedLog.afterState.sendRoot}` ) } - return l2Block + return childChainBlock } private async getBlockFromNodeNum( rollup: RollupUserLogic, nodeNum: BigNumber, - l2Provider: Provider + childProvider: Provider ): Promise { const { createdAtBlock } = await rollup.getNode(nodeNum) let createdFromBlock = createdAtBlock let createdToBlock = createdAtBlock - // If L1 is Arbitrum, then L2 is an Orbit chain. - if (await isArbitrumChain(this.l1Provider)) { + // If Parent is Arbitrum, then Child is an Orbit chain. + if (await isArbitrumChain(this.parentProvider)) { try { - const l2BlockRange = await getBlockRangesForL1BlockWithCache({ - l1Provider: this.l1Provider as JsonRpcProvider, - l2Provider: l2Provider as JsonRpcProvider, - forL1Block: createdAtBlock.toNumber(), + const childChainBlockRange = await getBlockRangesForL1BlockWithCache({ + parentProvider: this.parentProvider as JsonRpcProvider, + childProvider: childProvider as JsonRpcProvider, + forParentChainBlock: createdAtBlock.toNumber(), }) - const startBlock = l2BlockRange[0] - const endBlock = l2BlockRange[1] + const startBlock = childChainBlockRange[0] + const endBlock = childChainBlockRange[1] if (!startBlock || !endBlock) { throw new Error() } @@ -314,18 +333,18 @@ export class L2ToL1MessageReaderNitro extends L2ToL1MessageNitro { ) return await this.getBlockFromNodeLog( - l2Provider as JsonRpcProvider, + childProvider as JsonRpcProvider, logs[0] ) } - protected async getBatchNumber(l2Provider: Provider) { + protected async getBatchNumber(childProvider: Provider) { if (this.l1BatchNumber == undefined) { // findBatchContainingBlock errors if block number does not exist try { const nodeInterface = NodeInterface__factory.connect( NODE_INTERFACE_ADDRESS, - l2Provider + childProvider ) const res = await nodeInterface.findBatchContainingBlock( this.event.arbBlockNum @@ -339,26 +358,28 @@ export class L2ToL1MessageReaderNitro extends L2ToL1MessageNitro { return this.l1BatchNumber } - protected async getSendProps(l2Provider: Provider) { + protected async getSendProps(childProvider: Provider) { if (!this.sendRootConfirmed) { - const l2Network = await getChildChain(l2Provider) + const childChain = await getChildChain(childProvider) const rollup = RollupUserLogic__factory.connect( - l2Network.ethBridge.rollup, - this.l1Provider + childChain.ethBridge.rollup, + this.parentProvider ) const latestConfirmedNodeNum = await rollup.callStatic.latestConfirmed() - const l2BlockConfirmed = await this.getBlockFromNodeNum( + const childChainBlockConfirmed = await this.getBlockFromNodeNum( rollup, latestConfirmedNodeNum, - l2Provider + childProvider ) - const sendRootSizeConfirmed = BigNumber.from(l2BlockConfirmed.sendCount) + const sendRootSizeConfirmed = BigNumber.from( + childChainBlockConfirmed.sendCount + ) if (sendRootSizeConfirmed.gt(this.event.position)) { this.sendRootSize = sendRootSizeConfirmed - this.sendRootHash = l2BlockConfirmed.sendRoot + this.sendRootHash = childChainBlockConfirmed.sendRoot this.sendRootConfirmed = true } else { // if the node has yet to be confirmed we'll still try to find proof info from unconfirmed nodes @@ -366,16 +387,16 @@ export class L2ToL1MessageReaderNitro extends L2ToL1MessageNitro { if (latestNodeNum.gt(latestConfirmedNodeNum)) { // In rare case latestNodeNum can be equal to latestConfirmedNodeNum // eg immediately after an upgrade, or at genesis, or on a chain where confirmation time = 0 like AnyTrust may have - const l2Block = await this.getBlockFromNodeNum( + const childChainBlock = await this.getBlockFromNodeNum( rollup, latestNodeNum, - l2Provider + childProvider ) - const sendRootSize = BigNumber.from(l2Block.sendCount) + const sendRootSize = BigNumber.from(childChainBlock.sendCount) if (sendRootSize.gt(this.event.position)) { this.sendRootSize = sendRootSize - this.sendRootHash = l2Block.sendRoot + this.sendRootHash = childChainBlock.sendRoot } } } @@ -395,47 +416,47 @@ export class L2ToL1MessageReaderNitro extends L2ToL1MessageNitro { * @returns */ public async waitUntilReadyToExecute( - l2Provider: Provider, + childProvider: Provider, retryDelay = 500 ): Promise { - const status = await this.status(l2Provider) + const status = await this.status(childProvider) if ( - status === L2ToL1MessageStatus.CONFIRMED || - status === L2ToL1MessageStatus.EXECUTED + status === ChildToParentChainMessageStatus.CONFIRMED || + status === ChildToParentChainMessageStatus.EXECUTED ) { return } else { await wait(retryDelay) - await this.waitUntilReadyToExecute(l2Provider, retryDelay) + await this.waitUntilReadyToExecute(childProvider, retryDelay) } } /** - * Estimates the L1 block number in which this L2 to L1 tx will be available for execution. + * Estimates the parent chain block number in which this child chain to parent chain tx will be available for execution. * If the message can or already has been executed, this returns null - * @param l2Provider - * @returns expected L1 block number where the L2 to L1 message will be executable. Returns null if the message can be or already has been executed + * @param childProvider + * @returns expected parent chain block number where the child chain to parent chain message will be executable. Returns null if the message can be or already has been executed */ public async getFirstExecutableBlock( - l2Provider: Provider + childProvider: Provider ): Promise { - const l2Network = await getChildChain(l2Provider) + const childChain = await getChildChain(childProvider) const rollup = RollupUserLogic__factory.connect( - l2Network.ethBridge.rollup, - this.l1Provider + childChain.ethBridge.rollup, + this.parentProvider ) - const status = await this.status(l2Provider) - if (status === L2ToL1MessageStatus.EXECUTED) return null - if (status === L2ToL1MessageStatus.CONFIRMED) return null + const status = await this.status(childProvider) + if (status === ChildToParentChainMessageStatus.EXECUTED) return null + if (status === ChildToParentChainMessageStatus.CONFIRMED) return null // consistency check in case we change the enum in the future - if (status !== L2ToL1MessageStatus.UNCONFIRMED) - throw new ArbSdkError('L2ToL1Msg expected to be unconfirmed') + if (status !== ChildToParentChainMessageStatus.UNCONFIRMED) + throw new ArbSdkError('ChildToParentChainMsg expected to be unconfirmed') - const latestBlock = await this.l1Provider.getBlockNumber() - const eventFetcher = new EventFetcher(this.l1Provider) + const latestBlock = await this.parentProvider.getBlockNumber() + const eventFetcher = new EventFetcher(this.parentProvider) const logs = ( await eventFetcher.getEvents( RollupUserLogic__factory, @@ -443,7 +464,7 @@ export class L2ToL1MessageReaderNitro extends L2ToL1MessageNitro { { fromBlock: Math.max( latestBlock - - BigNumber.from(l2Network.confirmPeriodBlocks) + BigNumber.from(childChain.confirmPeriodBlocks) .add(ASSERTION_CONFIRMED_PADDING) .toNumber(), 0 @@ -454,21 +475,21 @@ export class L2ToL1MessageReaderNitro extends L2ToL1MessageNitro { ) ).sort((a, b) => a.event.nodeNum.toNumber() - b.event.nodeNum.toNumber()) - const lastL2Block = + const lastChildChainBlock = logs.length === 0 ? undefined : await this.getBlockFromNodeLog( - l2Provider as JsonRpcProvider, + childProvider as JsonRpcProvider, logs[logs.length - 1] ) - const lastSendCount = lastL2Block - ? BigNumber.from(lastL2Block.sendCount) + const lastSendCount = lastChildChainBlock + ? BigNumber.from(lastChildChainBlock.sendCount) : BigNumber.from(0) - // here we assume the L2 to L1 tx is actually valid, so the user needs to wait the max time + // here we assume the Child to Parent tx is actually valid, so the user needs to wait the max time // since there isn't a pending node that includes this message yet if (lastSendCount.lte(this.event.position)) - return BigNumber.from(l2Network.confirmPeriodBlocks) + return BigNumber.from(childChain.confirmPeriodBlocks) .add(ASSERTION_CREATED_PADDING) .add(ASSERTION_CONFIRMED_PADDING) .add(latestBlock) @@ -481,11 +502,11 @@ export class L2ToL1MessageReaderNitro extends L2ToL1MessageNitro { while (left <= right) { const mid = Math.floor((left + right) / 2) const log = logs[mid] - const l2Block = await this.getBlockFromNodeLog( - l2Provider as JsonRpcProvider, + const childChainBlock = await this.getBlockFromNodeLog( + childProvider as JsonRpcProvider, log ) - const sendCount = BigNumber.from(l2Block.sendCount) + const sendCount = BigNumber.from(childChainBlock.sendCount) if (sendCount.gt(this.event.position)) { foundLog = log right = mid - 1 @@ -501,45 +522,45 @@ export class L2ToL1MessageReaderNitro extends L2ToL1MessageNitro { } /** - * Provides read and write access for nitro l2-to-l1-messages + * Provides read and write access for nitro child-to-Parent-messages */ -export class L2ToL1MessageWriterNitro extends L2ToL1MessageReaderNitro { +export class ChildToParentChainMessageWriterNitro extends ChildToParentChainMessageReaderNitro { /** - * Instantiates a new `L2ToL1MessageWriterNitro` object. + * Instantiates a new `ChildToParentChainMessageWriterNitro` object. * - * @param {Signer} l1Signer The signer to be used for executing the L2-to-L1 message. - * @param {EventArgs} event The event containing the data of the L2-to-L1 message. - * @param {Provider} [l1Provider] Optional. Used to override the Provider which is attached to `l1Signer` in case you need more control. This will be a required parameter in a future major version update. + * @param {Signer} parentSigner The signer to be used for executing the Child-to-Parent message. + * @param {EventArgs} event The event containing the data of the Child-to-Parent message. + * @param {Provider} [parentProvider] Optional. Used to override the Provider which is attached to `parentSigner` in case you need more control. This will be a required parameter in a future major version update. */ constructor( - private readonly l1Signer: Signer, - event: EventArgs, - l1Provider?: Provider + private readonly parentSigner: Signer, + event: EventArgs, + parentProvider?: Provider ) { - super(l1Provider ?? l1Signer.provider!, event) + super(parentProvider ?? parentSigner.provider!, event) } /** - * Executes the L2ToL1Message on L1. + * Executes the ChildToParentChainMessage on Parent Chain. * Will throw an error if the outbox entry has not been created, which happens when the * corresponding assertion is confirmed. * @returns */ public async execute( - l2Provider: Provider, + childProvider: Provider, overrides?: Overrides ): Promise { - const status = await this.status(l2Provider) - if (status !== L2ToL1MessageStatus.CONFIRMED) { + const status = await this.status(childProvider) + if (status !== ChildToParentChainMessageStatus.CONFIRMED) { throw new ArbSdkError( - `Cannot execute message. Status is: ${status} but must be ${L2ToL1MessageStatus.CONFIRMED}.` + `Cannot execute message. Status is: ${status} but must be ${ChildToParentChainMessageStatus.CONFIRMED}.` ) } - const proof = await this.getOutboxProof(l2Provider) - const l2Network = await getChildChain(l2Provider) + const proof = await this.getOutboxProof(childProvider) + const childChain = await getChildChain(childProvider) const outbox = Outbox__factory.connect( - l2Network.ethBridge.outbox, - this.l1Signer + childChain.ethBridge.outbox, + this.parentSigner ) return await outbox.executeTransaction(