feat(wallet): mainnet pruned and full on-device chain modes
Cuprate in-process and TUI keys 1/2/3 pick mainnet pruned, mainnet full, or experimental testnet. Datadirs are split so a prune store cannot mix with a full one. Android storage floors scale with the choice. Cuprate remains pre-production; mainnet is unvalidated.
This commit is contained in:
parent
0acf89a0b4
commit
5080652e3b
11 changed files with 397 additions and 77 deletions
|
|
@ -724,6 +724,8 @@ class WireViewModel(app: Application) : AndroidViewModel(app) {
|
|||
// an onion daemon outright while no `arti` is bundled.
|
||||
artiBin = expectedArtiPath(),
|
||||
walletFilename = WalletChildBinaries.WALLET_FILENAME,
|
||||
mainnet = false,
|
||||
prune = false,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -752,6 +754,8 @@ class WireViewModel(app: Application) : AndroidViewModel(app) {
|
|||
walletRpcBin = bins.walletRpc.orEmpty(),
|
||||
artiBin = expectedArtiPath(),
|
||||
walletFilename = WalletChildBinaries.WALLET_FILENAME,
|
||||
mainnet = false,
|
||||
prune = false,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -767,12 +771,14 @@ class WireViewModel(app: Application) : AndroidViewModel(app) {
|
|||
* 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.
|
||||
* `$ONIONWIRE_HOME/chain/{testnet,mainnet-pruned,mainnet-full}` from
|
||||
* [mainnet] and [prune], so Kotlin never invents an absolute path.
|
||||
*/
|
||||
suspend fun setInProcessCuprate(bins: WalletChildBinaryPaths): Result<Unit> =
|
||||
suspend fun setInProcessCuprate(
|
||||
bins: WalletChildBinaryPaths,
|
||||
mainnet: Boolean,
|
||||
prune: Boolean,
|
||||
): Result<Unit> =
|
||||
withContext(Dispatchers.IO) {
|
||||
runCatching {
|
||||
requireWire().setChainSource(
|
||||
|
|
@ -787,6 +793,8 @@ class WireViewModel(app: Application) : AndroidViewModel(app) {
|
|||
// clearnet, so the core never spawns the SOCKS child.
|
||||
artiBin = expectedArtiPath(),
|
||||
walletFilename = WalletChildBinaries.WALLET_FILENAME,
|
||||
mainnet = mainnet,
|
||||
prune = prune,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -318,9 +318,8 @@ const val STARTING_CHILD_NOTICE: String =
|
|||
*/
|
||||
const val CUPRATE_PREPRODUCTION_WARNING: String =
|
||||
"On-device node is Cuprate, which is pre-production: its own user book says do NOT use " +
|
||||
"cuprated for any serious purposes, it runs testnet only here (mainnet is unvalidated), " +
|
||||
"and its monerod RPC parity is incomplete (Cuprate issue #278). Try the in-process " +
|
||||
"path; do not hold funds on it."
|
||||
"cuprated for any serious purposes, mainnet is unvalidated, and its monerod RPC parity " +
|
||||
"is incomplete (Cuprate issue #278). Try the in-process path; do not hold funds on it."
|
||||
|
||||
/**
|
||||
* This build was compiled without the `cuprate-daemon` feature, so the stored
|
||||
|
|
@ -342,18 +341,36 @@ const val CUPRATE_NOT_IN_BUILD_NOTICE: String =
|
|||
* measured honestly is the free space on the filesystem the fjall store grows
|
||||
* into, and the device can be told when that is not enough.
|
||||
*/
|
||||
const val CHAIN_FREE_SPACE_FLOOR_BYTES: Long = 3L * 1024 * 1024 * 1024
|
||||
const val CHAIN_TESTNET_FLOOR_BYTES: Long = 3L * 1024 * 1024 * 1024
|
||||
const val CHAIN_MAINNET_PRUNED_FLOOR_BYTES: Long = 64L * 1024 * 1024 * 1024
|
||||
const val CHAIN_MAINNET_FULL_FLOOR_BYTES: Long = 280L * 1024 * 1024 * 1024
|
||||
|
||||
/** Testnet floor, kept so existing tests still name one constant. */
|
||||
const val CHAIN_FREE_SPACE_FLOOR_BYTES: Long = CHAIN_TESTNET_FLOOR_BYTES
|
||||
|
||||
fun chainStorageFloorBytes(mainnet: Boolean, prune: Boolean): Long = when {
|
||||
!mainnet -> CHAIN_TESTNET_FLOOR_BYTES
|
||||
prune -> CHAIN_MAINNET_PRUNED_FLOOR_BYTES
|
||||
else -> CHAIN_MAINNET_FULL_FLOOR_BYTES
|
||||
}
|
||||
|
||||
/**
|
||||
* What the chain store costs, in the user's terms: the free space this device
|
||||
* actually has, and what the node does *not* tell us.
|
||||
*/
|
||||
fun chainStorageLine(freeBytes: Long?): String = when {
|
||||
freeBytes == null ->
|
||||
"chain store: free space on this device could not be read."
|
||||
else ->
|
||||
"chain store: ${formatBytes(freeBytes)} free on this device — a synced testnet store " +
|
||||
"grows into it. The node reports no size estimate of its own."
|
||||
fun chainStorageLine(freeBytes: Long?, mainnet: Boolean = false, prune: Boolean = false): String {
|
||||
val kind = when {
|
||||
!mainnet -> "a synced testnet store"
|
||||
prune -> "a pruned mainnet store (tens of GiB)"
|
||||
else -> "a full mainnet store (hundreds of GiB)"
|
||||
}
|
||||
return when {
|
||||
freeBytes == null ->
|
||||
"chain store: free space on this device could not be read."
|
||||
else ->
|
||||
"chain store: ${formatBytes(freeBytes)} free on this device — $kind " +
|
||||
"grows into it. The node reports no size estimate of its own."
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -361,13 +378,20 @@ fun chainStorageLine(freeBytes: Long?): String = when {
|
|||
* may. Fail-closed on an unreadable filesystem: an unknown free space is not
|
||||
* reported as enough.
|
||||
*/
|
||||
fun chainStorageBlockedReason(freeBytes: Long?): String? = when {
|
||||
freeBytes == null ->
|
||||
"Free space on the chain store's filesystem could not be read, so it is not known to fit."
|
||||
freeBytes < CHAIN_FREE_SPACE_FLOOR_BYTES ->
|
||||
"Not enough space for the chain store: ${formatBytes(freeBytes)} free, and the " +
|
||||
"on-device node needs at least ${formatBytes(CHAIN_FREE_SPACE_FLOOR_BYTES)}."
|
||||
else -> null
|
||||
fun chainStorageBlockedReason(
|
||||
freeBytes: Long?,
|
||||
mainnet: Boolean = false,
|
||||
prune: Boolean = false,
|
||||
): String? {
|
||||
val floor = chainStorageFloorBytes(mainnet, prune)
|
||||
return when {
|
||||
freeBytes == null ->
|
||||
"Free space on the chain store's filesystem could not be read, so it is not known to fit."
|
||||
freeBytes < floor ->
|
||||
"Not enough space for the chain store: ${formatBytes(freeBytes)} free, and the " +
|
||||
"on-device node needs at least ${formatBytes(floor)}."
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -253,10 +253,10 @@ fun WalletScreen(
|
|||
.onFailure { daemonError = it.message ?: it.toString() }
|
||||
}
|
||||
},
|
||||
onInProcessNode = {
|
||||
onInProcessNode = { mainnet, prune ->
|
||||
daemonError = null
|
||||
scope.launch {
|
||||
vm.setInProcessCuprate(bins)
|
||||
vm.setInProcessCuprate(bins, mainnet, prune)
|
||||
.onFailure { daemonError = it.message ?: it.toString() }
|
||||
}
|
||||
},
|
||||
|
|
@ -617,7 +617,7 @@ private fun WalletChildCard(
|
|||
onDaemonText: (String) -> Unit,
|
||||
onSaveDaemon: () -> Unit,
|
||||
onReceiveOnly: () -> Unit,
|
||||
onInProcessNode: () -> Unit,
|
||||
onInProcessNode: (mainnet: Boolean, prune: Boolean) -> Unit,
|
||||
starting: Boolean = false,
|
||||
onStart: () -> Unit,
|
||||
onStop: () -> Unit,
|
||||
|
|
@ -630,7 +630,15 @@ private fun WalletChildCard(
|
|||
// poller, or the user would press Start having seen neither.
|
||||
val inProcess = input?.chainInProcess == true || chain?.kind == ChainChoice.IN_PROCESS_CUPRATE
|
||||
val startWhy = startBlockedReason(bins, input, onionDaemon, starting)
|
||||
?: if (inProcess) chainStorageBlockedReason(nodeFreeBytes) else null
|
||||
?: if (inProcess) {
|
||||
chainStorageBlockedReason(
|
||||
nodeFreeBytes,
|
||||
mainnet = chain?.mainnet == true,
|
||||
prune = chain?.prune == true,
|
||||
)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
val stopWhy = stopBlockedReason(input)
|
||||
|
||||
Card(
|
||||
|
|
@ -731,11 +739,25 @@ private fun WalletChildCard(
|
|||
// reads before Start.
|
||||
Spacer(Modifier.height(8.dp))
|
||||
OutlinedButton(
|
||||
onClick = onInProcessNode,
|
||||
onClick = { onInProcessNode(true, true) },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.testTag("wallet-chain-mainnet-pruned"),
|
||||
) { Text("Mainnet pruned") }
|
||||
Spacer(Modifier.height(4.dp))
|
||||
OutlinedButton(
|
||||
onClick = { onInProcessNode(true, false) },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.testTag("wallet-chain-mainnet-full"),
|
||||
) { Text("Mainnet full") }
|
||||
Spacer(Modifier.height(4.dp))
|
||||
OutlinedButton(
|
||||
onClick = { onInProcessNode(false, false) },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.testTag("wallet-chain-in-process"),
|
||||
) { Text("On-device node (Cuprate)") }
|
||||
) { Text("Testnet (experimental)") }
|
||||
|
||||
if (inProcess) {
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
|
@ -749,7 +771,11 @@ private fun WalletChildCard(
|
|||
)
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Text(
|
||||
chainStorageLine(nodeFreeBytes),
|
||||
chainStorageLine(
|
||||
nodeFreeBytes,
|
||||
mainnet = chain?.mainnet == true,
|
||||
prune = chain?.prune == true,
|
||||
),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier
|
||||
|
|
|
|||
Loading…
Reference in a new issue