Commit 902985f2 authored by smartcontracts's avatar smartcontracts Committed by GitHub

feat(dtl): add L1 sync shutoff block flag (#4190)

Adds a flag to the DTL that will tell the L1 sync to not sync beyond a
given block height. Can be used to prepare forked networks.
parent 5c012b7b
---
'@eth-optimism/data-transport-layer': patch
---
Add L1 sync shutoff block
......@@ -214,11 +214,19 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> {
(await this.state.db.getHighestSyncedL1Block()) ||
this.state.startingL1BlockNumber
const currentL1Block = await this.state.l1RpcProvider.getBlockNumber()
const targetL1Block = Math.min(
let targetL1Block = Math.min(
highestSyncedL1Block + this.options.logsPerPollingInterval,
currentL1Block - this.options.confirmations
)
// Don't sync beyond the shutoff block!
if (this.options.l1SyncShutoffBlock !== undefined) {
targetL1Block = Math.min(
targetL1Block,
this.options.l1SyncShutoffBlock
)
}
// We're already at the head, so no point in attempting to sync.
if (highestSyncedL1Block === targetL1Block) {
await sleep(this.options.pollingInterval)
......
......@@ -26,6 +26,7 @@ export interface L1DataTransportServiceOptions {
l2RpcProvider: string
l2RpcProviderUser?: string
l2RpcProviderPassword?: string
l1SyncShutoffBlock?: number
metrics?: Metrics
dbPath: string
logsPerPollingInterval: number
......
......@@ -29,6 +29,7 @@ type ethNetwork = 'mainnet' | 'kovan' | 'goerli'
l1RpcProviderUser: config.str('l1-rpc-user'),
l1RpcProviderPassword: config.str('l1-rpc-password'),
addressManager: config.str('address-manager'),
l1SyncShutoffBlock: config.uint('l1-sync-shutoff-block'),
pollingInterval: config.uint('polling-interval', 5000),
logsPerPollingInterval: config.uint('logs-per-polling-interval', 2000),
dangerouslyCatchAllErrors: config.bool(
......
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