Running a Network Node
This project lets you set up a local read-only replica of the Optimistic Ethereum chain (either the main one or the Kovan testnet). New transactions are submitted either to the sequencer outside of Ethereum or to the Canonical Transaction Chain on L1, so submitting transactions to an L2 replica does not make sense.
Architecture
You need two components to replicate Optimistic Ethereum:
-
data-transport-layer, which retrieves and indexes blocks from L1. To access L1 you need an Ethereum Layer 1 provider, such as Infura. -
l2geth, which provides an Ethereum node where you applications can connect and run API calls.
Software Packages
These packages are required to run the replica:
In addition, if you want to run the sync test, you need:
- Node.js, version 12 or later
- Classic Yarn
Configuration
To configure the project, clone this repository and copy the env.example file to .env.
Set L1_RPC_ENDPOINT in the .env file to your Ethereum Layer1 RPC provider (local node, Infura, etc.)
Additional Settings
Change any other settings required for your environment
| Variable | Purpose | Default |
|---|---|---|
| L1_RPC_ENDPOINT | External layer 1 RPC provider (you provide) | - |
| DTL_IMAGE_TAG | Data transport layer version | 0.4.3 |
| DTL_PORT | Port number for the data-transport-layer endpoint | 7879 |
| ETH_NETWORK | Ethereum Layer1 and Layer2 network (mainnet,kovan) | mainnet (change to kovan for the test network) |
| ETH_NETWORK_RPC_PROVIDER | Layer2 source of truth endpoint, used for the sync check | https://mainnet.optimism.io (change to https://kovan.optimism.io for the test network) |
| ETH_REPLICA_RPC_PROVIDER | Layer2 local replica endpoint, used for the sync check | http://localhost:9991 |
| L2GETH_HTTP_PORT | Port number for the l2geth endpoint | 9991 |
| L2GETH_IMAGE_TAG | L2geth version | 0.4.6 |
Docker Image Versions
We recommend using the latest versions of both docker images. Find them as GitHub tags here and as published Docker images linked in the badges:
| Package | Docker |
|---|---|
@eth-optimism/l2geth |
|
@eth-optimism/data-transport-layer |
Usage
-
Start the replica:
-
Get the logs for
l2geth:docker logs op-replica_l2geth_1
-
Get the logs for
data-transport-layer:docker logs op-replica_dtl_1
-
Stop the replica:
Sync Check
To make sure your replica is running correctly, we've provided a script that checks its state roots against our sequencer.
yarn
npx ts-node src/sync-check.ts
You can also run this sync check as an express server that exposes metrics: