Skip to content

smartcontracts/op-replica

 
 

Repository files navigation

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.

Resource requirements

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.

Software Packages

These packages are required to run the replica:

  1. Docker
  2. Docker compose

In addition, if you want to run the sync test, you need:

  1. Node.js, version 12 or later
  2. Classic Yarn

Configuration

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.

Additional Settings

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

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 Docker Image Version (latest by date)
@eth-optimism/data-transport-layer Docker Image Version (latest by date)

Usage

  • 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

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:

npx ts-node src/index.ts

Transaction-write latency Check

We've also provided a script to test a replica endpoint's transaction latency.

yarn
npx ts-node src/tx-latency.ts

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 77.4%
  • TypeScript 22.6%