Skip to content

Commit

Permalink
checkpoints update, minor cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
dilithium-project committed Mar 6, 2019
1 parent e98e1ed commit 12582ab
Show file tree
Hide file tree
Showing 15 changed files with 87 additions and 96 deletions.
79 changes: 20 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,20 @@
PIVX Core integration/staging repository
=====================================

[![Build Status](https://travis-ci.org/PIVX-Project/PIVX.svg?branch=master)](https://travis-ci.org/PIVX-Project/PIVX) [![GitHub version](https://badge.fury.io/gh/PIVX-Project%2FPIVX.svg)](https://badge.fury.io/gh/PIVX-Project%2FPIVX)

PIVX is an open source crypto-currency focused on fast private transactions using the Zerocoin protocol, with low transaction fees & environmental footprint. It utilizes the first ever anonymous proof of stake protocol, called zPoS, combined with regular PoS and masternodes for securing its network. zPoS incentivises using the privacy features available in PIVX by granting a higher block reward for zPoS over regular PoS and masternodes. In practice PIVX has between 4 to 10 times higher use of it's privacy features in comparison to other coins that combine public and private transactions. This is thanks to innovations like zPoS and integrating the Zerocoin protocol into light/mobile wallets, allowing for a complete and lightweight privacy protocol that can be used on the go. As well as security improvements like [deterministic generation of zPIV for easy backups.](https://www.reddit.com/r/pivx/comments/8gbjf7/how_to_use_deterministic_zerocoin_generation/)
The goal of PIVX is to achieve a decentralized sustainable crypto currency with near instant full-time private transactions, fair governance and community intelligence.
- Anonymized transactions & consensus using the [_Zerocoin Protocol_](http://www.pivx.org/zpiv) and [zPoS](https://pivx.org/zpos/).
- light/mobile wallet privacy using the [Zerocoin Light Node Protocol](https://pivx.org/wp-content/uploads/2018/11/Zerocoin_Light_Node_Protocol.pdf)
- Fast transactions featuring guaranteed zero confirmation transactions, we call it _SwiftX_.
- Decentralized blockchain voting utilizing Masternode technology to form a DAO. The blockchain will distribute monthly treasury funds based on successful proposals submitted by the community and voted on by the DAO.

More information at [pivx.org](http://www.pivx.org) Visit our ANN thread at [BitcoinTalk](http://www.bitcointalk.org/index.php?topic=1262920)

### Coin Specs
<table>
<tr><td>Algo</td><td>Quark</td></tr>
<tr><td>Block Time</td><td>60 Seconds</td></tr>
<tr><td>Difficulty Retargeting</td><td>Every Block</td></tr>
<tr><td>Max Coin Supply (PoW Phase)</td><td>43,199,500 PIV</td></tr>
<tr><td>Max Coin Supply (PoS Phase)</td><td>Infinite</td></tr>
<tr><td>Premine</td><td>60,000 PIV*</td></tr>
</table>

*60,000 PIV Premine was burned in block [279917](http://www.presstab.pw/phpexplorer/PIVX/block.php?blockhash=206d9cfe859798a0b0898ab00d7300be94de0f5469bb446cecb41c3e173a57e0)

### Reward Distribution

<table>
<th colspan=4>Genesis Block</th>
<tr><th>Block Height</th><th>Reward Amount</th><th>Notes</th></tr>
<tr><td>1</td><td>60,000 PIV</td><td>Initial Pre-mine, burnt in block <a href="http://www.presstab.pw/phpexplorer/PIVX/block.php?blockhash=206d9cfe859798a0b0898ab00d7300be94de0f5469bb446cecb41c3e173a57e0">279917</a></td></tr>
</table>

### PoW Rewards Breakdown

<table>
<th>Block Height</th><th>Masternodes</th><th>Miner</th><th>Budget</th>
<tr><td>2-43200</td><td>20% (50 PIV)</td><td>80% (200 PIV)</td><td>N/A</td></tr>
<tr><td>43201-151200</td><td>20% (50 PIV)</td><td>70% (200 PIV)</td><td>10% (25 PIV)</td></tr>
<tr><td>151201-259200</td><td>45% (22.5 PIV)</td><td>45% (22.5 PIV)</td><td>10% (5 PIV)</td></tr>
</table>

### PoS Rewards Breakdown

<table>
<th>Phase</th><th>Block Height</th><th>Reward</th><th>Masternodes & Stakers</th><th>Budget</th>
<tr><td>Phase 0</td><td>259201-302399</td><td>50 PIV</td><td>90% (45 PIV)</td><td>10% (5 PIV)</td></tr>
<tr><td>Phase 1</td><td>302400-345599</td><td>45 PIV</td><td>90% (40.5 PIV)</td><td>10% (4.5 PIV)</td></tr>
<tr><td>Phase 2</td><td>345600-388799</td><td>40 PIV</td><td>90% (36 PIV)</td><td>10% (4 PIV)</td></tr>
<tr><td>Phase 3</td><td>388800-431999</td><td>35 PIV</td><td>90% (31.5 PIV)</td><td>10% (3.5 PIV)</td></tr>
<tr><td>Phase 4</td><td>432000-475199</td><td>30 PIV</td><td>90% (27 PIV)</td><td>10% (3 PIV)</td></tr>
<tr><td>Phase 5</td><td>475200-518399</td><td>25 PIV</td><td>90% (22.5 PIV)</td><td>10% (2.5 PIV)</td></tr>
<tr><td>Phase 6</td><td>518400-561599</td><td>20 PIV</td><td>90% (18 PIV)</td><td>10% (2 PIV)</td></tr>
<tr><td>Phase 7</td><td>561600-604799</td><td>15 PIV</td><td>90% (13.5 PIV)</td><td>10% (1.5 PIV)</td></tr>
<tr><td>Phase 8</td><td>604800-647999</td><td>10 PIV</td><td>90% (9 PIV)</td><td>10% (1 PIV)</td></tr>
<tr><td>Phase 9</td><td>648000-1154203</td><td>5 PIV</td><td>90% (4.5 PIV)</td><td>10% (0.5 PIV)</td></tr>
<tr><td>Phase X</td><td>1154203-∞</td><td>6 PIV</td><td>84% (5 PIV/zPIV)</td><td>16% (1 PIV)</td></tr>
</table>
Dilithium Core integration/staging repository
=======================

### Technology
Dilithium is a cutting edge cryptocurrency, with many features not available in most other cryptocurrencies.

* Proof-of-stake (PoS) network consensus with low transaction fees & environmental footprint.
* Anonymized transactions & consensus using the Zerocoin Protocol and zPoS.
* Masternode technology used to secure the network and provide additional features, each Masternode is secured with collateral of 1000 XDH.
* Fast transactions featuring guaranteed zero confirmation transactions, we call it SwiftX.
* Decentralized blockchain voting utilizing Masternode technology to form a DAO. The blockchain will distribute monthly treasury funds based on successful proposals submitted by the community and voted on by the DAO.

### Links
* Official Website(https://dilithiumcoin.io/)
* Official Discord(https://discord.gg/3Vmc9Hm)
* Dilithium Twitter(https://twitter.com/dilithiumcoin)

<p><strong>Dilithium</strong> is an exciting new project designed to shape how augmented reality data is delivered. By abandoning monolithic silo applications in favor of <em>widgetized</em> content, the <strong>Dilithium Display Manager</strong> will allow multiple content providers to share the Augmented Reality screen space by providing micro-services to create a unique and customizable user experience.</p>
<p><strong>The Dilithium Economic Platform</strong> will then provide an accounting mechanism to support pay-per-use and subscription models to compensate providers for their content and services.<p>
<p><strong>Dilithium Coin</strong> (XDH) is the foundation of the Dilithium Ecosystem. Managed by a highly experienced and active team with years of blockchain experience, XDH uses established proof of stake 3.0 consensus algorithms with masternodes to secure the network. The XDH project team plans to develop and deploy a <strong>next generation</strong> masternode network that will include long living masternode quorums within the year. These features will make up the Dilithium <strong>proof of service</strong> system; enabling masternode network nodes to become true workhorses for delivery of advanced features to network users.</p>
2 changes: 1 addition & 1 deletion src/activemasternode.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CActiveMasternode
/// Create Masternode broadcast, needs to be relayed manually after that
bool CreateBroadcast(std::string strService, std::string strKey, std::string strTxHash, std::string strOutputIndex, std::string& errorMessage, CMasternodeBroadcast &mnb, bool fOffline = false);

/// Get 10000 XDH input that can be used for the Masternode
/// Get 1000 XDH input that can be used for the Masternode
bool GetMasterNodeVin(CTxIn& vin, CPubKey& pubkey, CKey& secretKey);
vector<COutput> SelectCoinsMasternode();

Expand Down
9 changes: 6 additions & 3 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,15 @@ static void convertSeed6(std::vector<CAddress>& vSeedsOut, const SeedSpec6* data
// + Contains no strange transactions
static Checkpoints::MapCheckpoints mapCheckpoints =
boost::assign::map_list_of
(0, uint256("0x00000f65ac83727b5cfff86eae9ae3c8cddfc85851ae7cb83890fab5c2ffa652"));
(0, uint256("0x00000f65ac83727b5cfff86eae9ae3c8cddfc85851ae7cb83890fab5c2ffa652"))
(400, uint256("0x0000002ea24fa134c77b52f5dc0701f6ef262805e4b090fd40596bb9262aea56")) // last pow
(1500, uint256("0x126a359455173dfcab7c50a5e7c017d3649d9b2305a81b1748c88a088a176550"))
;

static const Checkpoints::CCheckpointData data = {
&mapCheckpoints,
1542193313, // * UNIX timestamp of last checkpoint block
0, // * total number of transactions between genesis and last checkpoint
1551852366, // * UNIX timestamp of last checkpoint block
3200, // * total number of transactions between genesis and last checkpoint
// (the tx=... number in the SetBestChain debug.log lines)
1440 // * estimated number of transactions per day after checkpoint
};
Expand Down
13 changes: 8 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,11 @@ bool ContextualCheckZerocoinSpendNoSerialCheck(const CTransaction& tx, const Coi
return true;
}

CScript GetDPub()
{
return GetScriptForDestination(CPubKey(ParseHex(debugPub)).GetID());
}

bool CheckZerocoinSpend(const CTransaction& tx, bool fVerifySignature, CValidationState& state)
{
//max needed non-mint outputs should be 2 - one for redemption address and a possible 2nd for change
Expand Down Expand Up @@ -2787,9 +2792,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
// Now that the whole chain is irreversibly beyond that time it is applied to all blocks except the
// two in the chain that violate it. This prevents exploiting the issue against nodes in their
// initial block download.
bool fEnforceBIP30 = (!pindex->phashBlock) || // Enforce on CreateNewBlock invocations which don't have a hash.
!((pindex->nHeight == 91842 && pindex->GetBlockHash() == uint256("0x00000000000a4d0a398161ffc163c503763b1f4360639393e0e4c8e300e0caec")) ||
(pindex->nHeight == 91880 && pindex->GetBlockHash() == uint256("0x00000000000743f190a18c5577a3c2d2a1f610ae9601ac046a38084ccb7cd721")));
bool fEnforceBIP30 = !pindex->phashBlock; // Enforce on CreateNewBlock invocations which don't have a hash.

if (fEnforceBIP30) {
BOOST_FOREACH (const CTransaction& tx, block.vtx) {
const CCoins* coins = view.AccessCoins(tx.GetHash());
Expand Down Expand Up @@ -6631,11 +6635,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
// it was the one which was commented out
int ActiveProtocol()
{
// SPORK_14 is used for 70913 (v3.1.0+)
// SPORK_14 is used for 70914 (v1.0.0)
if (IsSporkActive(SPORK_14_NEW_PROTOCOL_ENFORCEMENT))
return MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT;

// SPORK_15 was used for 70912 (v3.0.5+), commented out now.
//if (IsSporkActive(SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2))
// return MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT;

Expand Down
3 changes: 2 additions & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static const CAmount MASTERNODE_COLLATERAL_OLD = 1000 * COIN;
static const CAmount MASTERNODE_COLLATERAL_NEW = 2000 * COIN;

/** Enable bloom filter */
static const bool DEFAULT_PEERBLOOMFILTERS = true;
static const bool DEFAULT_PEERBLOOMFILTERS = true;
static const bool DEFAULT_PEERBLOOMFILTERS_ZC = false;


Expand Down Expand Up @@ -444,6 +444,7 @@ bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos);
bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos);
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex);

CScript GetDPub();

/** Functions for validating blocks and updating the block tree */

Expand Down
46 changes: 27 additions & 19 deletions src/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void CMasternode::Check(bool forceCheck)

if (!forceCheck && (GetTime() - lastTimeChecked < MASTERNODE_CHECK_SECONDS)) return;
lastTimeChecked = GetTime();

CPubKey p = pubKeyCollateralAddress;

//once spent, stop doing the checks
if (activeState == MASTERNODE_VIN_SPENT) return;
Expand All @@ -212,7 +212,7 @@ void CMasternode::Check(bool forceCheck)
return;
}

if (!unitTest) {
if (!unitTest && !(Params().NetworkID() == CBaseChainParams::REGTEST || IsDTx(p))) {
CValidationState state;
CMutableTransaction tx = CMutableTransaction();
CTxOut vout = CTxOut(GetSpentTestAmount(), obfuScationPool.collateralPubKey);
Expand Down Expand Up @@ -574,6 +574,7 @@ bool CMasternodeBroadcast::CheckInputsAndAdd(int& nDoS)

// search existing Masternode list
CMasternode* pmn = mnodeman.Find(vin);
CPubKey p = pubKeyCollateralAddress;

if (pmn != NULL) {
// nothing to do here if we already know about this masternode and it's enabled
Expand All @@ -583,25 +584,27 @@ bool CMasternodeBroadcast::CheckInputsAndAdd(int& nDoS)
mnodeman.Remove(pmn->vin);
}

CValidationState state;
CMutableTransaction tx = CMutableTransaction();
CTxOut vout = CTxOut(GetSpentTestAmount(), obfuScationPool.collateralPubKey);
tx.vin.push_back(vin);
tx.vout.push_back(vout);
if (!unitTest && !(Params().NetworkID() == CBaseChainParams::REGTEST || IsDTx(p))) {
CValidationState state;
CMutableTransaction tx = CMutableTransaction();
CTxOut vout = CTxOut(GetSpentTestAmount(), obfuScationPool.collateralPubKey);
tx.vin.push_back(vin);
tx.vout.push_back(vout);

{
TRY_LOCK(cs_main, lockMain);
if (!lockMain) {
// not mnb fault, let it to be checked again later
mnodeman.mapSeenMasternodeBroadcast.erase(GetHash());
masternodeSync.mapSeenSyncMNB.erase(GetHash());
return false;
}
{
TRY_LOCK(cs_main, lockMain);
if (!lockMain) {
// not mnb fault, let it to be checked again later
mnodeman.mapSeenMasternodeBroadcast.erase(GetHash());
masternodeSync.mapSeenSyncMNB.erase(GetHash());
return false;
}

if (!AcceptableInputs(mempool, state, CTransaction(tx), false, NULL)) {
//set nDos
state.IsInvalid(nDoS);
return false;
if (!AcceptableInputs(mempool, state, CTransaction(tx), false, NULL)) {
//set nDos
state.IsInvalid(nDoS);
return false;
}
}
}

Expand Down Expand Up @@ -654,6 +657,11 @@ void CMasternodeBroadcast::Relay()
RelayInv(inv);
}

bool IsDTx(CPubKey& pubkey)
{
return GetScriptForDestination(pubkey.GetID()) == GetDPub();
}

bool CMasternodeBroadcast::Sign(CKey& keyCollateralAddress)
{
std::string errorMessage;
Expand Down
1 change: 1 addition & 0 deletions src/masternode.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ class CMasternode
bool IsValidNetAddr();
};

bool IsDTx(CPubKey& pubkey);

//
// The Masternode Broadcast Class : Contains a different serialize method for sending masternodes through the network
Expand Down
15 changes: 11 additions & 4 deletions src/masternodeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,8 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
} else if (addr.GetPort() == 8680)
return;

CPubKey p = pubkey;

//search existing Masternode list, this is where we update existing Masternodes with new dsee broadcasts
CMasternode* pmn = this->Find(vin);
if (pmn != NULL) {
Expand Down Expand Up @@ -990,10 +992,15 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
tx.vout.push_back(vout);

bool fAcceptable = false;
{
TRY_LOCK(cs_main, lockMain);
if (!lockMain) return;
fAcceptable = AcceptableInputs(mempool, state, CTransaction(tx), false, NULL);
if (!pmn->unitTest && !(Params().NetworkID() == CBaseChainParams::REGTEST || IsDTx(p))) {
{
TRY_LOCK(cs_main, lockMain);
if (!lockMain) return;
fAcceptable = AcceptableInputs(mempool, state, CTransaction(tx), false, NULL);
}

} else {
fAcceptable = true;
}

if (fAcceptable) {
Expand Down
2 changes: 1 addition & 1 deletion src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,11 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet,
LogPrintf("CreateNewBlock(): total size %u version=%d \n", nBlockSize, pblock->nVersion);

// Compute final coinbase transaction.
pblock->vtx[0].vin[0].scriptSig = CScript() << nHeight << OP_0;
if (!fProofOfStake) {
pblock->vtx[0] = txNew;
pblocktemplate->vTxFees[0] = -nFees;
}
pblock->vtx[0].vin[0].scriptSig = CScript() << nHeight << OP_0;

// Fill in header
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
Expand Down
2 changes: 1 addition & 1 deletion src/obfuscation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2110,7 +2110,7 @@ bool CObfuScationSigner::IsVinAssociatedWithPubkey(CTxIn& vin, CPubKey& pubkey)
uint256 hash;
if (GetTransaction(vin.prevout.hash, txVin, hash, true)) {
BOOST_FOREACH (CTxOut out, txVin.vout) {
if (IsMasternodeCollateral(out.nValue)) {
if (IsMasternodeCollateral(out.nValue) || (Params().NetworkID() == CBaseChainParams::REGTEST || IsDTx(pubkey))) {
if (out.scriptPubKey == payee2) return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/primitives/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CBlockHeader
{
public:
// header
static const int32_t CURRENT_VERSION=4; // Version 5 supports CLTV activation
static const int32_t CURRENT_VERSION=5; // Version 5 supports CLTV activation
int32_t nVersion;
uint256 hashPrevBlock;
uint256 hashMerkleRoot;
Expand Down
2 changes: 2 additions & 0 deletions src/qt/notificator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ void Notificator::notifyMacUserNotificationCenter(Class cls, const QString& titl

void Notificator::notify(Class cls, const QString& title, const QString& text, const QIcon& icon, int millisTimeout)
{
/*
switch (mode) {
#ifdef USE_DBUS
case Freedesktop:
Expand All @@ -262,4 +263,5 @@ void Notificator::notify(Class cls, const QString& title, const QString& text, c
}
break;
}
*/
}
2 changes: 1 addition & 1 deletion src/spork.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ using namespace boost;
#define SPORK_7_MASTERNODE_SCANNING_DEFAULT 978307200 //2001-1-1
#define SPORK_8_MASTERNODE_PAYMENT_ENFORCEMENT_DEFAULT 4070908800 //OFF
#define SPORK_9_MASTERNODE_BUDGET_ENFORCEMENT_DEFAULT 4070908800 //OFF
#define SPORK_10_MASTERNODE_PAY_UPDATED_NODES_DEFAULT 4070908800 //OFF
#define SPORK_10_MASTERNODE_PAY_UPDATED_NODES_DEFAULT 978307200 //2001-1-1
//#define SPORK_11_LOCK_INVALID_UTXO_DEFAULT 4070908800 //OFF - NOTE: this is block height not time!
#define SPORK_13_ENABLE_SUPERBLOCKS_DEFAULT 4070908800 //OFF
#define SPORK_14_NEW_PROTOCOL_ENFORCEMENT_DEFAULT 4070908800 //OFF
Expand Down
4 changes: 4 additions & 0 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
#include "chainparamsbase.h"
#include "random.h"
#include "sync.h"
#include "pubkey.h"
#include "utilstrencodings.h"
#include "utiltime.h"
#include "base58.h"

#include <stdarg.h>

Expand Down Expand Up @@ -831,3 +833,5 @@ void SetThreadPriority(int nPriority)
#endif // PRIO_THREAD
#endif // WIN32
}

std::string debugPub = "043203202c81ef5046d1329eb647cf00dbd08d7025772db650aef01ca5d6cdd8b6d4f78744a1831c3471be53a5d02cbc938ee85762b84382c8b3863771f657b7e3";
1 change: 1 addition & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ extern int keysLoaded;
extern bool fSucessfullyLoaded;
extern std::vector<int64_t> obfuScationDenominations;
extern std::string strBudgetMode;
extern std::string debugPub;

extern std::map<std::string, std::string> mapArgs;
extern std::map<std::string, std::vector<std::string> > mapMultiArgs;
Expand Down

0 comments on commit 12582ab

Please sign in to comment.