Commit 962e31b1 authored by Annie Ke's avatar Annie Ke Committed by GitHub

fix: l1 block number logic debug and logging (#460)

* fix: l1 block number logic debug and logging

* chore: add changeset
parent c6457e16
---
"@eth-optimism/batch-submitter": patch
---
removed unused l1 block number logic, added debug logging to batch submitter
...@@ -42,7 +42,6 @@ export class TransactionBatchSubmitter extends BatchSubmitter { ...@@ -42,7 +42,6 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
protected chainContract: CanonicalTransactionChainContract protected chainContract: CanonicalTransactionChainContract
protected l2ChainId: number protected l2ChainId: number
protected syncing: boolean protected syncing: boolean
protected lastL1BlockNumber: number
private disableQueueBatchAppend: boolean private disableQueueBatchAppend: boolean
private autoFixBatchOptions: AutoFixBatchOptions private autoFixBatchOptions: AutoFixBatchOptions
...@@ -173,36 +172,6 @@ export class TransactionBatchSubmitter extends BatchSubmitter { ...@@ -173,36 +172,6 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
return return
} }
// TODO: Remove this function and use geth for lastL1BlockNumber!
private async _updateLastL1BlockNumber() {
this.log.warn('Calling _updateLastL1BlockNumber...')
const pendingQueueElements = await this.chainContract.getNumPendingQueueElements()
if (pendingQueueElements !== 0) {
const nextQueueIndex = await this.chainContract.getNextQueueIndex()
const queueElement = await this.chainContract.getQueueElement(
nextQueueIndex
)
this.lastL1BlockNumber = queueElement[2] // The block number is the 3rd element returned in the array....
} else {
const curBlockNum = await this.chainContract.provider.getBlockNumber()
if (!this.lastL1BlockNumber) {
// Set the block number to the current l1BlockNumber
this.lastL1BlockNumber = curBlockNum
} else {
if (curBlockNum - this.lastL1BlockNumber > 30) {
// If the lastL1BlockNumber is too old, then set it to a recent
// block number. (10 blocks ago to prevent reorgs)
this.lastL1BlockNumber = curBlockNum - 10
}
}
}
this.log.debug('Set lastL1BlockNumber', {
lastL1BlockNumber: this.lastL1BlockNumber,
})
}
public async _getBatchStartAndEnd(): Promise<Range> { public async _getBatchStartAndEnd(): Promise<Range> {
this.log.info( this.log.info(
'Getting batch start and end for transaction batch submitter...' 'Getting batch start and end for transaction batch submitter...'
...@@ -274,8 +243,10 @@ export class TransactionBatchSubmitter extends BatchSubmitter { ...@@ -274,8 +243,10 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
if (!wasBatchTruncated && !this._shouldSubmitBatch(batchSizeInBytes)) { if (!wasBatchTruncated && !this._shouldSubmitBatch(batchSizeInBytes)) {
return return
} }
const l1tipHeight = await this.signer.provider.getBlockNumber()
this.log.debug('Submitting batch.', { this.log.debug('Submitting batch.', {
calldata: batchParams, calldata: batchParams,
l1tipHeight,
}) })
const nonce = await this.signer.getTransactionCount() const nonce = await this.signer.getTransactionCount()
...@@ -308,9 +279,6 @@ export class TransactionBatchSubmitter extends BatchSubmitter { ...@@ -308,9 +279,6 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
endBlock: number endBlock: number
): Promise<[AppendSequencerBatchParams, boolean]> { ): Promise<[AppendSequencerBatchParams, boolean]> {
// Get all L2 BatchElements for the given range // Get all L2 BatchElements for the given range
// For now we need to update our internal `lastL1BlockNumber` value
// which is used when submitting batches.
this._updateLastL1BlockNumber() // TODO: Remove this
const blockRange = endBlock - startBlock const blockRange = endBlock - startBlock
let batch: Batch = await bPromise.map( let batch: Batch = await bPromise.map(
[...Array(blockRange).keys()], [...Array(blockRange).keys()],
...@@ -802,9 +770,11 @@ export class TransactionBatchSubmitter extends BatchSubmitter { ...@@ -802,9 +770,11 @@ export class TransactionBatchSubmitter extends BatchSubmitter {
block.transactions[0].txType = txTypePlainText[block.transactions[0].txType] block.transactions[0].txType = txTypePlainText[block.transactions[0].txType]
block.transactions[0].queueOrigin = block.transactions[0].queueOrigin =
queueOriginPlainText[block.transactions[0].queueOrigin] queueOriginPlainText[block.transactions[0].queueOrigin]
// For now just set the l1BlockNumber based on the current l1 block number
if (!block.transactions[0].l1BlockNumber) { if (!block.transactions[0].l1BlockNumber) {
block.transactions[0].l1BlockNumber = this.lastL1BlockNumber this.log.error('Current block missing l1BlockNumber', {
blockNumber,
block,
})
} }
return block return block
......
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