Commit 13d8a11e authored by Mark Tyneway's avatar Mark Tyneway Committed by Kelvin Fichter

dtl: use `ethers.StaticJsonRpcProvider` to reduce `eth_chainId` requests

There is no need to query for the chain id over and over again
when syncing from L2 using the DTL. This also reduces the amount
of logs for the `docker-compose` setup and will save requests to
the sequencer in production.
parent d3cb1b86
---
'@eth-optimism/data-transport-layer': patch
---
Use ethers.StaticJsonRpcProvider for the L2 Provider to lower API requests
/* Imports: External */ /* Imports: External */
import { BaseService, Metrics } from '@eth-optimism/common-ts' import { BaseService, Metrics } from '@eth-optimism/common-ts'
import { JsonRpcProvider } from '@ethersproject/providers' import { StaticJsonRpcProvider } from '@ethersproject/providers'
import { BigNumber } from 'ethers' import { BigNumber } from 'ethers'
import { LevelUp } from 'levelup' import { LevelUp } from 'levelup'
import axios from 'axios' import axios from 'axios'
...@@ -72,7 +72,7 @@ export class L2IngestionService extends BaseService<L2IngestionServiceOptions> { ...@@ -72,7 +72,7 @@ export class L2IngestionService extends BaseService<L2IngestionServiceOptions> {
private state: { private state: {
db: TransportDB db: TransportDB
l2RpcProvider: JsonRpcProvider l2RpcProvider: StaticJsonRpcProvider
} = {} as any } = {} as any
protected async _init(): Promise<void> { protected async _init(): Promise<void> {
...@@ -88,7 +88,7 @@ export class L2IngestionService extends BaseService<L2IngestionServiceOptions> { ...@@ -88,7 +88,7 @@ export class L2IngestionService extends BaseService<L2IngestionServiceOptions> {
this.state.l2RpcProvider = this.state.l2RpcProvider =
typeof this.options.l2RpcProvider === 'string' typeof this.options.l2RpcProvider === 'string'
? new JsonRpcProvider(this.options.l2RpcProvider) ? new StaticJsonRpcProvider(this.options.l2RpcProvider)
: this.options.l2RpcProvider : this.options.l2RpcProvider
} }
......
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