android: build the SDK with cuprate-daemon and offer the on-device node #113
Loading…
Reference in a new issue
No description provided.
Delete branch "onionwire/t_f05be394-android-build-the-sdk-with-cuprate-daemo"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What this does
Part 3 of "cuprated built in": the in-process chain daemon is now in the APK, and the wallet screen can pick it.
Stacked on the SDK card (#111). #111 merged into
onionwire/t_04975420-…, a branch that was already merged intomain, so its commit (64a1f29) is not onmain— this branch therefore carries it. A recovery card is landing those two commits onmain; once it does, this branch is rebased ontomainand the diff below becomesandroid/**-only. Until then the PR diff includes the parent'scrates/onionwire-sdk/**.Build: the feature is on, for the Android target only
android/sdk/build.gradle.kts—cargoBuildAndroidnow runscargo ndk … build --release --lib --features cuprate-daemon.cargoHostLib/uniffiBindgenstay feature-free on purpose: the host cdylib exists only souniffi-bindgen --librarycan dlopen it, and the UniFFI surface does not fork on a cargo feature.Three things the link needs, each of which fails as something else:
__clear_cache;randomx-rslinks the NDK's stublibstdc++.a, so without-lc++_static -lc++abithe link dies on__cxa_allocate_exception.cargo ndk --link-builtinscovers the builtins only, and-static-libstdc++is ignored by NDK clang.CARGO_TARGET_<TRIPLE>_RUSTFLAGS, notRUSTFLAGS— a global rustflags also applies to build scripts and proc macros, which are host-targeted, where-lc++_staticbreaks the link.aarch64-linux-androidin~/.cargo/config.toml, and API 21 fails this link (pthread_atforkis API 23+).ANDROID_NDKis exported too, orcmake-rsaborts andrandomx-rs's build script panics.The task logs the feature it builds with, so the CI log carries the request and not just the task name:
Wallet screen
ChainChoice.InProcessCupratewith an emptymonerod_datadir, which the SDK resolves to$ONIONWIRE_HOME/chain— Kotlin never invents an absolute path. Save daemon / Receive-only / Start / Stop are untouched.· node <word>fromWalletChildStatus.node_statefor this source only, and an unrecognised word is never rendered as ready.WalletChildStatushas no size field and Cuprate's restricted RPC reports a hardcoded 5 GiBdatabase_sizeplaceholder, so a number taken from the node would be fiction.WalletChildStatusTextTest. Opt-in, never a default.NO_WALLET_RPC_MESSAGEandONION_NEEDS_ARTI_NOTICEstill gate Start: Cuprate has no wallet layer, somonero-wallet-rpcstays a child, and an in-process node does not bundlearti.chain_height()internally but does not expose it over UniFFI, so the screen does not show a number it cannot get.CI gate: in the artifact, not merely requested
android-ci.ymlextractslib/<abi>/libonionwire_sdk.sofrom the built APK and fails the job unless it containstarget_max_memory— a rodata literal fromsrc/cuprate.rs's config TOML, compiled only under#[cfg(feature = "cuprate-daemon")]. Negative control: v0.7.0's shipped.sohas zero occurrences of it (and ofrandomx/cuprated).Local numbers (this machine, 16 cores, sanity check — CI builds the APK)
libonionwire_sdk.solib/arm64-v8a/librandomx_rs-<hash>.so1,122,296 B / 387,996 deflatedlibrandomx_rs-<hash>.sois not a load-time dependency:readelf -d libonionwire_sdk.solistsliblog.soand nothing else, and RandomX is statically inside the SDK's.so.cargo-ndkcopies every cdylib in the target directory, andrandomx-rsalso builds one; it is left in place rather than filtered out (seeandroid/CUPRATE_DAEMON.md).:app:testDebugUnitTest— 98 tests, 0 failures.scripts/build-android-local.sh— exit 0, APK + AAR checksums verified.Not verified
The daemon was not run on a device or emulator: there is no
arm64-v8aAVD on the build host and no aarch64 Android sysroot forqemu-user. Proven: it cross-compiles and links against the NDK C++ runtime, the feature is in the shipped.so, the artifact packages, the Kotlin compiles and its unit tests pass. Not proven: thatcupratedstarts, opens its fjall store and answers on loopback under Android's runtime.Docs:
android/CUPRATE_DAEMON.md(new),android/MONERO_BINARIES.md(pointer).RandomX is the C++ half of the in-process chain daemon and `randomx-rs`'s build script drives it through `cmake-rs`. Neither `android-ci.yml` nor `android-release.yml` installed `cmake` in its `debian:bookworm` container, so the first CI run of this branch compiled 410 crates in 11m37s and then died with error: failed to run custom build command for `randomx-rs …` failed to execute command: No such file or directory (os error 2) is `cmake` not installed? surfacing as Gradle's "Process 'command 'cargo'' finished with non-zero exit value 101" — which reads like a Rust error and is not one. Both workflows install it now. `android-ci.yml` also reports the cargo target volume after the build, next to the wall clock: the disk cost of the feature on the runner is part of the measurement this change owes.The Android jobs pinned `RUST_TOOLCHAIN: "1.91"` — the workspace MSRV — and the cuprated graph does not build on it. `tapes`, a Cuprate dependency this repo cannot patch, calls `VecDeque::pop_front_if`, stable only from 1.93: error[E0658]: use of unstable library feature `vec_deque_pop_if` --> /cargo/git/checkouts/tapes-.../src/tapes/rolling_tape.rs:396:34 1.98 is the stable release the graph is built and tested with on the dev machine (rustc 1.98.1) and the one the cross-compile spike used. `ci.yml`, `release.yml` and the `rust-version = "1.91"` MSRV are untouched: the feature-off workspace builds on 1.91, and moving the MSRV is a separate decision, flagged in the PR. Both workflows, and `android/CUPRATE_DAEMON.md` records it as a pitfall.Run 406 built the APK successfully (BUILD SUCCESSFUL in 44m 7s) and the gate then reported "the cuprate-daemon feature is NOT in this APK" while the line above it printed `target_max_memory` **5** times. The bug is the classic one: strings -a x.so | grep -q pattern # under `set -o pipefail` `grep -q` exits at the first match and closes the pipe; `strings` takes SIGPIPE (141) and pipefail makes the pipeline status non-zero, so `if ! ...` ran. The count is captured into a variable now (grep -c reads the whole stream, no SIGPIPE) and the gate fails on `< 1`, which is what it always meant.c23f38cb309afa22a0bf