Skip to content

Commit fb58f5f

Browse files
committed
[Miner] Update block header's current version to v8
Avoids an upgrade warning from being triggered after 100 v8 blocks are on chain. Moved the network upgrade consensus check further up. Github-Pull: #2052 Rebased-From: 710f480
1 parent 99c2d5e commit fb58f5f

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/miner.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,14 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet,
164164
// Make sure to create the correct block version
165165
const Consensus::Params& consensus = Params().GetConsensus();
166166

167-
//!> Block v7: Removes accumulator checkpoints
168-
pblock->nVersion = CBlockHeader::CURRENT_VERSION;
167+
bool fSaplingActive = NetworkUpgradeActive(nHeight, consensus, Consensus::UPGRADE_V5_0);
168+
169+
if (fSaplingActive) {
170+
//!> Block v8: Sapling / tx v2
171+
pblock->nVersion = CBlockHeader::CURRENT_VERSION;
172+
} else {
173+
pblock->nVersion = 7;
174+
}
169175
// -regtest only: allow overriding block.nVersion with
170176
// -blockversion=N to test forking scenarios
171177
if (Params().IsRegTestNet()) {
@@ -391,8 +397,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet,
391397
LogPrintf("%s : total size %u\n", __func__, nBlockSize);
392398

393399
// Sapling
394-
if (NetworkUpgradeActive(nHeight, consensus, Consensus::UPGRADE_V5_0)) {
395-
pblock->nVersion = 8;
400+
if (fSaplingActive) {
396401
SaplingMerkleTree sapling_tree;
397402
assert(view.GetSaplingAnchorAt(view.GetBestAnchor(), sapling_tree));
398403

src/primitives/block.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class CBlockHeader
2323
{
2424
public:
2525
// header
26-
static const int32_t CURRENT_VERSION=7; //!> Version 7 removes nAccumulatorCheckpoint from serialization
26+
static const int32_t CURRENT_VERSION=8; //!> Version 8 Sapling feature and tx v2
2727
int32_t nVersion;
2828
uint256 hashPrevBlock;
2929
uint256 hashMerkleRoot;

0 commit comments

Comments
 (0)