From 7983a3dc68e4c1134d400d1438a7d9574e79e81c Mon Sep 17 00:00:00 2001 From: DanS Date: Wed, 28 Oct 2026 11:22:58 -0500 Subject: [PATCH] doc: describe consolidation as it now works; fix zsweep doc errors Rewrite the consolidation part of doc/zsweep-consolidation.md to match the code: off by default (also for GUI wallets, which the doc claimed were on), what an eligible note is, the threshold/batch/maxtxs policy and its defaults including -consolidationinterval, smallest-first and the randomised input count, the 8-output shape, locking only the round's notes, skipped bad-witness notes, the fee range (fee 0 is no longer accepted), the spending-key requirement, z_consolidationstatus (the doc named z_sweepstatus) and its verbose mode, z_consolidate, and the off-but-suggested hint. Also fix -zsweepinterval: it defaults to 10 (values below 5 fall back to 10), not the 5 the doc and -help claimed. Co-Authored-By: Claude Opus 5.5 --- doc/zsweep-consolidation.md | 65 +++++++++++++++++++++++++++++++++---- src/init.cpp | 2 +- 2 files changed, 59 insertions(+), 8 deletions(-) diff --git a/doc/zsweep-consolidation.md b/doc/zsweep-consolidation.md index ded919365..b99c9cd47 100644 --- a/doc/zsweep-consolidation.md +++ b/doc/zsweep-consolidation.md @@ -13,7 +13,7 @@ This is to document zsweep and consolidation for advanced DragonX users. A user can use these options at the command line, but it is **recommended to configure these options within the DRAGONX.conf file**. -Consolidation takes many unspent shielded UTXOs (zutxos) into one zutxo, which makes spending them in the future faster and potentially cost less in fees. It also helps prevent certain kinds of metadata leakages and spam attacks. It is not recommended for very large wallets (wallet.dat files with thousands of transactions) for performance reasons. This is why it defaults to OFF for CLI full nodes but ON for GUI wallets that use an embedded dragonxd. +Consolidation merges many unspent shielded notes (zutxos) of one z-address into a few notes of that same address, which makes spending them later faster and cheaper, keeps the wallet smaller and shortens witness rebuilds and rescans. It never moves funds between addresses. Both zsweep and consolidation are **off by default** in dragonxd, for CLI nodes and for GUI wallets that run an embedded dragonxd alike (the ObsidianDragon GUI does its own, separate auto-consolidation through `z_mergetoaddress`). Zsweep is when you sweep numerous zutxos into one z-address that you configure. This z-address can be local to that system or it can be configured to sweep to a remote wallet on a different system with the zsweepexternal=1 option, which is explained below in the Zsweep section. @@ -32,7 +32,7 @@ Zsweep is when you sweep numerous zutxos into one z-address that you configure. | Zsweep Option Name| Details of what it does | |-------------------|-------------------------| | zsweepexternal=1 | Will enable the option to zsweep to an "external" z-address which exists in a wallet on a different system. | - | zsweepinterval=5 | By default zsweep runs every 5 blocks, so set and modify this value to change that. | + | zsweepinterval=10 | By default zsweep runs every 10 blocks (values below 5 fall back to 10), so set and modify this value to change that. | | zsweepmaxinputs=8 | By default zsweep makes sure to not reduce the anonset in any tx by having a maximum number of inputs of 8. This should be fine for new wallets, but if you have an existing wallet with many zutxos it can be changed with this option. Keep in mind that large values will make sweeping faster at the expense of reducing the AnonSet. | | zsweepfee=0 | The default zsweep fee is 10000 puposhis or 0.0001 DRAGONX, the default for all transactions. To use fee=0 for zsweep transactions, set this option. | | zsweepexclude=zs1... | Exclude a certain address from being swept. Can be used multiple times to exclude multiple addressses | @@ -41,7 +41,31 @@ Zsweep is when you sweep numerous zutxos into one z-address that you configure. ## Consolidation -1. We add the following to our conf file as per the Pre-Step. +Mining with auto-shielding on (the default for wallets created or restored by dragonxd) adds one shielded note to the +wallet per auto-shield round. Over weeks that is thousands of small notes, which slow down sends, balance calls and +witness rebuilds. Consolidation keeps that in check. + +### What a round does + +* An address is consolidated only when it holds **more than** `consolidationthreshold` (default 25) *eligible* + notes: unspent (also not spent by a transaction still in the mempool), not locked by another operation, spendable + by this wallet, and at least 11 confirmations deep. Addresses at or below the threshold are left alone. +* For each such address a round sends up to `consolidationmaxtxs` (default 3) transactions. Each spends up to + `consolidationbatchsize` (default 15) of the address's **smallest** notes and pays their value, minus the fee, back + to **the same address**. The big note an earlier round produced is therefore not merged again every round. +* The number of inputs per transaction is drawn at random between two thirds of the batch size and the batch size + (10 to 15 by default), so rounds don't all look alike. A transaction never takes an address's last remaining note, + so every address keeps at least one spendable note while the round confirms. +* Each transaction has exactly 8 shielded outputs: the real one plus 7 zero-value dummy ("Sietch") outputs to random + addresses, so it does not shrink the anonymity set. It pays `consolidationtxfee`, or no fee when its notes are worth + no more than the fee, and expires 15 blocks after it is made. +* Only the notes a round actually spends are locked while it proves, so sends made meanwhile still see the rest of + the wallet. A note with a missing or unusable witness is skipped (and logged once); the round goes on without it. +* With the defaults, an address over the threshold loses 27 to 42 notes per round, and a round runs every 25 blocks. + +### Turning it on + +1. Add the following to the conf file as per the Pre-Step. ``` consolidation=1 ``` @@ -50,10 +74,34 @@ Zsweep is when you sweep numerous zutxos into one z-address that you configure. | Consolidation Option Name| Details of what it does | |--------------------------|-------------------------| - | consolidationtxfee=0 | The default consolidation fee is 10000 puposhis or 0.0001 DRAGONX, the default for all transactions. To use fee=0 for consolidation transactions, set this option. | - | consolidatesaplingaddress=zs1... | Default of consolidation is set to all, but you can set this option if you have one specific z-address (zs1... is a placeholder for this documentation) that you want to only consolidate to. | + | consolidationinterval=25 | Blocks between rounds (default 25, minimum 5; smaller values are raised to 5). | + | consolidationthreshold=25 | Only addresses with more than this many eligible notes are consolidated (default 25, minimum 1). | + | consolidationbatchsize=15 | Most notes one consolidation transaction spends (default 15, clamped to 2..50). | + | consolidationmaxtxs=3 | Most consolidation transactions per address per round (default 3, clamped to 1..100). | + | consolidationtxfee=10000 | Fee in puposhis per consolidation transaction (default 10000 = 0.0001 DRAGONX; allowed range 1000..10000000, anything else falls back to the default). | + | consolidatesaplingaddress=zs1... | Only consolidate this address (may be given several times). The default is every address the wallet can spend. The wallet must hold the address's spending key, or dragonxd refuses to start. | -1. The following DragonX RPC will let you view your consolidation configuration options and run-time stats at the command line: `dragonx-cli z_sweepstatus` +1. `dragonx-cli z_consolidationstatus` shows the settings, whether a round is running, when the next one is due, + cumulative totals (`notes_consolidated`, `amount_consolidated` in puposhis), the last round (`last_round`: height, + time, txids, notes merged, amount merged, notes skipped, error) and, when rounds can't run, why + (`disabled_reason`). `dragonx-cli z_consolidationstatus true` also counts the eligible notes of every address and + lists which are over the threshold (this walks the whole wallet, so it is only done on request). + +### Consolidating on demand + +`dragonx-cli z_consolidate` runs one round now with the current settings, also when `consolidation` is off, so a CLI +miner can clean up whenever it suits them. It takes optional overrides, in order: fee (in DRAGONX), batch size, +maximum transactions per address, and a JSON array of addresses; pass `null` to keep a setting, e.g. +`dragonx-cli z_consolidate null 50 20 '["zs1..."]'`. It returns an operation id; `z_getoperationstatus` / +`z_getoperationresult` give the result. It refuses while the node is syncing, while the wallet is locked, and while a +consolidation, zsweep or auto-shield round is in flight. + +### Off, but suggested + +When consolidation is off and some address has more notes than the threshold, dragonxd logs once after loading the +wallet: `N addresses have more than 25 spendable notes; consider -consolidation=1 or z_consolidate`. +`z_autoshieldstatus` then reports `consolidation_suggested: true`, and `z_consolidationstatus true` reports +`consolidation_suggested` and `consolidation_suggested_count`. ## Zsweep & Consolidation Together @@ -66,6 +114,10 @@ Zsweep is when you sweep numerous zutxos into one z-address that you configure. 1. Then follow along with the zsweep section above if you want to set specific options for the zsweep behavior. +1. With zsweep on, consolidation only works on the sweep address (a `consolidatesaplingaddress` other than the + sweep address is refused at startup). Sweep and consolidation never run at the same time, and a sweep is not + started when a consolidation round is due within 5 blocks. + ### Copyright The DragonX Developers, jahway603, and The Hush Developers @@ -73,4 +125,3 @@ The DragonX Developers, jahway603, and The Hush Developers ### License GPLv3 - diff --git a/src/init.cpp b/src/init.cpp index 1e80eb76a..60af3bce8 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -490,7 +490,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-zsweep", _("Enable zaddr sweeping, automatically move all shielded funds to a one address once per X blocks")); strUsage += HelpMessageOpt("-zsweepaddress=", _("Specify the shielded address where swept funds will be sent)")); strUsage += HelpMessageOpt("-zsweepfee", strprintf(_("Fee amount in puposhis used send sweep transactions. (default %i)"), DEFAULT_SWEEP_FEE)); - strUsage += HelpMessageOpt("-zsweepinterval", strprintf(_("Sweep shielded funds every X blocks (default %i)"), 5)); + strUsage += HelpMessageOpt("-zsweepinterval", strprintf(_("Sweep shielded funds every X blocks (default %i)"), 10)); strUsage += HelpMessageOpt("-zsweepmaxinputs", strprintf(_("Maximum number of shielded inputs to sweep per transaction (default %i)"), 8)); // By default we only allow sweeping to the current wallet which must have the spending key of the sweep zaddr // This hopefully will make it harder for people to accidentally sweep funds to a wrong zaddr and lose funds