Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AC_PREREQ([2.69])
define(_CLIENT_VERSION_MAJOR, 3)
define(_CLIENT_VERSION_MINOR, 1)
define(_CLIENT_VERSION_MINOR, 2)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_RC, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
Expand Down
38 changes: 29 additions & 9 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,13 @@ class CMainParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 1056905;

// Supply hardfork
consensus.nSubsidyAddress = "mbc1qsr02lgky5tghhxupl4u48l96h7fdk07muekwru";
consensus.nSubsidyHeight = 2650000;
consensus.nSubsidyAmount = 11000000000 * COIN;

consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000000000054d62a0d6408");
consensus.defaultAssumeValid = uint256S("0xd7b08ed3874a97dbf7bc8ba3b7b55e75704c57e3a2c52737232fbcdc93bed040"); // 1056000
consensus.defaultAssumeValid = uint256S("0x23eef88fbc540be75a7b61188bcf118c29db9d4f5fa663863d0458f74ba675b2"); // 1056000

/**
* The message start string is designed to be unlikely to occur in normal data.
Expand All @@ -143,12 +148,12 @@ class CMainParams : public CChainParams {
// Decrease reward by 30% each 2 years
consensus.rewardEpoch = 525960 * 2;
consensus.rewardEpochRate = 0.3;
consensus.rewardEpochRate_v2 = 0.18;

const char* pszTimestamp = "The WSJ 09/Oct/2019 Nobel Prize in Chemistry Awarded to Developers of Lithium-Ion Batteries";
std::vector<SnapshotProvider> providers = {
{"http://snapshot.microbitcoin.org", "/mainnet.csv"},
{"http://micro.codepillow.io", "/mainnet.csv"},
{"http://sman.pw", "/snapshot/mainnet.csv"}
};

vSnapshot = InitSnapshot("mainnet.csv", providers);
Expand Down Expand Up @@ -190,6 +195,8 @@ class CMainParams : public CChainParams {
{ 800000, uint256S("0x038389a836e6f90e0f379bdc6a0c74d841eb6dbec8b23e2b335a981be3d0a56f")},
{ 900000, uint256S("0xb7381d1d7c281eec55fa985fd28bdb0c3bf5373a936ea37b3d861a7520d128f4")},
{ 1000000, uint256S("0x849d3a7f266d3ba3ebce81c20f467f532832652a86e6495b03ec77985535efc9")},
{ 2000000, uint256S("0xa4ecd2833734ce7bb8fb1af7ae53bc33c4bf986dbc7eb87d8d01d6873fdb7ded")},
{ 2600000, uint256S("0x23eef88fbc540be75a7b61188bcf118c29db9d4f5fa663863d0458f74ba675b2")},
}
};

Expand All @@ -198,10 +205,10 @@ class CMainParams : public CChainParams {
};

chainTxData = ChainTxData{
// Data from rpc: getchaintxstats 4096 d7b08ed3874a97dbf7bc8ba3b7b55e75704c57e3a2c52737232fbcdc93bed040
/* nTime */ 1634486414,
/* nTxCount */ 1381700,
/* dTxRate */ 0.02002703629723786
// Data from rpc: getchaintxstats 4096 23eef88fbc540be75a7b61188bcf118c29db9d4f5fa663863d0458f74ba675b2
/* nTime */ 1727905204,
/* nTxCount */ 3043896,
/* dTxRate */ 0.01708408484745776
};
}
};
Expand Down Expand Up @@ -239,15 +246,21 @@ class CTestNetParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = 1628640000; // August 11th, 2021
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay

// Supply hardfork
consensus.nSubsidyAddress = "";
consensus.nSubsidyHeight = 99999999999;
consensus.nSubsidyAmount = 1000 * COIN;

consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000005180c3bd8290da33a1a");
consensus.defaultAssumeValid = uint256S("0x0000000000004ae2f3896ca8ecd41c460a35bf6184e145d91558cece1c688a76"); // 2010000

consensus.lwmaAveragingWindow = 90;
consensus.baseReward = 5500 * COIN;

// Decrease reward by 30% each 2 years
consensus.rewardEpoch = 525960 * 2;
consensus.rewardEpoch = 525960 * 2;
consensus.rewardEpochRate = 0.3;
consensus.rewardEpochRate_v2 = 0.18;

pchMessageStart[0] = 0x74;
pchMessageStart[1] = 0x6d;
Expand Down Expand Up @@ -395,8 +408,9 @@ class SigNetParams : public CChainParams {
consensus.baseReward = 5500 * COIN;

// Decrease reward by 30% each 2 years
consensus.rewardEpoch = 525960 * 2;
consensus.rewardEpoch = 525960 * 2;
consensus.rewardEpochRate = 0.3;
consensus.rewardEpochRate_v2 = 0.18;

const char* pszTimestamp = "The WSJ 09/Oct/2019 Nobel Prize in Chemistry Awarded to Developers of Lithium-Ion Batteries";
vSnapshot = EmptySnapshot();
Expand Down Expand Up @@ -458,6 +472,11 @@ class CRegTestParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay

// Supply hardfork
consensus.nSubsidyAddress = "rmbc1q0xey88kv87e7c82dj8kuje4tesvster8a562ux";
consensus.nSubsidyHeight = 200;
consensus.nSubsidyAmount = 11000000000 * COIN;

consensus.nMinimumChainWork = uint256{};
consensus.defaultAssumeValid = uint256{};

Expand All @@ -476,8 +495,9 @@ class CRegTestParams : public CChainParams {
consensus.baseReward = 5500 * COIN;

// Decrease reward by 30% each 2 years
consensus.rewardEpoch = 525960 * 2;
consensus.rewardEpoch = 525960 * 2;
consensus.rewardEpochRate = 0.3;
consensus.rewardEpochRate_v2 = 0.18;

const char* pszTimestamp = "Cretaceous Bird-Like Dinosaur Had Adaptations for Swimming and Diving | Sci-News Dec 2, 2022";

Expand Down
6 changes: 6 additions & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,15 @@ struct Params {
uint256 defaultAssumeValid;
int lwmaAveragingWindow;
double rewardEpochRate;
double rewardEpochRate_v2;
CAmount baseReward;
int rewardEpoch;

// Subsidy hardfork
std::string nSubsidyAddress;
int nSubsidyHeight;
CAmount nSubsidyAmount;

/**
* If true, witness commitments contain a payload equal to a MicroBitcoin Script solution
* to the signet challenge. See BIP325.
Expand Down
5 changes: 5 additions & 0 deletions src/pow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ unsigned int Lwma3CalculateNextWorkRequired(const CBlockIndex* pindexLast, const
const arith_uint256 powLimit = UintToArith256(params.powLimit);
if (height < N) { return powLimit.GetCompact(); }

// Subsidy hardfork
// Here we reset the diff in order to guarantee smooth experience
if (height >= params.nSubsidyHeight && height < params.nSubsidyHeight + N)
return powLimit.GetCompact();

arith_uint256 sumTarget, previousDiff, nextTarget;
int64_t thisTimestamp, previousTimestamp;
int64_t t = 0, j = 0, solvetimeSum = 0;
Expand Down
36 changes: 35 additions & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
#include <validationinterface.h>
#include <warnings.h>

#include <key_io.h>
#include <script/standard.h>

#include <numeric>
#include <optional>
#include <string>
Expand Down Expand Up @@ -1193,7 +1196,17 @@ CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMe

CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
{
const long double r = 1 + (std::log(1 - consensusParams.rewardEpochRate) / consensusParams.rewardEpoch);
double rewardEpochRate = consensusParams.rewardEpochRate;

// Subsidy hardfork
if (nHeight == ::Params().GetConsensus().nSubsidyHeight)
return ::Params().GetConsensus().nSubsidyAmount;

// Updated epoch reduction rate post hardfork
if (nHeight > ::Params().GetConsensus().nSubsidyHeight)
rewardEpochRate = consensusParams.rewardEpochRate_v2;

const long double r = 1 + (std::log(1 - rewardEpochRate) / consensusParams.rewardEpoch);
return consensusParams.baseReward * std::pow(r, nHeight);
}

Expand Down Expand Up @@ -3263,6 +3276,27 @@ static bool ContextualCheckBlock(const CBlock& block, BlockValidationState& stat
}
}

// Subsidy hardfork
if (nHeight == ::Params().GetConsensus().nSubsidyHeight) {
// Just in case
if (block.vtx[0]->vout.size() < 1) {
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-subsidy-hardfork-output", "invalid subsidy outoutput");
}

const CTxOut& output = block.vtx[0]->vout[0];

CTxDestination destination = DecodeDestination(::Params().GetConsensus().nSubsidyAddress);
CScript subsidyScript = GetScriptForDestination(destination);

if (output.scriptPubKey != subsidyScript) {
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-subsidy-hardfork-scriptpubkey", "invalid subsidy address");
}

if (output.nValue != ::Params().GetConsensus().nSubsidyAmount) {
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-subsidy-hardfork-amount", "invalid subsidy amount");
}
}

// Validation for witness commitments.
// * We compute the witness hash (which is the hash including witnesses) of all the block's transactions, except the
// coinbase (where 0x0000....0000 is used instead).
Expand Down