-
Notifications
You must be signed in to change notification settings - Fork 36.2k
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
rpc: Tidy up reporting of buried and ongoing softforks #16328
Conversation
fa75ca8
to
fa3d019
Compare
utACK fa3d019 I've read the code and it looks good to me. |
How does this fit in with buried softfork changes like #16060? |
This is the first commit from #16060, with some changes to the tests and release notes. |
a6a6eeb
to
16eb289
Compare
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. |
16eb289
to
9151277
Compare
Thanks. Yes, probably makes sense to split this off from the burying itself. |
e125215
to
fae687c
Compare
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 the "active" field needs fixing one way or the other before merge.
Three other suggestions:
- include a
"bips": [141, 143, 147]
field to make it easy to look up what's being implemented - change the old names to "heightincb", "strictder" and "cltv" for consistency (and so you don't have to remember what bip34 was or which was bip65 and which was bip66)
- move this into a "getforkinfo" rpc and out of "getblockchaininfo"; that way getblockchaininfo is just ~14 lines, and the bits that change every block aren't hidden behind a wall of soft fork info that rarely changes at all
Draft implementation of the above suggestions at https://github.com/ajtowns/bitcoin/commits/201907-getforkinfo if any of them seem worthwhile.
Edited to add: big concept ack!
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.
A couple of comments inline
Incidentally, you've force-pushed to this branch 9 times since opening it (7 since I last reviewed), without any additional comments in the PR. Without any explanation for why you're making those changes, it was a lot of effort to re-review this PR. I don't see the rationale for reverting some of the previous changes, for example.
6bb4929
to
fa6065f
Compare
Addressed review from @practicalswift and @ajtowns (excellent stuff, thanks!) In particular:
I left out (from @ajtowns branch): |
This combines reporting of buried (formally ISM) softfork deployments and BIP9 versionbits softfork deployments into one JSON object Co-authored-by: Anthony Towns <aj@erisian.com.au> Co-authored-by: John Newbery <john@johnnewbery.com>
fa6065f
to
3065c16
Compare
3065c16
to
4a4178b
Compare
Not sure why I didn't think of it earlier, but there's a much easier way of fixing the off-by-one issue with "active" that doesn't need changes to versionbits, given we do the "height" calculation anyway: @@ -1189,6 +1189,7 @@ static void BuriedForkDescPushBack(UniValue& softforks, const std::string& name,
rv.pushKV("type", "buried");
rv.pushKV("height", height);
rv.pushKV("active", tip.nHeight + 1 >= height);
+ rv.pushKV("enforced", tip.nHeight >= height);
softforks.pushKV(name, rv);
}
@@ -1227,12 +1228,15 @@ static UniValue BIP9SoftForkDesc(const CBlockIndex* pindex, const Consensus::Par
UniValue rv(UniValue::VOBJ);
rv.pushKV("type", "vb");
rv.pushKV("vb", bip9);
+ int height = -1;
if (ThresholdState::LOCKED_IN == thresholdState) {
- rv.pushKV("height", since_height + consensusParams.nMinerConfirmationWindow);
+ height = since_height + consensusParams.nMinerConfirmationWindow;
} else if (ThresholdState::ACTIVE == thresholdState) {
- rv.pushKV("height", since_height);
+ height = since_height;
}
+ if (height >= 0) rv.pushKV("height", height);
rv.pushKV("active", ThresholdState::ACTIVE == thresholdState);
+ rv.pushKV("enforced", (height >= 0 && pindex->nHeight >= height));
return rv;
} (I added a differently named field to make sure Also, you've got a typo in the commit message, "Renambe bip9..". |
This unifies how softforks (e.g. buried, ISM, BIP9, ...) are reported. The output of
getforkinfo()
is now always a dict, where the key is the name of the softfork and the value is a dict with further details.