Commit ffadcb45 authored by Mark Tyneway's avatar Mark Tyneway

dtl: smaller range for filter query

On fresh startup, the DTL attempts to make a range
query that is very large when the starting L1 block
height is not configured. It looks for ownership
transferred events on the address manager, the first
one to happen indicates that the address manager was
deployed at that height.

Now that we use the same address manager over time instead
of the old way of upgrading the system where we would
redeploy the address manager each time, we must pass
the L1 start height as a config option to the DTL,
otherwise it will attempt to sync old transactions
(from a previous regenesis).

This commit will reduce the range at which the DTL
will query for the events, as alchemy only supports
a range of 2000. This will make the search prohibitively
slow, but that is ok as the value ought to be configured
anyways.

This functionality is really only useful for ephemeral networks.

A new logline is added for convenience.
parent ba3de8ea
---
'@eth-optimism/data-transport-layer': patch
---
Smaller filter query for searching for L1 start height. This number should be configured so that the search does not need to happen because using a smaller filter will cause it to take too long.
......@@ -167,7 +167,7 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> {
startingL1BlockNumber = this.options.l1StartHeight
} else {
this.logger.info(
'Attempting to find an appropriate L1 block height to begin sync...'
'Attempting to find an appropriate L1 block height to begin sync. This may take a long time.'
)
startingL1BlockNumber = await this._findStartingL1BlockNumber()
}
......@@ -453,12 +453,18 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> {
private async _findStartingL1BlockNumber(): Promise<number> {
const currentL1Block = await this.state.l1RpcProvider.getBlockNumber()
const filter =
this.state.contracts.Lib_AddressManager.filters.OwnershipTransferred()
for (let i = 0; i < currentL1Block; i += 2000) {
const start = i
const end = Math.min(i + 2000, currentL1Block)
this.logger.info(`Searching for ${filter} from ${start} to ${end}`)
for (let i = 0; i < currentL1Block; i += 1000000) {
const events = await this.state.contracts.Lib_AddressManager.queryFilter(
this.state.contracts.Lib_AddressManager.filters.OwnershipTransferred(),
i,
Math.min(i + 1000000, currentL1Block)
filter,
start,
end
)
if (events.length > 0) {
......
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