android: build the SDK with cuprate-daemon and offer the on-device node
Part 3 of "cuprated built in": the chain daemon now ships inside the APK and the wallet screen can pick it. Build (android/sdk/build.gradle.kts) - `cargoBuildAndroid` runs `cargo ndk … build --release --lib --features cuprate-daemon`. The Android target only: `cargoHostLib` / `uniffiBindgen` stay feature-free, because the host cdylib exists only so `uniffi-bindgen --library` can dlopen it and the UniFFI surface does not fork on a cargo feature. - The link needs the NDK's libc++ and compiler-rt builtins explicitly (RandomX is C++ and its aarch64 JIT calls `__clear_cache`; `randomx-rs` links the NDK's stub `libstdc++.a`). `cargo ndk --link-builtins` covers the builtins only, so the whole set is spelled out as per-ABI `CARGO_TARGET_<TRIPLE>_RUSTFLAGS` — a global `RUSTFLAGS` would break the host build scripts. The linker is the NDK clang driver at the app's API level, named explicitly, because the dev machines pin the API 21 wrapper for `aarch64-linux-android` and API 21 fails this link. - `ANDROID_NDK` is exported alongside `ANDROID_NDK_HOME`/`NDK_HOME`: without it `cmake-rs` aborts and `randomx-rs`'s build script panics. - The task logs the feature it builds with, so CI carries the request, not just the task name. Wallet screen - Third chain source, **On-device node (Cuprate)**, beside the daemon field and Receive-only. Stored as `ChainChoice.InProcessCuprate` with an empty `monerod_datadir`, which the SDK resolves to `$ONIONWIRE_HOME/chain`. Existing Save daemon / Receive-only / Start / Stop behaviour is unchanged. - The status line grows `· node <word>` from `WalletChildStatus.node_state` for this source only, fail-closed on an unrecognised word. No sync height: the SDK exposes none, so the screen does not show a number it cannot get. - Storage honesty: free space on the chain store's filesystem, and Start is refused below a 3 GiB floor or when that filesystem cannot be read. The floor is a floor, not a sync estimate — nothing here exposes one. - The pre-production warning (quoted user book, testnet only, Cuprate issue #278) is a sentence above Start, assertable in a test. Opt-in, never a default. - The daemon field's hint no longer suggests a loopback daemon on the phone. CI - `android-ci.yml` extracts `lib/<abi>/libonionwire_sdk.so` from the built APK and fails the job unless it contains `target_max_memory`, a rodata literal compiled only under `cuprate-daemon`. v0.7.0's shipped `.so` has zero of them, so this separates "in the artifact" from "requested". Docs - `android/CUPRATE_DAEMON.md`: the build wiring, the link line, the CI gate, and an explicit "not verified on a device" section. `MONERO_BINARIES.md` points at it for the chain source that is not a binary.
This commit is contained in:
parent
773dacb062
commit
e6b6bc8dd6
9 changed files with 807 additions and 11 deletions
|
|
@ -11,6 +11,7 @@ import com.siriusdevops.onionwire.crypto.StoredPassphraseStore
|
|||
import com.siriusdevops.onionwire.keepalive.KeepAliveService
|
||||
import com.siriusdevops.onionwire.keepalive.KeepAliveStatus
|
||||
import com.siriusdevops.onionwire.keepalive.NodeHost
|
||||
import com.siriusdevops.onionwire.wallet.ChainStorage
|
||||
import com.siriusdevops.onionwire.wallet.NO_WALLET_RPC_MESSAGE
|
||||
import com.siriusdevops.onionwire.wallet.WalletChildBinaries
|
||||
import com.siriusdevops.onionwire.wallet.WalletChildBinaryPaths
|
||||
|
|
@ -722,6 +723,48 @@ class WireViewModel(app: Application) : AndroidViewModel(app) {
|
|||
refreshWalletChild()
|
||||
}
|
||||
|
||||
/**
|
||||
* The third chain source: the chain daemon **inside this app** (Cuprate), no
|
||||
* `monerod` binary and no remote operator. Stores the setting; [startWalletChild]
|
||||
* is what launches the node *and* the wallet child (one call in the core).
|
||||
*
|
||||
* `monerodDatadir` is left empty on purpose: the SDK resolves that to
|
||||
* `$ONIONWIRE_HOME/chain`, the same per-identity directory a spawned `monerod`
|
||||
* would use, so Kotlin never invents an absolute path. `monero-wallet-rpc` is
|
||||
* still required — Cuprate has no wallet layer, so the subprocess stays, and the
|
||||
* core rejects a config without it.
|
||||
*/
|
||||
suspend fun setInProcessCuprate(bins: WalletChildBinaryPaths): Result<Unit> =
|
||||
withContext(Dispatchers.IO) {
|
||||
runCatching {
|
||||
requireWire().setChainSource(
|
||||
ChainConfig(
|
||||
kind = ChainChoice.IN_PROCESS_CUPRATE,
|
||||
monerodBin = "",
|
||||
monerodDatadir = "",
|
||||
host = "",
|
||||
port = 0u,
|
||||
walletRpcBin = bins.walletRpc.orEmpty(),
|
||||
// Inert for this source: an in-process node is loopback
|
||||
// clearnet, so the core never spawns the SOCKS child.
|
||||
artiBin = expectedArtiPath(),
|
||||
walletFilename = WalletChildBinaries.WALLET_FILENAME,
|
||||
),
|
||||
)
|
||||
}
|
||||
}.onSuccess {
|
||||
_walletChildError.value = null
|
||||
refreshChainSource()
|
||||
refreshWalletChild()
|
||||
}
|
||||
|
||||
/**
|
||||
* Free bytes on the filesystem the in-process chain store grows into, or
|
||||
* `null` when it cannot be read. The screen shows this before the user commits
|
||||
* to a store on the device; it is a measurement, not an estimate.
|
||||
*/
|
||||
fun chainFreeBytes(): Long? = ChainStorage.freeBytes(home)
|
||||
|
||||
/**
|
||||
* Spawns the child (and its daemon/SOCKS siblings) and returns what the core
|
||||
* reached.
|
||||
|
|
|
|||
Loading…
Reference in a new issue