validation: VerifyDB only needs Consensus::Params
Previously we were passing in CChainParams, when VerifyDB only needed the Consensus::Params subset.
This commit is contained in:
1 parent
4da9c076d1
commit
15f2e33bb3
6 files changed
+18
-16
No files matched your search
+2
-2
@@ -1425,7 +1425,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
chainman,
|
chainman,
|
||||||
Assert(node.mempool.get()),
|
Assert(node.mempool.get()),
|
||||||
fPruneMode,
|
fPruneMode,
|
||||||
chainparams,
|
chainparams.GetConsensus(),
|
||||||
fReindexChainState,
|
fReindexChainState,
|
||||||
nBlockTreeDBCache,
|
nBlockTreeDBCache,
|
||||||
nCoinDBCache,
|
nCoinDBCache,
|
||||||
@@ -1486,7 +1486,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
|||||||
rv2 = VerifyLoadedChainstate(chainman,
|
rv2 = VerifyLoadedChainstate(chainman,
|
||||||
fReset,
|
fReset,
|
||||||
fReindexChainState,
|
fReindexChainState,
|
||||||
chainparams,
|
chainparams.GetConsensus(),
|
||||||
check_blocks,
|
check_blocks,
|
||||||
args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL),
|
args.GetIntArg("-checklevel", DEFAULT_CHECKLEVEL),
|
||||||
static_cast<int64_t(*)()>(GetTime));
|
static_cast<int64_t(*)()>(GetTime));
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include <node/chainstate.h>
|
#include <node/chainstate.h>
|
||||||
|
|
||||||
#include <chainparams.h> // for CChainParams
|
#include <consensus/params.h> // for Consensus::Params
|
||||||
#include <node/blockstorage.h> // for CleanupBlockRevFiles, fHavePruned, fReindex
|
#include <node/blockstorage.h> // for CleanupBlockRevFiles, fHavePruned, fReindex
|
||||||
#include <validation.h> // for a lot of things
|
#include <validation.h> // for a lot of things
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
|
|||||||
ChainstateManager& chainman,
|
ChainstateManager& chainman,
|
||||||
CTxMemPool* mempool,
|
CTxMemPool* mempool,
|
||||||
bool fPruneMode,
|
bool fPruneMode,
|
||||||
const CChainParams& chainparams,
|
const Consensus::Params& consensus_params,
|
||||||
bool fReindexChainState,
|
bool fReindexChainState,
|
||||||
int64_t nBlockTreeDBCache,
|
int64_t nBlockTreeDBCache,
|
||||||
int64_t nCoinDBCache,
|
int64_t nCoinDBCache,
|
||||||
@@ -57,7 +57,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!chainman.BlockIndex().empty() &&
|
if (!chainman.BlockIndex().empty() &&
|
||||||
!chainman.m_blockman.LookupBlockIndex(chainparams.GetConsensus().hashGenesisBlock)) {
|
!chainman.m_blockman.LookupBlockIndex(consensus_params.hashGenesisBlock)) {
|
||||||
return ChainstateLoadingError::ERROR_BAD_GENESIS_BLOCK;
|
return ChainstateLoadingError::ERROR_BAD_GENESIS_BLOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +128,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
|
|||||||
std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManager& chainman,
|
std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManager& chainman,
|
||||||
bool fReset,
|
bool fReset,
|
||||||
bool fReindexChainState,
|
bool fReindexChainState,
|
||||||
const CChainParams& chainparams,
|
const Consensus::Params& consensus_params,
|
||||||
unsigned int check_blocks,
|
unsigned int check_blocks,
|
||||||
unsigned int check_level,
|
unsigned int check_level,
|
||||||
std::function<int64_t()> get_unix_time_seconds)
|
std::function<int64_t()> get_unix_time_seconds)
|
||||||
@@ -148,7 +148,7 @@ std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManage
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!CVerifyDB().VerifyDB(
|
if (!CVerifyDB().VerifyDB(
|
||||||
*chainstate, chainparams, chainstate->CoinsDB(),
|
*chainstate, consensus_params, chainstate->CoinsDB(),
|
||||||
check_level,
|
check_level,
|
||||||
check_blocks)) {
|
check_blocks)) {
|
||||||
return ChainstateLoadVerifyError::ERROR_CORRUPTED_BLOCK_DB;
|
return ChainstateLoadVerifyError::ERROR_CORRUPTED_BLOCK_DB;
|
||||||
|
|||||||
@@ -9,8 +9,10 @@
|
|||||||
#include <functional> // for std::function
|
#include <functional> // for std::function
|
||||||
#include <optional> // for std::optional
|
#include <optional> // for std::optional
|
||||||
|
|
||||||
class CChainParams;
|
|
||||||
class ChainstateManager;
|
class ChainstateManager;
|
||||||
|
namespace Consensus {
|
||||||
|
struct Params;
|
||||||
|
}
|
||||||
class CTxMemPool;
|
class CTxMemPool;
|
||||||
|
|
||||||
enum class ChainstateLoadingError {
|
enum class ChainstateLoadingError {
|
||||||
@@ -56,7 +58,7 @@ std::optional<ChainstateLoadingError> LoadChainstate(bool fReset,
|
|||||||
ChainstateManager& chainman,
|
ChainstateManager& chainman,
|
||||||
CTxMemPool* mempool,
|
CTxMemPool* mempool,
|
||||||
bool fPruneMode,
|
bool fPruneMode,
|
||||||
const CChainParams& chainparams,
|
const Consensus::Params& consensus_params,
|
||||||
bool fReindexChainState,
|
bool fReindexChainState,
|
||||||
int64_t nBlockTreeDBCache,
|
int64_t nBlockTreeDBCache,
|
||||||
int64_t nCoinDBCache,
|
int64_t nCoinDBCache,
|
||||||
@@ -73,7 +75,7 @@ enum class ChainstateLoadVerifyError {
|
|||||||
std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManager& chainman,
|
std::optional<ChainstateLoadVerifyError> VerifyLoadedChainstate(ChainstateManager& chainman,
|
||||||
bool fReset,
|
bool fReset,
|
||||||
bool fReindexChainState,
|
bool fReindexChainState,
|
||||||
const CChainParams& chainparams,
|
const Consensus::Params& consensus_params,
|
||||||
unsigned int check_blocks,
|
unsigned int check_blocks,
|
||||||
unsigned int check_level,
|
unsigned int check_level,
|
||||||
std::function<int64_t()> get_unix_time_seconds);
|
std::function<int64_t()> get_unix_time_seconds);
|
||||||
|
|||||||
@@ -1364,7 +1364,7 @@ static RPCHelpMan verifychain()
|
|||||||
|
|
||||||
CChainState& active_chainstate = chainman.ActiveChainstate();
|
CChainState& active_chainstate = chainman.ActiveChainstate();
|
||||||
return CVerifyDB().VerifyDB(
|
return CVerifyDB().VerifyDB(
|
||||||
active_chainstate, Params(), active_chainstate.CoinsTip(), check_level, check_depth);
|
active_chainstate, Params().GetConsensus(), active_chainstate.CoinsTip(), check_level, check_depth);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -3860,7 +3860,7 @@ CVerifyDB::~CVerifyDB()
|
|||||||
|
|
||||||
bool CVerifyDB::VerifyDB(
|
bool CVerifyDB::VerifyDB(
|
||||||
CChainState& chainstate,
|
CChainState& chainstate,
|
||||||
const CChainParams& chainparams,
|
const Consensus::Params& consensus_params,
|
||||||
CCoinsView& coinsview,
|
CCoinsView& coinsview,
|
||||||
int nCheckLevel, int nCheckDepth)
|
int nCheckLevel, int nCheckDepth)
|
||||||
{
|
{
|
||||||
@@ -3902,10 +3902,10 @@ bool CVerifyDB::VerifyDB(
|
|||||||
}
|
}
|
||||||
CBlock block;
|
CBlock block;
|
||||||
// check level 0: read from disk
|
// check level 0: read from disk
|
||||||
if (!ReadBlockFromDisk(block, pindex, chainparams.GetConsensus()))
|
if (!ReadBlockFromDisk(block, pindex, consensus_params))
|
||||||
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||||
// check level 1: verify block validity
|
// check level 1: verify block validity
|
||||||
if (nCheckLevel >= 1 && !CheckBlock(block, state, chainparams.GetConsensus()))
|
if (nCheckLevel >= 1 && !CheckBlock(block, state, consensus_params))
|
||||||
return error("%s: *** found bad block at %d, hash=%s (%s)\n", __func__,
|
return error("%s: *** found bad block at %d, hash=%s (%s)\n", __func__,
|
||||||
pindex->nHeight, pindex->GetBlockHash().ToString(), state.ToString());
|
pindex->nHeight, pindex->GetBlockHash().ToString(), state.ToString());
|
||||||
// check level 2: verify undo validity
|
// check level 2: verify undo validity
|
||||||
@@ -3953,7 +3953,7 @@ bool CVerifyDB::VerifyDB(
|
|||||||
uiInterface.ShowProgress(_("Verifying blocks…").translated, percentageDone, false);
|
uiInterface.ShowProgress(_("Verifying blocks…").translated, percentageDone, false);
|
||||||
pindex = chainstate.m_chain.Next(pindex);
|
pindex = chainstate.m_chain.Next(pindex);
|
||||||
CBlock block;
|
CBlock block;
|
||||||
if (!ReadBlockFromDisk(block, pindex, chainparams.GetConsensus()))
|
if (!ReadBlockFromDisk(block, pindex, consensus_params))
|
||||||
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||||
if (!chainstate.ConnectBlock(block, state, pindex, coins)) {
|
if (!chainstate.ConnectBlock(block, state, pindex, coins)) {
|
||||||
return error("VerifyDB(): *** found unconnectable block at %d, hash=%s (%s)", pindex->nHeight, pindex->GetBlockHash().ToString(), state.ToString());
|
return error("VerifyDB(): *** found unconnectable block at %d, hash=%s (%s)", pindex->nHeight, pindex->GetBlockHash().ToString(), state.ToString());
|
||||||
|
|||||||
+1
-1
@@ -344,7 +344,7 @@ public:
|
|||||||
~CVerifyDB();
|
~CVerifyDB();
|
||||||
bool VerifyDB(
|
bool VerifyDB(
|
||||||
CChainState& chainstate,
|
CChainState& chainstate,
|
||||||
const CChainParams& chainparams,
|
const Consensus::Params& consensus_params,
|
||||||
CCoinsView& coinsview,
|
CCoinsView& coinsview,
|
||||||
int nCheckLevel,
|
int nCheckLevel,
|
||||||
int nCheckDepth) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
int nCheckDepth) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||||
|
|||||||
Reference in new issue
Block a user