Skip to content

Conversation

sipa
Copy link
Member

@sipa sipa commented May 20, 2017

This implements a 3072-bit MuHash discussed on https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2017-May/014337.html as a replacement for the hash_serialized field in gettxoutsetinfo.

This is an order-independent hash, allowing it to be computed either by iterating over the UTXO set in non-sorted order. It also supports incremental addition and deletion of entries from the hash, allowing it to be updated on the fly for each block. Neither of these approaches is currently implemented.

Copy link
Contributor

@paveljanik paveljanik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Release notes entry needed.

@@ -0,0 +1,329 @@
#include "muhash.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copyright header missing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

for (int i = 0; i < 10; ++i) {
unsigned char res[384];
int table[4];
for (int i = 0; i < 4; ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i shadowing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

}
for (int order = 0; order < 4; ++order) {
MuHash3072 acc;
for (int i = 0; i < 4; ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i shadowing

y /= x; // x=X, y=Y/X, z=X/Y
z *= y; // x=X, y=Y/X, z=1
z.Finalize(out);
for (int i = 0; i < 384; ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i shadowing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@n1bor
Copy link

n1bor commented Jan 1, 2018

@sipa - did this POC of chainstate only sync:
https://gist.github.com/n1bor/d5b0330a9addb0bf5e0f869518883522
https://botbot.me/freenode/bitcoin-core-dev/2016-10-24/?msg=75398575&page=3

Worked well - syncs as fast at you can download chainstate db (30mins for 2.8gig chainstate). Network was the bottleneck.
Should be able to rework to use MuHash easily - and rethink the snapshot interval/process.
But if consensus is to NEVER commit chain-state to blockchain - then is all a little pointless. gmaxwell did suggest an expiring consensus rule so if want to change from MuHash would be easy - which would do.

Or guess could compute hash by downloading every block! Then no security loss. But 150Gig download - so still 8hrs for 40Mbit connection. (think the hashing would take about 1 hour but in parallel with download).

@sipa
Copy link
Member Author

sipa commented Feb 8, 2018

Closing as stale.

@sipa sipa closed this Feb 8, 2018
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants