Skip to content

Commit

Permalink
v1.3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HellMar committed Oct 22, 2018
1 parent 3487350 commit e72905e
Show file tree
Hide file tree
Showing 24 changed files with 284 additions and 214 deletions.
37 changes: 18 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ XDNA is a brand new digital currency that combines all the positive aspects of s
The project brings tangible benefits not only to the digital world but also to the real one.


More information at [xdna.io](http://www.xdna.io) Visit our ANN thread at [BitcoinTalk](https://bitcointalk.org/index.php?topic=4517612.0), join our group at [Discord] (https://discord.gg/S9adMgS).
More information at [xdna.io](https://xdna.io) Visit our ANN thread at [BitcoinTalk](https://bitcointalk.org/index.php?topic=4517612.0), join our group at [Discord] (https://discord.gg/S9adMgS).

### Coin Specs

Expand All @@ -15,8 +15,7 @@ More information at [xdna.io](http://www.xdna.io) Visit our ANN thread at [Bitco
<tr><td>POW phase duration</td><td>1440000 blocks</td></tr>
<tr><td>PoW block reward</td><td>Dynamic from 4 to 511 XDNA</td></tr>
<tr><td>Instamine protection</td><td>First 720 blocks</td></tr>
<tr><td>Hashing algorithm from start</td><td>Keccak</td></tr>
<tr><td>Hashing algorithm from 15.00 GMT 08 Aug 2018 </td><td>HEX</td></tr>
<tr><td>Hashing algorithm</td><td>HEX</td></tr>
<tr><td>Estimated XDNA supply during POW</td><td>138,000,000</td></tr>
<tr><td>POS starting block</td><td>1440001</td></tr>
<tr><td>POS phase duration</td><td>Unlimited</td></tr>
Expand All @@ -34,21 +33,21 @@ More information at [xdna.io](http://www.xdna.io) Visit our ANN thread at [Bitco
### Block reward

<table>
<tr><th>Level</th><th>Network hashrate (Th/s)</th><th>Block reward</th></tr>
<tr><th>1</th><th>0</th><th>4</th></tr>
<tr><th>2</th><th>2</th><th>5</th></tr>
<tr><th>3</th><th>3</th><th>7</th></tr>
<tr><th>4</th><th>5</th><th>9</th></tr>
<tr><th>5</th><th>8</th><th>11</th></tr>
<tr><th>6</th><th>13</th><th>15</th></tr>
<tr><th>7</th><th>21</th><th>20</th></tr>
<tr><th>8</th><th>34</th><th>27</th></tr>
<tr><th>9</th><th>55</th><th>39</th></tr>
<tr><th>10</th><th>89</th><th>57</th></tr>
<tr><th>11</th><th>144</th><th>85</th></tr>
<tr><th>12</th><th>233</th><th>131</th></tr>
<tr><th>13</th><th>377</th><th>204</th></tr>
<tr><th>14</th><th>610</th><th>321</th></tr>
<tr><th>15</th><th>987</th><th>511</th></tr>
<tr><th>Level</th><th>Network hashrate (Gh/s)</th><th>Block reward</th></tr>
<tr><th>1</th><th>10</th><th>4</th></tr>
<tr><th>2</th><th>20</th><th>5</th></tr>
<tr><th>3</th><th>30</th><th>7</th></tr>
<tr><th>4</th><th>50</th><th>10</th></tr>
<tr><th>5</th><th>80</th><th>14</th></tr>
<tr><th>6</th><th>130</th><th>19</th></tr>
<tr><th>7</th><th>210</th><th>25</th></tr>
<tr><th>8</th><th>340</th><th>32</th></tr>
<tr><th>9</th><th>550</th><th>40</th></tr>
<tr><th>10</th><th>890</th><th>49</th></tr>
<tr><th>11</th><th>1.440</th><th>59</th></tr>
<tr><th>12</th><th>2.330</th><th>70</th></tr>
<tr><th>13</th><th>3.770</th><th>82</th></tr>
<tr><th>14</th><th>6.100</th><th>95</th></tr>
<tr><th>15</th><th>9.870</th><th>109</th></tr>
</table>
![](doc/POW.png)
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 1)
define(_CLIENT_VERSION_MINOR, 2)
define(_CLIENT_VERSION_REVISION, 1)
define(_CLIENT_VERSION_MINOR, 3)
define(_CLIENT_VERSION_REVISION, 0)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2018)
Expand Down
2 changes: 2 additions & 0 deletions doc/build-windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Acquire the source in the usual way:
git clone https://github.com/XDNA-Core/XDNA.git

To build executables for Windows 32-bit:

cd XDNA
PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') # strip out problematic Windows %PATH% imported var
cd depends
Expand All @@ -34,6 +35,7 @@ To build executables for Windows 32-bit:
make

To build executables for Windows 64-bit:

cd XDNA
PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') # strip out problematic Windows %PATH% imported var
cd depends
Expand Down
4 changes: 3 additions & 1 deletion src/chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ using namespace std;

int64_t CChain::GetNetworkHashPS(int lookup, int height)
{
--height;

CBlockIndex *pb = this->Tip();

if (height >= 0 && height < this->Height())
Expand Down Expand Up @@ -112,4 +114,4 @@ uint256 CBlockIndex::GetBlockTrust() const
uint256 bnPoWTrust = ((~uint256(0) >> 20) / (bnTarget + 1));
return bnPoWTrust > 1 ? bnPoWTrust : 1;
}
}
}
2 changes: 1 addition & 1 deletion src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ class CChain
CBlockIndex* Tip(bool fProofOfStake = false) const
{
if (vChain.size() < 1)
return NULL;
return nullptr;

CBlockIndex* pindex = vChain[vChain.size() - 1];

Expand Down
83 changes: 75 additions & 8 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "util.h"
#include "utilstrencodings.h"

#include <mutex>
#include <assert.h>
#include <limits>

Expand Down Expand Up @@ -56,12 +57,13 @@ static Checkpoints::MapCheckpoints mapCheckpoints =
boost::assign::map_list_of(0, uint256("000003b39d72ad4da1eb2ef2d044032dd95750cc25c435ecad2a236dd22b99fe"))
(50, uint256("000000224104db4572f767923cafd543f36b9a4d1eee117c4dc3e1961ca6371b"))
(60200, uint256("00000000000031ba24b923e1966fbe17ae0cdff1efa9d1efc556e2a3cafb5c55"))
(134000, uint256("0000000000c08ddeef3b04f5ead225a8d5f4765756d32407b74da5ca9c708b80"));
(134000, uint256("0000000000c08ddeef3b04f5ead225a8d5f4765756d32407b74da5ca9c708b80"))
(165000, uint256("00000000010f679ac3889908996bed4716f33de4608eb48594fd36b65f03831b"));

static const Checkpoints::CCheckpointData data = {
&mapCheckpoints,
1538143032, // * UNIX timestamp of last checkpoint block
193164, // * total number of transactions between genesis and last checkpoint
1540098739, // * UNIX timestamp of last checkpoint block
234944, // * total number of transactions between genesis and last checkpoint
// (the tx=... number in the SetBestChain debug.log lines)
2000 // * estimated number of transactions per day after checkpoint
};
Expand All @@ -82,18 +84,56 @@ static const Checkpoints::CCheckpointData dataRegtest = {
0,
100};

CAmount CChainParams::SubsidyValue(SubsidySwitchPoints::key_type level, uint32_t nTime) const
const CChainParams::SubsidySwitchPoints& CChainParams::GetSubsidySwitchPoints(uint32_t nTime, int nHeight) const
{
const auto& points = (nTime <= nHEXHashTimestamp) ? subsidySwitchPoints : subsidySwitchPoints_HEXHash;
if(nTime <= nHEXHashTimestamp)
return subsidySwitchPoints;
else if(nTime <= nF2Timestamp)
return subsidySwitchPoints_HEXHash;
else if(nHeight < static_cast<int>(subsidyScheduleStart_F2))
return subsidySwitchPoints_HEXHash;

SubsidySwitchPoints::const_iterator point = points.upper_bound(level);
auto decrease_interval = std::min(subsidyDecreaseCount_F2, (nHeight - subsidyScheduleStart_F2) / subsidyDecreaseInterval_F2);

if(point != subsidySwitchPoints.begin())
return subsidySwitchPointsSchedule_F2.find(decrease_interval)->second;
}

CAmount CChainParams::SubsidyValue(SubsidySwitchPoints::key_type level, uint32_t nTime, int nHeight) const
{
const auto& switch_points = GetSubsidySwitchPoints(nTime, nHeight);

SubsidySwitchPoints::const_iterator point = switch_points.upper_bound(level);

if(point != switch_points.begin())
point = std::prev(point);

return point->second;
}

void CChainParams::initSubsidySwitchPointsSchedule()
{
subsidySwitchPointsSchedule_F2[0u] = subsidySwitchPoints_F2_0;

for(auto i = 1u; i <= subsidyDecreaseCount_F2; ++i)
{
subsidySwitchPointsSchedule_F2[i] = subsidySwitchPointsSchedule_F2[i - 1];

for(auto& sp : subsidySwitchPointsSchedule_F2[i])
{
auto prev_value = sp.second;

sp.second *= 10000u - subsidyDecreaseValue_F2;
sp.second /= 10000u;
sp.second += COIN / 10u - 1u;
sp.second /= COIN / 10u;
sp.second *= COIN / 10u;

if(sp.second == prev_value && sp.second > COIN / 10u)
sp.second -= COIN / 10u;
}
}
}

class CMainParams : public CChainParams
{
public:
Expand Down Expand Up @@ -157,6 +197,32 @@ class CMainParams : public CChainParams
};
assert(subsidySwitchPoints_HEXHash.size());

subsidySwitchPoints_F2_0 = {
{0 , 38 * (COIN/10)},
{20 * 1e9, 47 * (COIN/10)},
{30 * 1e9, 66 * (COIN/10)},
{50 * 1e9, 94 * (COIN/10)},
{80 * 1e9, 131 * (COIN/10)},
{130 * 1e9, 177 * (COIN/10)},
{210 * 1e9, 233 * (COIN/10)},
{340 * 1e9, 298 * (COIN/10)},
{550 * 1e9, 373 * (COIN/10)},
{890 * 1e9, 456 * (COIN/10)},
{1440 * 1e9, 550 * (COIN/10)},
{2330 * 1e9, 652 * (COIN/10)},
{3770 * 1e9, 764 * (COIN/10)},
{6100 * 1e9, 885 * (COIN/10)},
{9870 * 1e9, 1015 * (COIN/10)},
};
assert(subsidySwitchPoints_F2_0.size());

subsidyScheduleStart_F2 = 177000; // block#XXXXXX ~= nF2Timestamp + 1 day
subsidyDecreaseInterval_F2 = 43200; // 43200 bloks ~= 30 days
subsidyDecreaseCount_F2 = 23; // 23
subsidyDecreaseValue_F2 = 694; // 694 = 6,94% * 100

initSubsidySwitchPointsSchedule();

nMaxReorganizationDepth = 100;
nEnforceBlockUpgradeMajority = 750;
nRejectBlockOutdatedMajority = 950;
Expand Down Expand Up @@ -230,7 +296,8 @@ class CMainParams : public CChainParams
strObfuscationPoolDummyAddress = "X87q2gC9j6nNrnzCsg4aY6bHMLsT9nUhEw";
nStartMasternodePayments = 1403728576; //Wed, 25 Jun 2014 20:36:16 GMT

nHEXHashTimestamp = 1533567600; // 6 August 2018 г., 15:00:00 GMT+00:00
nHEXHashTimestamp = 1533567600; // 6 August 2018, 15:00:00 GMT+00:00
nF2Timestamp = 1540728000; // 28 October 2018, 12:00:00 GMT+00:00
}

const Checkpoints::CCheckpointData& Checkpoints() const
Expand Down
18 changes: 13 additions & 5 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CChainParams
int GetDefaultPort() const { return nDefaultPort; }
const uint256& ProofOfWorkLimit() const { return bnProofOfWorkLimit; }
const uint256& StartWork() const { return bnStartWork; }
CAmount SubsidyValue(SubsidySwitchPoints::key_type level, uint32_t nTime) const;
CAmount SubsidyValue(SubsidySwitchPoints::key_type level, uint32_t nTime, int nHeight) const;
/** Used to check majorities for block version upgrade */
int EnforceBlockUpgradeMajority() const { return nEnforceBlockUpgradeMajority; }
int RejectBlockOutdatedMajority() const { return nRejectBlockOutdatedMajority; }
Expand Down Expand Up @@ -112,11 +112,9 @@ class CChainParams
int StartMNPaymentsBlock() const {return nStartMasternodePaymentsBlock; }

uint32_t HEXHashActivationTime() const {return nHEXHashTimestamp;}
uint32_t F2ActivationTime() const {return nF2Timestamp;}

const SubsidySwitchPoints& GetSubsidySwitchPoints(uint32_t nTime) const
{
return (nTime <= nHEXHashTimestamp) ? subsidySwitchPoints : subsidySwitchPoints_HEXHash;
}
const SubsidySwitchPoints& GetSubsidySwitchPoints(uint32_t nTime, int nHeight) const;

protected:
CChainParams() {}
Expand Down Expand Up @@ -167,6 +165,16 @@ class CChainParams

uint32_t nHEXHashTimestamp;
SubsidySwitchPoints subsidySwitchPoints_HEXHash;

uint32_t nF2Timestamp;
SubsidySwitchPoints subsidySwitchPoints_F2_0;
std::map<uint32_t, SubsidySwitchPoints> subsidySwitchPointsSchedule_F2;
uint32_t subsidyScheduleStart_F2;
uint32_t subsidyDecreaseInterval_F2;
uint32_t subsidyDecreaseCount_F2;
uint32_t subsidyDecreaseValue_F2;

void initSubsidySwitchPointsSchedule();
};

/**
Expand Down
4 changes: 2 additions & 2 deletions src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

//! These need to be macros, as clientversion.cpp's and xdna*-res.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 1
#define CLIENT_VERSION_MINOR 2
#define CLIENT_VERSION_REVISION 1
#define CLIENT_VERSION_MINOR 3
#define CLIENT_VERSION_REVISION 0
#define CLIENT_VERSION_BUILD 0

//! Set to true for release, false for prerelease or test build
Expand Down
34 changes: 16 additions & 18 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1619,9 +1619,9 @@ double ConvertBitsToDouble(unsigned int nBits)

CAmount GetBlockValue(int nHeight, uint32_t nTime)
{
if (nHeight == 0) {
if (nHeight == 1) {
return 971712 * COIN;
} else if (nHeight < Params().ANTI_INSTAMINE_TIME()) {
} else if (nHeight <= Params().ANTI_INSTAMINE_TIME()) {
return 1 * COIN;

// POS Year 1
Expand Down Expand Up @@ -1673,25 +1673,23 @@ CAmount GetBlockValue(int nHeight, uint32_t nTime)

int64_t netHashRate = chainActive.GetNetworkHashPS(24, nHeight);

return Params().SubsidyValue(netHashRate, nTime);
return Params().SubsidyValue(netHashRate, nTime, nHeight);
}

int64_t GetMasternodePayment(int nHeight, unsigned mnlevel, int64_t blockValue)
int64_t GetMasternodePayment(int nHeight, uint32_t nTime, unsigned mnlevel, int64_t blockValue)
{
if (nHeight <= Params().StartMNPaymentsBlock())
return 0;

switch(mnlevel)
{
case 1:
return blockValue / 100 * 3;
std::vector<unsigned> coeff;

case 2:
return blockValue / 100 * 9;
if(nTime <= Params().F2ActivationTime())
coeff = { 3, 9, 15 };
else
coeff = { 5, 15, 25 };

case 3:
return blockValue / 100 * 15;
}
if(mnlevel - 1 < coeff.size())
return blockValue / 100 * coeff[mnlevel - 1];

return 0;
}
Expand Down Expand Up @@ -2215,7 +2213,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime1 - nTimeStart), 0.001 * (nTime1 - nTimeStart) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime1 - nTimeStart) / (nInputs - 1), nTimeConnect * 0.000001);

//PoW phase redistributed fees to miner. PoS stage destroys fees.
CAmount nExpectedMint = GetBlockValue(pindex->pprev->nHeight, block.nTime);
CAmount nExpectedMint = GetBlockValue(pindex->pprev->nHeight + 1, block.nTime);
if (block.IsProofOfWork())
nExpectedMint += nFees;

Expand Down Expand Up @@ -3133,7 +3131,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
else {
int nHeight = 0;
CBlockIndex* pindexPrev = chainActive.Tip();
if (pindexPrev == NULL)
if (!pindexPrev)
nHeight = 0;
else
if (pindexPrev->GetBlockHash() == block.hashPrevBlock)
Expand Down Expand Up @@ -3168,7 +3166,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
return state.DoS(100, error("CheckBlock() : coinbase do not have the dev or fund reward (vout)."),
REJECT_INVALID, "bad-cb-reward-missing");

CAmount block_value = GetBlockValue(nHeight - 1, block.nTime);
CAmount block_value = GetBlockValue(nHeight, block.nTime);

if (block.vtx[0].vout[DevIndex].nValue < block_value * Params().GetDevFee() / 100 || block.vtx[0].vout[FoudIndex].nValue < block_value * Params().GetFundFee() / 100)
return state.DoS(100, error("CheckBlock() : coinbase do not have the enough reward for dev or fund."),
Expand Down Expand Up @@ -3607,7 +3605,7 @@ bool ProcessNewBlock(CValidationState& state, CNode* pfrom, CBlock* pblock, CDis
if (!fLiteMode) {
if (masternodeSync.RequestedMasternodeAssets > MASTERNODE_SYNC_LIST) {
obfuScationPool.NewBlock();
masternodePayments.ProcessBlock(GetHeight() + 10);
masternodePayments.ProcessBlock(GetHeight());
}
}

Expand Down Expand Up @@ -5418,7 +5416,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,

int ActiveProtocol()
{
if(Params().HEXHashActivationTime() < GetAdjustedTime())
if(Params().F2ActivationTime() < GetAdjustedTime())
return MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT;

// if (IsSporkActive(SPORK_X_NEW_PROTOCOL_ENFORCEMENT_X))
Expand Down
2 changes: 1 addition & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ bool DisconnectBlocksAndReprocess(int blocks);

// ***TODO***
double ConvertBitsToDouble(unsigned int nBits);
int64_t GetMasternodePayment(int nHeight, unsigned mnlevel, int64_t blockValue);
int64_t GetMasternodePayment(int nHeight, uint32_t nTime, unsigned mnlevel, int64_t blockValue);

bool ActivateBestChain(CValidationState& state, CBlock* pblock = NULL, bool fAlreadyChecked = false);
CAmount GetBlockValue(int nHeight, uint32_t nTime);
Expand Down
Loading

0 comments on commit e72905e

Please sign in to comment.