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/warm-news-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@eth-optimism/data-transport-layer': patch
---

Handle case where the remote block isn't found for `GET /eth/context/latest` and `GET /eth/context/blocknumber/:number`
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ export class L1TransportServer extends BaseService<L1TransportServerOptions> {
const blockNumber = Math.max(0, tip - this.options.confirmations)

const block = await this.state.l1RpcProvider.getBlock(blockNumber)
if (block === null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this results in an error either way, I think it's good to be explicit

throw new Error(`Cannot GET /eth/context/latest at ${blockNumber}`)
}

return {
blockNumber: block.number,
Expand All @@ -366,6 +369,10 @@ export class L1TransportServer extends BaseService<L1TransportServerOptions> {
}

const block = await this.state.l1RpcProvider.getBlock(number)
if (block === null) {
throw new Error(`Cannot GET /eth/context/blocknumber/${number}`)
}

return {
blockNumber: block.number,
timestamp: block.timestamp,
Expand Down