Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Jul 2, 2019

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.

@maflcko maflcko force-pushed the 1907-rpcSoftforks branch 2 times, most recently from fa75ca8 to fa3d019 Compare July 2, 2019 18:13
@jnewbery
Copy link
Contributor

jnewbery commented Jul 2, 2019

utACK fa3d019

I've read the code and it looks good to me.

@laanwj
Copy link
Member

laanwj commented Jul 2, 2019

How does this fit in with buried softfork changes like #16060?

@jnewbery
Copy link
Contributor

jnewbery commented Jul 2, 2019

How does this fit in with buried softfork changes like

This is the first commit from #16060, with some changes to the tests and release notes.

@maflcko maflcko force-pushed the 1907-rpcSoftforks branch 4 times, most recently from a6a6eeb to 16eb289 Compare July 2, 2019 19:03
@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 2, 2019

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #16365 (Log RPC parameters (arguments) if -debug=rpcparams by LarryRuane)
  • #16229 (Standardise deployment handling by ajtowns)
  • #16060 (Bury bip9 deployments by jnewbery)

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.

@maflcko maflcko changed the title rpc: Tidy up reporting of buried and ongoing softforks WIP rpc: Tidy up reporting of buried and ongoing softforks Jul 2, 2019
@laanwj
Copy link
Member

laanwj commented Jul 3, 2019

This is the first commit from #16060, with some changes to the tests and release notes.

Thanks. Yes, probably makes sense to split this off from the burying itself.

@maflcko maflcko changed the title WIP rpc: Tidy up reporting of buried and ongoing softforks rpc: Tidy up reporting of buried and ongoing softforks Jul 3, 2019
@maflcko maflcko force-pushed the 1907-rpcSoftforks branch 2 times, most recently from e125215 to fae687c Compare July 3, 2019 16:46
Copy link
Contributor

@ajtowns ajtowns left a 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!

src/rpc/blockchain.cpp Outdated Show resolved Hide resolved
src/rpc/blockchain.cpp Outdated Show resolved Hide resolved
src/rpc/blockchain.cpp Show resolved Hide resolved
Copy link
Contributor

@jnewbery jnewbery left a 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.

src/rpc/blockchain.cpp Outdated Show resolved Hide resolved
src/rpc/blockchain.cpp Outdated Show resolved Hide resolved
@maflcko maflcko force-pushed the 1907-rpcSoftforks branch 4 times, most recently from 6bb4929 to fa6065f Compare July 19, 2019 17:43
@maflcko
Copy link
Member Author

maflcko commented Jul 19, 2019

Addressed review from @practicalswift and @ajtowns (excellent stuff, thanks!)

In particular:

  • Moved it to a new rpc to not clutter exiting rpcs
  • Made the resulting dict atomic (by acquiring cs_main, to avoid races with incoming blocks)
  • Made both types consistent (by reintroducing the "off-by-one")
  • Renamed "bip9" to "vb", since BIP 8 is also a version bits deployment mechanism

I left out (from @ajtowns branch):

  • 70f425e because I didn't like the non-rpc changes. Feel free to submit as a follow up pull request
  • 83709e7 because of the additional changes. Feel free to submit as follow up

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>
@ajtowns
Copy link
Contributor

ajtowns commented Jul 21, 2019

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 "active": True matches up with "vb": { "status": "active", .. }, since bumping the info in the "vb" field really needs changes to versionbits.cpp to make much sense.

Also, you've got a typo in the commit message, "Renambe bip9..".

@maflcko maflcko closed this Jul 23, 2019
@maflcko maflcko deleted the 1907-rpcSoftforks branch July 23, 2019 21:06
@jnewbery jnewbery mentioned this pull request Jul 29, 2019
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants