Skip to content

Commit 2b45cf0

Browse files
committed
Merge bitcoin/bitcoin#19521: Coinstats Index
5f96d7d rpc: gettxoutsetinfo rejects hash_serialized_2 for specific height (Fabian Jahr) 23fe504 test: Add test for coinstatsindex behavior in reorgs (Fabian Jahr) 90c966b rpc: Allow gettxoutsetinfo and getblockstats for stale blocks (Fabian Jahr) b936239 index, rpc: Add use_index option for gettxoutsetinfo (Fabian Jahr) bb7788b test: Test coinstatsindex robustness across restarts (Fabian Jahr) e0938c2 test: Add tests for block_info in gettxoutsetinfo (Fabian Jahr) 2501576 rpc, index: Add verbose amounts tracking to Coinstats index (Fabian Jahr) 655d929 test: add coinstatsindex getindexinfo coverage, improve current tests (Jon Atack) ca01bb8 rpc: Add Coinstats index to getindexinfo (Fabian Jahr) 57a026c test: Add unit test for Coinstats index (Fabian Jahr) 6a4c0c0 test: Add functional test for Coinstats index (Fabian Jahr) 3f166ec rpc: gettxoutsetinfo can be requested for specific blockheights (Fabian Jahr) 3c914d5 index: Coinstats index can be activated with command line flag (Fabian Jahr) dd58a4d index: Add Coinstats index (Fabian Jahr) a8a46c4 refactor: Simplify ApplyStats and ApplyHash (Fabian Jahr) 9c8a265 refactor: Pass hash_type to CoinsStats in stats object (Fabian Jahr) 2e2648a crypto: Make MuHash Remove method efficient (Fabian Jahr) Pull request description: This is part of the coinstats index project tracked in #18000 While the review of the new UTXO set hash algorithm (MuHash) takes longer recently #19328 was merged which added the possibility to run `gettxoutsetinfo` with a specific hash type. As the first type it added `hash_type=none` which skips the hashing of the UTXO set altogether. This alone did not make `gettxoutsetinfo` much faster but it allows the use of an index for the remaining coin statistics even before a new hashing algorithm has been added. Credit to Sjors for the idea to take this intermediate step. Features summary: - Users can start their node with the option `-coinstatsindex` which syncs the index in the background - After the index is synced the user can use `gettxoutsetinfo` with `hash_type=none` or `hash_type=muhash` and will get the response instantly out of the index - The user can specify a height or block hash when calling `gettxoutsetinfo` to see coin statistics at a specific block height ACKs for top commit: Sjors: re-tACK 5f96d7d jonatack: Code review re-ACK 5f96d7d per `git range-diff 13d27b4 07201d3 5f96d7d` promag: Tested ACK 5f96d7d. Light code review ACK 5f96d7d. Tree-SHA512: cbca78bee8e9605c19da4fbcd184625fb280200718396c694a56c7daab6f44ad23ca9fb5456d09f245d8b8d9659fdc2b3f3ce5e953c1c6cf4003dbc74c0463c2
2 parents 480bf01 + 5f96d7d commit 2b45cf0

22 files changed

+1177
-108
lines changed

src/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ BITCOIN_CORE_H = \
153153
i2p.h \
154154
index/base.h \
155155
index/blockfilterindex.h \
156+
index/coinstatsindex.h \
156157
index/disktxpos.h \
157158
index/txindex.h \
158159
indirectmap.h \
@@ -326,6 +327,7 @@ libbitcoin_server_a_SOURCES = \
326327
i2p.cpp \
327328
index/base.cpp \
328329
index/blockfilterindex.cpp \
330+
index/coinstatsindex.cpp \
329331
index/txindex.cpp \
330332
init.cpp \
331333
mapport.cpp \

src/Makefile.test.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ BITCOIN_TESTS =\
8080
test/bswap_tests.cpp \
8181
test/checkqueue_tests.cpp \
8282
test/coins_tests.cpp \
83+
test/coinstatsindex_tests.cpp \
8384
test/compilerbug_tests.cpp \
8485
test/compress_tests.cpp \
8586
test/crypto_tests.cpp \

src/crypto/muhash.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,6 @@ MuHash3072& MuHash3072::Insert(Span<const unsigned char> in) noexcept {
341341
}
342342

343343
MuHash3072& MuHash3072::Remove(Span<const unsigned char> in) noexcept {
344-
m_numerator.Divide(ToNum3072(in));
344+
m_denominator.Multiply(ToNum3072(in));
345345
return *this;
346346
}

src/index/base.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ class BaseIndex : public CValidationInterface
8181

8282
void ChainStateFlushed(const CBlockLocator& locator) override;
8383

84+
const CBlockIndex* CurrentIndex() { return m_best_block_index.load(); };
85+
8486
/// Initialize internal state from the database and block index.
8587
virtual bool Init();
8688

0 commit comments

Comments
 (0)