aboutsummaryrefslogtreecommitdiff
path: root/src/index/coinstatsindex.cpp
AgeCommit message (Collapse)Author
2022-09-13refactor: use std::string for index namesstickies-v
2022-07-20refactor: Pass reference to LookUpStatsMacroFake
2022-07-19Merge bitcoin/bitcoin#25645: refactor: Remove unused includes from dbwrapper.hfanquake
faf98aecf876fae0ec6d4d16b7e66f3a35253180 Remove unused includes in rpc/fees.cpp (MacroFake) 1111ddeedf7ea801507db4e23b4737ec183eb19c Remove unused includes from dbwrapper.h (MacroFake) fa77fdd0475fa15a1a3641c5d5a2bf7ad095aa84 Add missing includes (MacroFake) fa869ce2c2b906d8b087c4e7a5f1804a74b1c522 Add missing includes to node/chainstate (MacroFake) Pull request description: Unused includes are confusing, but also cause unrelated compile errors when the unused includes were to be removed. Fix that by adding the missing includes where they are needed and then remove them where they are not needed. This is also checked by iwyu. ACKs for top commit: hebasto: ACK faf98aecf876fae0ec6d4d16b7e66f3a35253180, I have reviewed the code and it looks OK, I agree it can be merged. jarolrod: Code Review ACK https://github.com/bitcoin/bitcoin/commit/faf98aecf876fae0ec6d4d16b7e66f3a35253180 Tree-SHA512: 75f3c6e6f6ecf8a98233e1a1463c75ca4e0eb3ec341150d274141072fe95413a3c2ec6386d1c527899cc63d43f63f5eb5991509847412773362808ddfb1bb435
2022-07-19Add missing includesMacroFake
They are needed, otherwise the next commit will not compile
2022-07-18indexes, refactor: Remove CChainState use in index CommitInternal methodRyan Ofsky
Replace CommitInternal method with CustomCommit and use interfaces::Chain instead of CChainState to generate block locator. This commit does not change behavior in any way, except in the (m_best_block_index == nullptr) case, which was added recently in https://github.com/bitcoin/bitcoin/pull/24117 as part of an ongoing attempt to prevent index corruption if bitcoind is interrupted during startup. New behavior in that case should be slightly better than the old behavior (skipping the entire custom+base commit now vs only skipping the base commit previously) and this might avoid more cases of corruption.
2022-07-18indexes, refactor: Remove CBlockIndex* uses in index Rewind methodsRyan Ofsky
Replace Rewind method with CustomRewind and pass block hashes and heights instead of CBlockIndex* pointers This commit does not change behavior in any way.
2022-07-18indexes, refactor: Remove CBlockIndex* uses in index WriteBlock methodsRyan Ofsky
Replace WriteBlock method with CustomAppend and pass BlockInfo struct instead of CBlockIndex* pointer This commit does not change behavior in any way.
2022-07-18indexes, refactor: Remove CBlockIndex* uses in index Init methodsRyan Ofsky
Replace overriden index Init() methods that use the best block CBlockIndex* pointer with pure CustomInit() callbacks that are passed the block hash and height. This gets rid of more CBlockIndex* pointer uses so indexes can work outside the bitcoin-node process. It also simplifies the initialization call sequence so index implementations are not responsible for initializing the base class. There is a slight change in behavior here since now the best block pointer is loaded and checked before the custom index init functions are called instead of while they are called.
2022-07-18indexes, refactor: Remove CBlockIndex* uses in coinstatsindex LookUpOne functionRyan Ofsky
This commit does not change behavior in any way.
2022-07-18indexes, refactor: Pass Chain interface instead of CChainState class to indexesRyan Ofsky
Passing abstract Chain interface will let indexes run in separate processes. This commit does not change behavior in any way.
2022-05-23style-only: Rearrange using decls after scripted-diffCarl Dong
2022-05-23scripted-diff: Move src/kernel/coinstats to kernel::Carl Dong
Introduces a new kernel:: namespace and move all of src/kernel/coinstats under it. In the verify script, lines like: line="$(grep -n 'namespace node {' -- src/kernel/coinstats.h | tail -n1 | cut -d: -f1)" sed -i -e "${line}s@namespace node {@namespace kernel {@" -- src/kernel/coinstats.h Are intended to replace only the last instance of "namespace node" with "namespace kernel", this is to avoid replacing forward declarations of things inside the node:: namespace. -BEGIN VERIFY SCRIPT- sed -E -i 's@namespace node@namespace kernel@g' -- src/kernel/coinstats.cpp line="$(grep -n 'namespace node {' -- src/kernel/coinstats.h | tail -n1 | cut -d: -f1)" sed -i -e "${line}s@namespace node {@namespace kernel {@" -- src/kernel/coinstats.h line="$(grep -n '// namespace node' -- src/kernel/coinstats.h | tail -n1 | cut -d: -f1)" sed -i -e "${line}s@// namespace node@// namespace kernel@" -- src/kernel/coinstats.h things='(CCoinsStats|CoinStatsHashType|GetBogoSize|TxOutSer|ComputeUTXOStats)' git grep -lE 'node::'"$things" | xargs sed -E -i 's@node::'"$things"'@kernel::\1@g' sed -E -i 's@'"$things"'@kernel::\1@g' -- src/node/coinstats.cpp src/node/coinstats.h sed -E -i 's@BlockManager@node::\0@g' -- src/kernel/coinstats.cpp -END VERIFY SCRIPT-
2022-05-23Move logic from LookupUTXOStatsWithIndex to CoinStatsIndex::LookUpStatsCarl Dong
The indexing codepath logic in node/coinstats.cpp is simple enough to be moved into CoinStatsIndex::LookUpStats, avoiding an additional layer of function calls. Callers are modified accordingly. Also, add 2 missed BOOST_CHECKs to the coinstatsindex_initial_sync unit test.
2022-03-09refactor: more const annotations for uses of CBlockIndex*Anthony Towns
2022-02-21index: Commit DB_MUHASH and DB_BEST_BLOCK to disk togetherMartin Zumsande
If these are written to disk at different times, unclean shutdowns can lead to index corruption.
2022-02-17index: check muhash is in sync on coinstatsindex launchFabian Jahr
2022-01-31index: Don't commit without valid m_best_block_indexMartin Zumsande
Also report an error when coinstatsindex init fails.
2022-01-06Add src/node/* code to node:: namespaceRussell Yanofsky
2021-12-17refactor: Avoid integer overflow in ApplyStats when activating snapshotMarcoFalke
2021-07-28Merge bitcoin/bitcoin#22047: index, rpc: Coinstatsindex follow-upsW. J. van der Laan
779e638ca9b2b37c247577d225b93ac762b0602f coinstats: Add comments for new coinstatsindex values (Fabian Jahr) 5b3d4e724f377834e24b1f014787cc7aa7fc30fe Index: Improve logging in coinstatsindex (Fabian Jahr) d4356d4e48f59c63894b68691cc21ed4892ee716 rpc: Block until synced if coinstatsindex is used in gettxoutsetinfo (Fabian Jahr) a5f6791139554936d13f367660283899a37ff5c7 rpc: Add missing gettxoutsetinfo help docs (Fabian Jahr) 01386bfd88019397237256cb16f91de346eb66f2 Index: Return early from failed coinstatsindex init (Fabian Jahr) 1e3842385b8c0d15086c7cd8736f8c67e6c0c285 index: Use batch writing in coinstatsindex WriteBlock (Fabian Jahr) fb65dde147f63422c4148b089c2f5be0bf5ba80f scripted-diff: Fix coinstats data member names (Fabian Jahr) 8ea8c927ac05980d6a81252e40b7444e9abb74f9 index: Avoid unnecessary type casts in coinstatsindex (Fabian Jahr) Pull request description: This is a collection of smaller follow-ups to #19521, addressing several post-merge review comments. ACKs for top commit: Sjors: re-utACK 779e638ca9b2b37c247577d225b93ac762b0602f jonatack: re-ACK 779e638ca9b2b37c247577d225b93ac762b0602f diff since last review involves doc changes only; rebased to current master and verified clean debug build/no silent conflicts, unit tests, and feature_coinstatsindex functional test laanwj: Code review ACK 779e638ca9b2b37c247577d225b93ac762b0602f Talkless: re-utACK 779e638ca9b2b37c247577d225b93ac762b0602f after cosmetic changes. Tree-SHA512: cb0d038d230c582d7fe3041c89b1e04d39971fab3739d540c609cf826754c6c513b12ded08ac92180aec7a9d7a70114ece50357bd1a902de4adaae9f30b8d699
2021-07-25Index: Improve logging in coinstatsindexFabian Jahr
More accurate logging of a warning should make clear if the recovery condition was hit while catching the results of the previous block.
2021-06-03Index: Return early from failed coinstatsindex initFabian Jahr
2021-06-03index: Use batch writing in coinstatsindex WriteBlockFabian Jahr
2021-06-03scripted-diff: Fix coinstats data member namesFabian Jahr
Initially these values were 'per block' in an earlier version but were then changed to total values. The names were not updated to reflect that. -BEGIN VERIFY SCRIPT- s() { git grep -l "$1" src | xargs sed -i "s/$1/$2/g"; } s 'm_block_unspendable_amount' 'm_total_unspendable_amount' s 'm_block_prevout_spent_amount' 'm_total_prevout_spent_amount' s 'm_block_new_outputs_ex_coinbase_amount' 'm_total_new_outputs_ex_coinbase_amount' s 'm_block_coinbase_amount' 'm_total_coinbase_amount' s 'block_unspendable_amount' 'total_unspendable_amount' s 'block_prevout_spent_amount' 'total_prevout_spent_amount' s 'block_new_outputs_ex_coinbase_amount' 'total_new_outputs_ex_coinbase_amount' s 'block_coinbase_amount' 'total_coinbase_amount' s 'unspendables_genesis_block' 'total_unspendables_genesis_block' s 'unspendables_bip30' 'total_unspendables_bip30' s 'unspendables_scripts' 'total_unspendables_scripts' s 'unspendables_unclaimed_rewards' 'total_unspendables_unclaimed_rewards' s 'm_unspendables_genesis_block' 'm_total_unspendables_genesis_block' s 'm_unspendables_bip30' 'm_total_unspendables_bip30' s 'm_unspendables_scripts' 'm_total_unspendables_scripts' s 'm_unspendables_unclaimed_rewards' 'm_total_unspendables_unclaimed_rewards' -END VERIFY SCRIPT-
2021-06-01Merge bitcoin/bitcoin#21767: [Bundle 6/n] Prune g_chainman usage in ↵MarcoFalke
auxiliary modules 7a799c9c2b8652e780d1fd5e1bf7d05b026c1c1a index: refactor-only: Reuse CChain ref (Carl Dong) db33cde80fff749c6adff9e91fca5f27f4bb6278 index: Add chainstate member to BaseIndex (Carl Dong) f4a47a1febfa35ab077f2a841fe31a8cd9618250 bench: Use existing chainman in AssembleBlock (Carl Dong) 91226eb91769aad5a63bc671595e1353a2b2247a bench: Use existing NodeContext in DuplicateInputs (Carl Dong) e6b4aa6eb53dc555ecab2922af35e7a2572faf4f miner: Pass in chainman to RegenerateCommitments (Carl Dong) 9ecade14252ad1972f668d2d2e4ef44fdfcb944a rest: Add GetChainman function and use it (Carl Dong) fc1c282845f6b8436d1ea4c68eb3511034c29bea rpc/blockchain: Use existing blockman in gettxoutsetinfo (Carl Dong) Pull request description: Overall PR: #20158 (tree-wide: De-globalize ChainstateManager) The first 2 commits are fixups addressing review for the last bundle: #21391 NEW note: 1. I have opened #21766 which keeps track of potential improvements where the flaws already existed before the de-globalization work, please post on that issue about these improvements, thanks! Note to reviewers: 1. This bundle may _apparently_ introduce usage of `g_chainman` or `::Chain(state|)Active()` globals, but these are resolved later on in the overall PR. [Commits of overall PR](https://github.com/bitcoin/bitcoin/pull/20158/commits) 2. There may be seemingly obvious local references to `ChainstateManager` or other validation objects which are not being used in callers of the current function in question, this is done intentionally to **_keep each commit centered around one function/method_** to ease review and to make the overall change systematic. We don't assume anything about our callers. Rest assured that once we are considering that particular caller in later commits, we will use the obvious local references. [Commits of overall PR](https://github.com/bitcoin/bitcoin/pull/20158/commits) 3. When changing a function/method that has many callers (e.g. `LookupBlockIndex` with 55 callers), it is sometimes easier (and less error-prone) to use a scripted-diff. When doing so, there will be 3 commits in sequence so that every commit compiles like so: 1. Add `new_function`, make `old_function` a wrapper of `new_function`, divert all calls to `old_function` to `new_function` **in the local module only** 2. Scripted-diff to divert all calls to `old_function` to `new_function` **in the rest of the codebase** 3. Remove `old_function` ACKs for top commit: jarolrod: ACK 7a799c9 ariard: Code Review ACK 7a799c9 fjahr: re-ACK 7a799c9c2b8652e780d1fd5e1bf7d05b026c1c1a MarcoFalke: review ACK 7a799c9c2b8652e780d1fd5e1bf7d05b026c1c1a 🌠 ryanofsky: Code review ACK 7a799c9c2b8652e780d1fd5e1bf7d05b026c1c1a. Basically no change since last review except fixed rebase conflicts and a new comment about REST Ensure() jamesob: conditional ACK 7a799c9c2b8652e780d1fd5e1bf7d05b026c1c1a ([`jamesob/ackr/21767.1.dongcarl.bundle_6_n_prune_g_chai`](https://github.com/jamesob/bitcoin/tree/ackr/21767.1.dongcarl.bundle_6_n_prune_g_chai)) Tree-SHA512: 531c00ddcb318817457db2812d9a9d930bc664e58e6f7f1c746350732b031dd624270bfa6b9f49d8056aeb6321d973f0e38e4ff914acd6768edd8602c017d10e
2021-05-27index: Add chainstate member to BaseIndexCarl Dong
2021-05-24index: Avoid unnecessary type casts in coinstatsindexFabian Jahr
2021-05-24scripted-diff: Replace `GetDataDir()` calls with `gArgs.GetDataDirNet()` callsKiminuo
-BEGIN VERIFY SCRIPT- git ls-files -- 'src' ':(exclude)src/util/system.h' ':(exclude)src/util/system.cpp' | xargs sed -i 's/GetDataDir()/gArgs.GetDataDirNet()/g'; -END VERIFY SCRIPT-
2021-05-01refactor: [index] Replace deprecated char with uint8_t in serializationMarcoFalke
2021-04-19rpc, index: Add verbose amounts tracking to Coinstats indexFabian Jahr
2021-04-19index: Add Coinstats indexFabian Jahr
The index holds the values previously calculated in coinstats.cpp for each block, representing the state of the UTXO set at each height.