refactor(prover): extract a prover-worker crate from asm-runner#143
Draft
prajwolrg wants to merge 6 commits into
Draft
refactor(prover): extract a prover-worker crate from asm-runner#143prajwolrg wants to merge 6 commits into
prajwolrg wants to merge 6 commits into
Conversation
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.
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.
|
Commit: c30c22c
|
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.
96a4ad4 to
a0e9737
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Proof scheduling and reconciliation lived inside the
asm-runnerbinary atbin/asm-runner/src/prover/, hard-wired to the concreteSledProofDb, so the orchestrator could not be tested against fakes or reused outside the binary. This PR extracts that logic into a dedicatedstrata-asm-prover-workercrate and groups the prover stack under a newcrates/extensions/prover/tree.The new worker mirrors the ASM worker's shape: it defines a
ProverContextumbrella 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 asstrata-asm-worker+asm-storage+ the binary'sworker_context.rs.Split into three reviewable commits, each of which compiles on its own:
relocate proof-types crate under extensions/prover— move + renamestrata-asm-proof-types→strata-asm-prover-types(mechanical).relocate proof-db crate as extensions/prover/storage— move + renamestrata-asm-proof-db→strata-asm-prover-storage(mechanical).extract proof orchestration into a prover-worker crate— introduceProverContext, make the orchestrator generic, split the proving backend intonative/sp1modules, and rewire the binary. This is where the real change lives.The
strata-asm-proof-impl(guest statements) crate intentionally stays incrates/proof/.Type of Change
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/testacross the affected crates under both default andsp1features; the migrated queue/scheduling unit tests and the runner/rpc tests pass.Now that the orchestrator is decoupled from sled, a fake
ProverContextcan exercise the full reconcile/schedule loop end-to-end — left as a follow-up rather than expanding this PR's scope.Checklist
Related Issues
STR-3699