Skip to content

Conversation

theuni
Copy link
Member

@theuni theuni commented Apr 24, 2015

See individual commit messages for more info.

This moves checkpoints directly into chainparams, then disconnects the checkpoints from Params. In addition, Checkpoints::fEnabled is moved into main as fCheckpointsEnabled because it's up to the app layer to control that behavior.

All that remains is to parametrize the checkpoints usage of mapBlockIndex, which requires some code shuffling first.

@theuni
Copy link
Member Author

theuni commented Apr 24, 2015

@jtimon you'll probably be interested in this

if (fImporting || fReindex || chainActive.Height() < Checkpoints::GetTotalBlocksEstimate())
if (fImporting || fReindex)
return true;
if (fCheckpointsEnabled && chainActive.Height() < Checkpoints::GetTotalBlocksEstimate(Params().Checkpoints()))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you declare a chainparams var at the beginning of the function?
That will make simpler to turn it into a parameter later

@jtimon
Copy link
Contributor

jtimon commented Apr 24, 2015

I like it. utACK apart from the nits.
This will conflict with #5975, mainly in ContextualCheckBlockHeader. Maybe it makes sense to rebase on top of that?

@jgarzik
Copy link
Contributor

jgarzik commented Apr 24, 2015

ACK (it-works test, did not perform a negative test)

@theuni theuni force-pushed the checkpoints-refactor branch 2 times, most recently from ce0ea10 to 6a1389d Compare April 24, 2015 15:57
@theuni
Copy link
Member Author

theuni commented Apr 24, 2015

@jtimon updated to address most of your nits.

Checkpoints::GetLastCheckpoint() has not been updated to use the BlockMap param, because that requires some code shuffling first. BlockMap can't be forward-declared, so we'd have to include main.h from checkpoints.h. I think it may make sense instead to just move GetLastCheckpoint() into main.

As for rebasing on top of #5975, I really think that kind of PR shuffling only slows things down. This should be a quick rebase for either one of us depending on which gets merged first, but this way neither one is holding up the other.

@@ -19,21 +20,22 @@ BOOST_FIXTURE_TEST_SUITE(Checkpoints_tests, BasicTestingSetup)

BOOST_AUTO_TEST_CASE(sanity)
{
const Checkpoints::CCheckpointData& checkpoints = Params().Checkpoints();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you replace with the following?

const Checkpoints::CCheckpointData& checkpoints = Params(CBaseChainParams::MAIN).Checkpoints();

@jtimon
Copy link
Contributor

jtimon commented Apr 25, 2015

Well, #5975 exists to accelerate a libconsensus move-only, moving the checkpoint stuff to consensus to later take it out again seems less clear. But fair enough on "neither one is holding up the other".

utACK apart from that last little nit.

@theuni theuni force-pushed the checkpoints-refactor branch from 6a1389d to 2407135 Compare April 29, 2015 00:03
@theuni
Copy link
Member Author

theuni commented Apr 29, 2015

@jtimon's nit addressed.

@sipa
Copy link
Member

sipa commented Apr 30, 2015

utACK

@@ -68,7 +68,7 @@ class CChainParams
const std::vector<CDNSSeedData>& DNSSeeds() const { return vSeeds; }
const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
const std::vector<CAddress>& FixedSeeds() const { return vFixedSeeds; }
virtual const Checkpoints::CCheckpointData& Checkpoints() const = 0;
Copy link
Member

Choose a reason for hiding this comment

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

How did a virtual sneak into here?! In any case, kudos for getting rid of it.

Copy link
Member

Choose a reason for hiding this comment

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

It had to be. Mainnet and testnet had different implementations for this method.

The result after this PR is obviously better, though.

@laanwj
Copy link
Member

laanwj commented Apr 30, 2015

utACK

@sipa
Copy link
Member

sipa commented Apr 30, 2015

Needs rebase.

theuni added 4 commits April 30, 2015 23:14
This drops the virtual call and simplifies the logic
Pass checkpoint data in as necessary
This pertains to app-state, so it doesn't make sense to handle inside the
checkpoint functions.
@theuni theuni force-pushed the checkpoints-refactor branch from 2407135 to a8cdaf5 Compare May 1, 2015 03:17
@theuni
Copy link
Member Author

theuni commented May 1, 2015

rebased after 739d615

@sipa
Copy link
Member

sipa commented May 1, 2015

reutACK

@laanwj laanwj merged commit a8cdaf5 into bitcoin:master May 6, 2015
laanwj added a commit that referenced this pull request May 6, 2015
a8cdaf5 checkpoints: move the checkpoints enable boolean into main (Cory Fields)
11982d3 checkpoints: Decouple checkpoints from Params (Cory Fields)
6996823 checkpoints: make checkpoints a member of CChainParams (Cory Fields)
9f13a10 checkpoints: store mapCheckpoints in CCheckpointData rather than a pointer (Cory Fields)
@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.

6 participants