Page MenuHomePhabricator

Add checkpoint for a recent block
ClosedPublic

Authored by deadalnix on Aug 6 2017, 00:47.

Details

Summary

As per title.

Test Plan
make check

Diff Detail

Repository
rABC Bitcoin ABC
Branch
checkpoint
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 667
Build 667: arc lint + arc unit

Event Timeline

Does this work with the 0.14 codebase? I thought core changed the checkpoints to only control script checks, and not to override most-chainwork.

I'm approving this because it does no harm regardless and it compiles and runs fine.

As for @dgenr8 's question:

In D429#7319, @dgenr8 wrote:

Does this work with the 0.14 codebase? I thought core changed the checkpoints to only control script checks, and not to override most-chainwork.

Hmm, in my (very brief) reading of the code it looks like the checkpoints are used to basically reject any chain forks before the checkpoint (even if they have more chain work). I could be wrong though as I'm a bit new to the consensus mechanism subtleties.

From validation.cpp:

static bool CheckIndexAgainstCheckpoint(const CBlockIndex *pindexPrev,
                                        CValidationState &state,
                                        const CChainParams &chainparams,
                                        const uint256 &hash) {
    if (*pindexPrev->phashBlock ==
        chainparams.GetConsensus().hashGenesisBlock) {
        return true;
    }

    int nHeight = pindexPrev->nHeight + 1;
    // Don't accept any forks from the main chain prior to last checkpoint
    CBlockIndex *pcheckpoint =
        Checkpoints::GetLastCheckpoint(chainparams.Checkpoints());
    if (pcheckpoint && nHeight < pcheckpoint->nHeight) {
        return state.DoS(
            100,
            error("%s: forked chain older than last checkpoint (height %d)",
                  __func__, nHeight));
    }

    return true;
}

Anyone else want to chime in on this? (Doing so would help me out a bit.. as like I said I'm a bit new to the intricacies of how core reaches consensus...).

This revision is now accepted and ready to land.Aug 6 2017, 06:16

It does work. Since 0.14 they do prefers using assumeValid and no new checkpoints are created, but it still there.

This revision was automatically updated to reflect the committed changes.

That function rejects a header that connects behind the checkpoint, but doesn't stop an existing fork from being extended.