diff --git a/.gitattributes b/.gitattributes index 0deaf2f3b..1ddf66bc3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,6 +7,8 @@ rust/crates/truapi-server/src/wasm/generated_bridge.rs linguist-generated=true ios/truapi-host/Sources/TrUAPIHost/truapi*.swift linguist-generated=true ios/truapi-host/Sources/TrUAPIHost/Resources/truapi-container.js linguist-generated=true ios/truapi-host/Sources/truapi*FFI/include/** linguist-generated=true +ios/truapi-host/Sources/TrUAPIHost/pvm_runtime.swift linguist-generated=true +ios/truapi-host/Sources/pvm_runtimeFFI/include/** linguist-generated=true ios/truapi-provider/Sources/TrUAPIProvider/truapi_provider.swift linguist-generated=true ios/*-provider/Sources/*FFI/include/** linguist-generated=true diff --git a/.github/PULL_REQUEST_TEMPLATE/release.md b/.github/PULL_REQUEST_TEMPLATE/release.md index 477649b40..1cc6649e6 100644 --- a/.github/PULL_REQUEST_TEMPLATE/release.md +++ b/.github/PULL_REQUEST_TEMPLATE/release.md @@ -2,7 +2,7 @@ > [!IMPORTANT] > The PR title must start with `release:` for the publish workflow to fire. -> Example: `release: @parity/truapi 0.5.0, @parity/truapi-host 0.2.0, @parity/ios-host 0.2.0, @parity/android-host 0.1.0`. +> Example: `release: @parity/truapi 0.5.0, @parity/truapi-host 0.2.0, @parity/pvm-browser-runtime 0.1.0, @parity/ios-host 0.2.0, @parity/android-host 0.1.0`. > Don't rewrite the squash commit subject in the merge dialog — the > `release:` prefix has to land on `main`. @@ -16,6 +16,7 @@ - [ ] Ran `npm run version-packages` to consume the changeset - [ ] `js/packages/truapi/package.json` version is bumped - [ ] `js/packages/truapi-host/package.json` version is bumped when releasing the host +- [ ] `js/packages/pvm-browser-runtime/package.json` declares the requested browser-runtime version - [ ] The PR title includes `@parity/ios-host ` when publishing the iOS host - [ ] Regenerated iOS bindings and container outputs are committed; CI builds and simulator-tests the XCFramework, publishes it, then commits `Package.swift` - [ ] The PR title includes `@parity/android-host ` when publishing the Android host AAR; nothing in the tree records that version, so there is no manifest to bump diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3a3970d06..9428bb861 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -72,7 +72,7 @@ jobs: # Trim whitespace around comma-separated targets. target="${target#"${target%%[![:space:]]*}"}" target="${target%"${target##*[![:space:]]}"}" - if [[ ! "${target}" =~ ^(@parity/truapi|@parity/truapi-host|@parity/ios-host|@parity/android-host)[[:space:]]+([^[:space:]]+)$ ]]; then + if [[ ! "${target}" =~ ^(@parity/truapi|@parity/truapi-host|@parity/pvm-browser-runtime|@parity/ios-host|@parity/android-host)[[:space:]]+([^[:space:]]+)$ ]]; then echo "::error::Unsupported release target '${target}' in subject: ${subject}" exit 1 fi @@ -93,6 +93,7 @@ jobs: cli_version="${declared_version}" ;; @parity/truapi-host) path="js/packages/truapi-host" ;; + @parity/pvm-browser-runtime) path="js/packages/pvm-browser-runtime" ;; @parity/ios-host) if [[ ! "${declared_version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+([+-][0-9A-Za-z.-]+)?$ ]]; then echo "::error::Invalid iOS host version '${declared_version}'." @@ -167,6 +168,7 @@ jobs: uses: dtolnay/rust-toolchain@5b842231ba77f5c045dba54ac5560fed2db780e2 # stable with: toolchain: stable + targets: wasm32-unknown-unknown - if: steps.version.outputs.proceed == 'true' uses: Swatinem/rust-cache@f0d9c3887740aee45f6153b24b3a6b815192ec16 # v2 @@ -188,6 +190,9 @@ jobs: npm run build --prefix js/packages/truapi-host npm run build:wasm --prefix js/packages/truapi-host fi + if grep -q '^@parity/pvm-browser-runtime|' <<< "${STEPS_VERSION_OUTPUTS_PACKAGES}"; then + npm run build --prefix js/packages/pvm-browser-runtime + fi env: STEPS_VERSION_OUTPUTS_PACKAGES: ${{ steps.version.outputs.packages }} diff --git a/.gitignore b/.gitignore index 34260c5fb..917af5987 100644 --- a/.gitignore +++ b/.gitignore @@ -68,3 +68,4 @@ js/packages/truapi/dist/generated/ js/packages/truapi-host/src/generated/ js/packages/truapi-host/dist/generated/ js/packages/truapi-host/dist/wasm/ +js/packages/pvm-browser-runtime/dist/ diff --git a/Cargo.lock b/Cargo.lock index 5a3f46235..decc781da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1510,7 +1510,7 @@ version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef975e30683b2d965054bb0a836f8973857c4ebf6acf274fe46617cd285060d8" dependencies = [ - "foldhash", + "foldhash 0.2.0", "libm", "portable-atomic", "siphasher", @@ -1592,6 +1592,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + [[package]] name = "foldhash" version = "0.2.0" @@ -1941,6 +1947,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" dependencies = [ "allocator-api2", + "foldhash 0.1.5", + "serde", ] [[package]] @@ -1951,7 +1959,7 @@ checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ "allocator-api2", "equivalent", - "foldhash", + "foldhash 0.2.0", "serde", "serde_core", ] @@ -1964,7 +1972,7 @@ checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" dependencies = [ "allocator-api2", "equivalent", - "foldhash", + "foldhash 0.2.0", ] [[package]] @@ -2620,6 +2628,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + [[package]] name = "libc" version = "0.2.189" @@ -3148,6 +3162,12 @@ version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" +[[package]] +name = "picosimd" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7823ffd00d2b55ebe51750a19f47f2a33cb1f1d135f5cba893379b81c4d44856" + [[package]] name = "pin-project" version = "1.1.13" @@ -3201,6 +3221,78 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" +[[package]] +name = "polkavm" +version = "0.37.0" +source = "git+https://github.com/paritytech/polkavm.git?rev=3df1d0309c4c81a1aad0a755d83570d203bba1d9#3df1d0309c4c81a1aad0a755d83570d203bba1d9" +dependencies = [ + "libc", + "log", + "picosimd", + "polkavm-assembler 0.37.0 (git+https://github.com/paritytech/polkavm.git?rev=3df1d0309c4c81a1aad0a755d83570d203bba1d9)", + "polkavm-common 0.37.0 (git+https://github.com/paritytech/polkavm.git?rev=3df1d0309c4c81a1aad0a755d83570d203bba1d9)", + "polkavm-linux-raw 0.37.0 (git+https://github.com/paritytech/polkavm.git?rev=3df1d0309c4c81a1aad0a755d83570d203bba1d9)", +] + +[[package]] +name = "polkavm" +version = "0.37.0" +source = "git+https://github.com/paritytech/polkavm.git?rev=8cc3c5601aa614b0f6dfac2ae3ee271942b3c997#8cc3c5601aa614b0f6dfac2ae3ee271942b3c997" +dependencies = [ + "libc", + "log", + "picosimd", + "polkavm-assembler 0.37.0 (git+https://github.com/paritytech/polkavm.git?rev=8cc3c5601aa614b0f6dfac2ae3ee271942b3c997)", + "polkavm-common 0.37.0 (git+https://github.com/paritytech/polkavm.git?rev=8cc3c5601aa614b0f6dfac2ae3ee271942b3c997)", + "polkavm-linux-raw 0.37.0 (git+https://github.com/paritytech/polkavm.git?rev=8cc3c5601aa614b0f6dfac2ae3ee271942b3c997)", +] + +[[package]] +name = "polkavm-assembler" +version = "0.37.0" +source = "git+https://github.com/paritytech/polkavm.git?rev=3df1d0309c4c81a1aad0a755d83570d203bba1d9#3df1d0309c4c81a1aad0a755d83570d203bba1d9" +dependencies = [ + "log", +] + +[[package]] +name = "polkavm-assembler" +version = "0.37.0" +source = "git+https://github.com/paritytech/polkavm.git?rev=8cc3c5601aa614b0f6dfac2ae3ee271942b3c997#8cc3c5601aa614b0f6dfac2ae3ee271942b3c997" +dependencies = [ + "log", +] + +[[package]] +name = "polkavm-common" +version = "0.37.0" +source = "git+https://github.com/paritytech/polkavm.git?rev=3df1d0309c4c81a1aad0a755d83570d203bba1d9#3df1d0309c4c81a1aad0a755d83570d203bba1d9" +dependencies = [ + "log", + "picosimd", + "polkavm-assembler 0.37.0 (git+https://github.com/paritytech/polkavm.git?rev=3df1d0309c4c81a1aad0a755d83570d203bba1d9)", +] + +[[package]] +name = "polkavm-common" +version = "0.37.0" +source = "git+https://github.com/paritytech/polkavm.git?rev=8cc3c5601aa614b0f6dfac2ae3ee271942b3c997#8cc3c5601aa614b0f6dfac2ae3ee271942b3c997" +dependencies = [ + "log", + "picosimd", + "polkavm-assembler 0.37.0 (git+https://github.com/paritytech/polkavm.git?rev=8cc3c5601aa614b0f6dfac2ae3ee271942b3c997)", +] + +[[package]] +name = "polkavm-linux-raw" +version = "0.37.0" +source = "git+https://github.com/paritytech/polkavm.git?rev=3df1d0309c4c81a1aad0a755d83570d203bba1d9#3df1d0309c4c81a1aad0a755d83570d203bba1d9" + +[[package]] +name = "polkavm-linux-raw" +version = "0.37.0" +source = "git+https://github.com/paritytech/polkavm.git?rev=8cc3c5601aa614b0f6dfac2ae3ee271942b3c997#8cc3c5601aa614b0f6dfac2ae3ee271942b3c997" + [[package]] name = "polling" version = "3.11.0" @@ -3318,6 +3410,28 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "pvm-gpu-wire" +version = "0.1.0" + +[[package]] +name = "pvm-runtime" +version = "0.1.0" +dependencies = [ + "anyhow", + "log", + "polkavm 0.37.0 (git+https://github.com/paritytech/polkavm.git?rev=3df1d0309c4c81a1aad0a755d83570d203bba1d9)", + "polkavm 0.37.0 (git+https://github.com/paritytech/polkavm.git?rev=8cc3c5601aa614b0f6dfac2ae3ee271942b3c997)", + "pvm-gpu-wire", + "serde", + "serde_json", + "thiserror 1.0.69", + "uniffi", + "wasm-encoder", + "wasmi", + "wasmparser 0.240.0", +] + [[package]] name = "qrcode" version = "0.14.1" @@ -4469,6 +4583,16 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "string-interner" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a3275464d7a9f2d4cac57c89c2ef96a8524dba2864c8d6f82e3980baf136f9b" +dependencies = [ + "hashbrown 0.15.5", + "serde", +] + [[package]] name = "strsim" version = "0.11.1" @@ -5287,6 +5411,7 @@ dependencies = [ "p256", "parity-scale-codec", "parking_lot", + "pvm-runtime", "rand 0.8.7", "scale-decode", "scale-info", @@ -5820,6 +5945,16 @@ version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c31d56021e873866c968588ed85ccdf56db5c426e44afdb4618c39895104b920" +[[package]] +name = "wasm-encoder" +version = "0.240.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06d642d8c5ecc083aafe9ceb32809276a304547a3a6eeecceb5d8152598bc71f" +dependencies = [ + "leb128fmt", + "wasmparser 0.240.0", +] + [[package]] name = "wasmi" version = "0.40.0" @@ -5833,7 +5968,7 @@ dependencies = [ "wasmi_collections", "wasmi_core", "wasmi_ir", - "wasmparser", + "wasmparser 0.221.3", ] [[package]] @@ -5841,6 +5976,9 @@ name = "wasmi_collections" version = "0.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e80d6b275b1c922021939d561574bf376613493ae2b61c6963b15db0e8813562" +dependencies = [ + "string-interner", +] [[package]] name = "wasmi_core" @@ -5868,6 +6006,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d06bfa36ab3ac2be0dee563380147a5b81ba10dd8885d7fbbc9eb574be67d185" dependencies = [ "bitflags", + "indexmap", +] + +[[package]] +name = "wasmparser" +version = "0.240.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b722dcf61e0ea47440b53ff83ccb5df8efec57a69d150e4f24882e4eba7e24a4" +dependencies = [ + "bitflags", + "hashbrown 0.15.5", + "indexmap", + "semver", + "serde", ] [[package]] diff --git a/Makefile b/Makefile index e4a7687db..47b937cfe 100644 --- a/Makefile +++ b/Makefile @@ -238,9 +238,9 @@ uniffi-kotlin: ## Regenerate Kotlin UniFFI bindings from the truapi-server cdyli --language kotlin \ --out-dir $(UNIFFI_KOTLIN_OUT) -# Android ABIs to cross-compile the cdylib for. arm64 + armv7 cover physical -# devices; x86_64 covers the emulator on Intel/Apple-silicon hosts. -ANDROID_ABIS ?= arm64-v8a armeabi-v7a x86_64 +# Android ABIs supported by both TrUAPI and PolkaVM. arm64 covers physical +# devices; x86_64 covers emulators. PolkaVM does not support 32-bit armv7. +ANDROID_ABIS ?= arm64-v8a x86_64 ANDROID_JNILIBS := android/truapi-host/src/main/jniLibs android-jni: ## Cross-compile libtruapi_server.so for Android ABIs into jniLibs (needs cargo-ndk + NDK). @@ -444,7 +444,8 @@ xcframework: uniffi ## Build truapi_server.xcframework for iOS device + simulato rm -rf $(XCFRAMEWORK_OUT) $(XCFRAMEWORK_HEADERS) mkdir -p $(XCFRAMEWORK_HEADERS) cp $(UNIFFI_SWIFT_TMP)/truapiFFI.h $(UNIFFI_SWIFT_TMP)/truapi_platformFFI.h \ - $(UNIFFI_SWIFT_TMP)/truapi_serverFFI.h $(XCFRAMEWORK_HEADERS)/ + $(UNIFFI_SWIFT_TMP)/truapi_serverFFI.h $(UNIFFI_SWIFT_TMP)/pvm_runtimeFFI.h \ + $(XCFRAMEWORK_HEADERS)/ cp $(UNIFFI_SWIFT_TMP)/truapi_serverFFI.modulemap $(XCFRAMEWORK_HEADERS)/module.modulemap slices=""; \ for target in $(XCFRAMEWORK_TARGETS); do \ diff --git a/Package.swift b/Package.swift index 8d53ea063..6a2eccabf 100644 --- a/Package.swift +++ b/Package.swift @@ -81,11 +81,18 @@ let package = Package( pkgConfig: nil, providers: [] ), + .systemLibrary( + name: "pvm_runtimeFFI", + path: "ios/truapi-host/Sources/pvm_runtimeFFI/include", + pkgConfig: nil, + providers: [] + ), binaryTarget, .target( name: "TrUAPIHost", dependencies: [ - "truapiFFI", "truapi_platformFFI", "truapi_serverFFI", "truapi_serverFFI_binary", + "truapiFFI", "truapi_platformFFI", "truapi_serverFFI", + "pvm_runtimeFFI", "truapi_serverFFI_binary", ], path: "ios/truapi-host/Sources/TrUAPIHost", resources: [.copy("Resources/truapi-container.js")] diff --git a/README.md b/README.md index 9b338dc3e..b71f30770 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,10 @@ const transport = createTransport(createMessagePortProvider(port)); const truapi = createClient(transport); const result = await truapi.accountManagement.accountGet({ - productAccountId: { dotNsIdentifier: "my-product.dot", derivationIndex: { tag: "Index", value: 0 } }, + productAccountId: { + dotNsIdentifier: "my-product.dot", + derivationIndex: { tag: "Index", value: 0 }, + }, }); ``` @@ -193,9 +196,11 @@ signer, then runs the wrapped command with the host already live. The product reaches it through a development-only `