Skip to content

Commit

Permalink
Merge pull request #65 from project-bitmark/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
dbkeys authored Jul 4, 2018
2 parents 6c44bad + d5d9d3d commit 2c236eb
Show file tree
Hide file tree
Showing 18 changed files with 208 additions and 91 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ Bitmark aims to be a relatively stable, user focused crypto currency, which refi

**Balance**: Every aspect of Bitmark has been designed in order to balance the interests of everybody involved or associated with the project. This includes [Investor Public Mining (IPM)](https://github.com/project-bitmark/bitmark/wiki/IPM-Pool) which balances Investors, Miners, and Developers in a way that is mutually beneficial and which critically enables those at the core to provide the best network experience to those who rely on it, the users.

* [Project - Documentation and Plan](https://github.com/project-bitmark/bitmark/wiki)
* [Discussion and Updates](https://bitcointalk.org/index.php?topic=3169983.0)
* [Documentation and Plan](https://github.com/project-bitmark/bitmark/wiki)
* [Discussion and Updates](https://bitcointalk.org/index.php?topic=660544.0)
* [Block Explorer](http://explorer.bitmark.co)
* [Testnet Explorer](http://explorer.bitmark.co/testnet)

## Getting Bitmark

Expand All @@ -48,13 +50,13 @@ rpcpassword=YoUrSecreT-PaSsWoRd
listen=1


## Note: Daniel J. Bernstein's libsodium cryptographic library is requred by Bitmark v0.9.7
##Note: libsodium cryptographic library is required by Bitmark v0.9.7

Ubuntu 16 and higher may simply do:

sudo apt-get install libsodium-dev

otherwise, you may have to compile this library from scratch:
otherwise, you may compile this library from sources::

git clone git://github.com/jedisct1/libsodium.git
cd libsodium
Expand All @@ -79,7 +81,7 @@ You can also use the bitmark-cli command to mine. The last parameter is the algo

`bitmark-cli setgenerate true <ncores> 3`

For equihash, it is recommended to use the built in miner as the cpuminer is slow at the moment.
For equihash and cryptonight, it is recommended to use the built in miner as the cpuminer is slow at the moment.

There are currently 3 types of tests implemented.

Expand All @@ -91,4 +93,4 @@ There are currently 3 types of tests implemented.

## Merge Mining

Also part of the hard fork is merge mining, a way to increase the hashpower security of the chain by allowing the mining of the chain simultaneously with another chain. All 8 algorithms are supported.
Also part of the hard fork is merge mining, a way to increase the hashpower security of the chain by allowing the mining of the chain simultaneously with other chains. All 8 algorithms are supported.
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 0)
define(_CLIENT_VERSION_MINOR, 9)
define(_CLIENT_VERSION_REVISION, 7)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_BUILD, 2)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2017)
define(_COPYRIGHT_YEAR, 2018)
AC_INIT([Bitmark Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[[email protected]],[bitmark])
AC_CONFIG_AUX_DIR([src/build-aux])
AC_CONFIG_MACRO_DIR([src/m4])
Expand Down
7 changes: 3 additions & 4 deletions doc/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Bitmark 0.9.5 BETA
Bitmark 0.9.7.1 BETA
=====================

Copyright (c) 2009-2018 Bitmark Developers


Setup
---------------------
[Bitmark Core](http://bitmark.io/en/download) is the original Bitmark client and it builds the backbone of the network. It downloads and stores the entire history of Bitmark transactions (as of December 2017, less than 1 GiB of data); depending on the speed of your computer and network connection, the synchronization process can take anywhere from a few hours to a day or more. Thankfully you only have to do this once. If you would like the process to go faster you can [download the blockchain directly](bootstrap.md).
[Bitmark Core](http://bitmark.io/en/download) is the original Bitmark client and it builds the backbone of the network. It downloads and stores the entire history of Bitmark transactions (as of June 2018, less than 1 GiB of data); depending on the speed of your computer and network connection, the synchronization process can take anywhere from a few hours to a day or more. Thankfully you only have to do this once. If you would like the process to go faster you can [download the blockchain directly](bootstrap.md).

Running
---------------------
Expand Down Expand Up @@ -71,5 +71,4 @@ The Bitmark repo's [root README](https://github.com/project-bitmark/bitmark/blob
License
---------------------
Distributed under the [MIT/X11 software license](http://www.opensource.org/licenses/mit-license.php).
This product includes software developed by the OpenSSL Project for use in the [OpenSSL Toolkit](http://www.openssl.org/). This product includes
cryptographic software written by Eric Young ([[email protected]](mailto:[email protected])), and UPnP software written by Thomas Bernard.
This product includes software developed by the OpenSSL Project for use in the [OpenSSL Toolkit](http://www.openssl.org/). This product includes cryptographic software written by Eric Young ([[email protected]](mailto:[email protected])), and UPnP software written by Thomas Bernard.
3 changes: 2 additions & 1 deletion src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ unsigned int pnSeed[] =
0x2D2141A1, // us.bitmark.io IP = 45.33.65.161 joe
0xCC447A12, // tx.bitmark.io IP = 204.68.122.18 tex
0xCC447A07, // seed.bitmark.mx IP = 204.68.122.7 jules
0xCC447A0B // one.zmark.org IP = 204.68.122.11 per
0xCC447A0B, // one.zmark.org IP = 204.68.122.11 per
0x8BA2E8F2 // uk.bitmark.one IP = 139.162.232.242 jim
};

class CMainParams : public CChainParams {
Expand Down
4 changes: 2 additions & 2 deletions src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
#define CLIENT_VERSION_MAJOR 0
#define CLIENT_VERSION_MINOR 9
#define CLIENT_VERSION_REVISION 7
#define CLIENT_VERSION_BUILD 1
#define CLIENT_VERSION_BUILD 2

// Set to true for release, false for prerelease (rc: release candidate) or test build
#define CLIENT_VERSION_IS_RELEASE false

// Copyright year (2009-this)

#define COPYRIGHT_YEAR 2017
#define COPYRIGHT_YEAR 2018

#endif //HAVE_CONFIG_H

Expand Down
13 changes: 11 additions & 2 deletions src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,9 +649,18 @@ bool CheckAuxPowProofOfWork(const CBlockHeader& block, const CChainParams& param
return true;
}

// Based on tests with general purpose CPUs, except for SHA256 which was designed for simplicity and suited for ASICs, so given a factor of 16 decrease in weight.
// Based on tests with general purpose CPUs,
// ( Except for SHA256 which was designed for simplicity and suited for ASICs,
// so given a factor of 16 decrease in weight. )
// Weighing gives more value to hashes from some algos over others,
// because, for example a Cryptonight hash is much more computationally expensive
// than a SHA256d hash.
// Weights should ultimately reflect the market value of hashes by different algorithms;
// this will vary constantly (and more significantly long-term with hardware developement)
// As of June, 2018 these values are closely reflective of market values seen on
// nicehash.com and miningrigrentals.com
unsigned int GetAlgoWeight (const int algo) {
unsigned int weight = 8000; // scrypt, lyra2rev2, and share this value
unsigned int weight = 8000; // scrypt, lyra2rev2 and 17 share this value.
switch (algo)
{
case ALGO_SHA256D:
Expand Down
2 changes: 1 addition & 1 deletion src/equihash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ bool Equihash<N,K>::IsValidSolution(const eh_HashState& base_state, std::vector<
return false;
}

LogPrintf("good solution size\n");
//LogPrintf("good solution size\n");

std::vector<FullStepRow<FinalFullWidth>> X;
X.reserve(1 << K);
Expand Down
25 changes: 15 additions & 10 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ bool onFork (const CBlockIndex * pindex) {
return pindex->onFork();
}

int64_t GetBlockValue(CBlockIndex* pindex, int64_t nFees, bool scale)
int64_t GetBlockValue(CBlockIndex* pindex, int64_t nFees, bool noScale)
{
// for testnet
int nHeight = pindex->nHeight;
Expand Down Expand Up @@ -1237,7 +1237,7 @@ int64_t GetBlockValue(CBlockIndex* pindex, int64_t nFees, bool scale)
}

unsigned int scalingFactor = 0;
if (onFork(pindex)) {
if (onFork(pindex) && !noScale) {
scalingFactor = pindex->subsidyScalingFactor;
if (!scalingFactor) { // find the key block and recalculate
CBlockIndex * pprev_algo = pindex;
Expand All @@ -1251,6 +1251,9 @@ int64_t GetBlockValue(CBlockIndex* pindex, int64_t nFees, bool scale)
} while (pprev_algo);
}
}
else {
scalingFactor = 0;
}

int64_t baseSubsidy = 0;
//LogPrintf("for height %d use scaling factor %f\n",nHeight,scalingFactor);
Expand Down Expand Up @@ -1405,7 +1408,7 @@ unsigned int ComputeMinWork(unsigned int nBase, int64_t nTime)

unsigned int static DarkGravityWave(const CBlockIndex* pindexLast, int algo) {

/* current difficulty formula, dash - DarkGravity v3, written by Evan Duffield - [email protected] */
/* current difficulty formula, DASH - DarkGravity v3, written by Evan Duffield - [email protected] */
const CBlockIndex *BlockLastSolved = pindexLast;
const CBlockIndex *BlockReading = pindexLast;
int64_t nActualTimespan = 0;
Expand Down Expand Up @@ -1597,7 +1600,7 @@ unsigned int static DarkGravityWave(const CBlockIndex* pindexLast, int algo) {
}


unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, int algo)
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, int algo)
{
if (RegTest()) return Params().ProofOfWorkLimit().GetCompact();
int nHeight = pindexLast->nHeight;
Expand All @@ -1609,6 +1612,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
workAlgo = 1;
}

// workAlgo functions here as post_fork boolean; 0: pre-fork, 1: post-fork
if (workAlgo == 0) {
unsigned int nProofOfWorkLimit = Params().ProofOfWorkLimit().GetCompact();

Expand Down Expand Up @@ -1673,13 +1677,14 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead

return bnNew.GetCompact();
} else {
// Post 8mPoW fork
return DarkGravityWave(pindexLast,algo);
}
}

unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock)
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast)
{
return GetNextWorkRequired(pindexLast, pblock, ALGO_SCRYPT);
return GetNextWorkRequired(pindexLast, ALGO_SCRYPT);
}

bool IsInitialBlockDownload()
Expand Down Expand Up @@ -2253,12 +2258,12 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
}
}

int64_t block_value_needed = GetBlockValue(pindex, nFees);
int64_t block_value_needed = GetBlockValue(pindex, nFees, false);

if (block.vtx[0].GetValueOut() > block_value_needed)
return state.DoS(100,
error("ConnectBlock() : coinbase pays too much (actual=%d vs limit=%d)",
block.vtx[0].GetValueOut(), GetBlockValue(pindex, nFees)),
block.vtx[0].GetValueOut(), GetBlockValue(pindex, nFees, false)),
REJECT_INVALID, "bad-cb-amount");

if (block.vtx[0].GetValueOut() < block_value_needed) {
Expand Down Expand Up @@ -2878,7 +2883,7 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CDiskBlockPos* dbp)

// Check proof of work
int block_algo = GetAlgo(block.nVersion);
unsigned int next_work_required = GetNextWorkRequired(pindexPrev, &block, block_algo);
unsigned int next_work_required = GetNextWorkRequired(pindexPrev, block_algo);
if (block.nBits != next_work_required) {
LogPrintf("nbits = %d, required = %d\n",block.nBits,next_work_required);
return state.DoS(100, error("AcceptBlock() : incorrect proof of work"),
Expand Down Expand Up @@ -5021,7 +5026,7 @@ unsigned long get_ssf_work (const CBlockIndex * pindex) {
CBigNum hashes_bn = pprev_algo->GetBlockWork();
for (int i=0; i<nSSF; i++) {
if (update_ssf(pprev_algo->nVersion)) {
return hashes_bn.getulong();
return (hashes_bn/1000000).getulong();
}
pprev_algo = get_pprev_algo(pprev_algo,-1);
if (!pprev_algo) return 0;
Expand Down
6 changes: 3 additions & 3 deletions src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, b
/** Find the best known block, and make it the tip of the block chain */
bool ActivateBestChain(CValidationState &state);
bool onFork(const CBlockIndex* pindex);
int64_t GetBlockValue(CBlockIndex* pindexPrev, int64_t nFees, bool scale = true);
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock);
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, int algo);
int64_t GetBlockValue(CBlockIndex* pindexPrev, int64_t nFees, bool noScale = false);
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast);
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, int algo);

void UpdateTime(CBlockHeader& block, const CBlockIndex* pindexPrev);

Expand Down
10 changes: 5 additions & 5 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
//printf("create new block with hash prev = %s (height %d)\n",pblock->hashPrevBlock.GetHex().c_str(),pindexPrev->nHeight);

UpdateTime(*pblock, pindexPrev);
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, miningAlgo);
pblock->nBits = GetNextWorkRequired(pindexPrev, miningAlgo);
//LogPrintf("create block nBits = %s\n",CBigNum().SetCompact(pblock->nBits).getuint256().GetHex().c_str());
pblock->nNonce = 0;
if (miningAlgo==ALGO_EQUIHASH) {
Expand All @@ -391,7 +391,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
indexDummy.pprev = pindexPrev;
indexDummy.nHeight = pindexPrev->nHeight + 1;

pblock->vtx[0].vout[0].nValue = GetBlockValue(&indexDummy, nFees);
pblock->vtx[0].vout[0].nValue = GetBlockValue(&indexDummy, nFees, false);

CCoinsViewCache viewNew(*pcoinsTip, true);

Expand Down Expand Up @@ -686,6 +686,9 @@ void static BitmarkMiner(CWallet *pwallet)
break;
}
}

pblock->nNonce256 = (CBigNum(pblock->nNonce256) + 1).getuint256();
nHashesDone += 1;

}
else while(true) {
Expand Down Expand Up @@ -760,9 +763,6 @@ void static BitmarkMiner(CWallet *pwallet)
if (pindexPrev != chainActive.Tip())
break;

if (miningAlgo==ALGO_EQUIHASH) {
pblock->nNonce256 = (CBigNum(pblock->nNonce256) + 1).getuint256();
}
// Update nTime every few seconds
UpdateTime(*pblock, pindexPrev);
nBlockTime = ByteReverse(pblock->nTime);
Expand Down
24 changes: 15 additions & 9 deletions src/rpcblockchain.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2010 Satoshi Nakamoto
// Original Code: Copyright (c) 2009-2014 The Bitcoin Core Developers
// Modified Code: Copyright (c) 2014 Project Bitmark
// Modified Code: Copyright (c) 2014-2018 Project Bitmark
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

Expand All @@ -18,7 +18,7 @@ using namespace std;

void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out, bool fIncludeHex);

double GetDifficulty(const CBlockIndex* blockindex, int algo)
double GetDifficulty(const CBlockIndex* blockindex, int algo, bool weighted, bool next)
{
// Floating point number that is a multiple of the minimum difficulty,
// minimum difficulty = 1.0.
Expand All @@ -41,7 +41,11 @@ double GetDifficulty(const CBlockIndex* blockindex, int algo)
}
}
unsigned int nBits = 0;
unsigned int algoWeight = GetAlgoWeight(algo);
unsigned int algoWeight = 1;
if (weighted) algoWeight = GetAlgoWeight(algo);
if (next) {
nBits = GetNextWorkRequired(chainActive.Tip(),algo);
}
if (blockindex && blockindex->nHeight>0) {
nBits = blockindex->nBits;
}
Expand Down Expand Up @@ -128,7 +132,7 @@ double GetPeakHashrate (const CBlockIndex* blockindex, int algo) {
return std::numeric_limits<double>::max();
}
//LogPrintf("hashes = %f, time = %f\n",(double)hashes_bn.getulong(),(double)time_f);
double hashes = ((double)hashes_bn.getulong())/((double)time_f);
double hashes = ((hashes_bn/time_f)/1000000).getulong();
//LogPrintf("hashes per sec = %f\n",hashes);
if (hashes>hashes_peak) hashes_peak = hashes;
}
Expand Down Expand Up @@ -192,7 +196,7 @@ double GetCurrentHashrate (const CBlockIndex* blockindex, int algo) { //as used
return std::numeric_limits<double>::max();
}
//LogPrintf("return %lu / %f\n",(double)hashes_bn.getulong(),(double)time_f);
return ((double)hashes_bn.getulong())/((double)time_f);
return ((hashes_bn/time_f)/1000000).getulong();
}
blockindex = get_pprev_algo(blockindex,-1);
} while (blockindex);
Expand Down Expand Up @@ -237,7 +241,7 @@ double GetMoneySupply (const CBlockIndex* blockindex, int algo) {
return ((double)blockindex->nMoneySupply)/100000000.;
}

double GetBlockReward (CBlockIndex * blockindex, int algo) {
double GetBlockReward (CBlockIndex * blockindex, int algo, bool noScale) {
if (blockindex == NULL) {
if (chainActive.Tip() == NULL)
return 0.;
Expand All @@ -256,7 +260,7 @@ double GetBlockReward (CBlockIndex * blockindex, int algo) {
CBlockIndex indexDummy(*pblock);
indexDummy.pprev = blockindex;
indexDummy.nHeight = blockindex->nHeight + 1;
return ((double)GetBlockValue(&indexDummy,0))/100000000.;
return ((double)GetBlockValue(&indexDummy,0,noScale))/100000000.;

}

Expand Down Expand Up @@ -351,9 +355,11 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex)
// 7 is the typical offset in monero, but not fully general
sprintf(prev_id+2*i,"%02x",vector_rep[i+7]);
}
result.push_back(Pair("parentblockprevid",prev_id));
result.push_back(Pair("parentblockprevhash",prev_id));
}
else {
result.push_back(Pair("parentblockprevhash",block.auxpow->parentBlock.hashPrevBlock.GetHex()));
}

}
result.push_back(Pair("SSF height",get_ssf_height(blockindex)));
result.push_back(Pair("SSF work", (int64_t)get_ssf_work(blockindex)));
Expand Down
Loading

0 comments on commit 2c236eb

Please sign in to comment.