Skip to content

Commit

Permalink
Merge branch 'op-erigon' of https://github.com/testinprod-io/op-erigon
Browse files Browse the repository at this point in the history
…into op-erigon
  • Loading branch information
boyuan-chen committed Mar 12, 2024
2 parents 8da622a + acf2258 commit 7ba45dc
Show file tree
Hide file tree
Showing 61 changed files with 16,920 additions and 130 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/download-page.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Trigger After Release

on:
workflow_run:
workflows: ["release"]
types:
- completed
on: workflow_dispatch
# workflow_run:
# workflows: ["release"]
# types:
# - completed

jobs:
after_release:
Expand Down
32 changes: 25 additions & 7 deletions .github/workflows/hive-nightly.yml → .github/workflows/hive.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,49 @@
name: Hive (Nightly)
name: Hive

on:
push:
branches:
- devel
- alpha
- stable
- op-erigon
pull_request:
branches:
- devel
- alpha
- stable
- op-erigon
types:
- opened
- reopened
- synchronize
- ready_for_review
schedule:
- cron: "0 01 * * *" # run at 1 am UTC every day
workflow_dispatch:

jobs:
hive:
runs-on: ubuntu-latest
runs-on: ubuntu-latest-m
steps:
- uses: AutoModality/action-clean@v1
- uses: actions/checkout@v3
with:
fetch-depth: 0 # fetch git tags for "git describe"

- name: build erigon image
run: DOCKER_TAG=thorax/erigon:ci-$GITHUB_SHA DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) make docker
run: DOCKER_TAG=testinprod/op-erigon:latest DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) make docker

# check with root permissions, should be cached from previous build
- name: build erigon image (root permissions)
run: sudo DOCKER_TAG=thorax/erigon:ci-$GITHUB_SHA DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) make docker
run: sudo DOCKER_TAG=testinprod/op-erigon:latest DOCKER_UID=$(id -u) DOCKER_GID=$(id -g) make docker

# exclude optimism/daisy-chain because it exhausts github ci disk space for downloading op-goerli database
- name: run hive and parse output
run: |
sudo mkdir -p /results-${{ github.run_id }}
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v ${{ github.workspace }}:/work thorax/hive:latest --sim ethereum/engine --results-root=/work/results-${{ github.run_id }} --client erigon_ci-$GITHUB_SHA --exit.fail=false
docker run --rm --pull always -v /var/run/docker.sock:/var/run/docker.sock -v ${{ github.workspace }}:/work --entrypoint /app/hivecioutput thorax/hive:latest --resultsdir=/work/results-${{ github.run_id }} --outdir=/work/results-${{ github.run_id }} --exclusionsfile=/work/hive/exclusions.json
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v ${{ github.workspace }}:/work testinprod/hive:latest --sim "^optimism/(rpc|l1ops|p2p)$" --results-root=/work/results-${{ github.run_id }} --client go-ethereum,op-erigon,op-proposer,op-batcher,op-node
docker run --rm --pull always -v /var/run/docker.sock:/var/run/docker.sock -v ${{ github.workspace }}:/work --entrypoint /app/hivecioutput testinprod/hive:latest --resultsdir=/work/results-${{ github.run_id }} --outdir=/work/results-${{ github.run_id }} --exclusionsfile=/work/hive/exclusions.json
- name: clean up containers
if: always()
Expand All @@ -42,4 +60,4 @@ jobs:
with:
name: Tests
path: results-${{ github.run_id }}/*.xml
reporter: java-junit
reporter: java-junit
3 changes: 2 additions & 1 deletion .github/workflows/test-integration-caplin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ jobs:
strategy:
matrix:
# disable macos-11 until https://github.com/ledgerwatch/erigon/issues/8789
os: [ ubuntu-22.04 ] # list of os: https://github.com/actions/virtual-environments
# os: [ ubuntu-20.04, macos-11 ] # list of os: https://github.com/actions/virtual-environments
os: [ ubuntu-20.04 ] # list of os: https://github.com/actions/virtual-environments
runs-on: ${{ matrix.os }}

steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
build/_vendor/pkg
/*.a
docs/readthedocs/build
.dev

#*
.#*
Expand Down
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ADD . .
RUN --mount=type=cache,target=/root/.cache \
--mount=type=cache,target=/tmp/go-build \
--mount=type=cache,target=/go/pkg/mod \
make BUILD_TAGS=nosqlite,noboltdb,nosilkworm all
make all


FROM docker.io/library/golang:1.20-alpine3.17 AS tools-builder
Expand Down Expand Up @@ -101,10 +101,8 @@ LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.description="Erigon Ethereum Client" \
org.label-schema.name="Erigon" \
org.label-schema.schema-version="1.0" \
org.label-schema.url="https://torquem.ch" \
org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/ledgerwatch/erigon.git" \
org.label-schema.vendor="Torquem" \
org.label-schema.vcs-url="https://github.com/testinprod-io/op-erigon.git" \
org.label-schema.version=$VERSION

ENTRYPOINT ["erigon"]
175 changes: 175 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,178 @@
# Optimistic Erigon
[![CI](https://github.com/testinprod-io/op-erigon/actions/workflows/ci.yml/badge.svg)](https://github.com/testinprod-io/op-erigon/actions/workflows/ci.yml) [![Integration tests](https://github.com/testinprod-io/op-erigon/actions/workflows/test-integration.yml/badge.svg)](https://github.com/testinprod-io/op-erigon/actions/workflows/test-integration.yml) [![Hive](https://github.com/testinprod-io/op-erigon/actions/workflows/hive.yml/badge.svg)](https://github.com/testinprod-io/op-erigon/actions/workflows/hive.yml) [![](https://dcbadge.vercel.app/api/server/42DFTeZwUZ?style=flat&compact=true)](https://discord.gg/42DFTeZwUZ)

A fork of [Erigon](https://github.com/ledgerwatch/erigon) that supports the [execution engine](https://github.com/ethereum-optimism/optimism/blob/develop/specs/exec-engine.md) of [OP stack](https://stack.optimism.io). Check out the fork status here: [https://op-erigon.testinprod.io](https://op-erigon.testinprod.io)

[`testinprod-io/erigon-lib`](https://github.com/testinprod-io/erigon-lib) has minimal backwards-compatible changes to add Optimism engine-api fields on the `op-erigon` branch.

[`testinprod-io/erigon-interfaces`](https://github.com/testinprod-io/erigon-interfaces) defines the protobuf changes for `erigon-lib` on the `op-erigon` branch.
- [Optimistic Erigon Project Status](#optimistic-erigon-project-status)
+ [Features that work correctly](#features-that-work-correctly)
+ [Features that don't work (or yet to be confirmed)](#features-that-dont-work-or-yet-to-be-confirmed)
- [Getting started with Optimism](#getting-started-with-optimism)
- [Example: Running An Optimism Mainnet Node](#example-running-an-optimism-mainnet-node)
- [Need any help?](#need-any-help)
- [Thanks](#thanks)
- [Original Erigon README.md](#erigon)

## Optimistic Erigon Project Status
Optimistic Erigon is still under development. Please note that some features are not fully implemented or tested.

### Features that work correctly
- Validator mode (Synchronizing to the Optimism Network with op-node)
- Ethereum standard JSON-RPC API
- JSON-RPC API for Otterscan
- All-in-One binary mode
- P2P transaction gossip

### Features that don't work (or yet to be confirmed)
- Block producing as a Sequencer
- Sequencer and proposer mode
- Running Erigon services as separate processes
- Erigon Snapshot

### Stability (dogfooding)
- [![Hive](https://github.com/testinprod-io/op-erigon/actions/workflows/hive.yml/badge.svg)](https://github.com/testinprod-io/op-erigon/actions/workflows/hive.yml)
- We've been running an op-erigon public RPC here:
- [https://op-erigon.mainnet.testinprod.io](https://op-erigon.mainnet.testinprod.io)
- [https://op-erigon.goerli.testinprod.io](https://op-erigon.goerli.testinprod.io)
- Our Otterscan (block explorer) uses our public RPC
- [https://otterscan.mainnet.testinprod.io](https://otterscan.mainnet.testinprod.io)
- [https://otterscan.goerli.testinprod.io](https://otterscan.goerli.testinprod.io)

## Getting started with Optimism
To build from the code, you can use the same command described below(`make erigon`)

You can use every flag erigon has. But there are some required flags and newly added flags for Optimism.

### `--datadir`
**[Required]**
op-erigon cannot execute state transition before the bedrock update. So if the chain was created before bedrock update, preconfigured data file is required to run the node. It includes blocks and states of the pre-bedrock chain.

You can download the chain data from following links:
- Optimism Mainnet:
- [https://op-erigon-backup.mainnet.testinprod.io](https://op-erigon-backup.mainnet.testinprod.io)
- Compressed: 115 GB, Uncompressed: 380 GB.
- Including blocks up to [105235064](https://optimistic.etherscan.io/block/105235064) (June 2023)

### `--externalcl`
**[Deprecated]**
An Optimism node needs a consensus client(op-node) and an execution client. op-erigon is intended to have an external consensus client though Erigon has its own consensus client.

This option specifies that Erigon will have an external consensus client. This is **required up to version `v2.39.0-0.1.1`**. In subsequent versions, this behavior has been made the default, and **using the flag will result in an error**.

### `--authrpc.addr`, `--authrpc.port`, `--authrpc.jwtsecret`
**[Required]**
Authenticated RPC configs that specify engine API connection info for the consensus client.

### `--rollup.sequencerhttp`
**[New flag / Optional]**
HTTP endpoint of the sequencer. op-erigon will route `eth_sendRawTransaction` calls to this URL. This is **required** for transaction submission since Bedrock does not currently have a public mempool. Refer to the documentation for the network you are participating in to get the correct URL.

For the OP-Mainnet, set the sequencer endpoint: `https://mainnet-sequencer.optimism.io`.

For the OP-Sepolia Testnet, set the sequencer endpoint: `https://sepolia-sequencer.optimism.io`

### `--rollup.historicalrpc`
**[New flag / Optional]**
The historical RPC endpoint. op-erigon queries historical execution data that op-erigon does not support to historical RPC—for example, pre-bedrock executions. For OP-Sepolia Testnet, please set this value to the Legacy Geth endpoint.

For more information about legacy geth, refer the [Optimism's node operator guide](https://community.optimism.io/docs/developers/bedrock/node-operator-guide/#legacy-geth).

### `--db.size.limit=8TB`
**[Required]**
Existing nodes whose MDBX page size equals 4kb must add --db.size.limit=8TB flag. Otherwise you will get MDBX_TOO_LARGE error. To check the current page size you can use `make db-tools && ./build/bin/mdbx_stat datadir/chaindata`.
If your chain is the one of `op-mainnet` & `op-goerli`, or your chain is synced before version `v2.55`, this flag is **REQUIRED**


### `--txpool.gossip.disable`
**[Optional]**
Disables transaction pool gossiping. Though this is not required, it's useful to set this to true since transaction pool gossip is currently unsupported in the Optimism protocol. If not provided, default value is set to `false`.

### `--maxpeers=0`, `--nodiscover`
**[Optional]**
Disable P2P. Execution-layer peering is currently not supported in the Optimism protocol. Though this is not required, it saves resources since TX pool gossip is currently not available.

## Support Chains
op-erigon supports every OP Stack chains listed in [superchain-registry](https://github.com/ethereum-optimism/superchain-registry).
You can config any superchain easily by setting `--chain` flag with the chain name written in the superchain registry, in lowercase. (e.g. `op-mainnet`, `base-sepolia`, etc.)
### Caution
If the chain was created before bedrock update, you need to download **pre-bedrock chain data**. See the following example to sync op-mainnet!

## Example: Running An Optimism Mainnet Node
### 1. Download and decompress the pre-bedrock chain data
You can download the pre-bedrock chain data from [https://op-erigon-backup.mainnet.testinprod.io](https://op-erigon-backup.mainnet.testinprod.io). Compressed: 115 GB, Uncompressed: 380 GB.
```bash
wget -c -O "backup.tar.gz" https://op-erigon-backup.mainnet.testinprod.io
tar -zxvf backup.tar.gz
```
After untaring, you will get a folder named `chaindata` which contains two files: `mdbx.dat` and `mdbx.lck`. Create a directory, move `chaindata` to the directory, and use the directory as a datadir(`$DATADIR`) for erigon. For example,
```bash
mkdir database
mv chaindata database/
export DATA_DIR=`pwd`/database
```

### 2. Configuring op-erigon
There are three options to run op-erigon. Please refer to the preceding descriptions for the required flags.
1. Build from the source
```bash
(build from the source)
$ make erigon

(example execution command)
$ ./build/bin/erigon \
--datadir=$DATA_DIR \
--private.api.addr=localhost:9090 \
--http.addr=0.0.0.0 \
--http.port=8545 \
--http.corsdomain="*" \
--http.vhosts="*" \
--authrpc.addr=0.0.0.0 \
--authrpc.port=8551 \
--authrpc.vhosts="*" \
--authrpc.jwtsecret=$JWT_SECRET_FILE \
--rollup.sequencerhttp="https://mainnet-sequencer.optimism.io" \
--rollup.historicalrpc="https://mainnet.optimism.io" \
--txpool.gossip.disable=true \
--chain=op-mainnet \
--db.size.limit=8TB \
--nodiscover
```
2. Use the Docker image: You can get the official Docker image from [testinprod/op-erigon](https://hub.docker.com/r/testinprod/op-erigon).
3. Use the Helm chart: If you want to deploy op-erigon to the K8S cluster, you can use [Helm chart](https://artifacthub.io/packages/helm/op-charts/erigon).

### 3. Configuring op-node
op-node is a consensus engine of OP stack. You can also build from the source, use official Docker image(`us-docker.pkg.dev/oplabs-tools-artifacts/images/op-node`), or [Helm chart](https://artifacthub.io/packages/helm/op-charts/op-node).

```bash
(example execution command)
$ op-node \
--l1=$L1_RPC_ENDPOINT \
--l2=$OP_ERIGON_ENGINE_API_ENDPOINT \
--l2.jwt-secret=$JWT_SECRET_FILE \
--network=op-mainnet \
--rpc.addr=0.0.0.0 \
--rpc.port=9545
```
For more information for op-node, refer the [Optimism's node operator guide](https://community.optimism.io/docs/developers/bedrock/node-operator-guide/#configuring-op-node).

## Need any help?
[![](https://dcbadge.vercel.app/api/server/42DFTeZwUZ?style=flat&compact=true)](https://discord.gg/42DFTeZwUZ) If you need help or find a bug, please share it with our discord!

## Thanks
- Erigon team for building this amazing, super fast, and cutting-edge efficient client.
- Willian for building an awesome open-sourced block explorer, Otterscan.
- Optimism Collective and OP Labs for the huge support and for building this amazing technology stack.
- Kelvin, Proto, and Lindsay for guiding and helping us a lot. Also, forkdiff is amazing.
- and Ethereum ❤️

_Let's stay Optimistic_ 🔴

---

<!-- Original Erigon README starts. -->

# Erigon

Erigon is an implementation of Ethereum (execution layer with embeddable consensus layer), on the efficiency
Expand Down
Loading

0 comments on commit 7ba45dc

Please sign in to comment.