Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Block Changes #56

Merged
merged 4 commits into from
Sep 2, 2020
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
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4

[Makefile]
indent_style = tab
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 3)
define(_CLIENT_VERSION_MINOR, 0)
define(_CLIENT_VERSION_REVISION, 0)
define(_CLIENT_VERSION_REVISION, 2)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2019)
define(_COPYRIGHT_YEAR, 2020)
AC_INIT([Ohmcoin Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[www.ohmcoin.io],[ohmcoin])
AC_CONFIG_SRCDIR([src/main.cpp])
AC_CONFIG_HEADERS([src/config/ohmcoin-config.h])
Expand Down
5 changes: 5 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ BITCOIN_CORE_H = \
compat/sanity.h \
consensus/merkle.h \
consensus/validation.h \
consensus/params.h \
consensus/upgrades.h \
compressor.h \
primitives/block.h \
primitives/deterministicmint.h \
Expand Down Expand Up @@ -219,6 +221,8 @@ libbitcoin_server_a_SOURCES = \
checkpoints.cpp \
httprpc.cpp \
httpserver.cpp \
consensus/params.cpp \
consensus/upgrades.cpp \
init.cpp \
leveldbwrapper.cpp \
main.cpp \
Expand Down Expand Up @@ -364,6 +368,7 @@ libbitcoin_common_a_SOURCES = \
coins.cpp \
compressor.cpp \
consensus/merkle.cpp \
consensus/upgrades.cpp \
primitives/block.cpp \
primitives/deterministicmint.cpp \
primitives/transaction.cpp \
Expand Down
94 changes: 78 additions & 16 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,23 +393,25 @@ class CMainParams : public CChainParams
nDefaultPort = 52020;
bnProofOfWorkLimit = ~uint256(0) >> 20;
nMaxReorganizationDepth = 100;
nEnforceBlockUpgradeMajority = 750;
nRejectBlockOutdatedMajority = 950;
nToCheckBlockUpgradeMajority = 1000;
nEnforceBlockUpgradeMajority = 2250;
nRejectBlockOutdatedMajority = 2850;
nToCheckBlockUpgradeMajority = 3000; // 24 hours (legacy)
nMinerThreads = 0;
nTargetTimespan = 1 * 30; // OHMC: 30 Seconds
nTargetSpacing = 1 * 30; // OHMC: 30 Seconds
nMaturity = 4;
nKarmanodeCountDrift = 20;
nMaxMoneyOut = 30000000 * COIN;
/* Legacy Blocktime */
nTargetTimespanLegacy = 1 * 60 * 40; // OHMC: 40 Minutes
nTargetSpacingLegacy = 1 * 30; // OHMC: 30 Seconds
/* New Blocktime */
nTargetTimespan = 1 * 60 * 60 * 2; // OHMC New: 120 Minutes
nTargetSpacing = 1 * 60 * 4; // OHMC New: 240 Seconds

/** Height or Time Based Activations **/
nLastPOWBlock = 1001;

nModifierUpdateBlock = 615800;

nZerocoinStartHeight = 999999999;

/**
* Build the genesis block. Note that the output of the genesis coinbase cannot
* be spent as it did not originally exist in the database.
Expand Down Expand Up @@ -477,16 +479,31 @@ class CMainParams : public CChainParams
"8441436038339044149526344321901146575444541784240209246165157233507787077498171257724679629263863563732899121548"
"31438167899885040445364023527381951378636564391212010397122822120720357";


nZerocoinStartHeight = 999999999;
nZerocoinLastOldParams = 99999999; // Updated to defer zerocoin v2 for further testing.

nMaxZerocoinSpendsPerTransaction = 7; // Assume about 20kb each
nMinZerocoinMintFee = 1 * CENT; //high fee required for zerocoin mints
nMintRequiredConfirmations = 20; //the maximum amount of confirmations until accumulated in 19
nRequiredAccumulation = 1;
nDefaultSecurityLevel = 100; //full security level for accumulators
nZerocoinHeaderVersion = 6; //Block headers must be this version once zerocoin is active
nZerocoinHeaderVersion = 99; //Block headers must be this version once zerocoin is active
nBudgetFeeConfirmations = 3; // Number of confirmations for the finalization fee

// Network upgrades
consensus.vUpgrades[Consensus::BASE_NETWORK].nActivationHeight =
Consensus::NetworkUpgrade::ALWAYS_ACTIVE;
consensus.vUpgrades[Consensus::UPGRADE_TESTDUMMY].nActivationHeight =
Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;
consensus.vUpgrades[Consensus::UPGRADE_V3_0_BLOCKTIME].nActivationHeight = 2977924;
consensus.vUpgrades[Consensus::UPGRADE_V3_0_BLOCKTIME].nProtocolVersion = 71020;
consensus.vUpgrades[Consensus::UPGRADE_V3_0_BLOCKREWARD].nActivationHeight = 2977924;
consensus.vUpgrades[Consensus::UPGRADE_V3_0_BLOCKREWARD].nProtocolVersion = 71020;
consensus.vUpgrades[Consensus::UPGRADE_V3_1_DUMMY].nActivationHeight =
Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;
consensus.vUpgrades[Consensus::UPGRADE_V3_2_DUMMY].nActivationHeight =
Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;

}

const Checkpoints::CCheckpointData& Checkpoints() const
Expand Down Expand Up @@ -516,20 +533,25 @@ class CTestNetParams : public CMainParams
nRejectBlockOutdatedMajority = 75;
nToCheckBlockUpgradeMajority = 100;
nMinerThreads = 0;
nTargetTimespan = 1 * 60; // Ohmcoin: 1 day
nTargetSpacing = 1 * 10; // Ohmcoin: 1 minute
/* Legacy Blocktime */
nTargetTimespanLegacy = 1 * 60 * 40; // OHMC: 40 Minutes
nTargetSpacingLegacy = 1 * 22; // OHMC: 22 Seconds
/* New Blocktime */
nTargetTimespan = 1 * 60 * 60 * 1; // OHMC New: 60 Minutes
nTargetSpacing = 1 * 60 * 2; // OHMC New: 120 Seconds

nMaturity = 15;
nKarmanodeCountDrift = 4;
nModifierUpdateBlock = 51197; //approx Mon, 17 Apr 2017 04:00:00 GMT
nMaxMoneyOut = 43199500 * COIN;
nLastPOWBlock = 200;
nZerocoinStartHeight = 200;
nZerocoinStartHeight = 999999999;

nZerocoinLastOldParams = 50000;

//! Modify the testnet genesis block so the timestamp is valid for a later start.
genesis.nTime = 1454124731;
genesis.nNonce = 2402015;
genesis.nTime = 1597378077;
genesis.nNonce = 8142020;

hashGenesisBlock = genesis.GetHash();
//assert(hashGenesisBlock == uint256("0xfab709a0c107fe7cf6b0d552c514ef3228f9e0f107cd3c9b2fcea96512342cd8"));
Expand Down Expand Up @@ -563,6 +585,18 @@ class CTestNetParams : public CMainParams
strObfuscationPoolDummyAddress = "y57cqfGRkekRyDRNeJiLtYVEbvhXrNbmox";
nBudgetFeeConfirmations = 3; // Number of confirmations for the finalization fee. We have to make this very short
// here because we only have a 8 block finalization window on testnet

// Network upgrades
consensus.vUpgrades[Consensus::BASE_NETWORK].nActivationHeight =
Consensus::NetworkUpgrade::ALWAYS_ACTIVE;
consensus.vUpgrades[Consensus::UPGRADE_TESTDUMMY].nActivationHeight =
Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;
consensus.vUpgrades[Consensus::UPGRADE_V3_0_BLOCKTIME].nActivationHeight = 33001;
consensus.vUpgrades[Consensus::UPGRADE_V3_0_BLOCKREWARD].nActivationHeight = 33002;
consensus.vUpgrades[Consensus::UPGRADE_V3_1_DUMMY].nActivationHeight =
Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;
consensus.vUpgrades[Consensus::UPGRADE_V3_2_DUMMY].nActivationHeight =
Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;
}
const Checkpoints::CCheckpointData& Checkpoints() const
{
Expand Down Expand Up @@ -590,8 +624,12 @@ class CRegTestParams : public CTestNetParams
nRejectBlockOutdatedMajority = 950;
nToCheckBlockUpgradeMajority = 1000;
nMinerThreads = 1;
nTargetTimespan = 24 * 60 * 60; // Ohmcoin: 1 day
nTargetSpacing = 1 * 60; // Ohmcoin: 1 minutes
/* Legacy Blocktime */
nTargetTimespanLegacy = 1 * 60 * 60 * 24; // OHMC: 24 Hours
nTargetSpacingLegacy = 1 * 30; // OHMC: 22 Seconds
/* New Blocktime */
nTargetTimespan = 1 * 60 * 60 * 2; // OHMC New: 120 Minutes
nTargetSpacing = 1 * 60 * 4; // OHMC New: 240 Seconds
bnProofOfWorkLimit = ~uint256(0) >> 1;
genesis.nTime = 1454124731;
genesis.nBits = 0x207fffff;
Expand Down Expand Up @@ -623,11 +661,30 @@ class CRegTestParams : public CTestNetParams
// "PublicKey": "04866dc02c998b7e1ab16fe14e0d86554595da90c36acb706a4d763b58ed0edb1f82c87e3ced065c5b299b26e12496956b9e5f9f19aa008b5c46229b15477c875a"
// }
strSporkKey = "04866dc02c998b7e1ab16fe14e0d86554595da90c36acb706a4d763b58ed0edb1f82c87e3ced065c5b299b26e12496956b9e5f9f19aa008b5c46229b15477c875a";

// Network upgrades
consensus.vUpgrades[Consensus::BASE_NETWORK].nActivationHeight =
Consensus::NetworkUpgrade::ALWAYS_ACTIVE;
consensus.vUpgrades[Consensus::UPGRADE_TESTDUMMY].nActivationHeight =
Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;
consensus.vUpgrades[Consensus::UPGRADE_V3_0_BLOCKTIME].nActivationHeight = 33002;
consensus.vUpgrades[Consensus::UPGRADE_V3_0_BLOCKREWARD].nActivationHeight = 33002;
consensus.vUpgrades[Consensus::UPGRADE_V3_1_DUMMY].nActivationHeight =
Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;
consensus.vUpgrades[Consensus::UPGRADE_V3_2_DUMMY].nActivationHeight =
Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT;
}

const Checkpoints::CCheckpointData& Checkpoints() const
{
return dataRegtest;
}

void UpdateNetworkUpgradeParameters(Consensus::UpgradeIndex idx, int nActivationHeight)
{
assert(idx > Consensus::BASE_NETWORK && idx < Consensus::MAX_NETWORK_UPGRADES);
consensus.vUpgrades[idx].nActivationHeight = nActivationHeight;
}
};
static CRegTestParams regTestParams;

Expand Down Expand Up @@ -715,3 +772,8 @@ bool SelectParamsFromCommandLine()
SelectParams(network);
return true;
}

void UpdateNetworkUpgradeParameters(Consensus::UpgradeIndex idx, int nActivationHeight)
{
regTestParams.UpdateNetworkUpgradeParameters(idx, nActivationHeight);
}
17 changes: 17 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "chainparamsbase.h"
#include "checkpoints.h"
#include "primitives/block.h"
#include "consensus/params.h"
#include "protocol.h"
#include "uint256.h"

Expand Down Expand Up @@ -46,6 +47,7 @@ class CChainParams
};

const uint256& HashGenesisBlock() const { return hashGenesisBlock; }
const Consensus::Params& GetConsensus() const { return consensus; }
const MessageStartChars& MessageStart() const { return pchMessageStart; }
const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; }
int GetDefaultPort() const { return nDefaultPort; }
Expand All @@ -71,11 +73,18 @@ class CChainParams
bool SkipProofOfWorkCheck() const { return fSkipProofOfWorkCheck; }
/** Make standard checks */
bool RequireStandard() const { return fRequireStandard; }
/** Legacy blocktime setting */
int64_t TargetTimespanLegacy() const { return nTargetTimespanLegacy; }
int64_t TargetSpacingLegacy() const { return nTargetSpacingLegacy; }
int64_t IntervalLegacy() const { return nTargetTimespanLegacy / nTargetSpacingLegacy; }
/** New blocktime setting */
int64_t TargetTimespan() const { return nTargetTimespan; }
int64_t TargetSpacing() const { return nTargetSpacing; }
int64_t Interval() const { return nTargetTimespan / nTargetSpacing; }
/** Majurity Checks */
int COINBASE_MATURITY() const { return nMaturity; }
unsigned int StakeMaturity() const { return nStakeMaturity; }
/** Max Money Checks */
CAmount MaxMoneyOut() const { return nMaxMoneyOut; }
/** The karmanode count that we will allow the see-saw reward payments to be off by */
int KarmanodeCountDrift() const { return nKarmanodeCountDrift; }
Expand Down Expand Up @@ -129,6 +138,8 @@ class CChainParams
int nToCheckBlockUpgradeMajority;
int64_t nTargetTimespan;
int64_t nTargetSpacing;
int64_t nTargetTimespanLegacy;
int64_t nTargetSpacingLegacy;
int nLastPOWBlock;
int nKarmanodeCountDrift;
int nMaturity;
Expand All @@ -142,6 +153,7 @@ class CChainParams
CBaseChainParams::Network networkID;
std::string strNetworkID;
CBlock genesis;
Consensus::Params consensus;
std::vector<CAddress> vFixedSeeds;
bool fMiningRequiresPeers;
bool fAllowMinDifficultyBlocks;
Expand Down Expand Up @@ -207,4 +219,9 @@ void SelectParams(CBaseChainParams::Network network);
*/
bool SelectParamsFromCommandLine();

/**
* Allows modifying the network upgrade regtest parameters.
*/
void UpdateNetworkUpgradeParameters(Consensus::UpgradeIndex idx, int nActivationHeight);

#endif // BITCOIN_CHAINPARAMS_H
26 changes: 26 additions & 0 deletions src/consensus/params.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) 2019 The Zcash developers
// Copyright (c) 2020 The PIVX developers
// Copyright (c) 2020 The OHMC developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or https://www.opensource.org/licenses/mit-license.php .

#include "consensus/params.h"
#include "consensus/upgrades.h"
#include "util.h"

namespace Consensus {

bool Params::NetworkUpgradeActive(int nHeight, Consensus::UpgradeIndex idx) const
{
if (idx >= Consensus::MAX_NETWORK_UPGRADES)
return error("%s: Upgrade index out of bounds: %d >= %d",
__func__, idx, Consensus::MAX_NETWORK_UPGRADES);

if (nHeight < 0)
return error("%s: Requested state for upgrade %s at negative height %d",
__func__, NetworkUpgradeInfo[idx].strName, nHeight);

return NetworkUpgradeState(nHeight, *this, idx) == UPGRADE_ACTIVE;
}

} // End consensus namespace
Loading