erigontech / erigontech/erigon

Remove ExecV3: Refactor SpawnBuilderExecStage

Open
#19,635 1 comment 0 reactions 0 assignees View on GitHub
tech debt reduction
Dominant language
Go
Stars
3.6k
Forks
1.5k
Avg merge
1d 16h
Merged PRs (30d)
455

Description

## Sub-task of #19318

### Phase 3: Refactor SpawnBuilderExecStage

**File**: `execution/builder/builderstages/exec.go`

Replace the two-pass execution model (NoopWriter + ExecV3 re-execution) with a single-pass model using a real `Writer` backed by `SharedDomains`.

### txNum layout per block
```
baseTxNum+0: initialization system calls (txIndex = -1)
baseTxNum+1: user tx 0
baseTxNum+2: user tx 1
...
baseTxNum+N: user tx N-1
baseTxNum+N+1: finalization system calls
```

### Refactored flow

1. Get `baseTxNum` from `sd.SeekCommitment()` (existing)
2. Create real `Writer` → `sd.AsPutDel(tx)` with `baseTxNum`
3. Create `BlockAssembler` with real writer + txNum advancement callback
4. `Initialize()` at `baseTxNum` (system calls)
5. `AddTransactions()` loop — `OnTxCommitted` callback advances writer/sd txNum
6. Advance to finalization slot: `baseTxNum + numTxns + 1`
7. `AssembleBlock()` (finalization + `CommitBlock`)
8. Write block metadata to DB (simplified — no senders recovery needed)
9. `ComputeCommitment()` directly (existing code, lines 303-311)

### Deleted code (~70 lines)

- `forceParallel` / `txUnwrapper` block (lines 260-296)
- `ExecV3()` call (line 298)
- `execTx`, `execSd`, `execCleanup` variables
- `SpawnRecoverSendersStage` call in `writeBlockForExecution`

### Kept code

- `simSd`/`simStateWriter`/`simStateReader` for `filterBadTransactions` (separate from main execution)
- `writeBlockForExecution` — simplified, still writes header/body/canonical hash/txNums
- `ComputeCommitment()` — unchanged

### Critical risk

**txNum sequencing must be exact.** `ComputeCommitment` depends on the txNum at which each `DomainPut` happens. The sequence (initialization → user txs → finalization) must match what ExecV3's executor would produce.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.