Skip to content

Commit

Permalink
Merged in updates-for-syncing-mainnet (pull request dashpay#41)
Browse files Browse the repository at this point in the history
Updates for syncing mainnet

Approved-by: Cevap
  • Loading branch information
FornaxA authored and Cevap committed Apr 2, 2020
2 parents c2ffcdf + 0b9191c commit a3ad4dc
Show file tree
Hide file tree
Showing 22 changed files with 244 additions and 53 deletions.
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ More information at [ionomy.com](https://www.ionomy.com) Visit our ANN thread at

Coin specifications ||
:------------ | :---:
Algorithm | Quark |
Algorithm | hybrid: X11 (PoW) / SHA-256 (PoS) |
Retargeting Algorithm | DGW |
Difficulty Retargeting | Every Block
Max Coin Supply | 48,035,935.4 ION
Max Coin Supply | Unlimited
Premine | 16,400,000 ION*

_*16,629,951 Ion Premine was burned in block [1](https://chainz.cryptoid.info/ion/block.dws?000000ed2f68cd6c7935831cc1d473da7c6decdb87e8b5dba0afff0b00002690.htm)_
Expand All @@ -68,28 +68,32 @@ _*16,629,951 Ion Premine was burned in block [1](https://chainz.cryptoid.info/io

### PoW Rewards Breakdown

Block Height | Masternodes | Miner | Total |
----------: | ----------: | ----: | ----: |
2-454 | 50% (11.5 ION) | 50% (11.5 ION) | 10,419 ION |
Block Height | Masternodes | Miner | Total | Max coin supply |
----------: | ----------: | ----: | ----: | ----: |
2-454 | 50% (11.5 ION) | 50% (11.5 ION) | 10,419 ION | 16,410,419 ION |

### PoS/PoW Rewards Breakdown

Block Height | Masternodes | Miner | Budget |
----------: | ----------: | ----: | -----: |
455-1000 | 50% (11.5 ION) | 50% (11.5 ION)| 12,558 ION |
Block Height | Masternodes | Miner/Minter | Budget | Max coin supply |
----------: | ----------: | ----: | -----: | ----: |
455-1000 | 50% (11.5 ION) | 50% (11.5 ION)| 12,558 ION | 16,422,977 ION |

### PoS Rewards Breakdown

Block Height | Masternodes | Miner | Budget |
----------: | ----------: | ----: | -----: |
1001-125147 | 50% (11.5 ION) | 50% (11.5 ION) | 2,855,381 ION |
125148-550001 | 50% (8.5 ION) | 50% (8.5 ION) | 7,222,518 ION |
550002-551441 | 50% (0.01 ION) | 50% (0.01 ION) | 28.8 ION |
551442-570063 | 50% (8.5 ION) | 50% (8.5 ION) | 316,574 ION |
570064-1013539 | 50% (5.75 ION) | 50% (5.75 ION) | 5,099,974 ION |
1013540-1457015 | 50% (2.875 ION) | 50% (2.875 ION) | 2,549,987 ION |
1457016-3677391 | 50% (0.925 ION) | 50% (0.925 ION) | 4,107,695.6 ION |
3677392-50981391 | 50% (0.1 ION) | 50% (0.1 ION) | 9,460,800 ION |
Block Height | Masternodes | Minter | Budget | Max coin supply |
----------: | ----------: | ----: | -----: | ----: |
1001-125146 | 50% (11.5 ION) | 50% (11.5 ION) | 2,855,358 ION | 19,278,335 ION |
125147-550001 | 50% (8.5 ION) | 50% (8.5 ION) | 7,222,535 ION | 26,500,870 ION |
550002-551441 | 50% (0.01 ION) | 50% (0.01 ION) | 28.8 ION | 26,500,898.8 ION |
551442-570063 | 50% (8.5 ION) | 50% (8.5 ION) | 316,574 ION | 26,817,472.8 ION |
570064-1013539 | 50% (5.75 ION) | 50% (5.75 ION) | 5,099,974 ION | 31,917,446.8 ION |
1013540-1600000 | 50% (2.875 ION) | 50% (2.875 ION) | 3,372,150.75 ION | 35,289,597.55 ION |

### Hybrid PoS/PoW Rewards Breakdown

Block Height | Masternodes | Miner | Minter | Annual (ION) | Annual (ELEC) |
----------: | ----------: | ----: | -----: | ----: | ----: |
1600000 - | 70% ION (0.35 ION) | 100% ELEC (0.5 ELEC)| 30% ION (0.15 ION)| 262,800 ION | 262,800 ELEC |

## Ion Core FAQ/Help
_get support/chat with us or send your request per [Email](mail:support@ionomy.com). You can also join our discord or encrypted chat on matrix._
Expand Down
2 changes: 1 addition & 1 deletion src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ class CRegTestParams : public CChainParams {
nPoolMinParticipants = 3;
nPoolMaxParticipants = 5;

// privKey: cP4EKFyJsHT39LDqgdcB43Y3YXjNyjb5Fuas1GQSeAtjnZWmZEQK
// privKey: 93QPD8M8SrVb4yL3E679sCGztzy1NRWYH3fs2wJQr2LMKnppFCJ
vSporkAddresses = {"gRgAY9dX7kN3tLNeVPQ8YoVGJdeNiE2Ubr"};
nMinSporkKeys = 1;
// regtest usually has no masternodes in most tests, so don't check for upgraged MNs
Expand Down
11 changes: 6 additions & 5 deletions src/consensus/tx_verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "tx_verify.h"

#include "chainparams.h"
#include "consensus.h"
#include "primitives/transaction.h"
#include "script/interpreter.h"
Expand Down Expand Up @@ -215,7 +216,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, const boo
return true;
}

bool Consensus::CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, CAmount& txfee)
bool Consensus::CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, CAmount& txfee, const Consensus::Params& params)
{
// are the actual inputs available?
if (!inputs.HaveInputs(tx)) {
Expand All @@ -230,22 +231,22 @@ bool Consensus::CheckTxInputs(const CTransaction& tx, CValidationState& state, c
assert(!coin.IsSpent());

// If prev is coinbase, coinstake or group authority confirguration, check that it's matured
if (coin.IsCoinStake() && nSpendHeight - coin.nHeight < (nSpendHeight <= 100 ? (int)10 : Params().nCoinbaseMaturity)) {
if (coin.IsCoinStake() && nSpendHeight - coin.nHeight < (nSpendHeight <= 100 ? (int)10 : params.nCoinbaseMaturity)) {
return state.Invalid(false,
REJECT_INVALID, "bad-txns-premature-spend-of-coinstake",
strprintf("tried to spend coinstake at depth %d", nSpendHeight - coin.nHeight));
}

if (coin.IsCoinBase() && nSpendHeight - coin.nHeight < (nSpendHeight <= 100 ? (int)10 : Params().nCoinbaseMaturity)) {
if (coin.IsCoinBase() && nSpendHeight - coin.nHeight < (nSpendHeight <= 100 ? (int)10 : params.nCoinbaseMaturity)) {
return state.Invalid(false,
REJECT_INVALID, "bad-txns-premature-spend-of-coinbase",
strprintf("tried to spend coinbase at depth %d", nSpendHeight - coin.nHeight));
}

if (IsOutputGroupedAuthority(coin.out)) {
if (nSpendHeight - coin.nHeight < Params().nOpGroupNewRequiredConfirmations) {
if (nSpendHeight - coin.nHeight < params.nOpGroupNewRequiredConfirmations) {
return state.Invalid(
error("CheckInputs() : tried to use a token authority before it reached maturity (%d confirmations)", Params().nOpGroupNewRequiredConfirmations),
error("CheckInputs() : tried to use a token authority before it reached maturity (%d confirmations)", params.nOpGroupNewRequiredConfirmations),
REJECT_INVALID, "bad-txns-premature-use-of-token-authority");
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/consensus/tx_verify.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define BITCOIN_CONSENSUS_TX_VERIFY_H

#include "amount.h"
#include "consensus/params.h"

#include <stdint.h>
#include <vector>
Expand All @@ -27,7 +28,7 @@ namespace Consensus {
* @param[out] txfee Set to the transaction fee if successful.
* Preconditions: tx.IsCoinBase() is false.
*/
bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, CAmount& txfee);
bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, CAmount& txfee, const Consensus::Params& params);
} // namespace Consensus

/** Auxiliary functions for transaction validation (ideally should not be exposed) */
Expand Down
23 changes: 23 additions & 0 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "primitives/transaction.h"
#include "netbase.h"
#include "scheduler.h"
#include "spork.h"
#include "ui_interface.h"
#include "utilstrencodings.h"
#include "validation.h"
Expand Down Expand Up @@ -2967,13 +2968,22 @@ void CConnman::RelayTransaction(const CTransaction& tx)
}
}

void CConnman::RelayInv(CInv &inv) {
RelayInv(inv, GetMinPeerVersion());
}

void CConnman::RelayInv(CInv &inv, const int minProtoVersion) {
LOCK(cs_vNodes);
for (const auto& pnode : vNodes)
if(pnode->nVersion >= minProtoVersion)
pnode->PushInventory(inv);
}

void CConnman::RelayInvFiltered(CInv &inv, const CTransaction& relatedTx)
{
RelayInvFiltered(inv, relatedTx, GetMinPeerVersion());
}

void CConnman::RelayInvFiltered(CInv &inv, const CTransaction& relatedTx, const int minProtoVersion)
{
LOCK(cs_vNodes);
Expand All @@ -2989,6 +2999,11 @@ void CConnman::RelayInvFiltered(CInv &inv, const CTransaction& relatedTx, const
}
}

void CConnman::RelayInvFiltered(CInv &inv, const uint256& relatedTxHash)
{
RelayInvFiltered(inv, relatedTxHash, GetMinPeerVersion());
}

void CConnman::RelayInvFiltered(CInv &inv, const uint256& relatedTxHash, const int minProtoVersion)
{
LOCK(cs_vNodes);
Expand Down Expand Up @@ -3396,3 +3411,11 @@ uint64_t CConnman::CalculateKeyedNetGroup(const CAddress& ad) const

return GetDeterministicRandomizer(RANDOMIZER_ID_NETGROUP).Write(vchNetGroup.data(), vchNetGroup.size()).Finalize();
}

int CConnman::GetMinPeerVersion() {
// SPORK_11 is used for 95705 (v3.3+)
if (sporkManager.IsSporkActive(SPORK_8_NEW_PROTOCOL_ENFORCEMENT))
return MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT;

return MIN_PEER_PROTO_VERSION_BEFORE_ENFORCEMENT;
}
11 changes: 8 additions & 3 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,13 @@ class CConnman
void ReleaseNodeVector(const std::vector<CNode*>& vecNodes);

void RelayTransaction(const CTransaction& tx);
void RelayInv(CInv &inv, const int minProtoVersion = MIN_PEER_PROTO_VERSION);
void RelayInvFiltered(CInv &inv, const CTransaction &relatedTx, const int minProtoVersion = MIN_PEER_PROTO_VERSION);
void RelayInv(CInv &inv, const int minProtoVersion);
void RelayInv(CInv &inv);
void RelayInvFiltered(CInv &inv, const CTransaction &relatedTx, const int minProtoVersion);
void RelayInvFiltered(CInv &inv, const CTransaction &relatedTx);
// This overload will not update node filters, so use it only for the cases when other messages will update related transaction data in filters
void RelayInvFiltered(CInv &inv, const uint256 &relatedTxHash, const int minProtoVersion = MIN_PEER_PROTO_VERSION);
void RelayInvFiltered(CInv &inv, const uint256 &relatedTxHash, const int minProtoVersion);
void RelayInvFiltered(CInv &inv, const uint256 &relatedTxHash);
void RemoveAskFor(const uint256& hash);

// Addrman functions
Expand Down Expand Up @@ -448,6 +451,8 @@ class CConnman
void WakeMessageHandler();
void WakeSelect();

int GetMinPeerVersion();

private:
struct ListenSocket {
SOCKET socket;
Expand Down
4 changes: 2 additions & 2 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1820,12 +1820,12 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
return false;
}

if (nVersion < MIN_PEER_PROTO_VERSION)
if (nVersion < connman->GetMinPeerVersion())
{
// disconnect from peers older than this proto version
LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->GetId(), nVersion);
connman->PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION)));
strprintf("Version must be %d or greater", connman->GetMinPeerVersion())));
pfrom->fDisconnect = true;
return false;
}
Expand Down
3 changes: 2 additions & 1 deletion src/pos/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "wallet/db.h"
#include "kernel.h"
#include "policy/policy.h"
#include "pow.h"
#include "script/interpreter.h"
#include "timedata.h"
#include "util.h"
Expand Down Expand Up @@ -91,7 +92,7 @@ static bool SelectBlockFromCandidates(
// the selection hash is divided by 2**32 so that proof-of-stake block
// is always favored over proof-of-work block. this is to preserve
// the energy efficiency property
if (pindex->IsProofOfStake())
if (IsProofOfStakeHeight(pindex->nHeight, Params().GetConsensus()))
hashSelection = ArithToUint256(UintToArith256(hashSelection) >> 32);

if (fSelected && UintToArith256(hashSelection) < UintToArith256(hashBest)) {
Expand Down
15 changes: 10 additions & 5 deletions src/pow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,12 @@ unsigned int static GetNextWorkRequiredOrig(const CBlockIndex* pindexLast, const
if (pindexLast == NULL)
return UintToArith256(bnTargetLimit).GetCompact(); // genesis block
const CBlockIndex* pindexPrev = pindexLast;
while (pindexPrev && pindexPrev->pprev && (pindexPrev->IsProofOfStake() != fProofOfStake))
while (pindexPrev && pindexPrev->pprev && (IsProofOfStakeHeight(pindexPrev->nHeight, params) != fProofOfStake))
pindexPrev = pindexPrev->pprev;
if (pindexPrev == NULL)
return UintToArith256(bnTargetLimit).GetCompact(); // first block
const CBlockIndex* pindexPrevPrev = pindexPrev->pprev;
while (pindexPrevPrev && pindexPrevPrev->pprev && (pindexPrevPrev->IsProofOfStake() != fProofOfStake))
while (pindexPrevPrev && pindexPrevPrev->pprev && (IsProofOfStakeHeight(pindexPrevPrev->nHeight, params) != fProofOfStake))
pindexPrevPrev = pindexPrevPrev->pprev;
if (pindexPrevPrev == NULL)
return UintToArith256(bnTargetLimit).GetCompact(); // second block
Expand Down Expand Up @@ -452,10 +452,8 @@ unsigned int static GetNextWorkRequiredOrig(const CBlockIndex* pindexLast, const
return bnNew.GetCompact();
}

unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const Consensus::Params& params, const bool fHybridPow)
{
bool IsProofOfStakeHeight(const int nHeight, const Consensus::Params& params) {
bool fProofOfStake;
const int nHeight = pindexLast->nHeight + 1;
if (nHeight >= params.POSStartHeight){
fProofOfStake = true;
} else if (Params().NetworkIDString() == CBaseChainParams::MAIN) {
Expand Down Expand Up @@ -505,6 +503,13 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const Consensus:
} else {
fProofOfStake = false;
}
return fProofOfStake;
}

unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const Consensus::Params& params, const bool fHybridPow)
{
const int nHeight = pindexLast->nHeight + 1;
bool fProofOfStake = IsProofOfStakeHeight(nHeight, params);

// this is only active on devnets
if (pindexLast->nHeight < params.nMinimumDifficultyBlocks) {
Expand Down
2 changes: 2 additions & 0 deletions src/pow.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const Consensus:
/** Check whether a block hash satisfies the proof-of-work requirement specified by nBits */
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params&);

bool IsProofOfStakeHeight(const int nHeight, const Consensus::Params& params);

#endif // BITCOIN_POW_H
2 changes: 1 addition & 1 deletion src/qt/transactiondesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco

if (wtx.IsCoinBase() || wtx.IsCoinStake())
{
int numBlocksToMaturity = Consensus::Params().nCoinbaseMaturity;
int numBlocksToMaturity = Params().GetConsensus().nCoinbaseMaturity;
strHTML += "<br>" + tr("Generated coins must mature %1 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, its state will change to \"not accepted\" and it won't be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.").arg(QString::number(numBlocksToMaturity)) + "<br>";
}

Expand Down
2 changes: 1 addition & 1 deletion src/script/standard.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CScriptID : public uint160
CScriptID(const uint160& in) : uint160(in) {}
};

static const unsigned int MAX_OP_RETURN_RELAY = 83; //!< bytes (+1 for OP_RETURN, +2 for the pushdata opcodes)
static const unsigned int MAX_OP_RETURN_RELAY = 184; //!< bytes (+1 for OP_RETURN, +5 for the OpRetGroupId, +178 for GroupDescData)
extern bool fAcceptDatacarrier;
extern unsigned nMaxDatacarrierBytes;

Expand Down
2 changes: 1 addition & 1 deletion src/spork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ std::vector<CSporkDef> sporkDefs = {
MAKE_SPORK_DEF(SPORK_5_MASTERNODE_BUDGET_ENFORCEMENT, 4070908800), // OFF
MAKE_SPORK_DEF(SPORK_6_MASTERNODE_ENABLE_SUPERBLOCKS, 4070908800), // OFF
MAKE_SPORK_DEF(SPORK_7_MASTERNODE_PAY_UPDATED_NODES, 1521851265), // GMT: Saturday, March 24, 2018 12:27:45 AM (OFF 4070908800)
MAKE_SPORK_DEF(SPORK_8_NEW_PROTOCOL_ENFORCEMENT, 1556668800), // GMT: Wednesday, May 1, 2019 12:00:00 AM (OFF 4070908800)
MAKE_SPORK_DEF(SPORK_8_NEW_PROTOCOL_ENFORCEMENT, 4070908800), // OFF
MAKE_SPORK_DEF(SPORK_9_ZEROCOIN_MAINTENANCE_MODE, 4070908800), // OFF
MAKE_SPORK_DEF(SPORK_10_TOKENGROUP_MAINTENANCE_MODE, 4070908800), // OFF
MAKE_SPORK_DEF(SPORK_11_NEW_PROTOCOL_ENFORCEMENT_2, 4070908800), // OFF
Expand Down
9 changes: 5 additions & 4 deletions src/tokens/rpctokenwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,12 @@ extern UniValue gettokenbalance(const JSONRPCRequest& request)

if (request.fHelp)
throw std::runtime_error(
"gettokenbalance ( \"groupid\" )\n"
"gettokenbalance ( \"groupid\" ) ( \"address\" )\n"
"\nIf groupID is not specified, returns all tokens with a balance (including token authorities).\n"
"If a groupID is specified, returns the balance of the specified token group.\n"
"\nArguments:\n"
"1. \"groupid\" (string, optional) the token group identifier\n"
"1. \"groupid\" (string, optional) the token group identifier to filter\n"
"2. \"address\" (string, optional) the ION address to filter\n"
"\n"
"\nExamples:\n" +
HelpExampleCli("gettokenbalance", "groupid ionrt1zwm0kzlyptdmwy3849fd6z5epesnjkruqlwlv02u7y6ymf75nk4qs6u85re") +
Expand Down Expand Up @@ -712,8 +713,8 @@ extern UniValue sendtoken(const JSONRPCRequest& request)

if (request.fHelp || request.params.size() < 1)
throw std::runtime_error(
"sendtoken \"groupid\" \"address\" amount \n"
"\nSends token to a given address.\n"
"sendtoken \"groupid\" \"address\" amount ( \"address\" amount ) ( .. ) \n"
"\nSends token to a given address. Specify multiple addresses and amounts for multiple recipients.\n"
"\n"
"1. \"groupid\" (string, required) the group identifier\n"
"2. \"address\" (string, required) the destination address\n"
Expand Down
Loading

0 comments on commit a3ad4dc

Please sign in to comment.