RFC: Redesign RingLocation in host_account_create_proof#18
RFC: Redesign RingLocation in host_account_create_proof#18filvecchiato wants to merge 11 commits into
Conversation
Incorporate feedback from triangle-js-sdks#81 (@Zebedeusz): - Remove RingIndex from RingLocationJunction (no longer an input) - Add ring_index and ring_revision (non-optional) to RingVrfProof so products can pass them to downstream precompiles (e.g. personhoodInfoByProof from individuality#891) without extra queries - Add "Abstraction-friendly" rationale addressing whether products should need to know ring location details at all - Add unresolved question about a well-known default RingLocation - Reference individuality#878, #891, and the original review thread
…tform (#18) UniFFI already gives Kotlin (Android) and Swift (iOS) trait surfaces straight from `truapi-platform`. Web hosts had hand-written TS types in `@parity/truapi-host-shared/src/runtime.ts` that mirrored the Rust traits manually — drift hazard. Codegen now covers TS too so all three platforms track the same Rust source. What's new: - `truapi-codegen` gains a platform-crate rustdoc parser (`src/platform.rs`, ~470 LOC). Walks each `pub trait`, classifies method return types (`Unit` / `Result<...>` / `BoxStream` / `Box<dyn T>` / plain), records `impl Future + Send` returns as async. Detects the `Platform` super-trait (method-less, composed of other local traits) and preserves the composition order. - New TS emitter `src/ts/host_callbacks.rs` (~250 LOC) emits one `export interface` per Rust capability trait plus a composite `HostCallbacks extends Storage, Navigation, ...` interface that mirrors `Platform`. Types resolve to existing imports from `@parity/truapi`. - CLI flags `--platform-input` and `--platform-ts-output` wire the emitter into the workflow. Existing `--input`/`--output`/`--host-output`/ `--rust-output` flags are unchanged. - `scripts/codegen.sh` runs `cargo +nightly rustdoc -p truapi-platform` alongside the existing `-p truapi` step and emits to `js/packages/truapi-host-shared/src/generated/host-callbacks.ts`. Consumer integration in `@parity/truapi-host-shared`: - `src/generated/` and `dist/generated/` added to `.gitignore` (matches the `@parity/truapi` policy). - `runtime.ts` re-exports the typed surface (`HostCallbacks`, `Storage`, `Navigation`, ...) from the generated file. `WasmRawCallbacks` stays in place — it's the byte-level WASM bridge surface and additionally covers core-internal account/sign/statement- store callbacks that aren't part of `truapi-platform`. A short doc-block makes the typed-vs-raw layering explicit. Bridging the two via a SCALE adapter is a deliberate follow-up. Tests: - `golden_host_callbacks_ts` integration test pairs rustdoc-of-both- crates with the codegen binary and diffs against a checked-in golden. - 178 workspace tests passing (was 177; +1 for the new golden). - wasm32 target builds clean. - `npm install && npm run build && npm test` clean in `@parity/truapi-host-shared`.
…emitter The new TS HostCallbacks emitter from #18 hand-chained 15 writeln! calls to build the output. CLAUDE.md (this commit also) now requires codegen modules to prefer indoc::writedoc! / formatdoc! over writeln! chains so the emitted shape stays visible in source. Switched host_callbacks.rs to: - writedoc! for the header + import block (two multi-line writes) - formatdoc! returning strings for trait interfaces, methods, and the super-interface; the parent function joins them - render_jsdoc returns a String instead of writing through a sink writeln! count: 15 → 2 (both inside writedoc! invocations themselves). Golden test rebuilt clean; workspace tests all pass.
|
Looked at what building a sybil resistant app using this API would look like. see my write-up here https://hackmd.io/@pgherveou/ryxz50Iffx |
|
@pgherveou cannot access the hackmd doc, can you inline here please? Is that related to paritytech/triangle-js-sdks#81 (comment)? |
|
@valentunn updated the link should work now |
|
Okay so the only concern right now seems to be related to the contexts we allow to generate proofs in. Current version uses |
| /// dotNS product identifier (e.g. `"my-product.dot"`). | ||
| pub type ProductId = String; | ||
|
|
||
| /// Arbitrary-byte suffix distinguishing contexts within a single product. | ||
| pub type ProductProofContextSuffix = Vec<u8>; |
There was a problem hiding this comment.
not a big fan of creating type alias, can we avoid it, and just use named field in ProductContext below, this also translate to a better generated JS API
RFC: Redesign RingLocation in host_account_create_proof
Summary
Redesigns the
RingLocationparameter inhost_account_create_proofto better support the evolving ring membership model.Checklist
docs/rfcs/0004-ringlocation-redesign.mdwith completed frontmatterdocs/rfcs/_index.mdwith a link to the new RFCrfc,proposalMotivation
The current
RingLocationdesign does not adequately support the proof-of-personhood ring membership model. Migrated from paritytech/triangle-js-sdks#81.Rendered
29-06-26 changes
contextual_alias,ring_index, andring_revisiontoRingVrfProof.ProductProofContext— replaced the confusingdomain: ProductAccountIdwith an explicit product-scoped context +product_context_bytesderivation.get_alias— now takes(ProductProofContext, RingLocation)so its alias matchescreate_proof.NotMembererror — distinguishes "not yet a member" from "ring not found".RingLocationa struct with requiredchain_id— removed theChainjunction so the chain is mandatory at the type level.30-06-26 changes
Include Accounts Protocol companion