Skip to content

Commit 34bcefe

Browse files
Merge branch 'main' into alex/etl_mmap_34
2 parents c4459c1 + 84fe7e5 commit 34bcefe

File tree

16 files changed

+457
-115
lines changed

16 files changed

+457
-115
lines changed
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
---
2+
name: launch-bal-devnet-2
3+
description: Launch erigon + Lighthouse on the bal-devnet-2 ethpandaops devnet (EIP-7928 Block Access Lists). Manages start/stop of both EL and CL clients with proper port offsets and JWT auth.
4+
allowed-tools: Bash, Read, Write, Edit, Glob
5+
allowed-prompts:
6+
- tool: Bash
7+
prompt: start, stop, and manage erigon and lighthouse processes for bal-devnet-2
8+
---
9+
10+
# Launch bal-devnet-2 (EIP-7928 BAL Devnet)
11+
12+
Run erigon (EL) + Lighthouse (CL) on the bal-devnet-2 ethpandaops devnet for testing EIP-7928 Block Access Lists.
13+
14+
## Network Details
15+
16+
| Parameter | Value |
17+
|-----------|-------|
18+
| Chain ID | 7033429093 |
19+
| Genesis timestamp | 1770388190 |
20+
| Amsterdam timestamp | 1770400508 (epoch 32) |
21+
| Lighthouse image | `ethpandaops/lighthouse:bal-devnet-2-65bb283` |
22+
| Lighthouse version | v8.0.1 (commit 65bb283, branch bal-devnet-2) |
23+
| Explorer | https://explorer.bal-devnet-2.ethpandaops.io |
24+
| Faucet | https://faucet.bal-devnet-2.ethpandaops.io |
25+
| RPC | https://rpc.bal-devnet-2.ethpandaops.io |
26+
| Checkpoint sync | https://checkpoint-sync.bal-devnet-2.ethpandaops.io |
27+
28+
## Working Directory
29+
30+
Ask the user where they want the working directory. Default suggestion: `~/bal-devnet-2/`.
31+
Use `$WORKDIR` throughout to refer to the chosen path.
32+
33+
```
34+
$WORKDIR/
35+
├── genesis.json # EL genesis
36+
├── config.yaml # CL beacon config
37+
├── genesis.ssz # CL genesis state
38+
├── testnet-config/ # Lighthouse testnet dir (config.yaml + genesis.ssz + deploy files)
39+
├── start-erigon.sh # Erigon start script (run FIRST)
40+
├── start-lighthouse.sh # Lighthouse start script (run SECOND)
41+
├── stop.sh # Stop both erigon + Lighthouse
42+
├── clean.sh # Stop, wipe data, re-init genesis
43+
├── erigon-data/ # Erigon datadir (contains jwt.hex)
44+
├── lighthouse-data/ # Lighthouse datadir
45+
├── erigon-console.log # Erigon stdout/stderr
46+
└── lighthouse-console.log # Lighthouse stdout/stderr
47+
```
48+
49+
## Port Assignments (offset +100)
50+
51+
| Service | Port | Protocol |
52+
|---------|------|----------|
53+
| Erigon HTTP RPC | 8645 | TCP |
54+
| Erigon Engine API (authrpc) | 8651 | TCP |
55+
| Erigon WebSocket | 8646 | TCP |
56+
| Erigon P2P | 30403 | TCP+UDP |
57+
| Erigon gRPC | 9190 | TCP |
58+
| Erigon Torrent | 42169 | TCP+UDP |
59+
| Erigon pprof | 6160 | TCP |
60+
| Erigon metrics | 6161 | TCP |
61+
| Lighthouse P2P | 9100 | TCP+UDP |
62+
| Lighthouse QUIC | 9101 | UDP |
63+
| Lighthouse HTTP API | 5152 | TCP |
64+
| Lighthouse metrics | 5264 | TCP |
65+
66+
## Workflow
67+
68+
### Step 1: Check Prerequisites
69+
70+
1. Verify erigon binary exists at `./build/bin/erigon`. If not, invoke `/erigon-build`.
71+
2. Verify the Lighthouse Docker image is available:
72+
```bash
73+
docker image inspect ethpandaops/lighthouse:bal-devnet-2-65bb283 > /dev/null 2>&1
74+
```
75+
If not, pull it:
76+
```bash
77+
docker pull ethpandaops/lighthouse:bal-devnet-2-65bb283
78+
```
79+
3. Verify config files exist in `$WORKDIR` (genesis.json, testnet-config/).
80+
If not, download them:
81+
```bash
82+
mkdir -p $WORKDIR/testnet-config
83+
curl -sL -o $WORKDIR/genesis.json https://config.bal-devnet-2.ethpandaops.io/el/genesis.json
84+
curl -sL -o $WORKDIR/testnet-config/config.yaml https://config.bal-devnet-2.ethpandaops.io/cl/config.yaml
85+
curl -sL -o $WORKDIR/testnet-config/genesis.ssz https://config.bal-devnet-2.ethpandaops.io/cl/genesis.ssz
86+
echo "0" > $WORKDIR/testnet-config/deposit_contract_block.txt
87+
echo "0" > $WORKDIR/testnet-config/deploy_block.txt
88+
```
89+
90+
### Step 2: Initialize Datadir (first run only)
91+
92+
If `$WORKDIR/erigon-data/chaindata` does not exist:
93+
```bash
94+
./build/bin/erigon init --datadir $WORKDIR/erigon-data $WORKDIR/genesis.json
95+
```
96+
97+
### Step 3: Create Scripts (first run only)
98+
99+
If the start/stop/clean scripts don't exist yet, generate them. The scripts must use absolute paths based on `$WORKDIR`. Key details:
100+
101+
**start-erigon.sh** — Runs erigon with `--externalcl`. Must start FIRST (creates JWT secret).
102+
- Env vars: `ERIGON_EXEC3_PARALLEL=true`, `ERIGON_ASSERT=true`, `ERIGON_EXEC3_WORKERS=12`, `LOG_HASH_MISMATCH_REASON=true`
103+
- Flags: `--datadir=$WORKDIR/erigon-data`, `--externalcl`, `--networkid=7033429093`, all 16 EL bootnodes, erigon static peers, `--prune.mode=minimal`, all offset ports (see port table), `--http.api=eth,erigon,engine,debug`, `--pprof`, `--metrics`
104+
- EL bootnodes: fetch from `https://config.bal-devnet-2.ethpandaops.io/api/v1/nodes/inventory` (extract enode URLs from `execution.enode` fields)
105+
106+
**start-lighthouse.sh** — Runs Lighthouse via Docker with `--network=host`. Must start SECOND.
107+
- Checks JWT exists at `$WORKDIR/erigon-data/jwt.hex`
108+
- Docker container name: `bal-devnet-2-lighthouse`
109+
- Mounts: `$WORKDIR/testnet-config:/config:ro`, `$WORKDIR/lighthouse-data:/data`, JWT as `/jwt.hex:ro`
110+
- Flags: `--testnet-dir=/config`, `--execution-endpoint=http://127.0.0.1:8651`, `--execution-jwt=/jwt.hex`, all 15 CL ENR bootnodes, offset ports, `--checkpoint-sync-url=https://checkpoint-sync.bal-devnet-2.ethpandaops.io`
111+
- CL bootnodes: fetch from same inventory URL (extract ENR entries from `consensus.enr` fields)
112+
113+
**stop.sh** — Stops Lighthouse (`docker stop bal-devnet-2-lighthouse`) then erigon (`pkill -f "datadir.*bal-devnet-2/erigon-data"`).
114+
115+
**clean.sh** — Runs `stop.sh`, removes erigon chain data (chaindata, snapshots, txpool, nodes, temp) and lighthouse data, re-initializes genesis.
116+
117+
### Step 4: Start Erigon (FIRST)
118+
119+
Erigon must start first because it creates the JWT secret that Lighthouse needs.
120+
121+
```bash
122+
cd $WORKDIR && nohup bash start-erigon.sh > erigon-console.log 2>&1 &
123+
```
124+
125+
Verify it started:
126+
- Check `tail $WORKDIR/erigon-console.log` for startup messages
127+
- Check JWT exists: `ls $WORKDIR/erigon-data/jwt.hex`
128+
- Check port binding: `ss -tlnp | grep 8651`
129+
130+
### Step 5: Start Lighthouse (SECOND)
131+
132+
After erigon is running and JWT exists:
133+
134+
```bash
135+
cd $WORKDIR && nohup bash start-lighthouse.sh > lighthouse-console.log 2>&1 &
136+
```
137+
138+
Verify it started:
139+
- Check `tail $WORKDIR/lighthouse-console.log` for "Lighthouse started"
140+
- Look for "Loaded checkpoint block and state" (checkpoint sync)
141+
- Look for `peers: "N"` showing peer connections
142+
143+
### Step 6: Monitor
144+
145+
```bash
146+
# Erigon sync progress
147+
tail -f $WORKDIR/erigon-console.log
148+
149+
# Lighthouse sync progress
150+
tail -f $WORKDIR/lighthouse-console.log
151+
152+
# Check erigon block height via RPC
153+
curl -s http://localhost:8645 -X POST -H "Content-Type: application/json" \
154+
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' | python3 -m json.tool
155+
156+
# Check lighthouse sync status
157+
curl -s http://localhost:5152/eth/v1/node/syncing | python3 -m json.tool
158+
```
159+
160+
### Step 7: Stop
161+
162+
```bash
163+
bash $WORKDIR/stop.sh
164+
```
165+
166+
This stops Lighthouse (via `docker stop`) then erigon (via `pkill`).
167+
168+
### Step 8: Clean (wipe data and re-init)
169+
170+
```bash
171+
bash $WORKDIR/clean.sh
172+
```
173+
174+
This runs `stop.sh`, removes erigon chain data (chaindata, snapshots, txpool, nodes, temp) and lighthouse data, then re-initializes genesis. After clean, start again with Steps 4-5.
175+
176+
## Troubleshooting
177+
178+
| Problem | Solution |
179+
|---------|----------|
180+
| JWT auth fails | Ensure erigon started first and `jwt.hex` exists. Lighthouse must mount the same file. |
181+
| No EL peers | Check firewall allows port 30403. Try adding `--nat=extip:<your-ip>`. |
182+
| No CL peers | Check firewall allows port 9100/9101. ENR bootnodes may have changed — re-fetch from inventory. |
183+
| "Head is optimistic" | Normal during initial sync. Erigon is behind Lighthouse. Will resolve as erigon catches up. |
184+
| Engine API timeout | Check erigon is running and authrpc port 8651 is accessible. |
185+
| Port conflict | Check `ss -tlnp | grep <port>`. Kill conflicting process or use higher offset. |

db/recsplit/recsplit.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636

3737
"github.com/erigontech/erigon/common"
3838
"github.com/erigontech/erigon/common/assert"
39+
"github.com/erigontech/erigon/common/background"
3940
"github.com/erigontech/erigon/common/dir"
4041
"github.com/erigontech/erigon/common/log/v3"
4142
"github.com/erigontech/erigon/common/mmap"
@@ -164,6 +165,8 @@ type RecSplit struct {
164165

165166
noFsync bool // fsync is enabled by default, but tests can manually disable
166167
timings Timings
168+
169+
progress *background.Progress // If set, tracks 0-100%: add-keys fills 0-50%, build fills 50-100%
167170
}
168171

169172
type RecSplitArgs struct {
@@ -395,6 +398,9 @@ func (rs *RecSplit) ResetNextSalt() {
395398
rs.collision = false
396399
rs.keysAdded = 0
397400
rs.salt++
401+
if rs.progress != nil {
402+
rs.progress.Processed.Store(0)
403+
}
398404
if rs.bucketCollector != nil {
399405
rs.bucketCollector.Close()
400406
}
@@ -519,6 +525,9 @@ func (rs *RecSplit) AddKey(key []byte, offset uint64) error {
519525

520526
rs.keysAdded++
521527
rs.prevOffset = offset
528+
if rs.progress != nil && rs.keysAdded%1024 == 0 {
529+
rs.progress.Processed.Add(1024)
530+
}
522531
return nil
523532
}
524533

@@ -790,6 +799,10 @@ func (rs *RecSplit) loadFuncBucket(k, v []byte, _ etl.CurrentTableReader, _ etl.
790799
if err := rs.recsplitCurrentBucket(); err != nil {
791800
return err
792801
}
802+
if rs.progress != nil {
803+
// Build phase fills the 50–100% half: each bucket ≈ bucketSize keys worth.
804+
rs.progress.Processed.Add(uint64(rs.bucketSize))
805+
}
793806
}
794807
rs.currentBucketIdx = bucketIdx
795808
}
@@ -820,6 +833,26 @@ func (rs *RecSplit) buildOffsetEf() error {
820833
return nil
821834
}
822835

836+
// KeyCount returns the number of keys added to the RecSplit.
837+
func (rs *RecSplit) KeyCount() uint64 { return rs.keysAdded }
838+
839+
// BucketCount returns the number of buckets.
840+
func (rs *RecSplit) BucketCount() uint64 { return rs.bucketCount }
841+
842+
// SetProgress wires a single progress tracker covering the full build lifecycle.
843+
// Total = 2*keyExpectedCount; AddKey fills 0→keyExpectedCount (0–50%) and
844+
// the bucket-building phase fills keyExpectedCount→2*keyExpectedCount (50–100%).
845+
// Progress is automatically reset on ResetNextSalt (collision retry).
846+
func (rs *RecSplit) SetProgress(p *background.Progress) {
847+
if p == nil {
848+
return
849+
}
850+
p.Name.Store(&rs.fileName)
851+
p.Processed.Store(0)
852+
p.Total.Store(2 * rs.keyExpectedCount)
853+
rs.progress = p
854+
}
855+
823856
// Build has to be called after all the keys have been added, and it initiates the process
824857
// of building the perfect hash function and writing index into a file
825858
func (rs *RecSplit) Build(ctx context.Context) error {

db/snaptype/type.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -492,11 +492,6 @@ func BuildIndex(ctx context.Context, info FileInfo, indexVersion version.Version
492492
}
493493
defer d.Close()
494494

495-
if p != nil {
496-
fname := info.Name()
497-
p.Name.Store(&fname)
498-
p.Total.Store(uint64(d.Count()))
499-
}
500495
cfg.KeyCount = d.Count()
501496
idxVer := indexVersion.Current
502497
cfg.IndexFile = filepath.Join(info.Dir(), info.Type.IdxFileName(idxVer, info.From, info.To))
@@ -515,6 +510,7 @@ func BuildIndex(ctx context.Context, info FileInfo, indexVersion version.Version
515510
defer d.MadvSequential().DisableReadAhead()
516511

517512
for {
513+
rs.SetProgress(p)
518514
g := d.MakeGetter()
519515
var i, offset, nextPos uint64
520516
word := make([]byte, 0, 4096)
@@ -560,11 +556,6 @@ func BuildIndexWithSnapName(ctx context.Context, info FileInfo, cfg recsplit.Rec
560556
}
561557
defer d.Close()
562558

563-
if p != nil {
564-
fname := info.Name()
565-
p.Name.Store(&fname)
566-
p.Total.Store(uint64(d.Count()))
567-
}
568559
cfg.KeyCount = d.Count()
569560
cfg.IndexFile = filepath.Join(info.Dir(), IdxFileName(info.Version, info.From, info.To, info.CaplinTypeString))
570561
rs, err := recsplit.NewRecSplit(cfg, logger)
@@ -577,6 +568,7 @@ func BuildIndexWithSnapName(ctx context.Context, info FileInfo, cfg recsplit.Rec
577568
defer d.MadvSequential().DisableReadAhead()
578569

579570
for {
571+
rs.SetProgress(p)
580572
g := d.MakeGetter()
581573
var i, offset, nextPos uint64
582574
word := make([]byte, 0, 4096)

db/snaptype2/block_types.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,6 @@ var (
244244
return fmt.Errorf("TransactionsIdx: at=%d-%d, pre index building, expect: %d, got %d", sn.From, sn.To, expectedCount, d.Count())
245245
}
246246

247-
if p != nil {
248-
name := sn.Name()
249-
p.Name.Store(&name)
250-
p.Total.Store(uint64(d.Count() * 2))
251-
}
252-
253247
txnHashIdx, err := recsplit.NewRecSplit(recsplit.RecSplitArgs{
254248
KeyCount: d.Count(),
255249

@@ -291,6 +285,7 @@ var (
291285
defer bodiesSegment.MadvSequential().DisableReadAhead()
292286

293287
for {
288+
txnHashIdx.SetProgress(p)
294289
g, bodyGetter := d.MakeGetter(), bodiesSegment.MakeGetter()
295290
var ti, offset, nextPos uint64
296291
blockNum := firstBlockNum
@@ -302,10 +297,6 @@ var (
302297
}
303298

304299
for g.HasNext() {
305-
if p != nil {
306-
p.Processed.Add(1)
307-
}
308-
309300
word, nextPos = g.Next(word[:0])
310301
select {
311302
case <-ctx.Done():

db/state/domain.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,7 @@ func buildHashMapAccessor(ctx context.Context, g *seg.Reader, idxPath string, va
12201220
return err
12211221
}
12221222
g.Reset(0)
1223+
rs.SetProgress(p)
12231224
for g.HasNext() {
12241225
word, valPos = g.Next(word[:0])
12251226
if values {
@@ -1234,8 +1235,6 @@ func buildHashMapAccessor(ctx context.Context, g *seg.Reader, idxPath string, va
12341235

12351236
// Skip value
12361237
keyPos, _ = g.Skip()
1237-
1238-
p.Processed.Add(1)
12391238
}
12401239
if err = rs.Build(ctx); err != nil {
12411240
if rs.Collision() {

db/state/history.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,12 @@ func (h *History) buildVI(ctx context.Context, historyIdxPath string, hist, efHi
283283
for {
284284
histReader.Reset(0)
285285
iiReader.Reset(0)
286+
rs.SetProgress(p)
286287

287288
valOffset = 0
288289
for iiReader.HasNext() {
289290
keyBuf, _ = iiReader.Next(keyBuf[:0])
290291
valBuf, _ = iiReader.Next(valBuf[:0])
291-
p.Processed.Add(1)
292292

293293
// fmt.Printf("ef key %x\n", keyBuf)
294294

0 commit comments

Comments
 (0)