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

IBD using chainwork instead of height and not using header timestamps #9053

Merged
merged 3 commits into from
Nov 3, 2016
Merged

IBD using chainwork instead of height and not using header timestamps #9053

merged 3 commits into from
Nov 3, 2016

Conversation

gmaxwell
Copy link
Contributor

@gmaxwell gmaxwell commented Nov 1, 2016

This introduces a 'minimum chain work' chainparam which is intended
to be the known amount of work in the chain for the network at the
time of software release. If you don't have this much work, you're
not yet caught up.

This is used instead of the count of blocks test from checkpoints.

This criteria is trivial to keep updated as there is no element of
subjectivity, trust, or position dependence to it. It is also a more
reliable metric of sync status than a block count.

This is the first step in a larger change to eliminate checkpoints
completely, but it's independently a good idea.

This PR makes IsInitialBlockDownload no longer use header-only timestamps.

This avoids a corner case (mostly visible on testnet) where bogus
headers can keep nodes in IsInitialBlockDownload.

@maflcko
Copy link
Member

maflcko commented Nov 1, 2016

utACK f3f8d2e

Nit: GetTotalBlocksEstimate is no longer used (only in tests). Feel free to remove that now.

@@ -47,6 +47,7 @@ Update the following:
- `doc/README.md` and `doc/README_windows.txt`
- `doc/Doxyfile`: `PROJECT_NUMBER` contains the full version
- `contrib/gitian-descriptors/*.yml`: usually one'd want to do this on master after branching off the release - but be sure to at least do it before a new major release
- `src/chainparams.cpp`: periodically update nMinimumChainWork with information from the getblockchaininfo rpc.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I think you want to move this up to the section " Before every minor and major release:"

@Leviathn
Copy link

Leviathn commented Nov 2, 2016

utACK - certainly a more reliable metric.

This introduces a 'minimum chain work' chainparam which is intended
 to be the known amount of work in the chain for the network at the
 time of software release.  If you don't have this much work, you're
 not yet caught up.

This is used instead of the count of blocks test from checkpoints.

This criteria is trivial to keep updated as there is no element of
subjectivity, trust, or position dependence to it. It is also a more
reliable metric of sync status than a block count.
GetTotalBlocksEstimate is no longer used and it was the only thing
 the checkpoint tests were testing.

Since checkpoints are on their way out it makes more sense to remove
 the test file than to cook up a new pointless test.
This avoids a corner case (mostly visible on testnet) where bogus
 headers can keep nodes in IsInitialBlockDownload.
@gmaxwell
Copy link
Contributor Author

gmaxwell commented Nov 2, 2016

@MarcoFalke nits addressed, I think.

@@ -96,6 +96,9 @@ class CMainParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = 1479168000; // November 15th, 2016.
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 1510704000; // November 15th, 2017.

// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000002cb971dd56d1c583c20f90");
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is this number from please?

Copy link
Member

Choose a reason for hiding this comment

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

@rebroad It is mentioned in the doc change in this very pull...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can just run the getblockchaininfo rpc per the instructions and observe that its a number equal to or greater than that in order to verify it. :)

@maflcko
Copy link
Member

maflcko commented Nov 2, 2016

re-utACK e141beb

@laanwj
Copy link
Member

laanwj commented Nov 2, 2016

utACK e141beb

@sipa
Copy link
Member

sipa commented Nov 3, 2016

utACK e141beb

@sipa
Copy link
Member

sipa commented Nov 3, 2016

I wonder if this should be backported to 0.13.2, as it fixes a visible issue on testnet.

@sipa sipa merged commit e141beb into bitcoin:master Nov 3, 2016
sipa added a commit that referenced this pull request Nov 3, 2016
…er timestamps

e141beb IsInitialBlockDownload no longer uses header-only timestamps. (Gregory Maxwell)
2082b55 Remove GetTotalBlocksEstimate and checkpoint tests that test nothing. (Gregory Maxwell)
fd46136 IBD check uses minimumchain work instead of checkpoints. (Gregory Maxwell)
@laanwj laanwj added this to the 0.13.2 milestone Nov 3, 2016
@laanwj laanwj removed this from the 0.13.2 milestone Nov 3, 2016
@jtimon
Copy link
Contributor

jtimon commented Nov 3, 2016

utACK e141beb very clean to read commit by commit.

return state;
if (chainActive.Tip()->nChainWork < UintToArith256(chainParams.GetConsensus().nMinimumChainWork))
return true;
if (chainActive.Tip()->GetBlockTime() < (GetTime() - nMaxTipAge))
Copy link
Contributor

Choose a reason for hiding this comment

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

Any particular reason to use GetTime here over GetAdjustedTime?

laanwj added a commit that referenced this pull request Dec 8, 2016
…d not using header timestamp (#9053)

5998a09 IsInitialBlockDownload no longer uses header-only timestamps. (Gregory Maxwell)
5b93eee Remove GetTotalBlocksEstimate and checkpoint tests that test nothing. (Gregory Maxwell)
ad20cdd IBD check uses minimumchain work instead of checkpoints. (Gregory Maxwell)
4c71fc4 Remove duplicate nBlocksEstimate cmp (we already checked IsIBD()) (Matt Corallo)
zkbot added a commit to zcash/zcash that referenced this pull request Jul 16, 2018
InitialBlockDownload upstream changes

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#7208
- bitcoin/bitcoin#8007
- bitcoin/bitcoin#9053
  - Excluding second commit (requires bitcoin/bitcoin#8865)
- bitcoin/bitcoin#10388
zkbot added a commit to zcash/zcash that referenced this pull request Jul 17, 2018
InitialBlockDownload upstream changes

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#7208
- bitcoin/bitcoin#8007
- bitcoin/bitcoin#9053
  - Excluding second commit (requires bitcoin/bitcoin#8865)
- bitcoin/bitcoin#10388
zkbot added a commit to zcash/zcash that referenced this pull request Jul 17, 2018
InitialBlockDownload upstream changes

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#7208
- bitcoin/bitcoin#8007
- bitcoin/bitcoin#9053
  - Excluding second commit (requires bitcoin/bitcoin#8865)
- bitcoin/bitcoin#10388
@scravy scravy mentioned this pull request Nov 13, 2018
92 tasks
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 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.

9 participants