feat(worker): per-block subscription stream#128
Open
prajwolrg wants to merge 1 commit into
Open
Conversation
8 tasks
49ac037 to
8a6d427
Compare
Codecov Report❌ Patch coverage is
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
|
Commit: ed89f59
|
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.
8a6d427 to
62febab
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
The ASM worker had derived-state consumers (Moho-state derivation today, proof requests later) wired into its hot path. This adds a per-block notification stream so consumers can react to each committed block on their own task instead of being baked into the worker.
AsmWorkerHandle::subscribe_blocks()hands out aSubscription<L1BlockCommitment>(aStream, with abacklog()depth signal). After each successful anchor-state commit, the service fans the new commitment out to all subscribers over unbounded channels and prunes dropped receivers viaretain.sendon 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 — henceAsmSubscribers. Mirrorsstrata-bridge'sbtc-trackersubscriber pattern.This is the foundation for STR-3698 (moho worker); the Moho consumer PR is stacked on top of this one.
Type of Change
Notes to Reviewers
Pure addition to
strata-asm-worker: no existing public API changed (subscribe_blocksis additive;submit_block/launchare unchanged).AsmWorkerHandle::new/AsmWorkerServiceState::neware nowpub(crate)since they take the privateAsmSubscribersregistry, but the builder is the only constructor and nothing outside the crate called them. Unit tests cover fan-out, ordering,backlog(), dead-subscriber pruning, and stream close.Checklist
Related Issues
Part of Jira STR-3698.