Skip to content

RFC: Redesign RingLocation in host_account_create_proof#18

Open
filvecchiato wants to merge 2 commits into
mainfrom
rfc/0004-ringlocation-redesign
Open

RFC: Redesign RingLocation in host_account_create_proof#18
filvecchiato wants to merge 2 commits into
mainfrom
rfc/0004-ringlocation-redesign

Conversation

@filvecchiato
Copy link
Copy Markdown
Collaborator

@filvecchiato filvecchiato commented Apr 23, 2026

RFC: Redesign RingLocation in host_account_create_proof

Summary

Redesigns the RingLocation parameter in host_account_create_proof to better support the evolving ring membership model.

Checklist

  • Added docs/rfcs/0004-ringlocation-redesign.md with completed frontmatter
  • Filled all RFC sections (Summary, Motivation, Detailed Design, Drawbacks, Alternatives, Unresolved Questions)
  • Updated docs/rfcs/_index.md with a link to the new RFC
  • Added labels: rfc, proposal

Motivation

The current RingLocation design does not adequately support the proof-of-personhood ring membership model. Migrated from paritytech/triangle-js-sdks#81.

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
pgherveou added a commit that referenced this pull request May 17, 2026
…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`.
pgherveou added a commit that referenced this pull request May 17, 2026
…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.
@filvecchiato filvecchiato changed the title RFC-0004: Redesign RingLocation in host_account_create_proof RFC: Redesign RingLocation in host_account_create_proof Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant