Skip to content

Commit

Permalink
First ots2 prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
wmitsuda committed Sep 8, 2023
1 parent 674b77f commit 89c766a
Show file tree
Hide file tree
Showing 59 changed files with 7,343 additions and 12 deletions.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
# Otterscan v2.0.0-alpha1 enabled Erigon

This branch contains the experimental version of Erigon with Otterscan API **v2.0.0-alpha1**.

Compatibility:

- Erigon v2.48.1
- Otterscan v2.0.0-alpha1

## Warnings/disclaimers (READ THIS FIRST!!!)

This is an experimental build. Make sure you are aware of the following first:

- Don't use this build on production servers.
- Make sure you backup your Erigon node before trying this build.
- This version is made available in source-code form only.
- DB model will change on next alphas. There will **NOT** be migration scripts. You'll need to restore your original Erigon node from a backup.
- For now it is compatible with Erigon 2 only, but the end game is to support Erigon 3 only. At some point in the future we may change it.
- Enabling Otterscan v2 support will produce extra data inside Erigon DB, so you'll need more disk space than a regular Erigon node.
- At the first run of this patched build, extra stages will produce new indexes from genesis, so there will be extra sync time. Once it reaches the tip, the extra stages will take neglegible time per block iteration.
- **Alphas were not optimized for space/time (yet). The goal here was to implement the spec for all token/contract indexing support and prove it was doable.**

## How to use it

### Erigon

Build this branch as usual with `make` command.

Add the `--experimental.ots2` CLI argument to the `erigon` command. That'll enable Otterscan V2 extra stages.

Also enable the `ots2` API namespace, i.e., `--http.api "eth,erigon,ots,ots2"`.

### Otterscan

See: https://github.com/otterscan/otterscan/blob/develop/docs/ots2.md

> The rest of this document contains the original Erigon README.
---

# Erigon

Erigon is an implementation of Ethereum (execution client with light client for consensus layer), on the efficiency
Expand Down
5 changes: 3 additions & 2 deletions cl/clparams/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,9 @@ var CheckpointSyncEndpoints = map[NetworkType][]string{
"https://prater-checkpoint-sync.stakely.io/eth/v2/debug/beacon/states/finalized",
},
SepoliaNetwork: {
"https://checkpoint-sync.sepolia.ethpandaops.io/eth/v2/debug/beacon/states/finalized",
"https://sepolia.beaconstate.info/eth/v2/debug/beacon/states/finalized",
// "https://checkpoint-sync.sepolia.ethpandaops.io/eth/v2/debug/beacon/states/finalized",
// "https://sepolia.beaconstate.info/eth/v2/debug/beacon/states/finalized",
"https://beaconstate-sepolia.chainsafe.io/eth/v2/debug/beacon/states/finalized",
},
GnosisNetwork: {
"https://checkpoint.gnosis.gateway.fm/eth/v2/debug/beacon/states/finalized",
Expand Down
6 changes: 4 additions & 2 deletions cmd/erigon-el/stages/stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
func nullStage(firstCycle bool, badBlockUnwind bool, s *stagedsync.StageState, u stagedsync.Unwinder, tx kv.RwTx, logger log.Logger) error {
return nil
}
func ExecutionStages(ctx context.Context, sm prune.Mode, snapshots stagedsync.SnapshotsCfg, headers stagedsync.HeadersCfg, cumulativeIndex stagedsync.CumulativeIndexCfg, blockHashCfg stagedsync.BlockHashesCfg, bodies stagedsync.BodiesCfg, senders stagedsync.SendersCfg, exec stagedsync.ExecuteBlockCfg, hashState stagedsync.HashStateCfg, trieCfg stagedsync.TrieCfg, history stagedsync.HistoryCfg, logIndex stagedsync.LogIndexCfg, callTraces stagedsync.CallTracesCfg, txLookup stagedsync.TxLookupCfg, finish stagedsync.FinishCfg, test bool) []*stagedsync.Stage {
defaultStages := stagedsync.DefaultStages(ctx, snapshots, headers, cumulativeIndex, blockHashCfg, bodies, senders, exec, hashState, trieCfg, history, logIndex, callTraces, txLookup, finish, test)
func ExecutionStages(ctx context.Context, sm prune.Mode, snapshots stagedsync.SnapshotsCfg, headers stagedsync.HeadersCfg, cumulativeIndex stagedsync.CumulativeIndexCfg, blockHashCfg stagedsync.BlockHashesCfg, bodies stagedsync.BodiesCfg, senders stagedsync.SendersCfg, exec stagedsync.ExecuteBlockCfg, hashState stagedsync.HashStateCfg, trieCfg stagedsync.TrieCfg, history stagedsync.HistoryCfg, logIndex stagedsync.LogIndexCfg, callTraces stagedsync.CallTracesCfg, txLookup stagedsync.TxLookupCfg, finish stagedsync.FinishCfg, caCfg stagedsync.ContractAnalyzerCfg, ots2Enabled bool, test bool) []*stagedsync.Stage {
defaultStages := stagedsync.DefaultStages(ctx, snapshots, headers, cumulativeIndex, blockHashCfg, bodies, senders, exec, hashState, trieCfg, history, logIndex, callTraces, txLookup, finish, caCfg, ots2Enabled, test)
// Remove body/headers stages
defaultStages[1].Forward = nullStage
defaultStages[4].Forward = nullStage
Expand Down Expand Up @@ -86,6 +86,8 @@ func NewStagedSync(
stagedsync.StageCallTracesCfg(db, cfg.Prune, 0, dirs.Tmp),
stagedsync.StageTxLookupCfg(db, cfg.Prune, dirs.Tmp, controlServer.ChainConfig.Bor, blockReader),
stagedsync.StageFinishCfg(db, dirs.Tmp, forkValidator),
stagedsync.StageDbAwareCfg(db, dirs.Tmp, controlServer.ChainConfig, blockReader, controlServer.Engine),
cfg.Ots2,
runInTestMode),
stagedsync.DefaultUnwindOrder,
stagedsync.DefaultPruneOrder,
Expand Down
Loading

0 comments on commit 89c766a

Please sign in to comment.