feat(sequencer): implement deterministic transaction sequencer and su… - #760
Merged
Chucks1093 merged 1 commit intoAug 24, 2026
Merged
Conversation
Alaka-ibr
force-pushed
the
feat/transaction-sequencer-758
branch
2 times, most recently
from
August 24, 2026 16:19
0b37eb0 to
12dfbbd
Compare
…pply drift guard (accesslayerorg#758) Add per-creator in-process FIFO sequencer and Redis distributed lock to serialise concurrent buy/sell operations and prevent supply drift. - CreatorSequencer in-process FIFO queue with 10s timeout and 5min idle GC - acquireSequencerLock distributed lock with TTL renewal and safe release - verifySupplyAndGuard detecting supply drift after on-chain transactions, setting Redis drift flag to halt operations - POST /api/v1/internal/sequencer/clear-drift/:creatorWallet endpoint to clear flag - Integration unit tests for queue FIFO, timeouts, GC, drift detection, and clearing
Alaka-ibr
force-pushed
the
feat/transaction-sequencer-758
branch
from
August 24, 2026 17:30
12dfbbd to
8313ce2
Compare
Member
|
LGTM |
6 tasks
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.
feat(sequencer): implement deterministic transaction sequencer and supply drift guard (#758)
Summary
Closes #758
When concurrent buy/sell operations hit the same creator, optimistic database commits can cause supply drift when on-chain execution sequence differs from read order. This PR implements a per-creator in-process FIFO sequencer and Redis distributed lock to serialize mutating operations per creator and halt operations if supply drift is detected.
Changes
1. In-Process FIFO Queue (
src/utils/creator-sequencer.utils.ts)CreatorSequencermaintains aMap<creatorWallet, AsyncQueue>.SequencerTimeoutError(503 sequencer_timeout).2. Redis Distributed Lock (
src/utils/sequencer-lock.utils.ts)seq_lock:{creatorWallet}(15s TTL, 5s background renewal interval).SequencerContentionError(503 sequencer_contention).3. Supply Drift Guard (
src/utils/supply-drift-guard.utils.ts)verifySupplyAndGuard: compares expected post-operation supply against actual supply returned on-chain.supply_drift_detectedand sets Redis flagdrift:{creatorWallet}to halt further operations.assertNoSupplyDrift: checks drift flag before operations.clearDrift: clears the Redis flag.4. Admin Clearance Endpoint (
src/modules/admin/sequencer.controllers.ts,src/modules/admin/sequencer.routes.ts)POST /api/v1/internal/sequencer/clear-drift/:creatorWallet: allows operators to clear the drift flag.Test Coverage
Unit tests in
src/utils/creator-sequencer.utils.test.ts&src/utils/supply-drift-guard.utils.test.ts(8 passed):SequencerTimeoutError.clearDrift.