From 698d5ff5b638d6ee3538641b7bd6afbcb0f23f97 Mon Sep 17 00:00:00 2001 From: Beshoy Girgis Date: Thu, 14 Jun 2018 11:31:09 -0500 Subject: [PATCH 1/4] Decrease effectiveness of timewarp attack --- configure.ac | 2 +- src/chainparams.cpp | 1 + src/chainparams.h | 2 ++ src/clientversion.h | 2 +- src/main.cpp | 12 ++++++++++-- src/version.h | 2 +- 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 272a253..b862066 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 1) define(_CLIENT_VERSION_MINOR, 3) define(_CLIENT_VERSION_REVISION, 0) -define(_CLIENT_VERSION_BUILD, 50) +define(_CLIENT_VERSION_BUILD, 51) define(_ZC_BUILD_VAL, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD), m4_eval(_CLIENT_VERSION_BUILD < 50), 1, m4_eval(_CLIENT_VERSION_BUILD - 24), m4_eval(_CLIENT_VERSION_BUILD == 50), 1, , m4_eval(_CLIENT_VERSION_BUILD - 50))) define(_CLIENT_VERSION_SUFFIX, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, _CLIENT_VERSION_REVISION-beta$1, m4_eval(_CLIENT_VERSION_BUILD < 50), 1, _CLIENT_VERSION_REVISION-rc$1, m4_eval(_CLIENT_VERSION_BUILD == 50), 1, _CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION-$1))) define(_CLIENT_VERSION_IS_RELEASE, true) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 708c2ef..b36a063 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -61,6 +61,7 @@ class CMainParams : public CChainParams { nDefaultPort = 1989; nMaxTipAge = 24 * 60 * 60; nPruneAfterHeight = 100000; + newTimeRule = 158750; eh_epoch_1 = eh200_9; eh_epoch_2 = eh144_5; eh_epoch_1_endblock = 160010; diff --git a/src/chainparams.h b/src/chainparams.h index 9b3dca1..7377ff8 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -102,6 +102,7 @@ class CChainParams std::string GetFoundersRewardAddressAtIndex(int i) const; /** Enforce coinbase consensus rule in regtest mode */ void SetRegTestCoinbaseMustBeProtected() { consensus.fCoinbaseMustBeProtected = true; } + int GetNewTimeRule() const { return newTimeRule; } protected: CChainParams() {} @@ -129,6 +130,7 @@ class CChainParams bool fTestnetToBeDeprecatedFieldRPC = false; Checkpoints::CCheckpointData checkpointData; std::vector vFoundersRewardAddress; + int newTimeRule; }; /** diff --git a/src/clientversion.h b/src/clientversion.h index 1544fce..03903b7 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -19,7 +19,7 @@ #define CLIENT_VERSION_MAJOR 1 #define CLIENT_VERSION_MINOR 3 #define CLIENT_VERSION_REVISION 0 -#define CLIENT_VERSION_BUILD 50 +#define CLIENT_VERSION_BUILD 51 //! Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE true diff --git a/src/main.cpp b/src/main.cpp index 0656d8b..ed564c0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3002,8 +3002,16 @@ bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool f return state.DoS(50, error("CheckBlockHeader(): proof of work failed"), REJECT_INVALID, "high-hash"); - // Check timestamp - if (block.GetBlockTime() > GetAdjustedTime() + 2 * 60 * 60) + unsigned int nHeight = chainActive.Height(); + const CChainParams& chainParams = Params(); + + // Check timestamp (old) + if (nHeight < chainParams.GetNewTimeRule() && block.GetBlockTime() > GetAdjustedTime() + 2 * 60 * 60) + return state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"), + REJECT_INVALID, "time-too-new"); + + // starting at height 158750, decrease to 30 minute window to decrease effectiveness of timewarp attack. + else if (nHeight >= chainParams.GetNewTimeRule() && block.GetBlockTime() > GetAdjustedTime() + 30 * 60) return state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"), REJECT_INVALID, "time-too-new"); diff --git a/src/version.h b/src/version.h index 197282f..9941c1b 100644 --- a/src/version.h +++ b/src/version.h @@ -9,7 +9,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 770004; +static const int PROTOCOL_VERSION = 770005; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; From b95abb16f498ca93007ca1f31a1c4389df0dd566 Mon Sep 17 00:00:00 2001 From: nick <33939323+NickRHill@users.noreply.github.com> Date: Fri, 15 Jun 2018 21:41:48 +0100 Subject: [PATCH 2/4] update block --- src/chainparams.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index b36a063..15832d2 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -61,7 +61,7 @@ class CMainParams : public CChainParams { nDefaultPort = 1989; nMaxTipAge = 24 * 60 * 60; nPruneAfterHeight = 100000; - newTimeRule = 158750; + newTimeRule = 159200; eh_epoch_1 = eh200_9; eh_epoch_2 = eh144_5; eh_epoch_1_endblock = 160010; From 0eca66746e7dcf3f78c90a3a113480682b10e18b Mon Sep 17 00:00:00 2001 From: nick <33939323+NickRHill@users.noreply.github.com> Date: Fri, 15 Jun 2018 23:01:01 +0100 Subject: [PATCH 3/4] set blockheight --- configure.ac | 2 +- src/chainparams.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index b862066..7af12d3 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N) AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 1) define(_CLIENT_VERSION_MINOR, 3) -define(_CLIENT_VERSION_REVISION, 0) +define(_CLIENT_VERSION_REVISION, 1) define(_CLIENT_VERSION_BUILD, 51) define(_ZC_BUILD_VAL, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD), m4_eval(_CLIENT_VERSION_BUILD < 50), 1, m4_eval(_CLIENT_VERSION_BUILD - 24), m4_eval(_CLIENT_VERSION_BUILD == 50), 1, , m4_eval(_CLIENT_VERSION_BUILD - 50))) define(_CLIENT_VERSION_SUFFIX, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, _CLIENT_VERSION_REVISION-beta$1, m4_eval(_CLIENT_VERSION_BUILD < 50), 1, _CLIENT_VERSION_REVISION-rc$1, m4_eval(_CLIENT_VERSION_BUILD == 50), 1, _CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION-$1))) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 15832d2..2cc6458 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -61,7 +61,7 @@ class CMainParams : public CChainParams { nDefaultPort = 1989; nMaxTipAge = 24 * 60 * 60; nPruneAfterHeight = 100000; - newTimeRule = 159200; + newTimeRule = 159300; eh_epoch_1 = eh200_9; eh_epoch_2 = eh144_5; eh_epoch_1_endblock = 160010; From 0b774f38130bc28a6ef87eaa32a9386c9066883e Mon Sep 17 00:00:00 2001 From: Beshoy Girgis Date: Fri, 15 Jun 2018 17:35:01 -0500 Subject: [PATCH 4/4] Decrease effectiveness of timewarp attack (#45) * Decrease effectiveness of timewarp attack * update block * set blockheight * Update comment with new height * update version * Increment version to 1.4.0 * Update clientversion.h --- configure.ac | 4 ++-- contrib/debian/changelog | 6 +++--- contrib/debian/control | 2 +- contrib/gitian-descriptors/gitian-linux.yml | 2 +- doc/man/bitcoinz-cli.1 | 6 +++--- doc/man/bitcoinz-tx.1 | 6 +++--- doc/man/bitcoinzd.1 | 6 +++--- src/clientversion.h | 2 +- src/main.cpp | 2 +- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/configure.ac b/configure.ac index 7af12d3..b90f165 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N) AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 1) -define(_CLIENT_VERSION_MINOR, 3) -define(_CLIENT_VERSION_REVISION, 1) +define(_CLIENT_VERSION_MINOR, 4) +define(_CLIENT_VERSION_REVISION, 0) define(_CLIENT_VERSION_BUILD, 51) define(_ZC_BUILD_VAL, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD), m4_eval(_CLIENT_VERSION_BUILD < 50), 1, m4_eval(_CLIENT_VERSION_BUILD - 24), m4_eval(_CLIENT_VERSION_BUILD == 50), 1, , m4_eval(_CLIENT_VERSION_BUILD - 50))) define(_CLIENT_VERSION_SUFFIX, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, _CLIENT_VERSION_REVISION-beta$1, m4_eval(_CLIENT_VERSION_BUILD < 50), 1, _CLIENT_VERSION_REVISION-rc$1, m4_eval(_CLIENT_VERSION_BUILD == 50), 1, _CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION-$1))) diff --git a/contrib/debian/changelog b/contrib/debian/changelog index c650947..d41c80a 100644 --- a/contrib/debian/changelog +++ b/contrib/debian/changelog @@ -1,5 +1,5 @@ -bitcoinz (1.3.0) stable; urgency=medium +bitcoinz (1.4.0) stable; urgency=high - * 1.3.0 release. + * 1.4.0 release. - -- The BitcoinZ Community Sat, 10 June 2018 00:15:00 +0100 + -- The BitcoinZ Community Fri, 15 June 2018 00:15:00 +0100 diff --git a/contrib/debian/control b/contrib/debian/control index b1ba34b..30ae24b 100644 --- a/contrib/debian/control +++ b/contrib/debian/control @@ -11,7 +11,7 @@ Vcs-Git: https://github.com/btcz/bitcoinz.git Vcs-Browser: https://github.com/btcz Package: bitcoinz -Version: 1.3.0 +Version: 1.4.0 Depends: ${shlibs:Depends} Architecture: all Description: BitcoinZ is a decentralized community project based on the Bitcoin and Zcash codebase. diff --git a/contrib/gitian-descriptors/gitian-linux.yml b/contrib/gitian-descriptors/gitian-linux.yml index bc4f210..5d86036 100644 --- a/contrib/gitian-descriptors/gitian-linux.yml +++ b/contrib/gitian-descriptors/gitian-linux.yml @@ -1,5 +1,5 @@ --- -name: "bitcoinz-1.3.0" +name: "bitcoinz-1.4.0" enable_cache: true distro: "debian" suites: diff --git a/doc/man/bitcoinz-cli.1 b/doc/man/bitcoinz-cli.1 index 7613fac..12cf630 100644 --- a/doc/man/bitcoinz-cli.1 +++ b/doc/man/bitcoinz-cli.1 @@ -1,9 +1,9 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.3. -.TH BITCOINZ-CLI "1" "June 2018" "bitcoinz-cli v1.3.0" "User Commands" +.TH BITCOINZ-CLI "1" "June 2018" "bitcoinz-cli v1.4.0" "User Commands" .SH NAME -bitcoinz-cli \- manual page for bitcoinz-cli v1.3.0 +bitcoinz-cli \- manual page for bitcoinz-cli v1.4.0 .SH DESCRIPTION -BitcoinZ RPC client version v1.3.0 +BitcoinZ RPC client version v1.4.0 .PP In order to ensure you are adequately protecting your privacy when using BitcoinZ, please see . diff --git a/doc/man/bitcoinz-tx.1 b/doc/man/bitcoinz-tx.1 index 2d7e271..a00843d 100644 --- a/doc/man/bitcoinz-tx.1 +++ b/doc/man/bitcoinz-tx.1 @@ -1,9 +1,9 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.3. -.TH BITCOINZ-TX "1" "June 2018" "bitcoinz-tx v1.3.0" "User Commands" +.TH BITCOINZ-TX "1" "June 2018" "bitcoinz-tx v1.4.0" "User Commands" .SH NAME -bitcoinz-tx \- manual page for bitcoinz-tx v1.3.0 +bitcoinz-tx \- manual page for bitcoinz-tx v1.4.0 .SH DESCRIPTION -BitcoinZ bitcoinz\-tx utility version v1.3.0 +BitcoinZ bitcoinz\-tx utility version v1.4.0 .SS "Usage:" .TP bitcoinz\-tx [options] [commands] diff --git a/doc/man/bitcoinzd.1 b/doc/man/bitcoinzd.1 index 53c7fd9..c698e91 100644 --- a/doc/man/bitcoinzd.1 +++ b/doc/man/bitcoinzd.1 @@ -1,9 +1,9 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.3. -.TH BITCOINZD "1" "June 2018" "bitcoinzd v1.3.0" "User Commands" +.TH BITCOINZD "1" "June 2018" "bitcoinzd v1.4.0" "User Commands" .SH NAME -bitcoinzd \- manual page for bitcoinzd v1.3.0 +bitcoinzd \- manual page for bitcoinzd v1.4.0 .SH DESCRIPTION -BitcoinZ Daemon version v1.3.0 +BitcoinZ Daemon version v1.4.0 .PP In order to ensure you are adequately protecting your privacy when using BitcoinZ, please see . diff --git a/src/clientversion.h b/src/clientversion.h index 03903b7..bad31e6 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -17,7 +17,7 @@ //! These need to be macros, as clientversion.cpp's and bitcoin*-res.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 1 -#define CLIENT_VERSION_MINOR 3 +#define CLIENT_VERSION_MINOR 4 #define CLIENT_VERSION_REVISION 0 #define CLIENT_VERSION_BUILD 51 diff --git a/src/main.cpp b/src/main.cpp index ed564c0..7dd0d9d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3010,7 +3010,7 @@ bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool f return state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"), REJECT_INVALID, "time-too-new"); - // starting at height 158750, decrease to 30 minute window to decrease effectiveness of timewarp attack. + // starting at height 159300, decrease to 30 minute window to decrease effectiveness of timewarp attack. else if (nHeight >= chainParams.GetNewTimeRule() && block.GetBlockTime() > GetAdjustedTime() + 30 * 60) return state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"), REJECT_INVALID, "time-too-new");