Skip to content

refactor(polkavm): isolate optional host composition - #540

Open
replghost wants to merge 109 commits into
mainfrom
feat/pvm-app-runtime
Open

replghost wants to merge 109 commits into
mainfrom
feat/pvm-app-runtime

Conversation

@replghost

@replghost replghost commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • replace truapi-pvm-host with the optional truapi-polkavm-host 0.2.0 composition crate
  • pin polkavm-host-runtime 0.3.0 at e60a6135be6e00c72c90ca4abe23d2002f4eb962; report that same immutable revision through the composition crate
  • keep truapi-server independent of PolkaVM
  • remove host-core-owned browser exports and generated PolkaVM mobile bindings; polkavm-host-runtime owns those distribution artifacts
  • restore the base Android ABI matrix, including armeabi-v7a

Boundary

truapi-polkavm-host is an rlib-only composition dependency. It exposes the namespaced polkavm_host_runtime and truapi_server APIs plus pinned version/revision constants. Downstream distribution crates decide which native ABI surfaces to export. Chat authority remains in #709, not this generic base.

CI follow-up

  • keep injected-host allowance helpers available on Wasm and use browser-compatible polling clocks
  • exclude only the native renewal driver and direct native RPC connection path from Wasm; no warning suppression or new browser authority
  • correct the stale public runtime source-revision constant
  • remove generated-source and compiler-wording snapshots rather than re-pin incidental text; schema-hash mutation, generation idempotence, macro-owned diagnostics, and compiled consumers remain covered

Current source and consumers

Local verification

  • RUSTFLAGS='-D warnings' cargo check --target wasm32-unknown-unknown -p truapi-server: passed
  • RUSTFLAGS='-D warnings' cargo test --workspace --all-features --no-fail-fast: 1,310 passed, 21 ignored
  • release Wasm rebuild, metadata stripping, and compressed-sidecar roundtrips: passed
  • a compiled consumer of the stacked composition crate reports runtime version 0.3.0 and source e60a6135be6e00c72c90ca4abe23d2002f4eb962

Fresh GitHub checks run on this update. This update is not a merge, release, or deployment.

@replghost
replghost requested a review from a team August 28, 2026 07:13
@replghost
replghost force-pushed the feat/pvm-app-runtime branch from 7f73849 to f6457f1 Compare August 28, 2026 07:15
@replghost
replghost enabled auto-merge August 28, 2026 07:15
@replghost

Copy link
Copy Markdown
Contributor Author

@pgherveou @eugypalu all required checks are green, including Rust/Clippy, Android, iOS, browser artifacts, and license policy. Could one of you provide the required host-sdk-team approval so the merge queue can admit this dependency?

@pgherveou pgherveou 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.

can we remove the generated files in the new js packages. Can't these be built from the src files ?

for the new bindings we can also added then to .gitattributes with linguist-generated=true, so that at least they show up as generated artifacts in the code review

@replghost

Copy link
Copy Markdown
Contributor Author

Addressed in b0e178e: removed the committed browser dist/ tree, ignored it, and kept build/test/release generation source-driven. npm test now proves a clean package checkout builds the WASM and split workers before checksum verification; npm pack --dry-run --json still contains all ten release files. Added linguist-generated=true for the new Swift and FFI binding outputs in .gitattributes.

@replghost
replghost requested a review from pgherveou August 28, 2026 09:18
@replghost

Copy link
Copy Markdown
Contributor Author

Cleanup CI is fully green; ready for rereview and merge queue admission.

@pgherveou

Copy link
Copy Markdown
Collaborator

DQ: why do all these things need to live in host-rust-core, they don't seem to have dependency on the rust-core stuff, and could be shipped independently ?

@replghost
replghost requested a review from Imod7 August 28, 2026 09:29
@replghost
replghost force-pushed the feat/pvm-app-runtime branch from b0e178e to e0f05c4 Compare August 28, 2026 09:32
@replghost

Copy link
Copy Markdown
Contributor Author

They share the Rust core directly rather than only co-locating artifacts:

  • @parity/pvm-browser-runtime compiles rust/crates/pvm-runtime to wasm32-unknown-unknown; its JS workers are the adapter around that Wasm ABI.
  • The same pvm-runtime crate is linked into truapi-server, so the existing UniFFI cdylib/XCFramework/AAR exports the native Swift/Kotlin runtime. A separate repository would require a second native library and package lifecycle in every host.
  • pvm-gpu-wire is shared by the native and browser implementations, keeping bounds and binary GPU records identical.
  • The existing host-rust-core CI/release jobs already regenerate UniFFI and publish the browser/native artifacts from one reviewed commit.

They could be split, but that would duplicate the Rust source/pins and create independent browser, XCFramework, and AAR versioning with an ABI-drift boundary. Keeping the runtime here makes the host-neutral Rust implementation the single source for all three targets; Epoca/Dotli/Brevity/Desktop remain independent consumers.

@replghost

Copy link
Copy Markdown
Contributor Author

Does that shared Rust/UniFFI dependency path resolve the repository-placement concern, or do you want the runtime split into a separate repository before merge?

@replghost

Copy link
Copy Markdown
Contributor Author

Additional review completed. Fixed three concrete boundary issues:

  • Native constructors now enforce the same program, gas, asset-count, per-file, aggregate-byte, and safe-path limits as the browser ABI before guest compilation.
  • The browser compiler backend now enforces the manifest graphics profile, one Tri2D submission per update, CoreVM framebuffer-only behavior, and GPU state/sequence errors consistently with the interpreter.
  • Browser worker termination now closes its timer and MessageChannel ports; invalid launches no longer leak host-thread channels.

Added behavioral browser tests for malformed launch inputs and cross-profile framebuffer submission. Full workspace result: 1,205 tests passed, Clippy -D warnings passed, package tests 4/4 passed, and committed iOS bindings remain current.

Vendored commit 56c67a306fc276129829f94db85a622061e17882 into both consumers and exercised it end to end: Epoca App v2 10/10 plus seven-app browser matrix 45/45; Dotli Doom, Quake, Duke3D, NES, egui, GPU Cube, and Scene Lab all passed on the compiler backend.

@replghost

Copy link
Copy Markdown
Contributor Author

PolkaVM dependency update:

  • Rebased epoca/aarch64-jit-0.37 onto current paritytech/polkavm@master; branch head is e06cce9, 6 commits ahead / 0 behind.
  • Ported the AArch64 JIT across the current code-blob, 32-bit address, dynamic-paging, memset, and 16 KiB page semantics.
  • PolkaVM verification: 4,090 passed, 2 ignored; AArch64 assembler clippy passes with warnings denied.
  • This PR now pins e06cce9 in commit 23f50c64.
  • Host CI is green, including Rust workspace, native build, iOS bindings/package, browser provider, codegen, and dependency licenses.

@replghost
replghost force-pushed the feat/pvm-app-runtime branch from 23f50c6 to d0e16fc Compare August 28, 2026 22:52
@replghost

Copy link
Copy Markdown
Contributor Author

Rebased the full PVM series onto current main (654c0cf0) with no semantic commit changes; git range-diff reports all 16 branch commits equivalent. New head: d0e16fcc.

Post-rebase verification:

  • cargo test -p pvm-runtime --all-features: 20 passed
  • npm test --prefix js/packages/pvm-browser-runtime: 4 passed

The PR is now up to date with main; remaining BLOCKED state is review protection while the refreshed CI run completes.

@replghost

Copy link
Copy Markdown
Contributor Author

Added in 2c08d25:

  • renamed the WebGPU Raster guest imports from epoca_gpu_* to the Host-neutral host_gpu_* namespace in the native and browser runtimes;
  • added the draft docs/runtime/polkavm-app-abi-v1.md contract covering lifecycle, memory, Host imports, bounds, failure behavior, and conformance scope.

Consumer cutovers:

  • paritytech/polkavm-app-kit#2
  • paritytech/epoca#385

Verification remains green: cargo test -p pvm-runtime -p pvm-gpu-wire (33 passed), browser package tests (4 passed), App Kit tests (4 passed), reproducible example build/verify (six artifacts), and Epoca GPU tests (4 passed).

@replghost replghost changed the title feat(pvm): add host-neutral app runtime feat(pvm): expose standalone runtime through host bridge Aug 29, 2026
@replghost

Copy link
Copy Markdown
Contributor Author

The repository-placement concern is now resolved by the extraction:

  • the runtime implementation, GPU wire contract, browser workers/Wasm, tests, ABI documentation, and releases live in paritytech/pvm-host-runtime;
  • the current immutable release is v0.1.4 at 235d1d407f3340fb73cb7a698fe973a9dad5251f;
  • this PR now retains only the thin truapi-pvm-host integration boundary, truapi-server/UniFFI wiring, and the reviewed runtime/asset pin.

Generated browser output remains source-built and verified in the standalone repository; committed Swift/FFI bindings are marked generated. The full bridge matrix is green.

@replghost
replghost force-pushed the feat/pvm-app-runtime branch 2 times, most recently from 8daab08 to 5e04221 Compare August 31, 2026 20:37
@github-actions github-actions Bot added the host-work Needs implementation in one or more host repos label Sep 14, 2026
@github-actions

github-actions Bot commented Sep 17, 2026

Copy link
Copy Markdown

iOS simulator preview

Built from 749cf906b, stamped with it in TrUAPICommit.

gh run download 35282939676 --name simulator-preview-749cf906b
unzip polkadot-app-*.app.zip
xcrun simctl install booted polkadot-app.app
xcrun simctl launch booted io.parity.polkadotapp.develop

Or download it in a browser, which arrives as a zip wrapping
the .app.zip, so it needs unzipping twice.

An arm64 simulator slice, so it needs an Apple Silicon Mac and does not
install on a device. Kept for 14 days, after which the link stops
resolving and a new push rebuilds it.

# Conflicts:
#	CHANGELOG.md
#	README.md
#	js/packages/truapi-host/CHANGELOG.md
#	js/packages/truapi-host/README.md
#	rust/crates/truapi-server/src/lib.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation github_actions Pull requests that update GitHub Actions code host-work Needs implementation in one or more host repos javascript Pull requests that update javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants