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
5 changes: 5 additions & 0 deletions .changeset/many-lizards-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/data-transport-layer': patch
---

Adds consistency checks for transaction entries in L1 syncing nodes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export type EventName =
| 'TransactionEnqueued'
| 'SequencerBatchAppended'
| 'StateBatchAppended'
| 'SequencerBatchAppendedTransaction'

export class MissingElementError extends Error {
constructor(public name: EventName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,21 @@ export const handleEventsSequencerBatchAppended: EventHandlerSet<
}
}

// Same consistency checks but for transaction entries.
if (
entry.transactionEntries.length > 0 &&
entry.transactionEntries[0].index > 0
) {
const prevTransactionEntry = await db.getTransactionByIndex(
entry.transactionEntries[0].index - 1
)

// We should *always* have a previous transaction here.
if (prevTransactionEntry === null) {
throw new MissingElementError('SequencerBatchAppendedTransaction')
}
}

await db.putTransactionEntries(entry.transactionEntries)

// Add an additional field to the enqueued transactions in the database
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> {
const handlers = {
SequencerBatchAppended:
this.state.db.getLatestTransactionBatch.bind(this.state.db),
SequencerBatchAppendedTransaction:
this.state.db.getLatestTransaction.bind(this.state.db),
StateBatchAppended: this.state.db.getLatestStateRootBatch.bind(
this.state.db
),
Expand Down