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

Update work calculation, and immediate hard fork to subvert attack #5

Merged
merged 8 commits into from
Apr 26, 2017
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
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 3)
define(_CLIENT_VERSION_MINOR, 11)
define(_CLIENT_VERSION_REVISION, 2)
define(_CLIENT_VERSION_REVISION, 3)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2017)
Expand Down
2 changes: 1 addition & 1 deletion src/amount.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CFeeRate
CFeeRate(const CFeeRate& other) { nSatoshisPerK = other.nSatoshisPerK; }

CAmount GetFee(size_t size) const; // unit returned is satoshis
CAmount GetFeePerK() const { return GetFee(50000); } // satoshis-per-1000-bytes
CAmount GetFeePerK() const { return GetFee(1000); } // satoshis-per-1000-bytes

friend bool operator<(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK < b.nSatoshisPerK; }
friend bool operator>(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK > b.nSatoshisPerK; }
Expand Down
11 changes: 6 additions & 5 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ class CMainParams : public CChainParams {
//consensus.nBlockAlgoNormalisedWorkStart = 740000; // block where algo combined weight starts
//consensus.nBlockAlgoNormalisedWorkDecayStart1 = 866000; // block where weight decay starts
//consensus.nBlockAlgoNormalisedWorkDecayStart2 = 932000; // block where weight decay starts
//consensus.nGeoAvgWork_Start = 4000000; // TODO
consensus.nGeoAvgWork_Start = 2387838;
consensus.nDGW3StartBlock = 1635000;
consensus.nMultiAlgoFork = 1930000; // Block where multi-algo difficulty adjustment and 45 second blocktime starts
consensus.nCoinbaseMaturityV2Start = 2422000;
consensus.nCoinbaseMaturityV2Start = 2387838;

/**
* The message start string is designed to be unlikely to occur in normal data.
Expand Down Expand Up @@ -149,11 +149,12 @@ class CMainParams : public CChainParams {
( 1924401, uint256S("0x2267dd4753f9e8fa088cdc4d257355b0a118ccd43a2f366c68de1aa260c4ba22"))
( 1934707, uint256S("0xe4527742cb236f24b355156213775e44da0e728ea453fae712fa672b18ce5f84"))
( 2050260, uint256S("0xbc55838e026131fab334f1c87de9fea3218d076f4de03dc19f94d4f12da7d6c1"))
( 2365716, uint256S("0x947827b4599512a675fc3789ac8778b3187277705ffda7b6e3cf6adaa31dac10")),
( 2365716, uint256S("0x947827b4599512a675fc3789ac8778b3187277705ffda7b6e3cf6adaa31dac10"))
( 2387838, uint256S("0x00000000000000254214c9f9fbdd39c07072b43df52f35a910509f4c5406c272")),
1491891115, // * UNIX timestamp of last checkpoint block
2604836, // * total number of transactions between genesis and last checkpoint
2629957, // * total number of transactions between genesis and last checkpoint
// (the tx=... number in the SetBestChain debug.log lines)
2000 // * estimated number of transactions per day after checkpoint
3000 // * estimated number of transactions per day after checkpoint
};
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//! These need to be macros, as clientversion.cpp's and bitcoin*-res.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 3
#define CLIENT_VERSION_MINOR 11
#define CLIENT_VERSION_REVISION 2
#define CLIENT_VERSION_REVISION 3
#define CLIENT_VERSION_BUILD 0

//! Set to true for release, false for prerelease or test build
Expand Down
2 changes: 1 addition & 1 deletion src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct Params {
//int64_t nBlockAlgoNormalisedWorkStart;
//int64_t nBlockAlgoNormalisedWorkDecayStart1;
//int64_t nBlockAlgoNormalisedWorkDecayStart2;
//int64_t nGeoAvgWork_Start;
int64_t nGeoAvgWork_Start;
int64_t nMultiAlgoFork;
int64_t nDGW3StartBlock;
int64_t nCoinbaseMaturityV2Start;
Expand Down
17 changes: 7 additions & 10 deletions src/pow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ arith_uint256 GetPrevWorkForAlgo(const CBlockIndex& block, int algo)
return arith_uint256(0);
} */

/*arith_uint256 GetPrevWorkForAlgoWithDecay3(const CBlockIndex& block, int algo)
arith_uint256 GetPrevWorkForAlgoWithDecay3(const CBlockIndex& block, int algo)
{
int nDistance = 0;
arith_uint256 nWork;
Expand All @@ -632,9 +632,9 @@ arith_uint256 GetPrevWorkForAlgo(const CBlockIndex& block, int algo)
nDistance++;
}
return arith_uint256(0);
}*/
}

/*arith_uint256 GetGeometricMeanPrevWork(const CBlockIndex& block) // TODO Argentum
arith_uint256 GetGeometricMeanPrevWork(const CBlockIndex& block)
{
//arith_uint256 bnRes;
arith_uint256 nBlockWork = GetBlockProofBase(block);
Expand All @@ -654,12 +654,9 @@ arith_uint256 GetPrevWorkForAlgo(const CBlockIndex& block, int algo)
// Compute the geometric mean
CBigNum bnRes = bnBlockWork.nthRoot(NUM_ALGOS);

// Scale to roughly match the old work calculation
bnRes <<= 7;

//return bnRes;
return UintToArith256(bnRes.getuint256());
}*/
}

arith_uint256 GetBlockProof(const CBlockIndex& block)
{
Expand All @@ -669,11 +666,11 @@ arith_uint256 GetBlockProof(const CBlockIndex& block)
int nHeight = block.nHeight;
int nAlgo = block.GetAlgo();

/*if (nHeight > chainparams.GetConsensus().nGeoAvgWork_Start) // TODO Argentum
if (nHeight >= chainparams.GetConsensus().nGeoAvgWork_Start)
{
bnTarget = GetGeometricMeanPrevWork(block);
}*/
if (nHeight >= chainparams.GetConsensus().nMultiAlgoFork)
}
else if (nHeight >= chainparams.GetConsensus().nMultiAlgoFork)
{
arith_uint256 nBlockWork = GetBlockProofBase(block);
for (int algo = 0; algo < NUM_ALGOS; algo++)
Expand Down
4 changes: 2 additions & 2 deletions src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
* network protocol versioning
*/

static const int PROTOCOL_VERSION = 1060000;
static const int PROTOCOL_VERSION = 1070000;

//! initial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 209;

//! disconnect from peers older than this proto version
static const int MIN_PEER_PROTO_VERSION = 1050000;
static const int MIN_PEER_PROTO_VERSION = 1070000;

// disconnect from peers older than this client sub version
static const std::string MIN_PEER_CLIENT_VERSION = "2.4.1";
Expand Down