smartcontracts / simple-optimism-node

The easiest way to run an Optimism node
MIT License
318 stars 106 forks source link

L1 RPC endpoint protected by basic auth is not working #67

Open olivbau opened 1 year ago

olivbau commented 1 year ago

My L1 RPC endpoint is protected by a basic auth. In my .env file I have something like this:

# L1 node to run fault detection against
FAULT_DETECTOR__L1_RPC_PROVIDER=https://username:password@myethnode.com

# Node to get chain data from (if SYNC_SOURCE is "l1" then use L1 node, etc.)
DATA_TRANSPORT_LAYER__RPC_ENDPOINT=https://username:password@myethnode.com

It doesn't seem to work, here is the DTL error:

simple-optimism-node-dtl-1  | {"level":30,"time":1682413470213,"msg":"Service is starting..."}
simple-optimism-node-dtl-1  | {"level":30,"time":1682413470214,"msg":"Service is initializing..."}
simple-optimism-node-dtl-1  | {"level":30,"time":1682413470214,"msg":"Initializing L1 Data Transport Service..."}
simple-optimism-node-dtl-1  | {"level":30,"time":1682413470249,"msg":"L2 chain ID is: 10"}
simple-optimism-node-dtl-1  | {"level":30,"time":1682413470249,"msg":"BSS HF1 will activate at: 2824317"}
simple-optimism-node-dtl-1  | {"level":30,"time":1682413470258,"msg":"Service is initializing..."}
simple-optimism-node-dtl-1  | {"level":30,"time":1682413470268,"defaultBackend":"l1","l1GasPriceBackend":"l1","msg":"HTTP Server Options"}
simple-optimism-node-dtl-1  | {"level":30,"time":1682413470268,"url":"https://username:password@myethnode.com.","msg":"HTTP Server L1 RPC Provider initialized"}
simple-optimism-node-dtl-1  | {"level":30,"time":1682413470269,"url":"https://username:password@myethnode.com.","msg":"HTTP Server L2 RPC Provider initialized"}
simple-optimism-node-dtl-1  | {"level":30,"time":1682413470269,"msg":"Service has initialized."}
simple-optimism-node-dtl-1  | {"level":30,"time":1682413470269,"msg":"Service is initializing..."}
simple-optimism-node-dtl-1  | Well, that's that. We ran into a fatal error. Here's the dump. Goodbye!
simple-optimism-node-dtl-1  | /opt/optimism/node_modules/@ethersproject/logger/lib/index.js:238
simple-optimism-node-dtl-1  |         var error = new Error(message);
simple-optimism-node-dtl-1  |                     ^
simple-optimism-node-dtl-1  |
simple-optimism-node-dtl-1  | Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.7.1)
simple-optimism-node-dtl-1  |     at Logger.makeError (/opt/optimism/node_modules/@ethersproject/logger/lib/index.js:238:21)
simple-optimism-node-dtl-1  |     at Logger.throwError (/opt/optimism/node_modules/@ethersproject/logger/lib/index.js:247:20)
simple-optimism-node-dtl-1  |     at StaticJsonRpcProvider.<anonymous> (/opt/optimism/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:609:54)
simple-optimism-node-dtl-1  |     at step (/opt/optimism/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:48:23)
simple-optimism-node-dtl-1  |     at Object.throw (/opt/optimism/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:29:53)
simple-optimism-node-dtl-1  |     at rejected (/opt/optimism/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:21:65)
simple-optimism-node-dtl-1  |     at processTicksAndRejections (node:internal/process/task_queues:96:5) {
simple-optimism-node-dtl-1  |   reason: 'could not detect network',
simple-optimism-node-dtl-1  |   code: 'NETWORK_ERROR',
simple-optimism-node-dtl-1  |   event: 'noNetwork'
simple-optimism-node-dtl-1  | }
simple-optimism-node-dtl-1 exited with code 1

Do you have any idea how I can get around this problem?

olivbau commented 1 year ago

It seems that there are envs for this problem: https://github.com/ethereum-optimism/optimism/tree/develop/packages/data-transport-layer#configuration-1

envs:

I'll try to create a PR to support this envs

olivbau commented 1 year ago

Unfortunately it seems that there are no user and password options for FAULT_DETECTOR__L1_RPC_PROVIDER and OP_NODE__RPC_ENDPOINT Do you have any ideas?

olivbau commented 1 year ago

I tried to use DATA_TRANSPORT_LAYER__L1_RPC_USER and DATA_TRANSPORT_LAYER__L1_RPC_PASSWORD for DATA_TRANSPORT_LAYER__RPC_ENDPOINT. And use https://user:password@host:port syntax for FAULT_DETECTOR__L1_RPC_PROVIDER and OP_NODE__RPC_ENDPOINT.

Here is what I changed (just add DATA_TRANSPORT_LAYER__L1_RPC_USER and DATA_TRANSPORT_LAYER__L1_RPC_PASSWORD support) https://github.com/smartcontracts/simple-optimism-node/compare/main...olivbau:simple-optimism-node:basicauth-support

But it's not working, here is the type of errors I get on the DTL:

{
    "level":50,
    "time":1682520117625,"extra":{"message":"TypeError: Cannot read properties of null (reading 'from')","stack":"TypeError: Cannot read properties of null (reading 'from')
    at Object.getExtraData (/opt/optimism/packages/data-transport-layer/dist/src/services/l1-ingestion/handlers/sequencer-batch-appended.js:27:38)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async L1IngestionService._syncEvents (/opt/optimism/packages/data-transport-layer/dist/src/services/l1-ingestion/service.js:286:39)
    at async L1IngestionService._start (/opt/optimism/packages/data-transport-layer/dist/src/services/l1-ingestion/service.js:165:17)
    at async L1IngestionService.start (/opt/optimism/packages/common-ts/dist/base-service/base-service.js:33:9)
    at async Promise.all (index 1)
    at async L1DataTransportService._start (/opt/optimism/packages/data-transport-layer/dist/src/services/main/service.js:69:13)
    at async L1DataTransportService.start (/opt/optimism/packages/common-ts/dist/base-service/base-service.js:33:9)
    at async /opt/optimism/packages/data-transport-layer/dist/src/services/run.js:78:9"},"msg":"Caught an unhandled error"
}

Do you have any ideas on how to fix this problem?