-
Notifications
You must be signed in to change notification settings - Fork 38.7k
rpc, logging: add backgroundvalidation to getblockchaininfo #33259
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
base: master
Are you sure you want to change the base?
rpc, logging: add backgroundvalidation to getblockchaininfo #33259
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33259. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsNo conflicts as of last run. |
|
Concept ACK |
luke-jr
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.
Concept ACK. Would be nice to test the active state.
@luke-jr what do you mean by active state? |
|
When there is a background sync, not just |
Github-Pull: bitcoin#33259 Rebased-From: c1f545248ea0966a3aad0d70fc4c317cd9611d3f
|
Would it be better to return an object, eg: {
"background": {
"blocks": 100000,
"bestblockhash": "000000000003ba27aa200b1cecaad478d2b00432346c3f1f3986da1afd33e506",
"mediantime": 1293622620,
"chainwork": "0000000000000000000000000000000000000000000000000644cb7f5234089e"
"verificationprogress": 0.001,
}
...
} |
b9d3ccb to
8efdfa9
Compare
|
@ajtowns sgtm, done. |
17d9926 to
fd504bb
Compare
|
2d48902999a7ad1fcf19a8e630c69d6228dbd373 added snapshot height 83a1721817fda4db88ba12e0395ed63ba064c41b modify the way verification progress is calculated for background validation -> context: #33259 (comment) |
f3ee351 to
2d48902
Compare
2d48902 to
01860ea
Compare
danielabrozzoni
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.
Concept ACK
I did a very rough first pass and the code looks good to me. As others have said, I would like to see a functional test testing the newly introduced fields when the background validation is in progress
c31014d to
a48d92a
Compare
|
@danielabrozzoni @ajtowns @luke-jr Tests implemented, not the cleanest way for sure, but I couldn't figure out anything simpler. |
a48d92a to
21fb4c9
Compare
|
21fb4c9 correct typos |
updates estimations to the block snapshot instead of the main chain tip as it will stop validation after reaching that height
21fb4c9 to
ea37456
Compare
|
Rebased on top of master to solve conflicts with #30214 |
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 ea37456
Built from source, tested, and reviewed the code. New RPC fields behave as expected.
Without loading UTXO snapshot: backgroundvalidation=false
Details
bitcoin-cli getblockchaininfo
...
"mediantime": 1231006505,
"verificationprogress": 7.692763291753853e-10,
"initialblockdownload": true,
"backgroundvalidation": false,
"chainwork": "0000000000000000000000000000000000000000000000000000000100010001",
"size_on_disk": 293,
"pruned": false,
...
With loadtxoutset: backgroundvalidation=true and background progress shown.
Details
bitcoin-cli getblockchaininfo
...
"mediantime": 1737334898,
"verificationprogress": 0.8812817484397629,
"initialblockdownload": true,
"backgroundvalidation": true,
"background": {
"snapshotheight": 880000,
"blocks": 34031,
"bestblockhash": "00000000b2d3088131445fb70bda85e90663c36a66d429a2089c05014b8aac2b",
"mediantime": 1263124911,
"chainwork": "000000000000000000000000000000000000000000000000000086355a943ee0",
"verificationprogress": 2.990124328575242e-05
},
"chainwork": "0000000000000000000000000000000000000000a879619cfddf806d3bdf607b",
"size_on_disk": 9569248,
"pruned": false,
...
Left a few nits in comments.
| auto historical_blocks{chainman.GetHistoricalBlockRange()}; | ||
| bool background_sync = historical_blocks.has_value(); | ||
| obj.pushKV("backgroundvalidation", background_sync); | ||
| if(historical_blocks) { |
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.
Nit: missing space after if → if (historical_blocks)
| UniValue bValidation(UniValue::VOBJ); | ||
| const CBlockIndex& btip{*CHECK_NONFATAL(historical_blocks->first)}; | ||
| const std::optional<int> bHeight{active_chainstate.SnapshotBase()->nHeight}; | ||
| if(bHeight) bValidation.pushKV("snapshotheight", *bHeight); |
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.
Nit: missing space after if → if (bHeight)
| const CBlockIndex& btip{*CHECK_NONFATAL(historical_blocks->first)}; | ||
| const std::optional<int> bHeight{active_chainstate.SnapshotBase()->nHeight}; | ||
| if(bHeight) bValidation.pushKV("snapshotheight", *bHeight); | ||
| bValidation.pushKV("blocks",btip.nHeight); |
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.
Nit: missing space after comma → bValidation.pushKV("blocks", btip.nHeight);
getblockchaininforeturnsverificationprogress=1andinitialblockdownload=falseeven if there's background validation.This PR adds information about background validation to rpc
getblockchaininfoin a similar way tovalidationprogressdoes.If assume utxo was used the output of a "sync" node performing background validation:
If assume utxo was not used the progress is hidden and background validation is set to false:
The PR also updates the way we estimate the verification progress returning a 100% on the snapshot block and not on the tip as we will stop doing background validation when reaching it.