Skip to content

refactor(prover): extract a prover-worker crate from asm-runner#143

Draft
prajwolrg wants to merge 6 commits into
mainfrom
STR-3699-prover-worker
Draft

refactor(prover): extract a prover-worker crate from asm-runner#143
prajwolrg wants to merge 6 commits into
mainfrom
STR-3699-prover-worker

Conversation

@prajwolrg
Copy link
Copy Markdown
Collaborator

Description

Proof scheduling and reconciliation lived inside the asm-runner binary at bin/asm-runner/src/prover/, hard-wired to the concrete SledProofDb, so the orchestrator could not be tested against fakes or reused outside the binary. This PR extracts that logic into a dedicated strata-asm-prover-worker crate and groups the prover stack under a new crates/extensions/prover/ tree.

The new worker mirrors the ASM worker's shape: it defines a ProverContext umbrella trait (proof storage + remote-job tracking + chain/state reads) and drives the orchestrator generically over it, while the binary supplies the concrete impl (AsmProverContext) that wires the sled stores and the Bitcoin client together — the same split as strata-asm-worker + asm-storage + the binary's worker_context.rs.

Split into three reviewable commits, each of which compiles on its own:

  • relocate proof-types crate under extensions/prover — move + rename strata-asm-proof-typesstrata-asm-prover-types (mechanical).
  • relocate proof-db crate as extensions/prover/storage — move + rename strata-asm-proof-dbstrata-asm-prover-storage (mechanical).
  • extract proof orchestration into a prover-worker crate — introduce ProverContext, make the orchestrator generic, split the proving backend into native/sp1 modules, and rewire the binary. This is where the real change lives.

The strata-asm-proof-impl (guest statements) crate intentionally stays in crates/proof/.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature/Enhancement (non-breaking change which adds functionality or enhances an existing one)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactor
  • New or updated tests
  • Dependency update
  • Security fix

Notes to Reviewers

No behavioral change is intended — the orchestration logic moved verbatim and was made generic over the context trait. The first two commits are pure move/rename noise; the substance is in the third. Verified with cargo check/clippy/test across the affected crates under both default and sp1 features; the migrated queue/scheduling unit tests and the runner/rpc tests pass.

Now that the orchestrator is decoupled from sled, a fake ProverContext can exercise the full reconcile/schedule loop end-to-end — left as a follow-up rather than expanding this PR's scope.

Checklist

  • I have performed a self-review of my code.
  • I have commented my code where necessary.
  • I have updated the documentation if needed.
  • My changes do not introduce new warnings.
  • I have added tests that prove my changes are effective or that my feature works.
  • New and existing tests pass with my changes.

Related Issues

STR-3699

Consumers of committed blocks (Moho-state derivation, and later proof
requests) were wired into the ASM worker's hot path. Expose
AsmWorkerHandle::subscribe_blocks(): after each anchor write the service
fans the new L1BlockCommitment out to subscribers over unbounded
channels and prunes dropped receivers. send on an unbounded channel is
non-blocking, so the worker never awaits a consumer and stays off the
critical path.

Subscribers fire only after a successful ASM commit, not on raw block
arrival -- hence AsmSubscribers.
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 7, 2026

Codecov Report

❌ Patch coverage is 81.18393% with 89 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/extensions/prover/worker/src/backend/sp1.rs 0.00% 36 Missing ⚠️
bin/asm-runner/src/prover_context.rs 75.39% 31 Missing ⚠️
...tes/extensions/prover/worker/src/backend/native.rs 71.42% 6 Missing ⚠️
crates/extensions/prover/worker/src/backend/mod.rs 80.76% 5 Missing ⚠️
crates/extensions/prover/worker/src/builder.rs 95.23% 3 Missing ⚠️
...rates/extensions/prover/worker/src/orchestrator.rs 90.00% 3 Missing ⚠️
crates/worker/src/subscription.rs 96.10% 3 Missing ⚠️
crates/extensions/prover/worker/src/input.rs 95.65% 2 Missing ⚠️
Files with missing lines Coverage Δ
bin/asm-runner/src/block_watcher.rs 82.50% <100.00%> (-0.66%) ⬇️
bin/asm-runner/src/bootstrap.rs 98.18% <100.00%> (-0.07%) ⬇️
bin/asm-runner/src/config.rs 100.00% <ø> (ø)
bin/asm-runner/src/main.rs 92.45% <ø> (ø)
bin/asm-runner/src/rpc_server.rs 97.74% <ø> (ø)
bin/asm-runner/src/worker_context.rs 66.47% <ø> (ø)
crates/extensions/prover/storage/src/sled/mod.rs 100.00% <ø> (ø)
...s/extensions/prover/storage/src/sled/moho_state.rs 100.00% <ø> (ø)
...tes/extensions/prover/storage/src/sled/proof_db.rs 100.00% <ø> (ø)
...tensions/prover/storage/src/sled/remote_mapping.rs 86.06% <ø> (ø)
... and 17 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

prajwolrg added 3 commits June 7, 2026 15:04
Begin grouping the prover stack under a single crates/extensions/prover tree.
Move the proof types crate there and rename it strata-asm-prover-types so the
naming matches the forthcoming prover-worker and prover-storage crates. Pure
relocation and rename; no logic changes.
Move the proof database crate alongside the relocated types crate and rename it
strata-asm-prover-storage, framing it as the prover's storage layer (the
analogue of asm-storage for the ASM worker). Pure relocation and rename; the
storage traits and sled implementations are unchanged.
Proof scheduling and reconciliation lived inside the asm-runner binary,
hard-wired to the concrete SledProofDb, so the orchestrator could not be
tested against fakes or reused outside the binary.

Introduce strata-asm-prover-worker, mirroring the ASM worker's shape: it
defines a ProverContext umbrella trait and drives the orchestrator generically
over it, while the binary supplies the concrete impl (AsmProverContext) wiring
the sled stores and the Bitcoin client. The proving backend is split into
native and sp1 modules behind the existing feature gate.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 7, 2026

Commit: c30c22c
SP1 Execution Results

program cycles gas
asm-stf 136,367,055 141,452,326
moho 5,223,555 5,525,314

prajwolrg added 2 commits June 7, 2026 16:31
A periodically-ticking consumer (the prover orchestrator) needs to drain
every buffered commitment at the top of each tick without parking on the
channel, and to learn that the worker has shut down once the backlog is
empty. recv() can only await; try_recv() covers both via Empty/Disconnected.
Proof requests were enqueued from the block watcher before the ASM worker
had committed the block. Subscribe the orchestrator to the worker's
post-commit stream instead: it expands each committed L1BlockCommitment
into its ASM step proof and Moho recursive proof internally, so proofs are
requested only for durably-stored blocks.

The subscription becomes the orchestrator's sole input, dropping the
ProverWorkerHandle/request_proof channel; the block watcher returns to
only feeding blocks to the worker.
@prajwolrg prajwolrg force-pushed the STR-3699-prover-worker branch from 96a4ad4 to a0e9737 Compare June 7, 2026 10:54
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.

1 participant