Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
An unwind-stage error in the shared helper leaves pending unwind state in Run and RunNoInterrupt, allowing later runs to retry the failed request; cleanup and regression coverage for both paths are needed.
1 open issue
What changed in this PR
This PR hardens Erigon’s execution unwind recovery by enforcing immutable snapshot boundaries and clearing pending unwind requests after failures or rejected execution.
Changes:
- Resolve unwind limits through the snapshot-aware block reader and reject missing executed diffsets.
- Add unwind cleanup to execution entry points and stop queuing unwinds for discarded serial execution.
- Add regression coverage for snapshot boundaries, failed-unwind recovery, and valid-ancestor selection.
| File | Description |
|---|---|
| node/eth/backend.go | Pass the transaction-number reader into sync pipelines. |
| execution/stagedsync/sync.go | Share unwind execution logic and add cancellation support. |
| execution/stagedsync/sync_test.go | Test failed-unwind cleanup and unknown snapshot boundaries. |
| execution/stagedsync/stageloop/stageloop.go | Wire the reader into in-memory execution. |
| execution/stagedsync/stage_execute.go | Reject missing diffsets and check snapshot-aware unwind limits. |
| execution/stagedsync/stage_execute_unwind_test.go | Test complete and missing executed diffsets. |
| execution/stagedsync/stage_execute_unwind_routing_test.go | Supply a block reader for unwind-routing tests. |
| execution/stagedsync/exec3.go | Use snapshot-aware limits and remove the executor’s unwinder field. |
| execution/stagedsync/exec3_serial.go | Stop queuing unwinds after failed execution. |
| execution/execmodule/set_head.go | Check snapshot limits and cancel pending unwind work on exit. |
| execution/execmodule/forkchoice.go | Preserve state-ahead recovery and clear pending unwinds during cleanup. |
| execution/execmodule/executor.go | Cancel pending validation unwinds on exit. |
| execution/execmodule/executor_snapshot_pin_internal_test.go | Update test pipeline construction with a reader. |
| execution/execmodule/execmoduletester/exec_module_tester.go | Wire readers into test pipelines. |
| execution/execmodule/exec_module_unwind_gap_test.go | Verify valid-ancestor selection after child rejection. |
| execution/execmodule/exec_module_test.go | Test re-sent heads below downloaded snapshot state. |
| db/rawdb/rawtemporaldb/accessors_commitment.go | Include immutable value-file boundaries in unwind limits. |
| db/rawdb/rawtemporaldb/accessors_commitment_test.go | Test boundary rounding, value-file selection, and snapshot mappings. |
| cmd/integration/commands/stages.go | Use snapshot-aware readers in integration commands. |
Review effort: Balanced
ef5ebf8 to
1a79dd2
Compare
There was a problem hiding this comment.
🔵 Needs a closer look
Changes to canonical unwind limits and recovery after failed state mutations need runtime confirmation of snapshot/pruning and next-request recovery integration tests, but builds and project tests are unavailable in this review environment.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
Return ReorgTooDeep when state files extend beyond the block index and the requested ancestor needs an unwind. A re-sent canonical tip can still advance the index. Keep pending-unwind cleanup in forkchoice, where a cycle can fail before the unwind runs.
Keep an explicit stage_exec rewind on the unwind path even when execution has already reached the earliest retained block. Check this boundary before bisecting a wrong-root range so unsigned subtraction cannot schedule an unwind ahead of the failing block.
…covery # Conflicts: # cmd/integration/commands/stages.go
|
|
||
| // PauseStateFileBuilds waits for any active build to finish and prevents new | ||
| // state-file builds until the caller invokes the returned function. | ||
| func (a *Aggregator) PauseStateFileBuilds(ctx context.Context) (func(), error) { |
There was a problem hiding this comment.
main already has logic: "start collate/build step N only when N+MaxReorgDepth are in DB" https://github.com/erigontech/erigon/blob/fcae0a6cca/execution/execfinality/context.go#L48
Don't see reason for additional coordination between unwind and build


Forkchoice now rejects a rewind into immutable state files with
-38006(“Too deep reorg”), even when MDBX still has changesets for those blocks. The unwind must keep the block containing the last transaction in the domain value files. The oldest retained changeset can limit the unwind further.When snapshot state is ahead of the block index, requesting a higher head on the same chain can advance the index and return
SYNCING. Resending the indexed tip while the index is still behind returnsSYNCINGagain and leaves the index at the same height.stage_exec --unwinduses the same limit. If only part of the requested rewind is possible, the command stops at the earliest allowed block. If even a one-block rewind would cross the limit, it returns an error.Execution requires a changeset for every block it removes, including the current tip. If the tip’s changeset is missing, the reorg fails and the original head stays canonical.
If an unwind stage fails,
Sync.RunandRunNoInterruptdiscard the pending request and reset the stage position. The next sync run starts from committed state.Closes #22301. Part of #21860.