Skip to content

Conversation

jlopp
Copy link
Contributor

@jlopp jlopp commented Sep 30, 2023

When writing some scripts that iterated over many blocks to generate hashrate estimates I realized that my script was going out of range of the current chain tip height but was not encountering any errors.

I believe that passing an invalid block height to this function but receiving the hashrate estimate for the chain tip instead should be considered unexpected behavior.

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 30, 2023

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

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK Sjors, kevkevinpal, achow101
Concept ACK luke-jr
Stale ACK maflcko

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

No conflicts as of last run.

@jlopp jlopp changed the title throw an error if an invalid block height is passed to getnetworkhashps RPC endpoint bugfix: throw an error if an invalid block height is passed to getnetworkhashps RPC Sep 30, 2023
Copy link
Contributor

@kevkevinpal kevkevinpal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 057b3e0

@jlopp jlopp force-pushed the getnetworkhashps_height_validation branch from 057b3e0 to 6074de6 Compare September 30, 2023 20:17
@kevkevinpal
Copy link
Contributor

reACK 6074de6

Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine to do this. Not sure if a release note is needed, because strictly speaking this could be a breaking change.

@jlopp jlopp requested review from maflcko and kevkevinpal October 2, 2023 17:06
@kevkevinpal
Copy link
Contributor

I would prefer 6074de6 and 786ba64 be squashed together in one commit

@jlopp jlopp force-pushed the getnetworkhashps_height_validation branch from 786ba64 to 1fd3715 Compare October 2, 2023 18:03
Copy link
Member

@luke-jr luke-jr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

nit: Remove pb == nullptr check below, as it is no longer possible.

@kevkevinpal
Copy link
Contributor

reACK 1fd3715

@DrahtBot DrahtBot removed the request for review from kevkevinpal October 3, 2023 05:53
@maflcko
Copy link
Member

maflcko commented Oct 3, 2023

lgtm ACK 1fd3715

@DrahtBot DrahtBot removed the request for review from maflcko October 3, 2023 07:55
@jlopp jlopp force-pushed the getnetworkhashps_height_validation branch from 1fd3715 to ec54efd Compare October 3, 2023 12:53
@jlopp
Copy link
Contributor Author

jlopp commented Oct 3, 2023

Upon further inspection I realized that the "lookup" nblocks parameter also had insufficient validation so I've added checks to ensure that it's either a positive number or -1.

@jlopp jlopp changed the title bugfix: throw an error if an invalid block height is passed to getnetworkhashps RPC bugfix: throw an error if an invalid parameter is passed to getnetworkhashps RPC Oct 3, 2023
Copy link
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about the last change

@jlopp jlopp force-pushed the getnetworkhashps_height_validation branch 3 times, most recently from 7198be5 to 565ad11 Compare October 3, 2023 15:43
@jlopp jlopp requested a review from maflcko October 3, 2023 15:45
@jlopp jlopp force-pushed the getnetworkhashps_height_validation branch from 565ad11 to 435ff29 Compare October 3, 2023 19:37
@jlopp jlopp requested a review from luke-jr October 4, 2023 11:22
@jlopp
Copy link
Contributor Author

jlopp commented Oct 4, 2023

Not sure what's going on with the windows build; it failed on a wallet address test with a socket timeout. Seems unrelated to my PR.

Looks like it's a known issue. #28509

Copy link
Member

@Sjors Sjors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lightly tested ACK 435ff29

@DrahtBot DrahtBot requested review from kevkevinpal and removed request for kevkevinpal October 10, 2023 13:57
@jlopp
Copy link
Contributor Author

jlopp commented Oct 17, 2023

Any further concerns?

@DrahtBot DrahtBot requested review from kevkevinpal and removed request for kevkevinpal October 17, 2023 16:24
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Oct 19, 2023
@jlopp jlopp force-pushed the getnetworkhashps_height_validation branch from 435ff29 to 9ac114e Compare November 7, 2023 17:59
@jlopp jlopp requested a review from Sjors November 8, 2023 20:08
@Sjors
Copy link
Member

Sjors commented Nov 9, 2023

Thanks for rebasing.

re-utACK 9ac114e

@DrahtBot DrahtBot requested review from kevkevinpal and removed request for kevkevinpal and Sjors November 9, 2023 01:15
@kevkevinpal
Copy link
Contributor

reACK 9ac114e

@DrahtBot DrahtBot removed the request for review from kevkevinpal November 20, 2023 22:44
@achow101
Copy link
Member

ACK 9ac114e

@achow101 achow101 merged commit 75462b3 into bitcoin:master Nov 28, 2023
@jlopp jlopp deleted the getnetworkhashps_height_validation branch November 29, 2023 12:37
glozow pushed a commit to glozow/bitcoin that referenced this pull request Apr 17, 2024
glozow added a commit that referenced this pull request May 24, 2024
aa7e876 [doc] add draft release notes for 26.2rc1 (glozow)
21d9aaa p2p, bugfix: detect addnode cjdns peers in GetAddedNodeInfo() (Jon Atack)
ec5ce2f windeploy: Renew certificate (Ava Chow)
96d0e81 rpc: Reword SighashFromStr error message (MarcoFalke)
6685aff rpc: move UniValue in blockToJSON (willcl-ark)
7f45e00 depends: Fix build of Qt for 32-bit platforms (laanwj)
f9b76ba ci: Pull in qtbase5-dev instead of seperate low-level libraries (laanwj)
c587753 doc: Suggest installing dev packages for debian/ubuntu qt5 build (laanwj)
7ecdb08 ci: Bump s390x to ubuntu:24.04 (MarcoFalke)
d9ef6cf sign: don't assume we are parsing a sane Miniscript (Antoine Poinsot)
e4859c8 depends: fix mingw-w64 Qt DEBUG=1 build (fanquake)
bb46b90 Fix #29767, set m_synced = true after Commit() (nanlour)
bf5b6fc Throw error if invalid parameters passed to getnetworkhashps RPC endpoint (Jameson Lopp)
a81a922 [rpc, bugfix] Enforce maximum value for setmocktime (dergoegge)
d39ea51 Change Luke Dashjr seed to dashjr-list-of-p2p-nodes.us (Luke Dashjr)
c21bbcc [doc] archive 26.1 release notes (glozow)

Pull request description:

  Archives 26.1 release notes and adds draft release notes for 26.2rc1

  Also backports:
  - #29691
  - #29869
  - #28554
  - #29747
  - #29853
  - #29856
  - #29764
  - #29776
  - #29985
  - #30094
  - #29870
  - #30149
  - #30085

ACKs for top commit:
  stickies-v:
    re-ACK aa7e876, only changes are fixing commit msg and transifex reference
  willcl-ark:
    ACK aa7e876

Tree-SHA512: b81ba6092640de696d782114cdf43e7ed1d63ea0a3231cade30653c2743d87700e0f852a1b1fcc42ae313b2d4f004e6026ddbad87d58c2fde0a660e90026ed98
@bitcoin bitcoin locked and limited conversation to collaborators Apr 5, 2025
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.

8 participants