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

dtl: Support basic authentication for RPC endpoints
4 changes: 4 additions & 0 deletions packages/data-transport-layer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,13 @@ Here's the list of environment variables you can change:
| DATA_TRANSPORT_LAYER__SERVER_PORT | 7878 | Port to run the API on. |
| DATA_TRANSPORT_LAYER__SYNC_FROM_L1 | true | Whether or not to sync from L1. |
| DATA_TRANSPORT_LAYER__L1_RPC_ENDPOINT | - | RPC endpoint for an L1 node. |
| DATA_TRANSPORT_LAYER__L1_RPC_USER | - | Basic Authentication user for the L1 node endpoint. |
| DATA_TRANSPORT_LAYER__L1_RPC_PASSWORD | - | Basic Authentication password for the L1 node endpoint. |
| DATA_TRANSPORT_LAYER__LOGS_PER_POLLING_INTERVAL | 2000 | Logs to sync per polling interval. |
| DATA_TRANSPORT_LAYER__SYNC_FROM_L2 | false | Whether or not to sync from L2. |
| DATA_TRANSPORT_LAYER__L2_RPC_ENDPOINT | - | RPC endpoint for an L2 node. |
| DATA_TRANSPORT_LAYER__L2_RPC_USER | - | Basic Authentication user for the L2 node endpoint. |
| DATA_TRANSPORT_LAYER__L2_RPC_PASSWORD | - | Basic Authentication password for the L2 node endpoint. |
| DATA_TRANSPORT_LAYER__TRANSACTIONS_PER_POLLING_INTERVAL | 1000 | Number of L2 transactions to query per polling interval. |
| DATA_TRANSPORT_LAYER__L2_CHAIN_ID | - | L2 chain ID. |
| DATA_TRANSPORT_LAYER__LEGACY_SEQUENCER_COMPATIBILITY | false | Whether or not to enable "legacy" sequencer sync (without the custom `eth_getBlockRange` endpoint) |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
/* Imports: External */
import {
fromHexString,
FallbackProvider,
sleep,
} from '@eth-optimism/core-utils'
import { fromHexString, sleep } from '@eth-optimism/core-utils'
import { BaseService, Metrics } from '@eth-optimism/common-ts'
import { TypedEvent } from '@eth-optimism/contracts/dist/types/common'
import { BaseProvider } from '@ethersproject/providers'
import { BaseProvider, StaticJsonRpcProvider } from '@ethersproject/providers'
import { LevelUp } from 'levelup'
import { constants } from 'ethers'
import { Gauge, Counter } from 'prom-client'
Expand Down Expand Up @@ -114,8 +110,11 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> {
this.l1IngestionMetrics = registerMetrics(this.metrics)

if (typeof this.options.l1RpcProvider === 'string') {
this.state.l1RpcProvider = FallbackProvider(this.options.l1RpcProvider, {
'User-Agent': 'data-transport-layer',
this.state.l1RpcProvider = new StaticJsonRpcProvider({
Copy link
Contributor

Choose a reason for hiding this comment

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

proxyd should be able to handle the retry logic now, so making this change should be fine

url: this.options.l1RpcProvider,
user: this.options.l1RpcProviderUser,
password: this.options.l1RpcProviderPassword,
headers: { 'User-Agent': 'data-transport-layer' },
})
} else {
this.state.l1RpcProvider = this.options.l1RpcProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ export class L2IngestionService extends BaseService<L2IngestionServiceOptions> {
typeof this.options.l2RpcProvider === 'string'
? new StaticJsonRpcProvider({
url: this.options.l2RpcProvider,
user: this.options.l2RpcProviderUser,
password: this.options.l2RpcProviderPassword,
headers: { 'User-Agent': 'data-transport-layer' },
})
: this.options.l2RpcProvider
Expand Down
4 changes: 4 additions & 0 deletions packages/data-transport-layer/src/services/main/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ export interface L1DataTransportServiceOptions {
dangerouslyCatchAllErrors?: boolean
hostname: string
l1RpcProvider: string
l1RpcProviderUser?: string
l1RpcProviderPassword?: string
l2ChainId: number
l2RpcProvider: string
l2RpcProviderUser?: string
l2RpcProviderPassword?: string
metrics?: Metrics
dbPath: string
logsPerPollingInterval: number
Expand Down
4 changes: 4 additions & 0 deletions packages/data-transport-layer/src/services/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ type ethNetwork = 'mainnet' | 'kovan' | 'goerli'
hostname: config.str('server-hostname', 'localhost'),
confirmations: config.uint('confirmations', 35),
l1RpcProvider: config.str('l1-rpc-endpoint'),
l1RpcProviderUser: config.str('l1-rpc-user'),
l1RpcProviderPassword: config.str('l1-rpc-password'),
addressManager: config.str('address-manager'),
pollingInterval: config.uint('polling-interval', 5000),
logsPerPollingInterval: config.uint('logs-per-polling-interval', 2000),
Expand All @@ -34,6 +36,8 @@ type ethNetwork = 'mainnet' | 'kovan' | 'goerli'
false
),
l2RpcProvider: config.str('l2-rpc-endpoint'),
l2RpcProviderUser: config.str('l2-rpc-user'),
l2RpcProviderPassword: config.str('l2-rpc-password'),
l2ChainId: config.uint('l2-chain-id'),
syncFromL1: config.bool('sync-from-l1', true),
syncFromL2: config.bool('sync-from-l2', false),
Expand Down