Skip to content

Commit

Permalink
qip-0012: Qi UTXO Pruning
Browse files Browse the repository at this point in the history
  • Loading branch information
wizeguyy committed Apr 3, 2024
1 parent c7f523e commit 980ebd2
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ Those proposing changes should consider that ultimately consent may rest with th
| [9](qip-0009.md) | Consensus (hard fork) | Interlinks | gameofpointers | standard | Draft |
| [10](qip-0010.md) | Consensus (hard fork) | Network Object Identifiers | wizeguyy | standard | Draft |
| [11](qip-0011.md) | Consensus (hard fork) | Paying for Account State Usage | wizeguyy | standard | Draft |
| [12](qip-0012.md) | Consensus (hard fork) | Qi UTXO Pruning | wizeguyy | standard | Draft |

<!-- IMPORTANT! See the instructions at the top of this page, do NOT JUST add QIPs here! -->
51 changes: 51 additions & 0 deletions qip-0012.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
```
QIP: 12
Layer: Consensus (hard fork)
Title: Qi UTXO Pruning
Author: wizeguyy <[email protected]>
Comments-Summary: No comments yet.
Comments-URI: https://github.com/quainetwork/qips/wiki/Comments:QIP-0012
Status: Draft
Type: Standards Track
Created: 2024-04-02
License: BSD-2-Clause
```

## Abstract
This QIP proposes a mechanism to prune dust UTXOs from the ledger.

## Motivation
Transaction outputs in the Qi UTXO ledger, occupy space and impose a burden on
UTXO transaction processing, from the set root recomputations. This is not a
problem under normal usage, but can become a problem if any users/wallets are
lazy or irresponsible with UTXO reconsolidation, or worse if the network
undergoes a spam attack. This QIP describes a protocol change to disincentivize
UTXO state pollution without meaningfully impacting normal transactional
behavior.

## Rationale
Normal Qi wallet behavior will involve some amount of UTXO splitting, to create
change outputs for payments, as well as UTXO reconsolidation as the wallet
acquires too many small change outputs. This QIP should not negatively impact
this expected user behavior, but should provide a cost to lazy wallets that do
not reconsolidate change outputs.

## Specification
We achieve this simply, by limiting the size of the UTXO set. If a transaction
creates new UTXOs which would exceed the UTXO set capacity, we destroy the
smallest UTXOs in the ledger. This is practical to do thanks to the fixed
denominations in the Qi ledger.

Since the network cost we are trying to control is related to the construction
of the UTXO set root, it is sensible to choose a capacity that reflects a
particular depth of the state tree. Since we use a Patricia Merkle trie, the
state root recomputation is bounded by the radix-16 update cost bound:
$O(log_{16}(N))$, where $N$ is the number of UTXOs in the set.

We set a max trie depth size of 10, which corresponds to a max UTXO set size of
$16^{10} \approx 1 trillion$ UTXOs. If a transaction mints new UTXOs which exceed
the $16^10$ limit, the node shall prune all of the smallest UTXOs from the UTXO
set, repeating this process until the UTXO set size is back within the limits.

## Copyright
This QIP licensed under the BSD 2-clause license.

0 comments on commit 980ebd2

Please sign in to comment.