refactor: event-driven BullMQ pipeline, remove MongoDB status polling#20
Draft
necipsagiro wants to merge 1 commit intofeat/proverfrom
Draft
refactor: event-driven BullMQ pipeline, remove MongoDB status polling#20necipsagiro wants to merge 1 commit intofeat/proverfrom
necipsagiro wants to merge 1 commit intofeat/proverfrom
Conversation
Remove redundant MongoDB status tracking (status[], failCount, timeoutAt, kind) and Master polling classes. Each worker now triggers the next pipeline stage upon completion via deterministic BullMQ jobs. Add startup recovery sweep for crash resilience and PipelineManager for worker lifecycle management. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
The previous architecture duplicated BullMQ's built-in capabilities in MongoDB:
status[]arrays on BlockEpoch/ProofEpoch tracked "waiting"/"processing"/"done" — but BullMQ already manages job statesfailCountfields reimplemented retry logic — but BullMQ hasattempts+ exponentialbackofftimeoutAtfields reimplemented timeout detection — but BullMQ haslockDuration+ stalled detectionwhile(true)loops looking for "waiting" records — creating unnecessary load and latencyWhat changed
MongoDB is now a pure data store. All job orchestration is handled by BullMQ.
while(true)+ sleep)status[]fieldsfailCount+ manual retryattempts: 3+ exponential backoff (10s → 20s → 40s)timeoutAt+ manual timeout checklockDuration(5min) + stalled detection (5s)New files
processors/triggers.ts— Event-driven stage transitions. After a worker stores a proof,tryEnqueueAggregation()checks if the sibling proof exists and enqueues the merge.tryEnqueueSettlement()enqueues the settler when the root proof is ready.processors/pipeline.ts—PipelineManagerreplaces the three separate Master classes. Creates all BullMQ workers, handles events, graceful shutdown (SIGTERM/SIGINT).processors/recovery.ts— Startup recovery sweep. Scans MongoDB for incomplete work (full epochs without proofs, sibling pairs without parent, unsettled roots) and enqueues missing jobs. Safe to run repeatedly thanks to deterministic job IDs.processors/utils/jobOptions.ts— Shared BullMQ config and deterministic job ID generators (bp:{height},agg:{height}:{index},settle:{height}).Deleted files
processors/base/Master.ts— Base polling classprocessors/block-prover/master.ts— BlockProver polling loopprocessors/aggregator/master.ts— Aggregator polling loopprocessors/settler/master.ts— Settler polling loopprocessors/block-prover/utils.ts— Status registration helpersdb/types.ts—BlockStatus,ProofStatus,ProofKindenumsSchema simplifications
status[],epochStatus,failCount,timeoutAtstatus[],kind,failCount,timeoutAt; addedsettled: booleanstatus,timeoutAtTest plan
npx vitest run)🤖 Generated with Claude Code