Rename hashLightClientRoot to hashBlockCommitments in block header
This commit is contained in:
parent
52cffbc828
commit
4da2347e96
18
src/chain.h
18
src/chain.h
|
@ -258,7 +258,7 @@ public:
|
|||
//! Root of the Sapling commitment tree as of the end of this block.
|
||||
//!
|
||||
//! - For blocks prior to (not including) the Heartwood activation block, this is
|
||||
//! always equal to hashLightClientRoot.
|
||||
//! always equal to hashBlockCommitments.
|
||||
//! - For blocks including and after the Heartwood activation block, this is only set
|
||||
//! once a block has been connected to the main chain, and will be null otherwise.
|
||||
uint256 hashFinalSaplingRoot;
|
||||
|
@ -268,13 +268,13 @@ public:
|
|||
//! - For blocks prior to and including the Heartwood activation block, this is
|
||||
//! always null.
|
||||
//! - For blocks after (not including) the Heartwood activation block, this is
|
||||
//! always equal to hashLightClientRoot.
|
||||
//! always equal to hashBlockCommitments.
|
||||
uint256 hashChainHistoryRoot;
|
||||
|
||||
//! block header
|
||||
int nVersion;
|
||||
uint256 hashMerkleRoot;
|
||||
uint256 hashLightClientRoot;
|
||||
uint256 hashBlockCommitments;
|
||||
unsigned int nTime;
|
||||
unsigned int nBits;
|
||||
uint256 nNonce;
|
||||
|
@ -307,7 +307,7 @@ public:
|
|||
|
||||
nVersion = 0;
|
||||
hashMerkleRoot = uint256();
|
||||
hashLightClientRoot = uint256();
|
||||
hashBlockCommitments = uint256();
|
||||
nTime = 0;
|
||||
nBits = 0;
|
||||
nNonce = uint256();
|
||||
|
@ -325,7 +325,7 @@ public:
|
|||
|
||||
nVersion = block.nVersion;
|
||||
hashMerkleRoot = block.hashMerkleRoot;
|
||||
hashLightClientRoot = block.hashLightClientRoot;
|
||||
hashBlockCommitments = block.hashBlockCommitments;
|
||||
nTime = block.nTime;
|
||||
nBits = block.nBits;
|
||||
nNonce = block.nNonce;
|
||||
|
@ -357,7 +357,7 @@ public:
|
|||
if (pprev)
|
||||
block.hashPrevBlock = pprev->GetBlockHash();
|
||||
block.hashMerkleRoot = hashMerkleRoot;
|
||||
block.hashLightClientRoot = hashLightClientRoot;
|
||||
block.hashBlockCommitments = hashBlockCommitments;
|
||||
block.nTime = nTime;
|
||||
block.nBits = nBits;
|
||||
block.nNonce = nNonce;
|
||||
|
@ -486,7 +486,7 @@ public:
|
|||
READWRITE(this->nVersion);
|
||||
READWRITE(hashPrev);
|
||||
READWRITE(hashMerkleRoot);
|
||||
READWRITE(hashLightClientRoot);
|
||||
READWRITE(hashBlockCommitments);
|
||||
READWRITE(nTime);
|
||||
READWRITE(nBits);
|
||||
READWRITE(nNonce);
|
||||
|
@ -512,7 +512,7 @@ public:
|
|||
} else if (ser_action.ForRead()) {
|
||||
// For block indices written before the client was Heartwood-aware,
|
||||
// these are always identical.
|
||||
hashFinalSaplingRoot = hashLightClientRoot;
|
||||
hashFinalSaplingRoot = hashBlockCommitments;
|
||||
}
|
||||
|
||||
// If you have just added new serialized fields above, remember to add
|
||||
|
@ -525,7 +525,7 @@ public:
|
|||
block.nVersion = nVersion;
|
||||
block.hashPrevBlock = hashPrev;
|
||||
block.hashMerkleRoot = hashMerkleRoot;
|
||||
block.hashLightClientRoot = hashLightClientRoot;
|
||||
block.hashBlockCommitments = hashBlockCommitments;
|
||||
block.nTime = nTime;
|
||||
block.nBits = nBits;
|
||||
block.nNonce = nNonce;
|
||||
|
|
22
src/main.cpp
22
src/main.cpp
|
@ -3016,15 +3016,15 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||
blockundo.old_sprout_tree_root = old_sprout_tree_root;
|
||||
|
||||
if (IsActivationHeight(pindex->nHeight, chainparams.GetConsensus(), Consensus::UPGRADE_HEARTWOOD)) {
|
||||
// In the block that activates ZIP 221, block.hashLightClientRoot MUST
|
||||
// In the block that activates ZIP 221, block.hashBlockCommitments MUST
|
||||
// be set to all zero bytes.
|
||||
if (!block.hashLightClientRoot.IsNull()) {
|
||||
if (!block.hashBlockCommitments.IsNull()) {
|
||||
return state.DoS(100,
|
||||
error("ConnectBlock(): block's hashLightClientRoot is incorrect (should be null)"),
|
||||
error("ConnectBlock(): block's hashBlockCommitments is incorrect (should be null)"),
|
||||
REJECT_INVALID, "bad-heartwood-root-in-block");
|
||||
}
|
||||
} else if (chainparams.GetConsensus().NetworkUpgradeActive(pindex->nHeight, Consensus::UPGRADE_HEARTWOOD)) {
|
||||
// If Heartwood is active, block.hashLightClientRoot must be the same as
|
||||
// If Heartwood is active, block.hashBlockCommitments must be the same as
|
||||
// the root of the history tree for the previous block. We only store
|
||||
// one tree per epoch, so we have two possible cases:
|
||||
// - If the previous block is in the previous epoch, this block won't
|
||||
|
@ -3032,17 +3032,17 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||
// - If the previous block is in this epoch, this block would affect
|
||||
// this epoch's tree root, but as we haven't updated the tree for this
|
||||
// block yet, view.GetHistoryRoot() returns the root we need.
|
||||
if (block.hashLightClientRoot != view.GetHistoryRoot(prevConsensusBranchId)) {
|
||||
if (block.hashBlockCommitments != view.GetHistoryRoot(prevConsensusBranchId)) {
|
||||
return state.DoS(100,
|
||||
error("ConnectBlock(): block's hashLightClientRoot is incorrect (should be history tree root)"),
|
||||
error("ConnectBlock(): block's hashBlockCommitments is incorrect (should be history tree root)"),
|
||||
REJECT_INVALID, "bad-heartwood-root-in-block");
|
||||
}
|
||||
} else if (chainparams.GetConsensus().NetworkUpgradeActive(pindex->nHeight, Consensus::UPGRADE_SAPLING)) {
|
||||
// If Sapling is active, block.hashLightClientRoot must be the
|
||||
// If Sapling is active, block.hashBlockCommitments must be the
|
||||
// same as the root of the Sapling tree
|
||||
if (block.hashLightClientRoot != sapling_tree.root()) {
|
||||
if (block.hashBlockCommitments != sapling_tree.root()) {
|
||||
return state.DoS(100,
|
||||
error("ConnectBlock(): block's hashLightClientRoot is incorrect (should be Sapling tree root)"),
|
||||
error("ConnectBlock(): block's hashBlockCommitments is incorrect (should be Sapling tree root)"),
|
||||
REJECT_INVALID, "bad-sapling-root-in-block");
|
||||
}
|
||||
}
|
||||
|
@ -3915,10 +3915,10 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block, const Consensus::Params&
|
|||
// hashChainHistoryRoot is null.
|
||||
} else if (consensusParams.NetworkUpgradeActive(pindexNew->nHeight, Consensus::UPGRADE_HEARTWOOD)) {
|
||||
// hashFinalSaplingRoot is currently null, and will be set correctly in ConnectBlock.
|
||||
pindexNew->hashChainHistoryRoot = pindexNew->hashLightClientRoot;
|
||||
pindexNew->hashChainHistoryRoot = pindexNew->hashBlockCommitments;
|
||||
} else {
|
||||
// hashChainHistoryRoot is null.
|
||||
pindexNew->hashFinalSaplingRoot = pindexNew->hashLightClientRoot;
|
||||
pindexNew->hashFinalSaplingRoot = pindexNew->hashBlockCommitments;
|
||||
}
|
||||
|
||||
pindexNew->BuildSkip();
|
||||
|
|
|
@ -622,11 +622,11 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const MinerAddre
|
|||
// Fill in header
|
||||
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
|
||||
if (IsActivationHeight(nHeight, chainparams.GetConsensus(), Consensus::UPGRADE_HEARTWOOD)) {
|
||||
pblock->hashLightClientRoot.SetNull();
|
||||
pblock->hashBlockCommitments.SetNull();
|
||||
} else if (chainparams.GetConsensus().NetworkUpgradeActive(nHeight, Consensus::UPGRADE_HEARTWOOD)) {
|
||||
pblock->hashLightClientRoot = view.GetHistoryRoot(prevConsensusBranchId);
|
||||
pblock->hashBlockCommitments = view.GetHistoryRoot(prevConsensusBranchId);
|
||||
} else {
|
||||
pblock->hashLightClientRoot = sapling_tree.root();
|
||||
pblock->hashBlockCommitments = sapling_tree.root();
|
||||
}
|
||||
UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev);
|
||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, chainparams.GetConsensus());
|
||||
|
|
|
@ -164,12 +164,12 @@ uint256 CBlock::BuildAuthDataMerkleTree() const
|
|||
std::string CBlock::ToString() const
|
||||
{
|
||||
std::stringstream s;
|
||||
s << strprintf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, hashLightClientRoot=%s, nTime=%u, nBits=%08x, nNonce=%s, vtx=%u)\n",
|
||||
s << strprintf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, hashBlockCommitments=%s, nTime=%u, nBits=%08x, nNonce=%s, vtx=%u)\n",
|
||||
GetHash().ToString(),
|
||||
nVersion,
|
||||
hashPrevBlock.ToString(),
|
||||
hashMerkleRoot.ToString(),
|
||||
hashLightClientRoot.ToString(),
|
||||
hashBlockCommitments.ToString(),
|
||||
nTime, nBits, nNonce.ToString(),
|
||||
vtx.size());
|
||||
for (unsigned int i = 0; i < vtx.size(); i++)
|
||||
|
|
|
@ -26,7 +26,7 @@ public:
|
|||
int32_t nVersion;
|
||||
uint256 hashPrevBlock;
|
||||
uint256 hashMerkleRoot;
|
||||
uint256 hashLightClientRoot;
|
||||
uint256 hashBlockCommitments;
|
||||
uint32_t nTime;
|
||||
uint32_t nBits;
|
||||
uint256 nNonce;
|
||||
|
@ -44,7 +44,7 @@ public:
|
|||
READWRITE(this->nVersion);
|
||||
READWRITE(hashPrevBlock);
|
||||
READWRITE(hashMerkleRoot);
|
||||
READWRITE(hashLightClientRoot);
|
||||
READWRITE(hashBlockCommitments);
|
||||
READWRITE(nTime);
|
||||
READWRITE(nBits);
|
||||
READWRITE(nNonce);
|
||||
|
@ -56,7 +56,7 @@ public:
|
|||
nVersion = CBlockHeader::CURRENT_VERSION;
|
||||
hashPrevBlock.SetNull();
|
||||
hashMerkleRoot.SetNull();
|
||||
hashLightClientRoot.SetNull();
|
||||
hashBlockCommitments.SetNull();
|
||||
nTime = 0;
|
||||
nBits = 0;
|
||||
nNonce = uint256();
|
||||
|
@ -118,7 +118,7 @@ public:
|
|||
block.nVersion = nVersion;
|
||||
block.hashPrevBlock = hashPrevBlock;
|
||||
block.hashMerkleRoot = hashMerkleRoot;
|
||||
block.hashLightClientRoot = hashLightClientRoot;
|
||||
block.hashBlockCommitments = hashBlockCommitments;
|
||||
block.nTime = nTime;
|
||||
block.nBits = nBits;
|
||||
block.nNonce = nNonce;
|
||||
|
@ -163,7 +163,7 @@ public:
|
|||
READWRITE(this->nVersion);
|
||||
READWRITE(hashPrevBlock);
|
||||
READWRITE(hashMerkleRoot);
|
||||
READWRITE(hashLightClientRoot);
|
||||
READWRITE(hashBlockCommitments);
|
||||
READWRITE(nTime);
|
||||
READWRITE(nBits);
|
||||
}
|
||||
|
|
|
@ -756,9 +756,9 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
|||
result.pushKV("capabilities", aCaps);
|
||||
result.pushKV("version", pblock->nVersion);
|
||||
result.pushKV("previousblockhash", pblock->hashPrevBlock.GetHex());
|
||||
result.pushKV("lightclientroothash", pblock->hashLightClientRoot.GetHex());
|
||||
result.pushKV("lightclientroothash", pblock->hashBlockCommitments.GetHex());
|
||||
// Deprecated; remove in a future release.
|
||||
result.pushKV("finalsaplingroothash", pblock->hashLightClientRoot.GetHex());
|
||||
result.pushKV("finalsaplingroothash", pblock->hashBlockCommitments.GetHex());
|
||||
result.pushKV("transactions", transactions);
|
||||
if (coinbasetxn) {
|
||||
assert(txCoinbase.isObject());
|
||||
|
|
|
@ -272,8 +272,8 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
|||
}
|
||||
*/
|
||||
|
||||
// These tests assume null hashLightClientRoot (before Sapling)
|
||||
pblock->hashLightClientRoot = uint256();
|
||||
// These tests assume null hashBlockCommitments (before Sapling)
|
||||
pblock->hashBlockCommitments = uint256();
|
||||
|
||||
CValidationState state;
|
||||
BOOST_CHECK(ProcessNewBlock(state, chainparams, NULL, pblock, true, NULL));
|
||||
|
|
14
src/txdb.cpp
14
src/txdb.cpp
|
@ -549,7 +549,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts(
|
|||
pindexNew->hashSproutAnchor = diskindex.hashSproutAnchor;
|
||||
pindexNew->nVersion = diskindex.nVersion;
|
||||
pindexNew->hashMerkleRoot = diskindex.hashMerkleRoot;
|
||||
pindexNew->hashLightClientRoot = diskindex.hashLightClientRoot;
|
||||
pindexNew->hashBlockCommitments = diskindex.hashBlockCommitments;
|
||||
pindexNew->nTime = diskindex.nTime;
|
||||
pindexNew->nBits = diskindex.nBits;
|
||||
pindexNew->nNonce = diskindex.nNonce;
|
||||
|
@ -590,16 +590,16 @@ bool CBlockTreeDB::LoadBlockIndexGuts(
|
|||
//
|
||||
if (diskindex.nClientVersion >= CHAIN_HISTORY_ROOT_VERSION &&
|
||||
chainParams.GetConsensus().NetworkUpgradeActive(pindexNew->nHeight, Consensus::UPGRADE_HEARTWOOD)) {
|
||||
if (pindexNew->hashLightClientRoot != pindexNew->hashChainHistoryRoot) {
|
||||
if (pindexNew->hashBlockCommitments != pindexNew->hashChainHistoryRoot) {
|
||||
return error(
|
||||
"LoadBlockIndex(): block index inconsistency detected (post-Heartwood; hashLightClientRoot %s != hashChainHistoryRoot %s): %s",
|
||||
pindexNew->hashLightClientRoot.ToString(), pindexNew->hashChainHistoryRoot.ToString(), pindexNew->ToString());
|
||||
"LoadBlockIndex(): block index inconsistency detected (post-Heartwood; hashBlockCommitments %s != hashChainHistoryRoot %s): %s",
|
||||
pindexNew->hashBlockCommitments.ToString(), pindexNew->hashChainHistoryRoot.ToString(), pindexNew->ToString());
|
||||
}
|
||||
} else {
|
||||
if (pindexNew->hashLightClientRoot != pindexNew->hashFinalSaplingRoot) {
|
||||
if (pindexNew->hashBlockCommitments != pindexNew->hashFinalSaplingRoot) {
|
||||
return error(
|
||||
"LoadBlockIndex(): block index inconsistency detected (pre-Heartwood; hashLightClientRoot %s != hashFinalSaplingRoot %s): %s",
|
||||
pindexNew->hashLightClientRoot.ToString(), pindexNew->hashFinalSaplingRoot.ToString(), pindexNew->ToString());
|
||||
"LoadBlockIndex(): block index inconsistency detected (pre-Heartwood; hashBlockCommitments %s != hashFinalSaplingRoot %s): %s",
|
||||
pindexNew->hashBlockCommitments.ToString(), pindexNew->hashFinalSaplingRoot.ToString(), pindexNew->ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue