Skip to content

Commit

Permalink
2.0.0.14 (#10)
Browse files Browse the repository at this point in the history
* Founder's mint
  • Loading branch information
maxirmx authored Feb 17, 2022
1 parent e1db7ce commit edcde1c
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 43 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 2)
define(_CLIENT_VERSION_MINOR, 0)
define(_CLIENT_VERSION_REVISION, 0)
define(_CLIENT_VERSION_BUILD, 13)
define(_CLIENT_VERSION_BUILD, 14)

define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2022)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Getting started with experimental CoinGreen GUI

1. Download CoinGreen windows-binaries.zip at https://github.com/coin-green/coingreen/releases/tag/v2.0.0.13
1. Download CoinGreen windows-binaries.zip at https://github.com/coin-green/coingreen/releases/tag/v2.0.0.14
2. Extract files to any appropriate folder
3. Start _coingreen-gui.exe_
4. Upon the first startup the application will ask for CoinGreen data folder. Select something that you consider reasonably safe from accident deletion.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
> [usermod man page](https://linux.die.net/man/8/usermod)
**All further steps shall be executed by coingreen user.**
* Download CoinGreen ubuntu-binaries.zip at https://github.com/coin-green/coingreen/releases/tag/v2.0.0.13
* Download CoinGreen ubuntu-binaries.zip at https://github.com/coin-green/coingreen/releases/tag/v2.0.0.14
* Extract files to _/home/coingreen_, check/set execution permissions (_chmod +x_) to _coingreend_, _coingreen-cli_, _coingree-tx_, _start.sh_, _util/rpcuser.py_
* Execute _util/rpcuser.py coingreen_

Expand Down
39 changes: 32 additions & 7 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,16 @@ static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits
class CMainParams : public CChainParams {
private:
Consensus::Params digishieldConsensus;
Consensus::Params digishield2Consensus;
Consensus::Params auxpowConsensus;
public:
CMainParams() {
strNetworkID = "main";

// CoinGreen
consensus.nNewDifficultyProtocol = 35835;
consensus.nFounderMintHeight = 35900;


// Blocks 0 - 35840 are conventional difficulty calculation
consensus.nMajorityEnforceBlockUpgrade = 1500;
Expand Down Expand Up @@ -130,15 +133,20 @@ class CMainParams : public CChainParams {
digishieldConsensus.nPowTargetTimespan = 10 * 60; // post-digishield: 10 minutes
digishieldConsensus.nCoinbaseMaturity = 30;

digishield2Consensus = digishieldConsensus;
digishield2Consensus.nPowTargetTimespan = 60;
digishield2Consensus.nHeightEffective = 35900;

// Blocks 371337+ are AuxPoW
auxpowConsensus = digishieldConsensus;
auxpowConsensus = digishield2Consensus;
auxpowConsensus.nHeightEffective = 371337;
auxpowConsensus.fAllowLegacyBlocks = false;

// Assemble the binary search tree of consensus parameters
pConsensusRoot = &digishieldConsensus;
digishieldConsensus.pLeft = &consensus;
digishieldConsensus.pRight = &auxpowConsensus;
digishieldConsensus.pRight = &digishield2Consensus;
digishield2Consensus.pRight = &auxpowConsensus;

/**
* The message start string is designed to be unlikely to occur in normal data.
Expand All @@ -157,6 +165,7 @@ class CMainParams : public CChainParams {

consensus.hashGenesisBlock = genesis.GetHash();
digishieldConsensus.hashGenesisBlock = consensus.hashGenesisBlock;
digishield2Consensus.hashGenesisBlock = consensus.hashGenesisBlock;
auxpowConsensus.hashGenesisBlock = consensus.hashGenesisBlock;

assert(genesis.hashMerkleRoot == uint256S("0x8d92c90adacac4d30083b56726716392cb433c2ec61fb5b3920705a0673ddf22"));
Expand Down Expand Up @@ -204,14 +213,16 @@ static CMainParams mainParams;
class CTestNetParams : public CChainParams {
private:
Consensus::Params digishieldConsensus;
Consensus::Params digishield2Consensus;
Consensus::Params auxpowConsensus;
Consensus::Params minDifficultyConsensus;
public:
CTestNetParams() {
strNetworkID = "test";

// CoinGreen
consensus.nNewDifficultyProtocol = 1;
consensus.nNewDifficultyProtocol = 35835;
consensus.nFounderMintHeight = 35900;

// Blocks 0 - 35840 are pre-Digishield
consensus.nHeightEffective = 0;
Expand Down Expand Up @@ -270,8 +281,13 @@ class CTestNetParams : public CChainParams {
digishieldConsensus.fPowAllowMinDifficultyBlocks = false;
digishieldConsensus.nCoinbaseMaturity = 30;

digishield2Consensus = digishieldConsensus;
digishield2Consensus.nPowTargetTimespan = 60;
digishield2Consensus.nHeightEffective = 35900;


// Blocks 157500 - 158099 are Digishield with minimum difficulty on all blocks
minDifficultyConsensus = digishieldConsensus;
minDifficultyConsensus = digishield2Consensus;
minDifficultyConsensus.nHeightEffective = 157500;
minDifficultyConsensus.fPowAllowDigishieldMinDifficultyBlocks = true;
minDifficultyConsensus.fPowAllowMinDifficultyBlocks = true;
Expand All @@ -287,6 +303,7 @@ class CTestNetParams : public CChainParams {
digishieldConsensus.pLeft = &consensus;
digishieldConsensus.pRight = &minDifficultyConsensus;
minDifficultyConsensus.pRight = &auxpowConsensus;
minDifficultyConsensus.pLeft = &digishield2Consensus;

pchMessageStart[0] = 0xfc;
pchMessageStart[1] = 0xc1;
Expand All @@ -299,6 +316,7 @@ class CTestNetParams : public CChainParams {
genesis = CreateGenesisBlock(1391503289, 997879, 0x1e0ffff0, 1, 88 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
digishieldConsensus.hashGenesisBlock = consensus.hashGenesisBlock;
digishield2Consensus.hashGenesisBlock = consensus.hashGenesisBlock;
minDifficultyConsensus.hashGenesisBlock = consensus.hashGenesisBlock;
auxpowConsensus.hashGenesisBlock = consensus.hashGenesisBlock;
assert(consensus.hashGenesisBlock == uint256S("0x7218688365a82efbc6ff539b85a12f11a3d788f08789af3c6af59bdd13420ba7"));
Expand Down Expand Up @@ -345,13 +363,15 @@ static CTestNetParams testNetParams;
class CRegTestParams : public CChainParams {
private:
Consensus::Params digishieldConsensus;
Consensus::Params digishield2Consensus;
Consensus::Params auxpowConsensus;
public:
CRegTestParams() {
strNetworkID = "regtest";

// CoinGreen
consensus.nNewDifficultyProtocol = 35835;
consensus.nFounderMintHeight = 35900;

consensus.nMajorityEnforceBlockUpgrade = 750;
consensus.nMajorityRejectBlockOutdated = 950;
Expand Down Expand Up @@ -397,14 +417,18 @@ class CRegTestParams : public CChainParams {
digishieldConsensus.nPowTargetTimespan = 1; // regtest: also retarget every second in digishield mode, for conformity
digishieldConsensus.fDigishieldDifficultyCalculation = true;

auxpowConsensus = digishieldConsensus;
digishield2Consensus = digishieldConsensus;
digishield2Consensus.nHeightEffective = 11;

auxpowConsensus = digishield2Consensus;
auxpowConsensus.fAllowLegacyBlocks = false;
auxpowConsensus.nHeightEffective = 20;

// Assemble the binary search tree of parameters
digishieldConsensus.pLeft = &consensus;
digishieldConsensus.pRight = &auxpowConsensus;
pConsensusRoot = &digishieldConsensus;
digishieldConsensus.pLeft = &consensus;
digishieldConsensus.pRight = &digishield2Consensus;
digishield2Consensus.pRight = &auxpowConsensus;

pchMessageStart[0] = 0xfa;
pchMessageStart[1] = 0xbf;
Expand All @@ -416,6 +440,7 @@ class CRegTestParams : public CChainParams {
genesis = CreateGenesisBlock(1296688602, 2, 0x207fffff, 1, 88 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
digishieldConsensus.hashGenesisBlock = consensus.hashGenesisBlock;
digishield2Consensus.hashGenesisBlock = consensus.hashGenesisBlock;
auxpowConsensus.hashGenesisBlock = consensus.hashGenesisBlock;
assert(consensus.hashGenesisBlock == uint256S("0xbe48b78dabf56759075d493a95a4c8b4fe56c2438caff6264d19b013037c1118"));
assert(genesis.hashMerkleRoot == uint256S("0x8d92c90adacac4d30083b56726716392cb433c2ec61fb5b3920705a0673ddf22"));
Expand Down
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define CLIENT_VERSION_MAJOR 2
#define CLIENT_VERSION_MINOR 0
#define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_BUILD 13
#define CLIENT_VERSION_BUILD 14

//! Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true
Expand Down
20 changes: 14 additions & 6 deletions src/coingreen.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2015 The Dogecoin Core developers
// Copyright (c) 2021 CoinGreen Core developers
// Copyright (c) 2021-2022 The CoinGreen Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand Down Expand Up @@ -39,7 +39,7 @@ bool AllowDigishieldMinDifficultyForBlock(const CBlockIndex* pindexLast, const C
}

// Digishield
// https://www.reddit.com/r/Digibyte/comments/213t7b/what_is_digishield_how_it_works_to_retarget/
// https://www.reddit.com/r/Digibyte/comments/213t7b/what_is_digishield_how_it_works_to_retarget/
unsigned int CalculateCoinGreenNextWorkRequired(const CBlockIndex* pindexLast, int64_t nFirstBlockTime, const Consensus::Params& params)
{
int nHeight = pindexLast->nHeight + 1;
Expand Down Expand Up @@ -129,12 +129,20 @@ bool CheckAuxPowProofOfWork(const CBlockHeader& block, const Consensus::Params&
return true;
}

CAmount GetCoinGreenBlockSubsidy(int nHeight, const Consensus::Params&, uint256)
CAmount GetCoinGreenBlockSubsidy(uint32_t nHeight, const Consensus::Params& params, uint256)
{
int rewards_pre = REWARD_PER_BLOCK*(nHeight-1) + GENESIS_BLOCK_REWARD;
int rewards_rem = INITIAL_SUPPLY - rewards_pre;
int reward = std::max(0, std::min(rewards_rem, REWARD_PER_BLOCK));
CAmount reward = 0;

if (nHeight == params.nFounderMintHeight) {
reward = FOUNDER_MINT;
}
else {
CAmount rewards_pre = nHeight < params.nFounderMintHeight ? REWARD_PER_BLOCK*(nHeight-1) + GENESIS_BLOCK_REWARD :
REWARD_PER_BLOCK*(nHeight-2) + GENESIS_BLOCK_REWARD + FOUNDER_MINT;
CAmount rewards_rem = INITIAL_SUPPLY - rewards_pre;
reward = rewards_rem < REWARD_PER_BLOCK ? rewards_rem : REWARD_PER_BLOCK;
reward = reward > 0 ? reward : 0;
}
return reward * COIN;
}

Expand Down
13 changes: 7 additions & 6 deletions src/coingreen.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2015 The Dogecoin Core developers
// Copyright (c) 2021 CoinGreen Core developers
// Copyright (c) 2015 The Dogecoin Core developers
// Copyright (c) 2021-2022 The CoinGreen Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand All @@ -12,13 +12,14 @@
// Initial supply - 43,000,000
// Mining reward per block 23

const int INITIAL_SUPPLY = 43000000;
const int REWARD_PER_BLOCK = 23;
const int GENESIS_BLOCK_REWARD = 88;
const CAmount INITIAL_SUPPLY = 43000000;
const CAmount FOUNDER_MINT = 10000000;
const CAmount REWARD_PER_BLOCK = 23;
const CAmount GENESIS_BLOCK_REWARD = 88;


bool AllowDigishieldMinDifficultyForBlock(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params);
CAmount GetCoinGreenBlockSubsidy(int nHeight, const Consensus::Params& consensusParams, uint256 prevHash);
CAmount GetCoinGreenBlockSubsidy(uint32_t nHeight, const Consensus::Params& consensusParams, uint256 prevHash);
unsigned int CalculateCoinGreenNextWorkRequired(const CBlockIndex* pindexLast, int64_t nLastRetargetTime, const Consensus::Params& params);

/**
Expand Down
3 changes: 2 additions & 1 deletion src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ struct Params {
bool fAllowLegacyBlocks;

/** CoinGreen */
int64_t nNewDifficultyProtocol;
uint32_t nNewDifficultyProtocol;
uint32_t nFounderMintHeight;

/** Height-aware consensus parameters */
uint32_t nHeightEffective; // When these parameters come into use
Expand Down
2 changes: 1 addition & 1 deletion src/pow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
// Return the last non-special-min-difficulty-rules-block
const CBlockIndex* pindex = pindexLast;
while (pindex->pprev && pindex->nHeight % params.DifficultyAdjustmentInterval() != 0 && pindex->nBits == nProofOfWorkLimit)
pindex = pindex->pprev;
pindex = pindex->pprev;
return pindex->nBits;
}
}
Expand Down
36 changes: 18 additions & 18 deletions src/test/coingreen_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2015 The Dogecoin Core developers
// Copyright (c) 2021 CoinGreen Core developers
// Copyright (c) 2021-2022 The CoinGreen Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand All @@ -14,31 +14,31 @@ BOOST_FIXTURE_TEST_SUITE(coingreen_tests, TestingSetup)

BOOST_AUTO_TEST_CASE(subsidy_limit_test)
{
int nHeight = 1;
uint32_t nHeight = 1;
const CChainParams& mainParams = Params(CBaseChainParams::MAIN);
CAmount nSubsidy = 0;
CAmount nSum = GENESIS_BLOCK_REWARD;
CAmount subsidy = 0;
CAmount sum = GENESIS_BLOCK_REWARD * COIN;
uint256 prevHash = uint256S("0");

int threshold = (INITIAL_SUPPLY-GENESIS_BLOCK_REWARD)/REWARD_PER_BLOCK;
uint32_t nThreshold = (INITIAL_SUPPLY - GENESIS_BLOCK_REWARD - FOUNDER_MINT)/REWARD_PER_BLOCK + 1;

for (nHeight = 1; nHeight <= threshold; nHeight++) {
nSubsidy = GetCoinGreenBlockSubsidy(nHeight, mainParams.GetConsensus(nHeight), prevHash);
nSum += nSubsidy;
BOOST_CHECK(nSubsidy == REWARD_PER_BLOCK * COIN);
for (nHeight = 1; nHeight <= nThreshold; nHeight++) {
subsidy = GetCoinGreenBlockSubsidy(nHeight, mainParams.GetConsensus(nHeight), prevHash);
sum += subsidy;
BOOST_CHECK(subsidy == ((nHeight == mainParams.GetConsensus(nHeight).nFounderMintHeight ? FOUNDER_MINT : REWARD_PER_BLOCK) * COIN));
}
nSubsidy = GetCoinGreenBlockSubsidy(nHeight, mainParams.GetConsensus(nHeight), prevHash);
BOOST_CHECK(nSubsidy == (INITIAL_SUPPLY - threshold*REWARD_PER_BLOCK - GENESIS_BLOCK_REWARD) * COIN);
nSum += nSubsidy;
subsidy = GetCoinGreenBlockSubsidy(nHeight, mainParams.GetConsensus(nHeight), prevHash);
CAmount expected = (INITIAL_SUPPLY - FOUNDER_MINT - (nThreshold-1)*REWARD_PER_BLOCK - GENESIS_BLOCK_REWARD);
BOOST_CHECK(subsidy == expected * COIN);
sum += subsidy;

nSubsidy = GetCoinGreenBlockSubsidy(nHeight+1, mainParams.GetConsensus(nHeight), prevHash);
BOOST_CHECK(nSubsidy == 0);
subsidy = GetCoinGreenBlockSubsidy(nHeight+1, mainParams.GetConsensus(nHeight), prevHash);
BOOST_CHECK(subsidy == 0);

nSubsidy = GetCoinGreenBlockSubsidy(nHeight+100, mainParams.GetConsensus(nHeight), prevHash);
BOOST_CHECK(nSubsidy == 0);
subsidy = GetCoinGreenBlockSubsidy(nHeight+100, mainParams.GetConsensus(nHeight), prevHash);
BOOST_CHECK(subsidy == 0);


BOOST_CHECK(nSum/COIN == (INITIAL_SUPPLY- GENESIS_BLOCK_REWARD));
BOOST_CHECK(sum/COIN == INITIAL_SUPPLY);

}

Expand Down

0 comments on commit edcde1c

Please sign in to comment.