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.
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.
The data-tansport-layer
should run with 1 CPU and 256Mb of memory.
The l2geth
process should run with 1 or 2 CPUs and between 4 and 8Gb of memory.
With this configuration a synchronization from block 0 to current height is expect to take about 8 hours.
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
To configure the project, clone this repository and copy the env.example
file to .env
.
Set the SHARED_ENV_PATH
to an existing collection of environment files, or copy those, make your changes and point to that new directory.
Fill in the rest of the .env
file with your endpoints.
Change any other settings required for your environment
Variable | Purpose | Default |
---|---|---|
DATA_TRANSPORT_LAYER__L2_RPC_ENDPOINT | ||
DTL_IMAGE_TAG | Data transport layer version | 0.4.3 |
ETH_NETWORK | Ethereum Layer1 and Layer2 network (mainnet,kovan) | mainnet (change to kovan for the test network) |
L2GETH_HTTP_PORT | Port number for the l2geth endpoint | 9991 |
L2GETH_IMAGE_TAG | L2geth version | 0.4.6 |
REPLICA_HEALTHCHECK__ETH_NETWORK_RPC_PROVIDER | The L2 endpoint to check the replica against | |
SHARED_ENV_PATH | Path to a directory containing env files | none (but check kustomize/replica/envs/) for examples |
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 |
-
Start the replica:
docker-compose up -d
-
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:
docker-compose down
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:
npx ts-node src/index.ts
We've also provided a script to test a replica endpoint's transaction latency.
yarn
npx ts-node src/tx-latency.ts