fix(server): serve product follow aliases and stamp statement expiry - #321
Closed
replghost wants to merge 1 commit into
Closed
fix(server): serve product follow aliases and stamp statement expiry#321replghost wants to merge 1 commit into
replghost wants to merge 1 commit into
Conversation
Live products drive the runtime through @novasamatech/product-sdk, which
established two conventions the runtime did not serve:
- chainHead operations carry the papi provider's synthetic follow
subscription id ("follow_0"), never the follow subscribe request id.
The connection now treats an unknown session-scoped id as an alias and
binds it to the session's most recent unaliased follow, matching the
native host coordinators. Ids never resolve across session scopes, and
alias bindings are dropped with their follow.
- statements arrive without an expiry field and rely on the host to
stamp one; deployed statement stores refuse expiry-less statements as
already elapsed. Proof creation now stamps a one-hour expiry (unix
seconds in the upper 32 bits, priority zero) before signing, retains
the host-assembled signed statement, and submission prefers those
exact bytes over the product's pre-proof re-assembly so the submitted
fields always match the proof's signature material.
Both behaviors reproduce the Epoca live A/B failure in
paritytech/epoca#174: zero Browse products and chain-query timeouts from
rejected follow ids, and Statement Store GenericError from expiry-less
submissions.
Collaborator
|
same as #317 reopen if got that wrong |
pgherveou
added a commit
that referenced
this pull request
Aug 4, 2026
Remove the Product SDK follow_N alias layer from ChainRuntime. Legacy follow aliases stay out of truapi-server per #317/#321: products upgrade to the current product-sdk, and hosts that still need tolerance for the legacy convention bridge it on their side. Refresh the host-callbacks.ts codegen golden for the AutoSigningKeys core-storage key.
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.
Problem
Epoca's live A/B against Paseo services (paritytech/epoca#174, evidence in the #168 rollout hold) showed the embedded runtime is not live-equivalent to the shipping legacy host loop, in two ways. Both were reproduced against the live People-next node and hermetically against the shipped wasm bundle:
@novasamatech/product-sdk) issues chainHead operations carrying the provider's synthetic follow subscription id (follow_0), never the follow subscribe request id.ChainConnection::require_remote_followstrict-matches its own keys and fails withunknown follow subscription id "cN:follow_0", so papi clients never initialize. Thehost-apiprotocol documents the field as "the follow subscription ID from the product-SDK (opaque string)", and the native host coordinators (e.g. UserAgentKit'sMobileChainFollowCoordinator, Epoca's legacy actor) already resolve it to the session's active follow.GenericError. Products create proofs for statements without an expiry field and expect the host to stamp one. Deployed statement stores (People-next runs the legacy expiry dialect:u64, unix seconds in the upper 32 bits) refuse expiry-less statements — the node answers{"status":"invalid","reason":"alreadyExpired"}and smoldot's statement store phrases the same rejection asInvalid statement encoding. The runtime signed and submitted the product's statement as-is.Change
chain_runtime.rs:ensure_follow_contextnow resolves the operation's follow id throughChainConnection::resolve_follow_key. An exact key wins; an unknown session-scoped id is treated as an opaque alias and bound to the session's most recent unaliased follow. Aliases never resolve across session scopes (cN:prefixes), are dropped with their follow, and are bounded per connection. Unknown ids with no active session follow keep the existing error.statement_store: proof creation (create_proofandcreate_proof_authorized) stamps a one-hour legacy-dialect expiry (priority zero) when the product omitted it, signs the stamped fields, and retains the host-assembledSignedStatementkeyed by its proof (entry-bounded bridge inRuntimeServices). Submission prefers those exact retained bytes over the product's pre-proof re-assembly, so the submitted fields always match the proof's signature material; the read-after-write cache serves the statement the store actually accepted.Validation
header_request_binds_product_follow_alias_within_session,header_request_rejects_product_follow_alias_across_sessions,statement_store_create_proof_stamps_missing_expiry_and_retains_statement,statement_store_submit_prefers_host_assembled_statement.cargo test -p truapi-server --lib: 400 passed.cargo clippy -p truapi-server --all-targetsclean;cargo check -p truapi-server --target wasm32-unknown-unknownclean;cargo fmtapplied.statement_submitprobes againstwss://paseo-people-next-system-rpc.polkadot.io: upstreampriority: u32encoding fails decode (Could not decode Field, variant doesn't exist), expiry-less statements returnalreadyExpired, future-expiry legacy statements proceed to proof verification.truapi-serverpin predates current main and needs its own adaptation —useragent-truapi-runtimedoes not compile against main today).