Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions packages/batch-submitter/src/batch-submitter/batch-submitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
} from '@ethersproject/abstract-provider'
import { Logger } from '@eth-optimism/core-utils'
import { OptimismProvider } from '@eth-optimism/provider'
import { getContractFactory } from '@eth-optimism/contracts'

/* Internal Imports */
import { Address, Bytes32 } from '../coders'
Expand Down Expand Up @@ -43,6 +44,7 @@ export abstract class BatchSubmitter {
readonly maxBatchSize: number,
readonly numConfirmations: number,
readonly finalityConfirmations: number,
readonly pullFromAddressManager: boolean,
readonly log: Logger
) {}

Expand Down Expand Up @@ -82,6 +84,30 @@ export abstract class BatchSubmitter {
return this.l2Provider.send('eth_chainId', [])
}

protected async _getChainAddresses(
info: RollupInfo
): Promise<{ ctcAddress: string; sccAddress: string }> {
if (!this.pullFromAddressManager) {
return {
ctcAddress: info.addresses.canonicalTransactionChain,
sccAddress: info.addresses.stateCommitmentChain,
}
}
const addressManager = (
await getContractFactory('Lib_AddressManager', this.signer)
).attach(info.addresses.addressResolver)
const sccAddress = await addressManager.getAddress(
'OVM_StateCommitmentChain'
)
const ctcAddress = await addressManager.getAddress(
'OVM_CanonicalTransactionChain'
)
return {
ctcAddress,
sccAddress,
}
}

protected async _submitAndLogTx(
txPromise: Promise<TransactionResponse>,
successMessage: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ export class StateBatchSubmitter extends BatchSubmitter {
process.exit(1)
}
this.syncing = info.syncing
const sccAddress = info.addresses.stateCommitmentChain
const ctcAddress = info.addresses.canonicalTransactionChain
const addrs = await this._getChainAddresses(info)
const sccAddress = addrs.sccAddress
const ctcAddress = addrs.ctcAddress

if (
typeof this.chainContract !== 'undefined' &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
process.exit(1)
}
this.syncing = info.syncing
const ctcAddress = info.addresses.canonicalTransactionChain
const addrs = await this._getChainAddresses(info)
const ctcAddress = addrs.ctcAddress

if (
typeof this.chainContract !== 'undefined' &&
Expand Down
2 changes: 2 additions & 0 deletions packages/batch-submitter/src/exec/run-batch-submitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const run = async () => {
parseInt(requiredEnvVars.MAX_BATCH_SIZE, 10),
parseInt(requiredEnvVars.NUM_CONFIRMATIONS, 10),
parseInt(requiredEnvVars.NUM_CONFIRMATIONS, 10),
true,
getLogger(TX_BATCH_SUBMITTER_LOG_TAG)
)

Expand All @@ -88,6 +89,7 @@ export const run = async () => {
parseInt(requiredEnvVars.MAX_BATCH_SIZE, 10),
parseInt(requiredEnvVars.NUM_CONFIRMATIONS, 10),
parseInt(requiredEnvVars.FINALITY_CONFIRMATIONS, 10),
true,
getLogger(STATE_BATCH_SUBMITTER_LOG_TAG)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ describe('TransactionBatchSubmitter', () => {
10,
1,
1,
false,
getLogger(TX_BATCH_SUBMITTER_LOG_TAG)
)
})
Expand Down