elements/src/block_proof.h
James Dorfman 1ab6187071 Bug fix: when CheckChallenge(...) is called on a trimmed header, temporarily
untrim it in order to extract the proof.

Without this fix, there would be an exception in this scenario, because a trimmed
header no longer has any proof information attached to it.

This scenario was occuring when a pre-dynafed node with trimmed blocks would receive
a new block header from its peer. The pre-dynafed node would try to validate the header
by comparing its proof to the previous block's proof, and this would cause an exception
if the previous block had pruned.

New headers are not pruned as soon as they're received. Rather, they are pruned whenever the block index
is flushed to disk. So, this behavior was only being observed in functional tests, when a pre-dynafed trimmed
node was restarted.
2024-10-08 04:50:58 +00:00

25 lines
814 B
C++

// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2018 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_BLOCK_PROOF_H
#define BITCOIN_BLOCK_PROOF_H
#include <consensus/params.h>
#include <stdint.h>
class CBlockHeader;
class CBlockIndex;
class CProof;
class CScript;
// Elements signed chain functionality
/** Check on header proof, depending on chain type, PoW or signed **/
bool CheckProof(const CBlockHeader& block, const Consensus::Params&);
bool CheckProofSignedParent(const CBlockHeader& block, const Consensus::Params&);
bool CheckChallenge(const CBlockHeader& block, CBlockIndex& indexLast, const Consensus::Params&);
#endif // BITCOIN_BLOCK_PROOF_H