Skip to content

execution/execmodule: reserve execution during startup - #23342

Draft
yperbasis wants to merge 2 commits into
mainfrom
yperbasis/statecache-startup-gate
Draft

execution/execmodule: reserve execution during startup#23342
yperbasis wants to merge 2 commits into
mainfrom
yperbasis/statecache-startup-gate

Conversation

@yperbasis

Copy link
Copy Markdown
Member

Closes #22925.

Problem

The execution semaphore was available as soon as NewExecModule returned. Engine and embedded RPC servers can start before the lifecycle calls ExecModule.Start, so a stateful engine request could run first. Payload validation could attach StateCache to a SharedDomains and start read-ahead from the pre-catch-up snapshot.

Frozen-block startup then advances durable state through cacheless SharedDomains. A pre-start reader could therefore leave or refill stale cache entries after catch-up.

End state

NewExecModule now reserves the existing execution permit before the module is exposed. ExecModule.Start owns that reservation through ProcessFrozenBlocks and releases it when startup returns. Try-acquire operations report Busy, while blocking operations wait.

Paths that do not run frozen-block initial sync explicitly finish startup. This keeps the test harness and legacy sync behavior unchanged.

No cache-populating execution path can now begin before or during frozen-block processing. ProcessFrozenBlocks remains cacheless, with no catch-up write-set copying, cache publication, or per-batch cache work.

Tests

The readiness regression test was written first and failed on main because a newly constructed module reported ready. Coverage also verifies that payload validation returns Busy before startup.

Validation on the final tree:

  • go test ./execution/execmodule/... -count=1
  • go test -race ./execution/execmodule/... -count=1 -timeout=10m
  • make test-short
  • make erigon
  • make integration

make lint was run twice on the final tree. Both runs reported no issue in the changed code and stopped only on the existing macOS unused-field report for residencyOnce in db/seg/decompress.go:199, which this PR does not modify.

@yperbasis
yperbasis marked this pull request as draft August 17, 2026 13:06
@yperbasis
yperbasis requested a balanced review from Copilot August 17, 2026 13:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reserves execution capacity during startup to prevent pre-catch-up state-cache access.

Changes:

  • Holds the execution semaphore until startup completes.
  • Releases the reservation for legacy and test paths without initial sync.
  • Adds readiness and pre-start validation regression tests.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
node/eth/backend.go Completes startup reservation across lifecycle paths.
execution/execmodule/execmoduletester/exec_module_tester.go Preserves test harness behavior.
execution/execmodule/exec_module.go Implements startup semaphore ownership.
execution/execmodule/exec_module_internal_test.go Tests readiness and pre-start rejection.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

execution: fence StateCache across frozen-block startup processing

2 participants