Registry Mirror
Skip to content

Conversation

@QuantumExplorer

@QuantumExplorer QuantumExplorer commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Basic explanation

What this does: It lets an app ask a node "tell me when something I care about happens" instead of asking again and again. The app names what it cares about (documents on a contract, or Platform addresses), and the node sends each matching transaction as soon as its block is final. This is the work of #5285 by PastaPastaPasta, brought up to date with today's v5.2-dev and finished for review. #5285 itself is untouched.

Value: Apps and wallets stop polling. A wallet watching its addresses, or an app watching a document type, learns of a change within one block and makes one long-lived request instead of many short ones. Nodes answer from blocks they already store, so Drive and block execution do no extra work.

Risks: Medium, and outside consensus. No code that runs during block execution changes. The new risk is load on a node's API side: each stream holds a connection open, bounded by 256 streams per node and 16 per source, with reads and matching bounded too. The stream is the node's word, not a proof, so a client must still read state with a proved query before acting. Not yet run on a live network.

Issue being fixed or feature implemented

Closes #5274.

Applications that react to Platform activity poll for it today, and a wallet watching its addresses does the same. Polling cost grows with users times feeds, runs into the gateway's per-IP limit, and notices changes late.

#5285 adds subscribeToStateTransitions, a server-streaming Platform RPC, for this. It was written against a v5.2-dev that is now about 470 commits old and no longer merges. This branch carries its six commits on today's v5.2-dev, which since gained the block queries (#6038), protocol version 16 (#6253) and two new kinds of transition. If this merges, #5285 can be closed.

What was done?

The feature (commits 1 to 6, by PastaPastaPasta, author and messages kept; #5285 describes each in full):

  1. feat(drive): DriveDocumentQueryFilter compares values in the form the schema stores, so one value in two encodings matches. It is generic over how it holds its contract, so a subscription builds it once.
  2. feat(dapi)!: the RPC, its messages and the regenerated clients. A request carries 1 to 16 filters and an optional start height. A response is a match (height, time, protocol version, hash, bytes, which filters and batch positions matched) or a checkpoint.
  3. feat(sdk): dash_platform_queries::subscriptions: the filter types, their wire form, and ResolvedFilters, which binds document filters to their contracts and matches transitions.
  4. feat(rs-dapi): the stream, served from the Tenderdash block store. Each subscription walks committed heights with its own cursor and never skips one. Reads are shared through a bounded cache, with at most 8 Tenderdash calls in flight.
  5. feat(dashmate): an Envoy route with the Core streams' timeouts.
  6. feat(sdk): Sdk::subscribe_to_state_transitions, which checks each transition's hash, resumes from the last checkpoint on another node, and bans a node that sends something invalid.

What bringing it onto today's v5.2-dev took

  • Additive conflicts, both sides kept: the RPC list and messages in platform.proto, VERSIONED_REQUESTS in dapi-grpc/build.rs (now 78), the metrics allowlist, imports, Cargo.toml and Cargo.lock.
  • Generated gRPC clients were regenerated from the merged proto with yarn workspace @dashevo/dapi-grpc build, not merged by hand.
  • rs-drive/src/query/filter.rs: keeps the newer refuse_state_generated_fields check and the Erase arm next to feat(platform)!: subscribe to committed state transitions matching document and address filters #5285's generic DriveDocumentQueryFilter<C>.
  • rs-dapi/src/clients/tenderdash_client.rs: both branches added block, block_results and the types they return. The versions already on v5.2-dev stay (getBlocks and getOwnerTransactionsInBlock use them), and from feat(platform)!: subscribe to committed state transitions matching document and address filters #5285 only what was missing is added: the blockchain call with BlockMeta and ResultBlockchainInfo, null accepted for ExecTxResult.events, and the decoding tests. The stream and the block queries now read blocks through one client.

What changed compared with #5285

On the node (rs-dapi)

  • A stream never starts above the node's tip:

    node at height 500; a client asks to start at 800 (a checkpoint told it 799 was scanned)
    before: opening checkpoint 799, then nothing until height 800: blocks 501 to 799 are never scanned
    after:  opening checkpoint 500, then every block from 501 on; a start more than 1,000 ahead is refused
    

    A checkpoint says every height up to it was scanned, and a node cannot say that of heights it has not reached.

  • A read keeps its place until Tenderdash answers. At most 8 Tenderdash calls are in flight. A call now counts against that until Tenderdash has answered it, whether or not a stream still waits, and none of the calls the stream makes (block, results, metas, status) has a deadline of its own. Before, a client that left, or a wait that timed out, freed the place while Tenderdash was still working, so reconnecting clients could pile work on a slow node. One status call is in flight at a time, so a slow status takes one place and not the ones block reads need.

  • A stream that opens before the node knows its tip takes the tip as soon as the node has it:

    node just restarted, Tenderdash takes seconds to answer a status call; many clients open streams at once
    before: each open asks for the tip in turn, one status call at a time; the ones still waiting after 30 seconds get UNAVAILABLE, though the tip was known after the first answer
    after:  every open still waiting takes the tip the moment the node's tip tracker publishes it
    
  • A stream waits 30 seconds for a read, from when it asks, whatever the read waits on in turn (its turn to match, another stream reading the same block, the 8 places, Tenderdash). It then ends with UNAVAILABLE.

  • Decoding and matching run on the blocking pool, not on the four async threads that serve every other request. A stream holds a decoded block only while it has one of two places to match it.

  • A node that cannot read its chain tip says so:

    node cannot reach Tenderdash; a stream has caught up at height 500
    before: checkpoint 500 every 10 seconds for as long as the stream stays open, as on a quiet chain
    after:  UNAVAILABLE once the tip has failed to be read for 30 seconds; new streams are refused until it is read again
    
  • Missing history is always FAILED_PRECONDITION. A range wholly below the store's base, a block pruned after its metas were read, and a start too far ahead of the node's tip were answered as UNAVAILABLE, which says the node is failing.

  • A status that ends a stream names the block that ended it, and no height to resume from:

    a client holds resume height 101 and reopens on a node at 95; the node starts at 96 and cannot read it
    before: UNAVAILABLE "cannot read block 96: ...; resume from 96" (following it moves the client back from 101)
    after:  UNAVAILABLE "cannot read block 96: ..."
    

    The same holds for a block the node cannot decode, or one executed under a protocol version it does not know.

In the SDK (dash-sdk)

  • The SDK refuses to subscribe until the network runs protocol version 16. A 5.1 node does not know the method. The request declares the version (needs_protocol_version, listed in rs-dapi-client/tests/request_inventory.rs), and Sdk::subscribe_to_state_transitions checks it before the first stream, the way the fetch paths do for every other method a release added:

    SDK on a network proven at protocol version 15
    before: the stream request is sent; every 5.1 node that answers UNIMPLEMENTED is banned and the next one is tried
    after:  Error::ProtocolVersionNotActive { method: "subscribe_to_state_transitions", required: 16, network: 15, .. }; nothing is sent
    
  • A node that only lacks history, or has no room for another stream, is not banned:

    the node pruned block 42; the SDK asks to resume from 42
    before: the node is banned for every request, then the next node is tried
    after:  the node is passed over for the next stream and stays usable; once 8 nodes in a row lack the height, the subscription ends with the refusal
    
  • The place to resume from only moves up, and so do the checkpoints an app is given. Every stream must open with a checkpoint, no higher than the height before its start:

    the SDK holds checkpoint 100,000 and opens a stream at 100,001
    first message is checkpoint 5,000,000   before: accepted, the subscription resumes from 5,000,001   after: node fault, banned, resumed from 100,001 elsewhere
    first message is checkpoint 99,990      before: node fault                                           after: the node started at its tip: its matches are delivered (possibly again),
                                                                                                                its checkpoints are kept back until they reach 100,000, and a break before
                                                                                                                that reopens at 100,001
    first message is checkpoint 0           before: node fault                                           after: node fault (no node starts that far below)
    

    Within one stream a checkpoint never goes back.

  • Bytes the SDK cannot decode must come from two nodes before it blames itself:

    a node sends a match at height 77 whose bytes do not decode
    before: the subscription ends with "this SDK is likely older than the network: upgrade it"
    after:  the stream resumes on another node, unblamed
            a second node sends the same bytes      -> the subscription ends with that error
            the same node sends them three times    -> it ends with "that node is faulty, or this SDK is older than the network"
    
  • Leftover bytes: rs-dapi and the SDK decode a committed transition as its block's protocol version did, which from protocol version 14 refuses bytes left over after the transition. A decoder generation this build does not know is refused, as execution refuses it.

  • SDK tests: the new ExecutionError::possibly_accepted field, and a 16 MiB stack for the test that builds a value 300 levels deep (the pattern the other deep-value tests use).

In the filters (dash-platform-queries)

  • A private document create from the shielded pool names no Platform address, so no address filter matches it.

  • A document erase (the purge of a deleted document's retained revisions) has no action a filter can name. Drive's filter already refuses to describe an erase by content. So it is delivered only by a filter without actions:

    filter: documents on contract C, no actions listed    -> an erase on C is delivered
    filter: documents on contract C, actions = [DELETE]   -> an erase on C is not delivered
    

    An ERASE action can be added to the proto later without breaking clients.

  • An address filter no longer matches the fallback address of an identity creation from the shielded pool. That address is credited only when the identity cannot be created, and the transition then fails. A failed transition is never delivered, so every delivered one named the address without crediting it:

    filter: addresses = [A], role = RECIPIENT
    transition: identity creation from the shielded pool, fallback address A, identity created (A is not credited)
    before: delivered as a match on A
    after:  not delivered
    
  • RECIPIENT means named as an output. Whether a named output is credited can depend on execution: a shield from an asset lock names where its surplus goes and may leave none. The proto and docs said "credits"; they now say what is matched.

  • A clause value is a scalar or a flat list of scalars. A nested list or a map is refused where it starts, without being walked.

Elsewhere

  • JavaScript clients (dapi-grpc): the Node and browser PlatformPromiseClient forward subscribeToStateTransitions and return the stream, as the Core clients do for theirs.
  • The docs say what the stream does not deliver (platform.proto, subscribeToStateTransitions.md): a transition that failed is never delivered, even one that was charged for and still changed an address balance (the fee taken from an address input, or the fallback credit above). A wallet learns of those from getRecentAddressBalanceChanges or a proved balance read.
  • One rule for where to resume, in every place that states it (the proto, the endpoint doc, the SDK docs): the height to resume from is the greater of the one the client holds and a received checkpoint plus one, and it never moves down. The stream's statuses say "the highest checkpoint" or name no height at all.
  • One decoder, two copies, one test. Drive ABCI keeps its own copy of the wire where clause decoder, since it depends on dash-platform-queries for its tests only. A test there now fails when the two read a clause differently.

Not in this PR

  • Proving a checkpoint, or a match. A checkpoint is a height and nothing else: it carries no quorum signature, so it is the node's word, like the rest of the stream. One that names a height the chain had not reached hides blocks until a stream reaches that height: each stream opened meanwhile starts at its node's tip, so what is committed between two streams is scanned by neither, and nothing below the tip of the first of them is. How many blocks that is depends on how far above the chain the checkpoint was; the 1,000 blocks a node lets a start be above its tip limit which starts it admits, not this. No honest node sends such a checkpoint; it is one way a node leaves matches out, and a proved read is the remedy. Closing it needs proof that the chain reached the checkpoint's height: the block's quorum signature sent with the checkpoint (what getBlocks returns when asked to prove), or a proved read during the stream. A signature would not show that nothing below a true height was left out; that takes a second node.
  • Matching on what execution did. Failed transitions that still move credits, and whether a named output was credited. Both need a record from Drive of what a transition changed, and a result code in the response.
  • One block reader, and one transition decoder, for the stream and the block queries. They share the Tenderdash calls, but the stream keeps its own cache of decoded blocks, and getBlocks and getOwnerTransactionsInBlock answers are still decoded leniently at every protocol version.
  • Reusing a transition's stored form across the alternatives of one filter (inside DriveDocumentQueryFilter).
  • wasm-sdk and js-evo-sdk bindings, and identity, token and data contract filters. The request's oneof takes new filter kinds later without breaking clients.

How Has This Been Tested?

On macOS (arm64), debug builds, on this head (which merges v5.2-dev at 58d2566):

  • cargo test -p rs-dapi --lib: 526 passed. This includes the stream tests (the scan loop against an in-memory chain: replay then live without gaps, start heights in and out of the window, idle checkpoints, per-source limits, stalled clients) and the Tenderdash decoding tests. New here: a start ahead of the tip begins at the tip and scans every block after it; a read nobody waits for keeps its place until Tenderdash answers; a slow status holds one place however many ask for it; a stream that opens while its own status call waits takes the tip the tracker publishes; a second reader of a stalled block, and a scan queued for its turn to match, give up 30 seconds after they asked; a range wholly below the store's base, and a block pruned after its metas were read, are heights the node lacks; a caught-up stream keeps checkpointing while the tip is read at one height and ends once it cannot be read; a status that ends a stream names its block and no height to resume from.
  • cargo test -p dash-platform-queries --lib subscriptions: 24 passed. New here: an erase reaches only a filter without actions; no address filter matches the fallback address of an identity creation; a shield's surplus address matches whatever it is credited; a nested list or a map, 100,000 levels deep in one case, is refused without being walked; a committed transition decodes by its block's decoder generation, and an unknown generation is refused.
  • cargo test -p dash-sdk --lib -- subscriptions protocol_gate: 102 passed. New here: subscribing is refused until the network is verified at protocol version 16; a node lacking heights is passed over and not banned; a stream that opens above its start, lower than a node may start, or without a checkpoint is a node fault; a stream that opens below the place to resume from has its matches delivered and its checkpoints kept back, and a break reopens at the place asked for; what is committed after the next stream opens is delivered; undecodable bytes end the subscription only when a second node delivers them, and one node repeating them three times ends it without the upgrade advice; leftover bytes are refused where the protocol refuses them; the subscription ends after 8 nodes in a row lack the heights.
  • cargo test -p drive-abci --lib query::document_query::v1::conversions: 1 passed, the test that holds the two where clause decoders together.
  • cargo test -p rs-dapi-client --test request_inventory: 5 passed, 1 ignored (it rewrites a committed file).
  • cargo test -p drive --lib query::filter: 85 passed.
  • yarn workspace @dashevo/dapi-grpc test:unit: 83 passed, 6 of them new for the two JavaScript clients; yarn lint is clean.
  • python3 .github/scripts/check-grpc-coverage.py: passes.
  • cargo check --locked -p wasm-sdk --target wasm32-unknown-unknown --lib: builds, so dash-sdk with the subscription module type-checks for wasm32.
  • cargo fmt --all -- --check and cargo clippy --all-targets --all-features --locked -- --no-deps -D warnings on dash-platform-queries, rs-dapi, rs-dapi-client, dash-sdk, dapi-grpc, drive and drive-abci: clean.

Not done: no run against a local network or devnet; the network-only test tests/fetch/state_transition_subscriptions.rs only compiles.

Public interface changes

gRPC (platform.proto), additive

  • rpc subscribeToStateTransitions(SubscribeToStateTransitionsRequest) returns (stream SubscribeToStateTransitionsResponse).
  • SubscribeToStateTransitionsRequest with DocumentFilter (contract, optional document type, up to 12 ActionMatch alternatives, optional batch owner), AddressFilter (up to 256 addresses and a Role: ANY, SENDER, RECIPIENT) and an optional from_block_height.
  • SubscribeToStateTransitionsResponse: a StateTransitionMatch or a Checkpoint.
  • from_block_height above the block after the node's tip is scanned from that block. The first checkpoint is then lower than from_block_height - 1, and matches below from_block_height can be delivered again. In feat(platform)!: subscribe to committed state transitions matching document and address filters #5285 the node waited for the height and delivered nothing before it. A client that reads the stream itself resumes from the highest checkpoint it received, not the last: its height to resume from is the greater of the one it holds (the height it first asked to start at included) and a checkpoint plus one.
  • Served by rs-dapi. Drive's QueryService answers UNIMPLEMENTED; the gateway routes the method to rs-dapi.
  • Statuses: INVALID_ARGUMENT (malformed or undecidable filter), NOT_FOUND (unknown data contract), OUT_OF_RANGE (start behind the replay window), RESOURCE_EXHAUSTED (limits, or a client that does not read), FAILED_PRECONDITION (the node no longer keeps a block, is more than 1,000 blocks short of the start height, or cannot decode a block), UNAVAILABLE (the node cannot read from Tenderdash, its chain tip included). Compared with feat(platform)!: subscribe to committed state transitions matching document and address filters #5285, a start too far ahead of the node's tip and pruned heights moved from UNAVAILABLE to FAILED_PRECONDITION, and a status message names the block that ended the stream but no height to resume from.

dash-sdk

  • New: Sdk::subscribe_to_state_transitions(filters, from_block_height, config) -> Result<StateTransitionSubscription, Error>. It fails with Error::ProtocolVersionNotActive until a verified answer shows the network at protocol version 16.
  • New module platform::subscriptions: StateTransitionSubscription (next, resume_height, into_stream), SubscriptionEvent, StateTransitionEvent, SubscriptionConfig.
  • StateTransitionSubscription::next ends with an error when the request is refused, a live start breaks before its first checkpoint, two nodes deliver bytes the SDK cannot decode (or the only node that answers delivers them three times), or 8 nodes in a row lack the heights asked for. Anything else is resumed.
  • SubscriptionEvent::Checkpoint is never lower than the one before it, and resume_height never goes down, so the last checkpoint is the one to save. A StateTransition event can be for a height below the last checkpoint: a transition delivered again by a node that started at its tip.

dash-platform-queries

  • New module subscriptions: StateTransitionFilter, DocumentFilter, DocumentActionMatch, DocumentAction, Role, ResolvedFilters, FilterMatch, SubscriptionFilterError, subscribe_request, check_filter_count, decode_committed_state_transition, MAX_START_ABOVE_TIP and the other MAX_* limits.
  • New module documents::from_proto: decoding of where clauses from their wire form.

rs-dapi-client

  • TransportRequest is implemented for SubscribeToStateTransitionsRequest; its needs_protocol_version() returns Some(16) and its settings ask not to ban a busy node (ban_busy_address: Some(false)).

dapi-grpc (JavaScript)

  • PlatformPromiseClient#subscribeToStateTransitions(request, metadata, options) in the Node client and (request, metadata) in the browser client. Both return the stream, not a promise.
  • New internal module lib/utils/rewireStream.js, which the Core browser client now uses too in place of its own copy.

drive

  • DriveDocumentQueryFilter<'a> becomes DriveDocumentQueryFilter<C: Deref<Target = DataContract>> (breaking, see below).
  • New: canonicalize_where_clause, DriveDocumentQueryFilter::canonicalize_clause_values. validate() now refuses clauses on fields outside the schema and operands that are not in canonical form.

rs-dapi (crate-internal)

  • TenderdashClient::blockchain, TenderdashClient::status_for_block_query, BlockMeta, ResultBlockchainInfo; PlatformServiceImpl gains the subscriptions field.

dashmate

  • The gateway's Envoy template routes subscribeToStateTransitions as a long-lived stream, in place of the route for subscribePlatformEvents, which has no RPC.

Breaking Changes

Both are Rust API only:

  • dapi-grpc: platform_server::Platform gains the associated type subscribeToStateTransitionsStream and the method subscribe_to_state_transitions. Implementations must add both; returning unimplemented, as drive-abci's QueryService does, is enough.
  • drive: DriveDocumentQueryFilter<'a> becomes DriveDocumentQueryFilter<C: Deref<Target = DataContract>>. Code naming the type writes DriveDocumentQueryFilter<&'a DataContract>.

On the wire the RPC and its messages are additive. No consensus code and no shipped protocol generation changes.

Checklist:

  • I have performed a self-review of my own code
  • My Rust, FFI, WASM, Swift or Kotlin changes follow the coding conventions
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed
  • If I added or changed GroveDB structure, I described it in the area's structure.rs, regenerated grovedb-structure.json, and checked the structure viewer link posted on this pull request
  • If I added or changed a system contract's document schemas, I checked the contract viewer link posted on this pull request

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

PR Hygiene · 4213ebe

  • Bots — thepastaclaw ✓
  • Self-review — post /self-reviewed
  • Build failed
  • Approvals
    • github (.github/grpc-queries-cache.json) — ktechmidas or shumkov
    • files with no dedicated owner — you own it
    • dashmate (packages/dashmate/docs/services/gateway.md, packages/dashmate/templates/platform/gateway/envoy.yaml.dot) — ktechmidas or shumkov
    • rust-dapi (packages/rs-dapi/Cargo.toml, packages/rs-dapi/src/clients/tenderdash_client.rs, packages/rs-dapi/src/metrics.rs and 7 more) — lklimek or shumkov
    • rs-drive-abci — you own it
    • rs-drive — you own it
    • rust-sdk (packages/rs-sdk/src/platform.rs, packages/rs-sdk/src/platform/subscriptions.rs, packages/rs-sdk/src/sdk/protocol_gate_tests.rs and 2 more) — lklimek or shumkov

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

@QuantumExplorer QuantumExplorer added this to the v5.2.0 milestone Nov 24, 2026
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 57 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 58d2566 and 4213ebe.

Files ignored due to path filters: 2

  • Cargo.lock is excluded by !**/*.lock
  • packages/dashmate/templates/platform/gateway/envoy.yaml.dot is excluded by !**/*.dot
Files selected for processing: 57

  • .github/grpc-queries-cache.json
  • packages/dapi-grpc/Cargo.toml
  • packages/dapi-grpc/build.rs
  • packages/dapi-grpc/clients/core/v0/web/CorePromiseClient.js
  • packages/dapi-grpc/clients/drive/v0/nodejs/drive_pbjs.js
  • packages/dapi-grpc/clients/platform/v0/java/org/dash/platform/dapi/v0/PlatformGrpc.java
  • packages/dapi-grpc/clients/platform/v0/nodejs/PlatformPromiseClient.js
  • packages/dapi-grpc/clients/platform/v0/nodejs/platform_pbjs.js
  • packages/dapi-grpc/clients/platform/v0/nodejs/platform_protoc.js
  • packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.h
  • packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbobjc.m
  • packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.h
  • packages/dapi-grpc/clients/platform/v0/objective-c/Platform.pbrpc.m
  • packages/dapi-grpc/clients/platform/v0/python/platform_pb2.py
  • packages/dapi-grpc/clients/platform/v0/python/platform_pb2_grpc.py
  • packages/dapi-grpc/clients/platform/v0/web/PlatformPromiseClient.js
  • packages/dapi-grpc/clients/platform/v0/web/platform_pb.d.ts
  • packages/dapi-grpc/clients/platform/v0/web/platform_pb.js
  • packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.d.ts
  • packages/dapi-grpc/clients/platform/v0/web/platform_pb_service.js
  • packages/dapi-grpc/lib/utils/rewireStream.js
  • packages/dapi-grpc/protos/platform/v0/platform.proto
  • packages/dapi-grpc/src/lib.rs
  • packages/dapi-grpc/test/unit/clients/platform/v0/nodejs/PlatformPromiseClient.spec.js
  • packages/dapi-grpc/test/unit/clients/platform/v0/web/PlatformPromiseClient.spec.js
  • packages/dapi/doc/endpoints/index.md
  • packages/dapi/doc/endpoints/streams/subscribeToStateTransitions.md
  • packages/dash-platform-queries/src/documents/document_query.rs
  • packages/dash-platform-queries/src/documents/from_proto.rs
  • packages/dash-platform-queries/src/documents/mod.rs
  • packages/dash-platform-queries/src/lib.rs
  • packages/dash-platform-queries/src/subscriptions/mod.rs
  • packages/dash-platform-queries/src/subscriptions/participants.rs
  • packages/dash-platform-queries/src/subscriptions/proto.rs
  • packages/dash-platform-queries/src/subscriptions/resolved.rs
  • packages/dash-platform-queries/src/subscriptions/tests.rs
  • packages/dashmate/docs/services/gateway.md
  • packages/rs-dapi-client/src/transport/grpc.rs
  • packages/rs-dapi-client/tests/request_inventory.rs
  • packages/rs-dapi/Cargo.toml
  • packages/rs-dapi/src/clients/tenderdash_client.rs
  • packages/rs-dapi/src/metrics.rs
  • packages/rs-dapi/src/server/grpc.rs
  • packages/rs-dapi/src/services/platform_service/mod.rs
  • packages/rs-dapi/src/services/platform_service/protobuf_request_errors.rs
  • packages/rs-dapi/src/services/platform_service/subscribe_to_state_transitions/block_source.rs
  • packages/rs-dapi/src/services/platform_service/subscribe_to_state_transitions/mod.rs
  • packages/rs-dapi/src/services/platform_service/subscribe_to_state_transitions/stream.rs
  • packages/rs-dapi/src/services/platform_service/subscribe_to_state_transitions/stream/tests.rs
  • packages/rs-drive-abci/src/query/document_query/v1/conversions.rs
  • packages/rs-drive-abci/src/query/service.rs
  • packages/rs-drive/src/query/filter.rs
  • packages/rs-sdk/src/platform.rs
  • packages/rs-sdk/src/platform/subscriptions.rs
  • packages/rs-sdk/src/sdk/protocol_gate_tests.rs
  • packages/rs-sdk/tests/fetch/mod.rs
  • packages/rs-sdk/tests/fetch/state_transition_subscriptions.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@thepastaclaw

thepastaclaw commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 4213ebe) · triage: normal

Base automatically changed from claude/state-transition-proof-b318cb to v5.2-dev November 25, 2026 01:53
@QuantumExplorer
QuantumExplorer force-pushed the feat/platform-subscriptions-on-6038 branch from 3f68557 to 5aa802d Compare November 25, 2026 02:10
@QuantumExplorer QuantumExplorer changed the title feat(platform)!: subscribe to committed state transitions matching document and address filters, on the before/after block proofs feat(platform)!: subscribe to committed state transitions matching document and address filters Nov 25, 2026
@QuantumExplorer
QuantumExplorer marked this pull request as ready for review November 25, 2026 02:11
@github-actions

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Nov 25, 2026
@QuantumExplorer
QuantumExplorer force-pushed the feat/platform-subscriptions-on-6038 branch from 5aa802d to c0a4e1c Compare November 25, 2026 13:21
@github-actions

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Phase 1 + Phase 2

Changes requested: 6 blockers

  • Caught-up subscriptions keep sending checkpoints after Tenderdash stops answering — packages/rs-dapi/src/services/platform_service/subscribe_to_state_transitions/stream.rs:145-149 (new)
    Impact: An app following the tip can stop receiving new matches without getting a stream error or triggering the SDK's idle failover.
  • Canceled subscription reads free fetch slots before Tenderdash finishes — packages/rs-dapi/src/services/platform_service/subscribe_to_state_transitions/block_source.rs:218-225 (new)
    Impact: When block reads are slow, reconnecting subscribers can add new work while the previous reads are still competing with other Tenderdash requests.
  • Subscription limits and pruned history can ban nodes that still serve ordinary queries — packages/rs-sdk/src/platform/subscriptions.rs:394-397 (new)
    Impact: An app whose subscriptions fill a node's quota or request history the node no longer retains can temporarily lose unrelated SDK queries through that node.
  • An unchecked checkpoint can skip requested replay and make healthy nodes look unavailable — packages/rs-sdk/src/platform/subscriptions.rs:511-530 (new)
    Impact: A client that saves a bad checkpoint can lose its replay position and, on reconnect, lose access to nodes that are otherwise serving correctly.
  • Malformed bytes from one node end a resumable subscription with an upgrade error — packages/rs-sdk/src/platform/subscriptions.rs:551-559 (new)
    Impact: A subscriber with a valid resume cursor can stop receiving events and be told to upgrade even though another node can serve the block to the current SDK.
  • Historical replay runs CPU-heavy matching on the workers that serve ordinary RPCs — packages/rs-dapi/src/services/platform_service/subscribe_to_state_transitions/stream.rs:398-408 (new)
    Impact: Concurrent catch-up subscriptions on a busy document contract can delay unrelated requests, even when the blocks are cached and no transitions match.

This PR adds a Tenderdash-backed stream for committed state transitions, with document and address filters, checkpoint-based replay, automatic Rust SDK reconnects, and an Envoy route. On this head, the Drive and rs-dapi image builds, Rust workspace and wasm32 checks, and end-to-end suites passed; review and PR Hygiene checks are still pending. Seven additional verified suggestions are omitted from the inline review budget.

🔴 6 blocking | 🟡 4 suggestion(s)

Review provenance

Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 6: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — Beyond the generated bindings, this is an intricate streaming change that adds a peer-facing deserialization path in packages/rs-sdk/src/platform/subscriptions.rs::decode, where remote nodes supply both the state-transition bytes and the protocol version used to decode them.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/rs-dapi/src/services/platform_service/subscribe_to_state_transitions/stream.rs`:
- [BLOCKING] packages/rs-dapi/src/services/platform_service/subscribe_to_state_transitions/stream.rs:145-149: Caught-up subscriptions keep sending checkpoints after Tenderdash stops answering
  Impact: An app following the tip can stop receiving new matches without getting a stream error or triggering the SDK's idle failover.
  An unreadable backend looks like a quiet chain until the stream is forced to reconnect. Once the tracker has published a nonzero height, failed tip probes only produce a debug log. `current_tip` still accepts that height for new streams, and the caught-up scan keeps sending ten-second checkpoints that satisfy the SDK's silence detector. Publish backend health alongside the last readable tip and end affected streams with `UNAVAILABLE` after a bounded failure interval. Test sustained probe failures separately from successful probes at an unchanged height.
- [BLOCKING] packages/rs-dapi/src/services/platform_service/subscribe_to_state_transitions/stream.rs:398-408: Historical replay runs CPU-heavy matching on the workers that serve ordinary RPCs
  Impact: Concurrent catch-up subscriptions on a busy document contract can delay unrelated requests, even when the blocks are cached and no transitions match.
  Neither the fetch semaphore nor response backpressure bounds matching work. `match_block` runs synchronously on one of DAPI's four Tokio workers after the read completes. For each document transition, a subscription can test up to 16 filters with 12 alternatives each; constrained alternatives can copy the same document and regenerate its stored fields repeatedly. A nonmatching block does not reach a response send, and a cache miss also performs synchronous base64 decoding, hashing, and transition decoding. Put conversion and matching behind bounded blocking work, preserve capacity for ordinary RPCs, and reuse the stored document form across alternatives that test the same transition.

In `packages/rs-dapi/src/services/platform_service/subscribe_to_state_transitions/block_source.rs`:
- [BLOCKING] packages/rs-dapi/src/services/platform_service/subscribe_to_state_transitions/block_source.rs:218-225: Canceled subscription reads free fetch slots before Tenderdash finishes
  Impact: When block reads are slow, reconnecting subscribers can add new work while the previous reads are still competing with other Tenderdash requests.
  The advertised eight-call limit does not bound outstanding backend work. The fetch future owns the permits, so a stream disconnect through `unless_closed` or a read timeout can release them after the RPC has been dispatched. Tenderdash's deployed `v2.0.0-dev.3` block handlers ignore the request context and continue their store reads. Follow the neighboring block queries' `run_holding_permit` pattern: keep queued work cancellable, let the dispatched task own the permit through completion, and put the deadline on the stream's wait for the shared result. Test that a timed-out waiter exits without freeing a slot before the backend finishes.

In `packages/rs-sdk/src/platform/subscriptions.rs`:
- [BLOCKING] packages/rs-sdk/src/platform/subscriptions.rs:394-397: Subscription limits and pruned history can ban nodes that still serve ordinary queries
  Impact: An app whose subscriptions fill a node's quota or request history the node no longer retains can temporarily lose unrelated SDK queries through that node.
  Replay eligibility and stream admission change the shared SDK address pool. A pruned height returned as `FAILED_PRECONDITION` reaches `blame` both during streaming and on open; `blame` bans the address for all methods by default. A fully pruned page takes a different path: Tenderdash rejects the range before returning metas, and DAPI maps that rejection to `UNAVAILABLE` rather than the documented history refusal. Admission's `RESOURCE_EXHAUSTED` can also cause a shared ban on open because the transport request inherits `ban_busy_address = true`. Classify missing history explicitly, keep replay exclusions local to the subscription or cursor, and opt out of busy-address bans for this RPC as the neighboring block queries do. Test that a node refusing the stream can still serve a current-state query.
- [BLOCKING] packages/rs-sdk/src/platform/subscriptions.rs:511-530: An unchecked checkpoint can skip requested replay and make healthy nodes look unavailable
  Impact: A client that saves a bad checkpoint can lose its replay position and, on reconnect, lose access to nodes that are otherwise serving correctly.
  Switching nodes does not recover from a checkpoint that has already poisoned the resume cursor. The endpoint promises that opening at `h` starts with a checkpoint at `h - 1`, but the SDK accepts a higher checkpoint and even accepts a transition before the opening checkpoint. It also accepts subsequent forward jumps without corroboration. If the saved cursor is more than 1,000 blocks ahead of another node, that node returns `UNAVAILABLE`, which the default open executor can turn into a shared ban. Require the opening checkpoint on every stream, verify its exact height for explicit starts, corroborate implausible forward jumps against proved height metadata, and distinguish a cursor-ahead refusal from a node-health failure.
- [BLOCKING] packages/rs-sdk/src/platform/subscriptions.rs:551-559: Malformed bytes from one node end a resumable subscription with an upgrade error
  Impact: A subscriber with a valid resume cursor can stop receiving events and be told to upgrade even though another node can serve the block to the current SDK.
  The SDK treats a matching hash as evidence that other nodes would return the same bytes, although the unproved response supplies both. Every decode error becomes terminal `Undecodable`; the existing test confirms that malformed bytes at a supported version never trigger a reconnect. The decoder also accepts trailing bytes even for blocks whose protocol selects exact consumption, so some malformed items pass rather than fail. Preserve typed decode outcomes and resume on another node for bad encoding under a supported version. Keep the local depth bound distinct, corroborate an unknown-version diagnosis before requiring an upgrade, and select permissive or exact decoding from the existing protocol slot.

In `packages/dash-platform-queries/src/subscriptions/participants.rs`:
- [SUGGESTION] packages/dash-platform-queries/src/subscriptions/participants.rs:36-39: A shield with no surplus matches an address it never credits
  Impact: A wallet watching `RECIPIENT` can receive a successful shield notification even though the watched address received no credits.
  The matcher reports every named `surplus_output` as a recipient, but the proto, Rust role and endpoint docs describe a recipient as an address the transition credits. The wallet's single-recipient funding flow can supply that address while shielding exactly the lock value minus the fee. Drive emits the address balance addition only for positive surplus, which depends on execution state, not just the serialized transition. Either define `RECIPIENT` consistently as a named potential output and test zero surplus, or use execution-derived effects to preserve the actual-credit guarantee.

In `packages/dapi-grpc/protos/platform/v0/platform.proto`:
- [SUGGESTION] packages/dapi-grpc/protos/platform/v0/platform.proto:189-190: The public Node and browser DAPI clients do not expose the new stream
  Impact: JavaScript users of the documented `v0.PlatformPromiseClient` get an undefined method when they try to open a state-transition subscription.
  The service descriptors and messages expose the RPC, but `node.js` and `browser.js` export handwritten Platform wrappers, and neither forwards `subscribeToStateTransitions`. The existing Core wrappers already show how to return a stream without promisifying it. Add and test equivalent forwarding in both Platform wrappers; this does not require the deferred wasm-sdk or js-evo-sdk bindings.

In `packages/dash-platform-queries/src/subscriptions/proto.rs`:
- [SUGGESTION] packages/dash-platform-queries/src/subscriptions/proto.rs:107-126: Nested filter operands are copied recursively before the encoder can reject them
  Impact: A Rust caller passing a deeply nested operand can exhaust its thread stack instead of receiving a local invalid-operand error.
  `narrowed` walks nested arrays and clones unsupported containers before the shared encoder checks whether the operand is a scalar or a flat list. The pre-pass also makes subscriptions send representable 128-bit integers as numbers while V1 document queries send the same values as decimal text, which the typed integer path rejects. Handle representable integers during one depth-bounded encoding traversal, and define and test the behavior for out-of-range integers and unsupported containers.

In `packages/dash-platform-queries/src/documents/from_proto.rs`:
- [SUGGESTION] packages/dash-platform-queries/src/documents/from_proto.rs:1-3: Subscriptions and document queries maintain separate decoders for the same wire clause
  Impact: An operator or operand-validation fix applied to only one decoder can make the two RPCs interpret the same protobuf clause differently.
  The new module copies the ordinary operator mapping, typed operand decoding and list-depth check from Drive ABCI's V1 document query. The comment is the only synchronization between them. Keep the schema-independent decoding in `dash-platform-queries`, which Drive ABCI already depends on, and map shared decode errors to the endpoint's `QueryError::InvalidArgument`. Window resolution can remain endpoint-specific without introducing a gRPC dependency in Drive.

@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

PastaPastaPasta and others added 13 commits November 25, 2026 22:18
…ment schema

DriveDocumentQueryFilter had no consumer, and clause values only matched transition values sent in the same encoding: an identifier as bytes never equalled one as base58 or Identifier, and a u8 field never equalled a U64 operand. Clause values and the transition values a clause reads are now both brought to the form the schema stores, element by element on typed arrays, so filters match regardless of how a client encoded an operand. Clauses on fields outside the schema are refused before their value is decoded, and null never satisfies an ordered comparison.

The filter is generic over how it holds its contract, so a subscription builds its filters once instead of per transition.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A server-streaming Platform RPC that delivers committed, successfully executed state transitions matching any of up to 16 document or address filters, interleaved with checkpoints a client resumes from. Drive answers it with unimplemented; DAPI serves it. Generated clients are regenerated.

BREAKING CHANGE: platform_server::Platform gains the subscribe_to_state_transitions method and its stream type, which implementations must add.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dash_platform_queries::subscriptions defines the request's document and address filters, their wire conversion, and ResolvedFilters, which binds document filters to their contracts and tells which filters a transition matches. Address roles are classified in one exhaustive match over every StateTransition variant, so a new variant does not compile until it is classified.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…block store

Each subscription walks committed heights with its own cursor, up to the highest height whose execution results are saved, so history and new blocks are read the same way and a missed websocket event cannot lose a block. Block and meta-page reads are single-flight, shared through a byte-bounded cache, and limited to 8 Tenderdash calls in flight. A height is never skipped: an undecodable transaction, an unknown protocol version or a pruned height ends the stream there.

Limits: 256 subscriptions per node, 16 per source, starts within 50k blocks behind and 1k ahead of the tip, and a client that does not read for 60 s is ended with RESOURCE_EXHAUSTED after its buffered messages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The gateway route uses the Core streams' timeouts and replaces the route for subscribePlatformEvents, which has no RPC behind it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sdk::subscribe_to_state_transitions returns a subscription that checks each transition's hash, decodes it with a bounded value depth, and resumes from the last checkpoint on another node with capped backoff. A node that sends a wrong hash, bad match indexes or a regressing checkpoint is banned; a transition the SDK cannot decode ends the subscription instead, since every node would send the same bytes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…are rebased onto

The subscription commits were written against an older v5.2-dev. Rebased
onto the before/after block proofs, they meet code that did not exist then:

- dash-platform-queries: classify the two variants added since. A private
  document create from the shielded pool names no platform address. A
  document erase has no action a filter can name, so only a document filter
  without actions delivers it; a test covers that.
- rs-dapi: the stream now reads blocks through the calls getBlocks and
  getOwnerTransactionsInBlock use, which have no deadline. Keep the 30
  second deadline the stream's reads had, so a stream fails and the client
  resumes elsewhere instead of stalling.
- rs-dapi-client: declare the protocol version from which every node serves
  subscribeToStateTransitions and list the method in the request inventory.
- rs-sdk: fill the new ExecutionError field in a test, drop an import that is
  no longer used, and run the deep-value test on a thread with enough stack.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tocol 16

A 5.1 node does not know subscribeToStateTransitions. It answers
UNIMPLEMENTED, which gets it banned. The request declares the protocol
version from which every node serves it, but
Sdk::subscribe_to_state_transitions opened the stream without checking.

It now asks the gate the fetch paths ask, once, before the first stream.
On a network not proven at protocol version 16 the call fails with
ProtocolVersionNotActive and nothing is sent.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…address

An identity creation from the shielded pool names an address that is
credited only when the identity cannot be created. The transition then
fails, and a subscription delivers only transitions that succeeded. So an
address filter matched that address exactly when it was not credited.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
- A transition that failed is never delivered, even one that was charged
  for and still changed the balance of an address it names.
- A document erase is delivered only by a filter that lists no actions.

The Objective-C header carries the proto comments, so it is regenerated.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…criptions

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ly flat clause values

Review fixes in the subscription filters:

- decode_committed_state_transition decodes a transition the way the block's
  protocol version decoded it for execution: from the version that takes a raw
  transition to be exactly one encoded transition, bytes left over after it are
  refused. rs-dapi and the SDK both decoded leniently at every version.
- A clause value is a scalar or a flat list of scalars. A nested list or a map
  was walked and copied in full before the encoder refused it, which a deep
  value could exhaust the stack with. It is now refused where it starts.
- A recipient is an address a transition names as an output. Whether it is
  credited is for execution to say: a shield from an asset lock names where its
  surplus goes and may leave none. The docs said "credits"; they now say so,
  and a test pins the surplus address of a shield that leaves nothing.

The Objective-C header carries the proto comments, so it is regenerated.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…d them when the tip cannot be read

Review fixes in the stream:

- A Tenderdash read keeps its share of the fetch budget until Tenderdash has
  answered it. The budget was held by the future of whoever waited, so a
  stream that went away or stopped waiting freed it while Tenderdash still
  worked on the read, and reconnecting clients could pile work on a slow node.
  The read now runs in a task that owns the permits, as the block queries do;
  the 30 second deadline is on the wait, queueing for the budget included.
- Blocks are decoded on the blocking pool, inside that task, and matched there
  too, two blocks at a time across all subscriptions. Both ran on the four
  async threads that serve every other request.
- The tip carries whether the node could read it. Once reading it has failed
  for 30 seconds, streams that have caught up end with UNAVAILABLE and new
  ones are refused. They kept sending checkpoints, which say the chain is
  quiet and keep the client from moving to a node that works.
- A range of metas wholly below the store's base is read as heights the node
  does not keep. Tenderdash refuses such a range, which was answered as
  UNAVAILABLE, where a range that reaches the base was answered as
  FAILED_PRECONDITION.
- A start ahead of the node's tip is FAILED_PRECONDITION, as a pruned height
  is: the node lacks the height and is not failing. UNAVAILABLE is retried by
  the client's executor, which bans the node for it.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ame one rule for where to resume

Two suggestions from the review that approved the subscription stream:

- A stream that opens before the tip is known asks Tenderdash for it, one
  status call at a time. Many clients open at once after a restart, and the
  ones still waiting their turn did not see the tracker publish the tip:
  with a status that takes seconds, the last of them ran out of time though
  the tip was known. They now take the tracker's publication when it comes
  first.
- The proto comment, the endpoint doc and two stream errors still said to
  resume from the last checkpoint. A client that reads the stream itself
  and does so moves its place to resume from back when a node starts at
  its tip. They now give the one rule the SDK follows: the height to resume
  from is the greater of the one held and a checkpoint plus one.

The Objective-C header carries the proto comments, so it is regenerated.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 25, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

New on this head: This revision lets a subscription use the tracker’s published tip while its own startup read is still pending, and documents how raw RPC clients can keep their resume height from moving backward. No CI checks had failed at review time; the Rust workspace and wasm32 tests, JS and NPM builds, and Docker image builds were still pending.

🟡 1 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

Review provenance

Source: reviewer 1: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); reviewer 7: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — The intricate streaming implementation adds peer-facing deserialization in packages/rs-sdk/src/platform/subscriptions.rs, where the SDK decodes state-transition bytes supplied by remote DAPI nodes according to the reported protocol version.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/rs-dapi/src/services/platform_service/subscribe_to_state_transitions/stream.rs`:
- [SUGGESTION] packages/rs-dapi/src/services/platform_service/subscribe_to_state_transitions/stream.rs:561-566: Raw RPC clients get conflicting resume advice when a replacement stream opens behind them
  Impact: A raw RPC client that follows a read or decode error from a lagging replacement node can rewind its saved cursor and replay blocks it already processed.
  A client holding resume height 101 can reopen on a node at height 95 and then be told to resume from 96 if that block fails to read once the node reaches it. The endpoint guide correctly tells the client to keep 101, but `read_failure` and both error branches in `matches_in` still prescribe the failed block’s height. Keep the block height as diagnostic information and remove the resume-height advice from all three errors; only the client knows the cursor it already holds.

@github-actions

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 25, 2026
…height to resume from

Three statuses that end a stream told the client to resume from the block
that ended it: a block that cannot be read, one executed under a protocol
version the node does not know, and one with a transaction the node cannot
decode.

A node asked to start above its tip starts at its tip, so that block can be
below the height the client holds. A client holding 101 that reopens on a
node at 95 was told to resume from 96, and one that followed the status
moved its place back and replayed blocks it had processed.

The statuses now name the block and leave the height to the client, which
is the only one that knows it. The rule stays where it is stated once: the
height to resume from is the greater of the one held and a checkpoint plus
one.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 25, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

New on this head: This head removes explicit restart heights from three subscription failure messages without changing their gRPC codes, and adds regression coverage for a decode failure below the requested start and a timed-out block read. GitHub reports no failed code checks; NPM release build validation, macOS generation, and changed-package detection are still pending.

🟡 1 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

Still open from earlier rounds (1)

  • 🟡 Suggestion: Raw RPC clients get conflicting resume advice when a replacement stream opens behind them — packages/dapi/doc/endpoints/streams/subscribeToStateTransitions.md:46-52 (thread)
Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-astra (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-astra (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-astra (agent: phase2-reviewer, role: platform-versioning); reviewer 6: gpt-6.2-astra (agent: phase2-reviewer, role: rust-quality); reviewer 7: gpt-6.2-astra (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: critical by gpt-6.2-sol (effort low) — The change is intricate and adds peer-facing deserialization in packages/rs-sdk/src/platform/subscriptions.rs, where the SDK decodes state-transition bytes supplied by remote DAPI nodes.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Single stage: Phase 1 and Phase 2 reviewed this head side by side, with no blocker gate between them (triage tier)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-astra — general (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — platform-versioning (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-astra — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/dapi/doc/endpoints/streams/subscribeToStateTransitions.md`:
- [SUGGESTION] packages/dapi/doc/endpoints/streams/subscribeToStateTransitions.md:46-52: Raw RPC clients get conflicting resume advice when a replacement stream opens behind them
  (carried; thread: https://github.com/dashpay/platform/pull/6249#discussion_r4698463882)

@github-actions

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 25, 2026
…scriptions-on-6038

Conflicts:
- packages/dapi-grpc/build.rs: VERSIONED_REQUESTS holds both sides' additions
  (the two emergency switch requests and the subscription request), 78 entries.
- the Java and Python Platform clients: regenerated from the merged proto with
  `yarn build` in packages/dapi-grpc. The other generated clients merged to
  what the generator writes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 30, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-review — Final validation — Phase 1 + Phase 2

New on this head: This head merges the updated v5.2-dev base branch; the subscription implementation and its prior fixes are unchanged since the last reviewed commit. CI has no failed code checks, while Kotlin SDK, NPM validation, changed-package detection, macOS generation, and PR Hygiene checks remain pending.

🔴 0 blocking | 🟡 0 suggestion(s) | 💬 0 nitpick(s)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — This is a large, intricate cross-cutting API and streaming change, but it does not modify consensus, funds, cryptography, storage migrations, or other critical surfaces as defined.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (antigravity quota lookup failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify the current code and confirm that no unresolved issues remain.

No unresolved findings remain from the prior review on this head.

@github-actions

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 30, 2026
@QuantumExplorer
QuantumExplorer merged commit 7fb4b64 into v5.2-dev Dec 1, 2026
34 of 36 checks passed
@QuantumExplorer
QuantumExplorer deleted the feat/platform-subscriptions-on-6038 branch December 1, 2026 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-self-review Waiting for the author to post /self-reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DAPI: stream committed document transitions that match a subscription filter (verifiable document subscriptions)

3 participants