Skip to content

Commit

Permalink
Merge pull request #44 from CloakProject/cloak.reboot
Browse files Browse the repository at this point in the history
Regtest setup, mining/staking code, coin/cent definitions, etc
  • Loading branch information
CloakProjectDev committed Oct 25, 2019
2 parents 9d8757b + 5f7a164 commit 39749cc
Show file tree
Hide file tree
Showing 53 changed files with 740 additions and 120 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,7 @@ contrib/devtools/split-debug.sh
*.user
build_msvc/go1.bat
build_msvc/go2.bat
build_msvc/bitcoin.sln.DotSettings.user
build_msvc/bitcoin.sln.DotSettings.user
build_msvc/bitcoin.sln.DotSettings.user
*.user
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": "x64-Debug"
}
6 changes: 6 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}
Binary file added .vs/codename-phoenix/v15/.suo
Binary file not shown.
Binary file added .vs/codename-phoenix/v15/Browse.VC.db
Binary file not shown.
Binary file added .vs/slnx.sqlite
Binary file not shown.
7 changes: 5 additions & 2 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"/usr/include/x86_64-linux-gnu",
"/usr/include",
"${workspaceRoot}"
]
]
},
{
"name": "Mac",
Expand All @@ -30,7 +30,10 @@
"/usr/local/include",
"/usr/include",
"${workspaceRoot}"
]
],
"includePath": [
"C:\\_cloak\\codename-phoenix\\src"
]
}
],
"version": 4
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Cloak Core integration/staging tree

[![Build Status](https://travis-ci.org/bitcoin/bitcoin.svg?branch=master)](https://travis-ci.org/bitcoin/bitcoin)

https://bitcoincore.org
https://www.cloakcoin.com

What is Cloak?
----------------
Expand All @@ -27,6 +27,8 @@ information or see https://opensource.org/licenses/MIT.
Development Process
-------------------

**Important**: Configure with [--disable-tests] and [--disable-bench] for now, while the codebase upgrade is in its early stages. Tests will be updated in due course and this requirement will cease.

The `master` branch is regularly built and tested, but is not guaranteed to be
completely stable. [Tags](https://github.com/bitcoin/bitcoin/tags) are created
regularly to indicate new official, stable release versions of Cloak Core.
Expand Down
Empty file.
Empty file.
Empty file.
10 changes: 4 additions & 6 deletions build_msvc/bitcoin.sln
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ Global
{2B384FA8-9EE1-4544-93CB-0D733C25E8CE}.Release|x86.ActiveCfg = Release|Win32
{2B384FA8-9EE1-4544-93CB-0D733C25E8CE}.Release|x86.Build.0 = Release|Win32
{E78473E9-B850-456C-9120-276301E04C06}.Debug|x64.ActiveCfg = Debug|x64
{E78473E9-B850-456C-9120-276301E04C06}.Debug|x64.Build.0 = Debug|x64
{E78473E9-B850-456C-9120-276301E04C06}.Debug|x86.ActiveCfg = Debug|x64
{E78473E9-B850-456C-9120-276301E04C06}.Debug|x86.Build.0 = Debug|x64
{E78473E9-B850-456C-9120-276301E04C06}.Release|x64.ActiveCfg = Release|x64
Expand Down Expand Up @@ -125,7 +124,6 @@ Global
{792D487F-F14C-49FC-A9DE-3FC150F31C3F}.Release|x86.ActiveCfg = Release|Win32
{792D487F-F14C-49FC-A9DE-3FC150F31C3F}.Release|x86.Build.0 = Release|Win32
{A56B73DB-D46D-4882-8374-1FE3FFA08F07}.Debug|x64.ActiveCfg = Debug|x64
{A56B73DB-D46D-4882-8374-1FE3FFA08F07}.Debug|x64.Build.0 = Debug|x64
{A56B73DB-D46D-4882-8374-1FE3FFA08F07}.Debug|x86.ActiveCfg = Debug|x64
{A56B73DB-D46D-4882-8374-1FE3FFA08F07}.Debug|x86.Build.0 = Debug|x64
{A56B73DB-D46D-4882-8374-1FE3FFA08F07}.Release|x64.ActiveCfg = Release|x64
Expand Down Expand Up @@ -185,10 +183,10 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F43BEA52-E17B-49C0-9404-6865A40EDD9F}
SolutionGuid = {4ABD1207-9A90-4EC9-A8EB-203638A2605D}
SolutionGuid = {2FB733C9-24CB-4BA5-A26B-F43DAD7996B7}
SolutionGuid = {D0CAE2D0-8DB1-4A0B-80EE-800AA6C64323}
SolutionGuid = {DA7D16A6-E5F0-45B3-B194-C3FE64F1BFCD}
SolutionGuid = {D0CAE2D0-8DB1-4A0B-80EE-800AA6C64323}
SolutionGuid = {2FB733C9-24CB-4BA5-A26B-F43DAD7996B7}
SolutionGuid = {4ABD1207-9A90-4EC9-A8EB-203638A2605D}
SolutionGuid = {F43BEA52-E17B-49C0-9404-6865A40EDD9F}
EndGlobalSection
EndGlobal
1 change: 1 addition & 0 deletions build_msvc/bitcoin.sln.DotSettings.user
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Int64 x:Key="/Default/CodeStyle/Naming/CSharpAutoNaming/AutoNamingCompletedVersion/@EntryValue">2</s:Int64>
<s:Boolean x:Key="/Default/CodeStyle/Naming/CSharpAutoNaming/IsNamingAutoDetectionCompleted/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/Naming/CSharpAutoNaming/IsNotificationDisabled/@EntryValue">True</s:Boolean></wpf:ResourceDictionary>
Empty file.
Empty file.
4 changes: 2 additions & 2 deletions src/amount.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
/** Amount in satoshis (Can be negative) */
typedef int64_t CAmount;

static const CAmount COIN = 1000000;
static const CAmount CENT = 10000;
static const CAmount COIN = 100000000;
static const CAmount CENT = 1000000;

/** No amount larger than this (in satoshi) is valid.
*
Expand Down
61 changes: 41 additions & 20 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ class CMainParams : public CChainParams {
consensus.nStakeMinAge = 60 * 60 * 1 * 1; // 1h, minimum age for coin age: 6h
consensus.nStakeMaxAge = 60 * 60 * 8 * 1; // 8h, stake age of full weight: 4d 60*60*24*1
consensus.nStakeTargetSpacing = 60; // 60 sec block spacing
consensus.nStakeModierInterval = MODIFIER_INTERVAL;
consensus.nStakeModifierInterval = MODIFIER_INTERVAL;
consensus.nCoinbaseMaturity = 40;

// Proof of work
consensus.nProofOfWorkLimit = ~arith_uint256("0") >> 20;
Expand Down Expand Up @@ -233,11 +234,12 @@ class CMainParams : public CChainParams {

/* disable fallback fee on mainnet */
m_fallback_fee_enabled = false;
fMiningRequiresPeers = true;
}
};

/**
* Testnet (v3)
* Testnet (v4)
*/
class CTestNetParams : public CChainParams {
public:
Expand All @@ -260,7 +262,8 @@ class CTestNetParams : public CChainParams {
consensus.nStakeMinAge = 2 * 60; // test net min age is 2 min
consensus.nStakeMaxAge = 6 * 60; // test net min age is 6 min
consensus.nStakeTargetSpacing = 60; // 60 sec block spacing
consensus.nStakeModierInterval = 60;
consensus.nStakeModifierInterval = 60;
consensus.nCoinbaseMaturity = 10; // test maturity is 10 blocks

// Proof of work
consensus.nProofOfWorkLimit = ~arith_uint256("0") >> 2;
Expand All @@ -285,11 +288,14 @@ class CTestNetParams : public CChainParams {
// By default assume that the signatures in ancestors of this block are valid.
consensus.defaultAssumeValid = uint256S("0x0000000000000000000000000000000000000000000000000000000000000000"); //1354312

pchMessageStart[0] = 0x28;
pchMessageStart[1] = 0x10;
pchMessageStart[2] = 0x76;
pchMessageStart[3] = 0x2B;
nDefaultPort = 29664;
unsigned int testnetNumber = 4; // hardcoded to testnet4 for now
unsigned char testNum = testnetNumber + 2;

pchMessageStart[0] = 0x22 + testNum;
pchMessageStart[1] = 0x0a + testNum;
pchMessageStart[2] = 0x70 + testNum;
pchMessageStart[3] = 0x25 + testNum;
nDefaultPort = 29665;
nPruneAfterHeight = 1000;

genesis = CreateGenesisBlock(1414697233, 1363324, 541065215, 1, 0);
Expand Down Expand Up @@ -336,6 +342,7 @@ class CTestNetParams : public CChainParams {

/* enable fallback fee on testnet */
m_fallback_fee_enabled = true;
fMiningRequiresPeers = true;
}
};

Expand All @@ -352,28 +359,42 @@ class CRegTestParams : public CChainParams {
consensus.BIP34Hash = uint256();
consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in rpc activation tests)
consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in rpc activation tests)
consensus.nProofOfWorkLimit = UintToArith256(uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
consensus.nPowTargetSpacing = 10 * 60;
consensus.fPowAllowMinDifficultyBlocks = true;
consensus.fPowNoRetargeting = true;
consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains
consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 2016)
consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 2016)
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;

// Proof of stake
consensus.nProofOfStakeLimit = ~arith_uint256("0") >> 2;
consensus.nStakeMinAge = 2 * 60; // regtest min age is 2 min
consensus.nStakeMaxAge = 6 * 60; // regtest max age is 6 min
consensus.nStakeTargetSpacing = 60; // 60 sec block spacing
consensus.nStakeModifierInterval = 60;
consensus.nCoinbaseMaturity = 10; // regtest maturity is 10 blocks

// Proof of work
consensus.nProofOfWorkLimit = UintToArith256(uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
consensus.nPowTargetTimespan = 60 * 30; // 30 blocks
consensus.nPowTargetSpacing = 3 * consensus.nStakeTargetSpacing;
consensus.fPowAllowMinDifficultyBlocks = true;
consensus.fPowNoRetargeting = true;

// Deployment of BIP68, BIP112, and BIP113.
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;

// Deployment of SegWit (BIP141, BIP143, and BIP147)
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;

// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x00");
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000000000000000000");

// By default assume that the signatures in ancestors of this block are valid.
consensus.defaultAssumeValid = uint256S("0x00");
consensus.defaultAssumeValid = uint256S("0x0000000000000000000000000000000000000000000000000000000000000000"); //1354312

pchMessageStart[0] = 0xfa;
pchMessageStart[1] = 0xbf;
Expand All @@ -384,9 +405,8 @@ class CRegTestParams : public CChainParams {

genesis = CreateGenesisBlock(1296688602, 2, 0x207fffff, 1, 50 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("0x0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"));
assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));

assert(consensus.hashGenesisBlock == uint256S("0x2e4b4c8f25132141584245e7513fe4b9ea6b771ae4c654a1ab5186ebf1a789b2"));
assert(genesis.hashMerkleRoot == uint256S("0x1831d9f590f8b705ed996fcaa37ece517cfa6eb619af6738b2606383eab5a619"));
vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.
vSeeds.clear(); //!< Regtest mode doesn't have any DNS seeds.

Expand All @@ -396,7 +416,7 @@ class CRegTestParams : public CChainParams {

checkpointData = {
{
{0, uint256S("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")},
{0, uint256S("2e4b4c8f25132141584245e7513fe4b9ea6b771ae4c654a1ab5186ebf1a789b2")},
}
};

Expand All @@ -416,6 +436,7 @@ class CRegTestParams : public CChainParams {

/* enable fallback fee on regtest */
m_fallback_fee_enabled = true;
fMiningRequiresPeers = false;
}
};

Expand Down
3 changes: 3 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class CChainParams
int GetDefaultPort() const { return nDefaultPort; }

const CBlock& GenesisBlock() const { return genesis; }
/** Make miner wait to have peers to avoid wasting work */
bool MiningRequiresPeers() const { return fMiningRequiresPeers; }
/** Default value for -checkmempool and -checkblockindex argument */
bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
/** Policy: Filter transactions that do not match well-defined patterns */
Expand Down Expand Up @@ -105,6 +107,7 @@ class CChainParams
std::string strNetworkID;
CBlock genesis;
std::vector<SeedSpec6> vFixedSeeds;
bool fMiningRequiresPeers;
bool fDefaultConsistencyChecks;
bool fRequireStandard;
bool fMineBlocksOnDemand;
Expand Down
4 changes: 2 additions & 2 deletions src/chainparamsbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ const CBaseChainParams& BaseParams()
std::unique_ptr<CBaseChainParams> CreateBaseChainParams(const std::string& chain)
{
if (chain == CBaseChainParams::MAIN)
return MakeUnique<CBaseChainParams>("", 8332);
return MakeUnique<CBaseChainParams>("", 29661);
else if (chain == CBaseChainParams::TESTNET)
return MakeUnique<CBaseChainParams>("testnet4", 18332);
return MakeUnique<CBaseChainParams>("testnet4", 29664);
else if (chain == CBaseChainParams::REGTEST)
return MakeUnique<CBaseChainParams>("regtest", 18443);
else
Expand Down
2 changes: 1 addition & 1 deletion src/consensus/consensus.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <stdlib.h>

/** The maximum allowed size for a serialized block, in bytes (only for buffer size limits) */
static const unsigned int MAX_BLOCK_SERIALIZED_SIZE = 4000000;
static const unsigned int MAX_BLOCK_SERIALIZED_SIZE = 1000000;
/** The maximum allowed weight for a block, see BIP 141 (network rule) */
static const unsigned int MAX_BLOCK_WEIGHT = 4000000;
/** The maximum allowed number of signature check operations in a block (network rule) */
Expand Down
3 changes: 2 additions & 1 deletion src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ struct Params {
unsigned int nStakeMinAge;
unsigned int nStakeMaxAge;
unsigned int nStakeTargetSpacing;
unsigned int nStakeModierInterval;
unsigned int nStakeModifierInterval;
unsigned int nCoinbaseMaturity;
};
} // namespace Consensus

Expand Down
9 changes: 7 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ static const bool DEFAULT_PROXYRANDOMIZE = true;
static const bool DEFAULT_REST_ENABLE = false;
static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false;

unsigned int nMinerSleep;

std::unique_ptr<CConnman> g_connman;
std::unique_ptr<PeerLogicValidation> peerLogic;

Expand Down Expand Up @@ -1339,6 +1341,9 @@ bool AppInitMain()
}
}

// cloak: staker sleep MS
nMinerSleep = gArgs.GetArg("-minersleep", 500);

// Check for host lookup allowed before parsing any network related parameters
fNameLookup = gArgs.GetBoolArg("-dns", DEFAULT_NAME_LOOKUP);

Expand Down Expand Up @@ -1768,8 +1773,8 @@ bool AppInitMain()

#if ENABLE_WALLET
// Generate coins in the background
SetStaking(gArgs.GetBoolArg("-staking", true));
threadGroup.create_thread(boost::bind(&CloakStaker, boost::cref(chainparams)));
Staker::SetStaking(gArgs.GetBoolArg("-staking", true));
threadGroup.create_thread(boost::bind(&Staker::CloakStaker, boost::cref(chainparams)));
#endif

return true;
Expand Down
2 changes: 1 addition & 1 deletion src/leveldb/db/skiplist.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ void SkipList<Key,Comparator>::Insert(const Key& key) {
// Our data structure does not allow duplicate insertion
assert(x == NULL || !Equal(key, x->key));

int height = RandomHeight();
int64_t height = RandomHeight();
if (height > GetMaxHeight()) {
for (int i = GetMaxHeight(); i < height; i++) {
prev[i] = head_;
Expand Down
Loading

0 comments on commit 39749cc

Please sign in to comment.