-
Notifications
You must be signed in to change notification settings - Fork 992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigate UTXO obsolescence #763
Comments
@ignopeverell How do we know an output is unspent if all we have is a Merkle proof and the commitment? For coinbase outputs today we can use the Merkle proof to prove how "old" the output is - but nothing about spent/unspent. We need to look in the MMR for this. I guess the same question but asked differently - how do we prevent double spends if nodes have pruned the year old UTXO out of the MMR? |
Sorry I hadn't fully thought this through when I filed this, it was more a placeholder to refine it some more. But I think there are a couple possible approaches.
Does that make more sense? |
Yeah thanks for that. My only hesitation is some of these options mean we end up with two alternative ways of handling spending outputs (two ways to validate it, two ways to build them, edge cases where they potentially interact etc.) and the complexity goes up. Being able to say the output MMR on a pruned node is capped at x and everything still works would be awesome. |
Wallets would have to store the obsolete UTXO data they care about and that data cannot be restored in case of loss, right? Wallets would have to warn when they get to handle obsolete data and automation could be provided to self-send UTXOs periodically (but ideally it should be possible to opt-out). More benefits to such a scheme:
|
Some nodes still would need to keep the UTXO and rangeproof information around, since anyone joining the network needs to check the rangeproofs. So introducing this feature would split the nodes in 2 types: archival and non-archival. Right now all nodes are archival nodes, in the sense that anyone can do a full state sync from any node. |
@jaspervdm wouldn't it suffice for those missing proofs to be validated when their owners try to spend them? My understanding is that the roots of the MMRs that track all UTXO data are still kept in the blockchain so new nodes should be able to validate transactions that try to spend obsolete UTXOs if they are presented with valid Merkle proofs. Why wouldn't that work? |
If somewhere in the past someone managed to create two outputs: one of -10 grin and another of +10 grin, they can now freely spend the +10 grin output. The -10 output would just never get spent |
Wouldn't one be able to spend the +10 output anyway as it stands today? |
The -10 would not have a valid rangeproof associated with it so neither of -10/+10 could be created. Today every node validates every rangeproof at creation time. |
What would it take for an attacker to add such an output in the chain? Would it be enough to mine it in a block even with a minority of the hashrate? Or would the invalid output invalidate the block, hence rational/honest miners wouldn't mine on it? In that case, in order for an atacker to obsolete a -10/+10 tx, they would have to control 51% of the hashrate over the course of a year (obsolesence time - creation time), right?
I don't think we would stop validating at creation in any case. |
The issue here is you cannot actually guarantee this with a large re-org. Say we are at height If a re-org occurs beyond the horizon, say to
But note: We do not see the full blocks between
|
Crossposting this here for discussion - https://www.grin-forum.org/t/aggregate-merkle-proofs/4948 |
@antiochp going back to your comment re deep re-orgs beyond horizon, I am not sure how that's relevant to utxo obsolesence. Presumably, in order for a deep re-org to be a problem with obsolete utxos, it would have to be deeper than (obsolescence time - creation time). What am I missing? |
I don't think you're missing anything. It would mean treating the obsolescence threshold as an implicit "checkpoint" though I think. Right now we can (at least in theory) reorg to any height all the way back to genesis. If we reorg past the obsolescence threshold then we reorg into "obsolete outputs" territory and not every node has the ability to validate the UTXO set at that point. @jaspervdm Every lightweight node could track a "sum of obsolete UTXOs". This would allow the sums to sum correctly w.r.t. the kernels. This would not solve the missing rangeproof problem though. But spending an "obsolete" output requires both a Merkle proof of its place in the outputs MMR and its associated rangeproof. For an output to be in the obsolete set it must have originally been in the "non-obsolete" UTXO set so must have had its rangeproof verified at creation time. Is there still a case where a large enough reorg could introduce obsolete outputs where the rangeproof has never been verified? |
The conversation yesterday about "old and new style bulletproofs" got me thinking about "obsolete outputs". We could do something along the lines of the "turnstyle" in ZCash - where pre-turnstyle outputs are simply not spendable until they pass through the turnstyle. In our case obsolete outputs would need to be refreshed (and converted into new style bulletproofs or whatever was required). We would not necessarily need to support both old and new in all regular txs. The conversion could be a specific process (spend one old one and replace with a new one for example). ZCash identifies inflation this way be forcing everything through non-shielded addresses to pass the turnstyle. We can't do this so we still have the problem of nodes not knowing if the set of obsolete outputs has caused inflation or not (the |
Just to add to what @jaspervdm was saying earlier. Even if we split the UTXO set into a "current" and an "obsolete" populations (presumably based on some cutoff or threshold) - all nodes still need to verify all rangeproofs. So even if we support obsolete UTXOs we still need to include all rangeproofs to cover every unspent output as part of the fast sync (IBD). But - the only time we use rangeproofs is when an output in the UTXO set is verified, either during fast sync or during tx and block propagation. Given all this it does feel like there may be more value in working toward supporting some kind of lightweight node (that discards rangeproofs after verification). This would potentially save a significant amount of disk space locally. We could discard rangeproofs and be smart about pruning the rangeproof MMR (we still want to be able to verify the MMR root for each header). This would not reduce the amount of data necessary for sync but I don't think we can do this anyway, even with old "obsolete" UTXOs. Edit: At height ~200,000 we have the following rangeproof data in our MMR.
Discarding rangeproofs on a lightweight node would save 93MB of data and most of 15MB of the hash file. |
I'm going to close this for now. I suspect the need for all nodes to validate all unspent rangeproofs is going to effectively negate any benefits gained from this. We know about it and we can always revisit exploration at some future point. |
We have these nice MMRs lying around to help secure our chain and we haven't put them to too much use yet. Here's a short outline of what could be a proposal:
There are multiple benefits to UTXO obsolescence:
The text was updated successfully, but these errors were encountered: