Skip to content
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

Use rolling muhash for UTXO set hash #25

Closed
wants to merge 10 commits into from

Conversation

fjahr
Copy link

@fjahr fjahr commented Aug 26, 2019

This PR is an update to bitcoin#10434. It implements a rolling UTXO set hash using the Muhash algorithm. The hash is accessible through the gettxoutsetinfo RPC call.

Design info:
UtxoSetHash is functioning as an Index (subclass of BaseIndex). It maintains the current Muhash object m_muhash that is updated with changes in the blockchain. It also saves 256bit digests of the Muhash for every block.

An alternative design could have hooked into ValidationInterface directly and used a flat-file structure for persistence instead of the DB. Thoughts on these alternatives welcome.

Find more details in the Proposal.

Known todos:

  • No finished implementations of rolling versions of ECMH and LtHash to compare
  • variable names including hash may refer to an instance of MuHash3072 or UtxoSetHash or a 256bit hash digest. This may be confusing and I want to clean this up naming all instances of MuHash something including muhash and everything referring to 256bit hashes something named digest
  • WriteBlock and ReverseBlock method could be considerably DRYed up
  • In order to make gettxoutsetinfo respond instantly, the other statistics that are collected by looping over the UTXO set will need to be updated on a rolling basis as well: total_amount, bogosize, txouts, transactions

@fjahr
Copy link
Author

fjahr commented Aug 27, 2019

For reference here are the branches with the alternative hashing algorithms, but these are not implemented as rolling, yet.

https://github.com/fjahr/bitcoin/tree/lthash
https://github.com/fjahr/bitcoin/tree/ecmh

@fjahr fjahr force-pushed the muhash-rolling branch 2 times, most recently from fc60e51 to c4681d1 Compare August 27, 2019 22:01
The UtxoSetHash is implemented as an index (subclass of BaseIndex)
and maintains data in LevelDB. It keeps the muhash for each block
in the database and also allows to search them by block hash or
height. It also maintains the global Muhash object which is being
modified as new blocks get added to the chain or as reorgs happen.

This commit also adds a serialization method to the Muhash object
to be able to persist it between restarts of the node.
@fjahr fjahr changed the title Use rolling muhash for UTXO set hash in gettxoutsetinfo Use rolling muhash for UTXO set hash Sep 4, 2019
@jnewbery
Copy link

Can you set the base branch to master for this?

@fjahr
Copy link
Author

fjahr commented Nov 1, 2019

@jnewbery moved my work in progress over here: #28

@fjahr fjahr closed this Nov 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants