Repository navigation
Description
Drive has a filter for matching document state transitions, written "to be used in the context of clients subscribing to document events" (#2761, #2781). DAPI has no RPC that uses it, and the Platform service has no streaming RPC at all, so an application that wants to react to new documents has to poll. We would like a server-streaming DAPI call that delivers the document transitions matching such a filter, in a form the client can verify.
We hit this building Dash Forge, a git forge that runs on Platform. Its notifications, CI runners and webhook relay all depend on hearing about new documents.
Expected Behavior
A client opens one stream with a filter (contract id, document type, action and clauses, the shape DriveDocumentQueryFilter already takes) and receives each matching document transition once it is committed, with its block height and transition hash. The client can check what it receives against Platform state instead of trusting the node that sent it.
Current Behavior
The filter exists, but nothing serves it.
packages/rs-drive/src/query/filter.rsL1-L35 describes "subscription filters for document state transitions".DriveDocumentQueryFiltertakes a contract, a document type and per-action clauses (DocumentActionMatchClauses, L86-L137), and evaluates a transition in two steps:matches_document_transition, thenmatches_original_documentwhen the clauses need the pre-change document.- It is maintained: fix(drive)!: subscription filters match generated properties a transition leaves out #5114 (in 5.0.0-beta.1) taught it to match generated properties. The book documents subscription filters too (derived-index-properties.md L100).
- At the tag, no crate outside
filter.rsrefers toDriveDocumentQueryFilterormatches_document_transition.
DAPI has no Platform stream.
- None of the 73 RPCs of the
Platformservice inplatform.protois server-streaming. The closest iswaitForStateTransitionResult, which waits for one transition whose hash the client already knows. - The
Coreservice does stream:subscribeToBlockHeadersWithChainLocks,subscribeToTransactionsWithProofsandsubscribeToMasternodeList(core.proto L13-L15).
rs-dapi already sees every Platform transaction.
- It holds a Tenderdash websocket subscription whose events carry the transaction hash, height, result and bytes (
TransactionEvent, tenderdash_websocket.rs L15-L21). It fans them out through the in-process event bus (streaming_service/mod.rs L162-L177), which already has aPlatformAllTxsfilter (subscriber_manager.rs L60-L67). - Today the only consumer is
waitForStateTransitionResult, which waits for one hash (wait_for_state_transition_result.rs L104-L114). Withprove: trueit fetches a proof for the transition through Drive's internalgetProofs(L364-L376).
An earlier attempt was closed. #2795 added subscribePlatformEvents: an event bus in drive-abci, block-committed and state-transition-result events, a DAPI proxy and an rs-sdk helper. Its description calls those events a proof of concept and lists "document updates, identity changes" as further work. It was closed unmerged on 2026-08-21. Parts of it are at the tag:
- the
rs-dash-event-buscrate, whose header still lists anevent_muxmodule that is not there (lib.rs L1-L8); subscribePlatformEventsin rs-dapi's table of streaming methods, although the proto has no such RPC (grpc.rs L116-L122).
We could not find an open issue or PR that tracks document subscriptions.
Possible Solution
A suggestion; you will know better where the pieces should live.
- A server-streaming RPC, for example
subscribeToDocumentTransitions(filter), whose request carries the fields ofDriveDocumentQueryFilter(contract id, document type name, action and clauses) and is checked with itsvalidate()(L496). - Each message carries the block height, the transition hash, the matching transition (or its index in the batch), and the block time.
- To verify, a client could ask for the same proof
waitForStateTransitionResultreturns withprove: true, either attached to the message or by a follow-up call per hash. Even without a proof on every message, a stream of hashes and heights that the client then reads with proofs would replace polling and keep the client verifying. - Some open questions we noticed and can't answer:
- Clauses on the original document (replace, delete, transfer, purchase) need the document as it was before the block. rs-dapi only hears about a transaction after it is committed, so it may be simpler to run the filter in drive-abci during execution, as feat(platform): add real-time platform event subscriptions via gRPC streaming #2795 emitted its events from
finalize_block. - A client that reconnects needs to resume from a height without gaps. Being able to start a stream at a given height would cover that.
- Limits on subscriptions per connection and per IP (one of feat(platform): add real-time platform event subscriptions via gRPC streaming #2795's review findings was that subscribers were unbounded).
- Clauses on the original document (replace, delete, transfer, purchase) need the document as it was before the block. rs-dapi only hears about a transaction after it is committed, so it may be simpler to run the filter in drive-abci during execution, as feat(platform): add real-time platform event subscriptions via gRPC streaming #2795 emitted its events from
Alternatives Considered
- Polling (what we do). Forge's inbox reads up to 12 document feeds every 60 seconds per open tab (inbox.ts L71-L77). Self-hosted CI runners poll their repositories every two minutes by default (forge-relay README L110-L113). Notifications arrive up to a minute late and CI up to two, and every poll that finds nothing still counts against dashmate's default gateway limit of 150 requests per minute per IP (getBaseConfigFactory.js L254-L255, rate_limiter.yaml.dot L1-L6).
- A relay. Forge ships a relay a user can run to poll on behalf of runners and wake them. It works, but it is one more service someone has to host, and the runner trusts it rather than Platform.
subscribePlatformEventsas in feat(platform): add real-time platform event subscriptions via gRPC streaming #2795. Block-committed events alone would let a client poll only when a block lands, which helps with latency but not with the number of reads. A document filter is what removes the reads.
Additional Context
- Every application with feeds, chat, notifications or a bot has the same need. Polling cost grows with users times feeds, and on public nodes it runs into the per-IP limit.
- Related: DAPI: a non-blocking call to look up a state transition's status by hash (pending, committed, dropped or unknown) #5269 (a non-blocking call that reports a state transition's status by hash).
- Environment: Platform 5.0.0-beta.1 on a devnet (sakura); clients are
@dashevo/evo-sdk/@dashevo/wasm-sdk5.0.0-beta.1 in the browser, and rs-sdk (dash-sdk) at tagv5.0.0-beta.1. Project: https://github.com/PastaPastaPasta/dash-forge
Activity