Reduce checkpoints' effect on consensus.

Instead of only checking height to decide whether to disable script checks,
actually check whether a block is an ancestor of a checkpoint, up to which
headers have been validated. This means that we don't have to prevent
accepting a side branch anymore - it will be safe, just less fast to
do.

We still need to prevent being fed a multitude of low-difficulty headers
filling up our memory. The mechanism for that is unchanged for now: once
a checkpoint is reached with headers, no headers chain branching off before
that point are allowed anymore.
This commit is contained in:
Pieter Wuille
2015-03-19 05:34:06 -07:00
parent 23254131a3
commit dce8360e44
6 changed files with 15 additions and 38 deletions

View File

@@ -21,21 +21,7 @@ BOOST_FIXTURE_TEST_SUITE(Checkpoints_tests, BasicTestingSetup)
BOOST_AUTO_TEST_CASE(sanity)
{
const Checkpoints::CCheckpointData& checkpoints = Params(CBaseChainParams::MAIN).Checkpoints();
uint256 p11111 = uint256S("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d");
uint256 p134444 = uint256S("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe");
BOOST_CHECK(Checkpoints::CheckBlock(checkpoints, 11111, p11111));
BOOST_CHECK(Checkpoints::CheckBlock(checkpoints, 134444, p134444));
// Wrong hashes at checkpoints should fail:
BOOST_CHECK(!Checkpoints::CheckBlock(checkpoints, 11111, p134444));
BOOST_CHECK(!Checkpoints::CheckBlock(checkpoints, 134444, p11111));
// ... but any hash not at a checkpoint should succeed:
BOOST_CHECK(Checkpoints::CheckBlock(checkpoints, 11111+1, p134444));
BOOST_CHECK(Checkpoints::CheckBlock(checkpoints, 134444+1, p11111));
BOOST_CHECK(Checkpoints::GetTotalBlocksEstimate(checkpoints) >= 134444);
}
}
BOOST_AUTO_TEST_SUITE_END()