Commit 1344e37d authored by Mark Tyneway's avatar Mark Tyneway Committed by Kelvin Fichter

dtl: config for starting L1 block number

Adds the config option `DATA_TRANSPORT_LAYER_STARTING_L1_BLOCK_NUMBER`
or `--starting-l1-blocknumber` that allows for the user to specify
the L1 blocknumber to begin syncing from. This prevents users from
syncing old batches from a previous regenesis.
parent 6fc50a20
---
'@eth-optimism/data-transport-layer': patch
---
Add config for L1 start height to allow for syncing specifically after a regenesis. Using the auto detect method will not work with the regenesis scheme of using the same AddressManager
......@@ -152,20 +152,31 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> {
this.options.addressManager
)
const startingL1BlockNumber = await this.state.db.getStartingL1Block()
if (startingL1BlockNumber) {
this.state.startingL1BlockNumber = startingL1BlockNumber
// Look up in the database for an indexed starting L1 block
let startingL1BlockNumber = await this.state.db.getStartingL1Block()
// If there isn't an indexed starting L1 block, that means we should pull it
// from config and then fallback to discovering it
if (startingL1BlockNumber === null || startingL1BlockNumber === undefined) {
if (this.options.l1StartHeight !== null && this.options.l1StartHeight !== undefined) {
startingL1BlockNumber = this.options.l1StartHeight
} else {
this.logger.info(
'Attempting to find an appropriate L1 block height to begin sync...'
)
this.state.startingL1BlockNumber = await this._findStartingL1BlockNumber()
startingL1BlockNumber = await this._findStartingL1BlockNumber()
}
}
if (!startingL1BlockNumber) {
throw new Error('Cannot find starting L1 block number')
}
this.logger.info('Starting sync', {
startingL1BlockNumber: this.state.startingL1BlockNumber,
startingL1BlockNumber,
})
this.state.startingL1BlockNumber = startingL1BlockNumber
await this.state.db.setStartingL1Block(this.state.startingL1BlockNumber)
}
// Store the total number of submitted transactions so the server can tell clients if we're
// done syncing or not
......
......@@ -35,6 +35,7 @@ export interface L1DataTransportServiceOptions {
sentryTraceRate?: number
defaultBackend: string
l1GasPriceBackend: string
l1StartHeight?: number
}
const optionSettings = {
......
......@@ -47,6 +47,7 @@ type ethNetwork = 'mainnet' | 'kovan' | 'goerli'
),
defaultBackend: config.str('default-backend', 'l1'),
l1GasPriceBackend: config.str('l1-gas-price-backend', 'l1'),
l1StartHeight: config.uint('l1-start-height'),
useSentry: config.bool('use-sentry', false),
sentryDsn: config.str('sentry-dsn'),
sentryTraceRate: config.ufloat('sentry-trace-rate', 0.05),
......
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