Skip to content

Heavy Hash cache#23

Draft
hidaloop wants to merge 10 commits intomasterfrom
obtc-nightly
Draft

Heavy Hash cache#23
hidaloop wants to merge 10 commits intomasterfrom
obtc-nightly

Conversation

@hidaloop
Copy link
Copy Markdown
Collaborator

Implements a database that stores Heavy Hash of blocks, making node performance better compromising memory.

Yet memory should not be an issue, as entry related to one block would take up 160 bits (key) + 256 bits (value) = 416 bits.
At the current chain state of 70_000 blocks this gives only 3.64 MB.

Heavy Hash is a resource intensive hashing algorithm, and at a current state block indexation and blockchain rescaning takes up to 6-8 minutes. This strongly impedes the performance of a serving node, and makes deployment with volumes really unpleasant. This issue also causes using wallets a very worrying experience.

A simple lookup table however solves both the problems.

Links:
Discord announcement

Note:
Data base is a bitcoin leveldb database, that works in the same way as block/index or chainstate.

barrystyle and others added 10 commits February 21, 2022 10:31
Cache powhashes in a persistent database. Test purposes.
Rationel:
Convience libraries built by bitcoin contain logically separated code, which allows for modularity. Introducing powcache -> dbwrapper dependecy breaks this modularity by making consensus dependant on server/wallet functionality.
Apart from that it breaks builds for libconsesnsus shared library, and bruteforce fixing by satisfying every symbol is incorrect. It is designed to be stand-alone and lightweight for a reason.
Thus this commit relinks powcache.* files to server library, and implements cache lookup outside of primitives.
1. Adds a wrapper around PoW cache database, which allows for easy substitution of any heavy block.GetHash() encounter.
2. Removes redundant calls.

Consideration:
Performing a database lookup with 160 bit long buffer instead of 256 bit blob.
Due to the fact that SHA1 output is 160 bits long 256 - 160 = 96 bits are zeros simply taking up space. It is not a big issue, but may result in extra 1 MB of data every week.
This takes into account regtest and testnet3 sub directories
GetCacheHash() uses SHA1 for a unique key. Its output size is 20 bytes -> 160 bits, however initial implementation uses 256 bit key, thus 96 bits are simply 0, which uses up extra memory.
@hidaloop hidaloop added the enhancement New feature or request label Jul 19, 2022
@hidaloop hidaloop requested review from pkvk and sevahul July 19, 2022 12:37
@hidaloop hidaloop linked an issue Jul 19, 2022 that may be closed by this pull request
@hidaloop
Copy link
Copy Markdown
Collaborator Author

Potential addition that may done to this PR is command line argument that controls a couple of parameters related to powcache:

  1. Cache size, as in block/index
  2. Whether to use powcache or not

But this optional, and imho shall not be the reason to postpone the merge.

@hidaloop hidaloop marked this pull request as draft July 20, 2022 16:22
@hidaloop
Copy link
Copy Markdown
Collaborator Author

Update:
This solution may be unnecessary.
After some experiments, it turned out that huge launch time is indeed due to matrix rank checking, as stated by the @asof in this issue.

@barrystyle
Copy link
Copy Markdown

All issues resolved in #17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Long open time Bitcoin Core Qt

2 participants