Skip to content

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

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

refactor(polkavm): isolate optional host composition#540
replghost wants to merge 83 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.3.0 composition crate
  • pin polkavm-host-runtime 0.3.0 at c7fea7467dff302b85f34d6327d87d74e77b4189, including the mediated input runtime API
  • keep truapi-server completely 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 explicitly 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.

Verification

  • TRUAPI_SKIP_PACKAGE_BUILD=1 ./scripts/codegen.sh
  • cargo test -p truapi-polkavm-host --locked: 1 passed
  • GitHub CI: all required jobs passed, including Rust workspace, codegen, browser tests, Android, iOS, and dependency-license checks

@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
@replghost
replghost force-pushed the feat/pvm-app-runtime branch from ed97e55 to 0a2172d Compare September 9, 2026 17:16
@replghost

Copy link
Copy Markdown
Contributor Author

Updated this existing native integration PR in 18af332c to pin the demand-driven mobile runtime from paritytech/polkavm-host-runtime#56. Verified with cargo test -p truapi-polkavm-host.

@github-actions github-actions Bot added documentation Improvements or additions to documentation github_actions Pull requests that update GitHub Actions code labels Sep 10, 2026
@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown

CI Status: 14 required jobs green, 13 passed and 1 skipped by path filter.

All job results
job result
android-bindings success
changes success
codegen success
e2e skipped
explorer success
ios-bindings success
ios-swift success
licenses success
playground success
rust success
ts-client success
ts-debugger success
ts-host success
wasm-provider success

Commit 37efb39a · run log

@replghost
replghost requested a review from a team September 10, 2026 20:56
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants