<oembed><type>rich</type><version>1.0</version><author_name>npub1sgs97fe0n9wehe6zw7drcxdz4cy9yt9pfqjv8gasz5jlk4zezc0quppx3c</author_name><author_url>https://nostr.ae/npub1sgs97fe0n9wehe6zw7drcxdz4cy9yt9pfqjv8gasz5jlk4zezc0quppx3c</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2017-04-06&#xA;📝 Original message:-----BEGIN PGP SIGNED MESSAGE-----&#xA;Hash: SHA256&#xA;&#xA;On 04/06/2017 03:12 PM, Tomas via bitcoin-dev wrote:&#xA;&#xA;Hi Tomas,&#xA;&#xA;&gt; I have been working on a bitcoin implementation that uses a&#xA;&gt; different approach to indexing for verifying the order of&#xA;&gt; transactions. Instead of using an index of unspent outputs, double&#xA;&gt; spends are verified by using a spend-tree where spends are scanned&#xA;&gt; against spent outputs instead of unspent outputs.&#xA;&#xA;This is the approach that genjix used in libbitcoin version2. With the&#xA;exception of de-linking (not deleted) in the case of reorgs, the&#xA;entire store is append only, implemented in a small set of memory&#xA;mapped files. The downsides to the approach are:&#xA;&#xA;(1) higher than necessary storage space requirement due to storing the&#xA;indexing data required for correlate the spends, and&#xA;&#xA;(2) higher than necessary validation complexity and cost in terms of&#xA;computing the spent-ness (including spender height) of an output.&#xA;&#xA;His implementation used a hash table, so performance-wise it did quite&#xA;well and would theoretically outperform a tree, O(1) vs. O(log2(N)).&#xA;&#xA;&gt; This allows for much better concurrency, as not only blocks, but&#xA;&gt; also individual inputs can be verified fully in parallel.&#xA;&#xA;I was successful in parallelizing input validation (across the inputs&#xA;of an unconfirmed tx and across the set of all inputs in a block)&#xA;using the v2 store. However, it is not the case that the spends&#xA;approach is necessary for concurrency.&#xA;&#xA;To resolve the above two problems the version3 store does not use a&#xA;spends table/index. Nor does it store any table of UTXOs. Yet&#xA;validation is highly parallelized. Instead of additional indexes it&#xA;uses the tx hash table, augmented with 32 bits per output for spender&#xA;height. So there is a O(1) cost of finding the tx and a O(N) cost of&#xA;finding the spender height where N is the number of outputs in the tx.&#xA;But because the number of outputs in a tx is bounded (by block size)&#xA;this is constant time in the number of transactions.&#xA;&#xA;This works out much faster than the spends table, and without the&#xA;storage cost or complexity disadvantages. It also scales with&#xA;available hardware, as the memory mapped files become in-memory hash&#xA;tables. For low memory machines we found it was important to implement&#xA;an opaque UTXO cache to limit paging, but for higher end systems zero&#xA;cache is optimal.&#xA;&#xA;&gt; I am sharing this not only to ask for your feedback, but also to&#xA;&gt; call for a clear separation of protocol and implementations: As&#xA;&gt; this solution, reversing the costs of outputs and inputs, seems to&#xA;&gt; have excellent performance characteristics (as shown in the test&#xA;&gt; results), updates to the protocol addressing the UTXO growth, might&#xA;&gt; not be worth considering *protocol improvements* and it might be&#xA;&gt; best to address these concerns as implementation details.&#xA;&#xA;I don&#39;t follow this part, maybe you could clarify. A spends index&#xA;grows with the size of the spend set (forever) as it cannot be pruned,&#xA;which certainly exceeds the size of the UTXO set (unless nothing is&#xA;spent). The advantage is that you don&#39;t have to keep rewriting the&#xA;store when you use a spends set (because the store can be append only).&#xA;&#xA;Feel free to message me if you&#39;d like to discuss in more detail, or to&#xA;continue on the libbitcoin mailing list (copied).&#xA;&#xA;e&#xA;-----BEGIN PGP SIGNATURE-----&#xA;Version: GnuPG v2.0.22 (GNU/Linux)&#xA;&#xA;iQEcBAEBCAAGBQJY5tFpAAoJEDzYwH8LXOFOcMgH/2mw5iOvUYNwvZ2z0KKTSUOA&#xA;Pd8d5mKoWvd94QxhQ+RyTbkEkMhHl75+zcBgRsfUTtZlBIe/Z0+OgVIN6ibEw+WD&#xA;w7k3HqgQi9gLgydEelxTAX+z3dJ24n4kCCdKAmZbBuK+Yr/7AViugbEqYemKepku&#xA;pRWZZS74MUvrYesc0xPn4Ao3DTzMjjY0K2mkuqV8jlwdfZjlAQX9pTx+iSCuMhkd&#xA;HJ8w7s8QnjVnUeOlLe29mZwaFJPyOTLJMqgDE6s2sXacAy5QQbVCatygvDQ8A/wC&#xA;ktBnKPFb2lGX3bGKu/KwABegBy/hyec+NP0wFR+0MVivCwTK1+SjeHu5MNOSVlM=&#xA;=tfVj&#xA;-----END PGP SIGNATURE-----</html></oembed>