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

Separate concepts of block difficulty and network difficulty in RPC #1308

Conversation

str4d
Copy link
Contributor

@str4d str4d commented Aug 26, 2016

"Block difficulty" is the difficulty listed in a block's header, which in the
testnet can sometimes be min-difficulty (if time-since-last-block is too large).

"Network difficulty" is the difficulty that the network was trying to satisfy
at a particular block height. In mainnet this is always equal to the difficulty
of the solved block for that height, but in testnet the network difficulty is
derived from the last non-min-difficulty block difficulty.

This commit fixes the RPC APIs that are intended to show network difficulty, so
that on testnet they don't sometimes drop to 1.0, confusing users.

Closes #1181

@str4d str4d added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. testnet usability A-rpc-interface Area: RPC interface labels Aug 26, 2016
@str4d str4d added this to the Beta 1 - complete RPC, audit mitigations, other linux support, user bugfixes milestone Aug 26, 2016
@str4d str4d added the A-pow Area: Proof-of-Work and mining label Aug 26, 2016
@@ -140,6 +140,7 @@ extern int64_t nWalletUnlockTime;
extern CAmount AmountFromValue(const json_spirit::Value& value);
extern json_spirit::Value ValueFromAmount(const CAmount& amount);
extern double GetDifficulty(const CBlockIndex* blockindex = NULL);
extern double GetNetworkDifficulty(const CBlockIndex* blockindex = NULL);
Copy link
Contributor

Choose a reason for hiding this comment

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

Arrgh C++ is horrible (default arguments in declaration but not definition).

@ebfull
Copy link
Contributor

ebfull commented Aug 30, 2016

utACK, needs a test.

"Block difficulty" is the difficulty listed in a block's header, which in the
testnet can sometimes be min-difficulty (if time-since-last-block is too large).

"Network difficulty" is the difficulty that the network was trying to satisfy
at a particular block height. In mainnet this is always equal to the difficulty
of the solved block for that height, but in testnet the network difficulty is
derived from the last non-min-difficulty block difficulty.

This commit fixes the RPC APIs that are intended to show network difficulty, so
that on testnet they don't sometimes drop to 1.0, confusing users.

Closes zcash#1181
@str4d str4d force-pushed the 1181-getmininginfo-testnet-difficulty-rules branch from a36b8e9 to 00939d0 Compare September 1, 2016 04:39
@str4d
Copy link
Contributor Author

str4d commented Sep 1, 2016

Rebased on latest so that I could add the test to the newly-added src/gtest/test_rpc.cpp.

@ebfull
Copy link
Contributor

ebfull commented Sep 1, 2016

ACK, good coverage. Thanks for writing that test. Good work!

@zkbot r+

@zkbot
Copy link
Contributor

zkbot commented Sep 1, 2016

📌 Commit a36b8e9 has been approved by ebfull

@ebfull
Copy link
Contributor

ebfull commented Sep 1, 2016

@zkbot r+ 00939d0

@zkbot
Copy link
Contributor

zkbot commented Sep 1, 2016

💡 This pull request was already approved, no need to approve it again.

@zkbot
Copy link
Contributor

zkbot commented Sep 1, 2016

🙀 00939d09ba9c3db8cca0b26721226459d4ee31ca is not a valid commit SHA. Please try again with a36b8e9.

@ageis
Copy link
Contributor

ageis commented Sep 1, 2016

I updated the head_sha in Homu for this PR.

@ebfull
Copy link
Contributor

ebfull commented Sep 1, 2016

@zkbot r+ 00939d0

@zkbot
Copy link
Contributor

zkbot commented Sep 1, 2016

⌛ Testing commit 00939d0 with merge 2640989...

zkbot pushed a commit that referenced this pull request Sep 1, 2016
…es, r=ebfull

Separate concepts of block difficulty and network difficulty in RPC

"Block difficulty" is the difficulty listed in a block's header, which in the
testnet can sometimes be min-difficulty (if time-since-last-block is too large).

"Network difficulty" is the difficulty that the network was trying to satisfy
at a particular block height. In mainnet this is always equal to the difficulty
of the solved block for that height, but in testnet the network difficulty is
derived from the last non-min-difficulty block difficulty.

This commit fixes the RPC APIs that are intended to show network difficulty, so
that on testnet they don't sometimes drop to 1.0, confusing users.

Closes #1181
@zkbot
Copy link
Contributor

zkbot commented Sep 1, 2016

☀️ Test successful - zcash

@zkbot zkbot merged commit 00939d0 into zcash:zc.v0.11.2.latest Sep 1, 2016
@str4d str4d deleted the 1181-getmininginfo-testnet-difficulty-rules branch September 2, 2016 01:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pow Area: Proof-of-Work and mining A-rpc-interface Area: RPC interface S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. testnet usability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants