Why Bitcoin Core uses checkpoints and not the assumevalid block?

Taking a look at chainparams.cpp (Core v28.0), I noticed that there's a list of checkpoints (checkpointData L168) with different blocks hardcoded.

How are the actually used? According to @PieterWuille in question 3114 they are Legacy and going to be removed. But the answer is 8 years old. Checking the code they are still being used (validation.cpp L4174) when checking block headers (if I understood the code correctly).

static bool ContextualCheckBlockHeader(...)
{
    ...
    // Check proof of work
    ...
    // Check against checkpoints
    if (chainman.m_options.checkpoints_enabled) {
        // Don't accept any forks from the main chain prior to last checkpoint.
        // GetLastCheckpoint finds the last checkpoint in MapCheckpoints that's in our
        // BlockIndex().
        const CBlockIndex* pcheckpoint = blockman.GetLastCheckpoint(chainman.GetParams().Checkpoints());
        if (pcheckpoint && nHeight < pcheckpoint->nHeight) {
            LogPrintf("ERROR: %s: forked chain older than last checkpoint (height %d)\n", __func__, nHeight);
            return state.Invalid(BlockValidationResult::BLOCK_CHECKPOINT, "bad-fork-prior-to-checkpoint");
        }
    }

    // Check timestamp against prev
    ...
    return true;
}

Why a list of checkpoints is saved if only the last one is used? Why are they still being used if the last checkpoint is from 2014? Wouldn't it better to use the assumevalid block as a "checkpoint"?



from Recent Questions - Bitcoin Stack Exchange https://ift.tt/taX0JCV
via IFTTT

Popular posts from this blog

Do Kwon’s Detention Prolonged Until 2024 As Montenegro Responds To Extradition Requests

Sam Bankman-Fried Trial Begins Tomorrow: 3 Reasons Ex-SEC Official Foresees Conviction

Future of Bitcoin encryption and security in a QC era