-
Notifications
You must be signed in to change notification settings - Fork 38.7k
index, rpc: Coinstatsindex follow-ups #22047
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
Conversation
src/rpc/blockchain.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if "value" is the best wording choice here. I see "amount" used much more in the codebase, and even variables/enums used here in PR uses "amount", not "value".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I see what you mean and I was on the fence there. I felt like amount could be easier mistaken to mean 'count' in this context but I am not a native speaker so maybe that feeling is just off. I have changed it to 'amount' since, as you say, consistency is better, all other things being equal.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
src/index/coinstatsindex.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unspendables are also "total", but don't mention it. Might be good to remove the "total_" here, or add it to unspendables?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped the total_ everywhere except for the m_total_amount, it seemed right to keep it in this case since it's closed to the corresponding legacy name nTotalAmount that is also still in use.
c6dfa1c to
f3cf029
Compare
Sjors
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly happy with f3cf0298180680900eabf1cd2827bd854d4cfeda
src/index/coinstatsindex.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
b778ac8f2b12f771e5b8ddcadc35ee267e57cfb0: I think the total_ prefix is more clear (and consistent with total_amount which you wanted to keep). So maybe use the second approach @MarcoFalke suggested:
unspendables are also "total", but don't mention it. Might be good to remove the "total_" here, or add it to unspendables?
More importantly, can you add comments explaining how these values are used? Their cumulative nature is a bit counter intuitive, though it makes sense for rollbacks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, changed the names to all use total_ and added comments explaining each of the new values in coinstats.h a bit more clearly.
|
tACK f3cf0298180680900eabf1cd2827bd854d4cfeda. Built on Debian Sid, ran |
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-
|
ACK d6dbb17 |
|
@MarcoFalke could you check if you are happy with this? :) |
jonatack
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK d6dbb17b1608502850e9e5c6ec29569cfcb23237 tested on signet after rebase to current master
Happy to re-ACK for any of the suggestions below, if you're so inclined.
src/index/coinstatsindex.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
18aa58b4 I did not test this change; it may be good to add a test here and for the same logging change above lines 125-130
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can really only hit this in cases of data corruption (or a bug somewhere else in the code). So that makes it really hard to test. I have made a note to look into it some more and think about how to add coverage without too much effort.
During initial sync after startup the gettxoutsetinfo RPC will still return an error while catching up. However, after the initial sync the index will not error immediately anymore when it's in the process of syncing to the tip while being called. Instead it will block until synced and then return the response.
More accurate logging of a warning should make clear if the recovery condition was hit while catching the results of the previous block.
|
Addressed @jonatack 's comments and fixed a typo. |
|
re-utACK 779e638 |
|
re-ACK 779e638 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 |
Talkless
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-utACK 779e638 after cosmetic changes.
| const auto& tx{block.vtx.at(i)}; | ||
|
|
||
| for (size_t j = 0; j < tx->vout.size(); ++j) { | ||
| for (uint32_t j = 0; j < tx->vout.size(); ++j) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't vector<…>::size() return a size_t, making this effectively a cast?
(apparently not necessarily: which size_type it returns is C++ library dependent)
|
Code review ACK 779e638 |
Github-Pull: bitcoin#22047 Rebased-From: 1e38423
Github-Pull: bitcoin#22047 Rebased-From: a5f6791
During initial sync after startup the gettxoutsetinfo RPC will still return an error while catching up. However, after the initial sync the index will not error immediately anymore when it's in the process of syncing to the tip while being called. Instead it will block until synced and then return the response. Github-Pull: bitcoin#22047 Rebased-From: d4356d4
More accurate logging of a warning should make clear if the recovery condition was hit while catching the results of the previous block. Github-Pull: bitcoin#22047 Rebased-From: 5b3d4e7
Summary: Main commit bitcoin/bitcoin@dd58a4d > index: Add Coinstats index > > The index holds the values previously calculated in coinstats.cpp for each block, representing the state of the UTXO set at each height. ----- bitcoin/bitcoin@57a026c > test: Add unit test for Coinstats index ----- bitcoin/bitcoin@8ea8c92 > index: Avoid unnecessary type casts in coinstatsindex ----- Replace two database writes with a single atomic batch write, to avoid a risk of database corruption. See [[ bitcoin/bitcoin@dd58a4d#r634089179 | the corresponding review ]]. bitcoin/bitcoin@1e38423 > index: Use batch writing in coinstatsindex WriteBlock ----- This is a backport of [[bitcoin/bitcoin#19521 | core#19521]] [4 & 8/17] and [[bitcoin/bitcoin#22047 | core#22047]] [1 & 3/3] Depends on D11597 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, sdulfari Reviewed By: #bitcoin_abc, sdulfari Subscribers: sdulfari Differential Revision: https://reviews.bitcoinabc.org/D11598
Summary: This is a backport of [[bitcoin/bitcoin#19521 | core#19521]] [11/17] and [[bitcoin/bitcoin#22047 | core#22047]] [2/3] bitcoin/bitcoin@2501576 bitcoin/bitcoin@fb65dde Depends on D11604 Test Plan: `ninja all check-all` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D11605
This is a collection of smaller follow-ups to #19521, addressing several post-merge review comments.