From 6e7b44b7c054d44be0b1a96aaec40c7b76e4fbc5 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 6 Mar 2021 16:32:41 -0500 Subject: [PATCH 01/19] daa fork height --- src/main.cpp | 9 +++++---- src/pow.cpp | 11 ++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 286ef28b0..bb3c4d4dc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5033,20 +5033,21 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta assert(pindexPrev); - int nHeight = pindexPrev->GetHeight()+1; - bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false; + int daaForkHeight = GetArg("-daaforkheight", 448450); + int nHeight = pindexPrev->GetHeight()+1; + bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false; // Check Proof-of-Work difficulty if (ishush3) { // The change of blocktime from 150s to 75s caused Weird Stuff in the difficulty/work calculations // caused by the fact that Difficulty Adjustment Algorithms do not take into account blocktime // changing at run-time, which breaks assumptions in the algorithm unsigned int nNextWork = GetNextWorkRequired(pindexPrev, &block, consensusParams); - //if ((nHeight < 340000 || nHeight > 342500) && block.nBits != nNextWork) { + //if ((nHeight < daaheight) && block.nBits != nNextWork) { if (block.nBits != nNextWork) { //cout << "Incorrect HUSH diffbits at height " << nHeight << // " " << block.nBits << " block.nBits vs. calc " << nNextWork << // " " << block.GetHash().ToString() << " @ " << block.GetBlockTime() << endl; - if (nHeight < 340000) { + if (nHeight < daaForkHeight) { return state.DoS(100, error("%s: Incorrect diffbits at height %d", __func__, nHeight), REJECT_INVALID, "bad-diffbits"); } else { LogPrintf("%s: Ignoring nbits calc : %lu vs block %lu\n",__func__, nNextWork, block.nBits ); diff --git a/src/pow.cpp b/src/pow.cpp index e51305faf..ad83a65a5 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -508,13 +508,10 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead // Changing this requires changing many other things and // changes consensus. Have fun -- Duke int64_t AveragingWindowTimespan(int32_t height) { - int64_t AWT = 2550; - /* - int32_t forkHeight = 0; - if (height >= forkHeight) { - AWT = 1275; - } - */ + // used in const methods, beware! + // This is the correct AWT for 75s blocktime, before block 340k + // the correct value was 2550 when the blocktime was 150s + int64_t AWT = 1275; return AWT; } From 95697cfaa81a3eba18ce3d993a24e4c3273ce3b3 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 27 Mar 2021 07:44:50 -0400 Subject: [PATCH 02/19] Enforce DAA fork at correct height --- src/main.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index bb3c4d4dc..01b51a0f9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5038,19 +5038,21 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false; // Check Proof-of-Work difficulty if (ishush3) { - // The change of blocktime from 150s to 75s caused Weird Stuff in the difficulty/work calculations + // The change of blocktime from 150s to 75s caused incorrect AWT of 34 blocks instead of 17 // caused by the fact that Difficulty Adjustment Algorithms do not take into account blocktime - // changing at run-time, which breaks assumptions in the algorithm + // changing at run-time, from Consensus::Params being a const struct unsigned int nNextWork = GetNextWorkRequired(pindexPrev, &block, consensusParams); - //if ((nHeight < daaheight) && block.nBits != nNextWork) { + if (block.nBits != nNextWork) { - //cout << "Incorrect HUSH diffbits at height " << nHeight << - // " " << block.nBits << " block.nBits vs. calc " << nNextWork << - // " " << block.GetHash().ToString() << " @ " << block.GetBlockTime() << endl; - if (nHeight < daaForkHeight) { - return state.DoS(100, error("%s: Incorrect diffbits at height %d", __func__, nHeight), REJECT_INVALID, "bad-diffbits"); + // Enforce correct nbits at DAA fork height, before that, ignore + if (nHeight > daaForkHeight) { + //cout << "Incorrect HUSH diffbits at height " << nHeight << + // " " << block.nBits << " block.nBits vs. calc " << nNextWork << + // " " << block.GetHash().ToString() << " @ " << block.GetBlockTime() << endl; + + return state.DoS(100, error("%s: Incorrect diffbits at height %d", __func__, nHeight), REJECT_INVALID, "bad-diffbits"); } else { - LogPrintf("%s: Ignoring nbits calc : %lu vs block %lu\n",__func__, nNextWork, block.nBits ); + //LogPrintf("%s: Ignoring nbits calc : %lu vs block %lu\n",__func__, nNextWork, block.nBits ); cout << "Ignoring nbits for height=" << nHeight << endl; } } From af5f461d0b5d8381cca944a73553ebfaf7d592a6 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 27 Mar 2021 07:48:45 -0400 Subject: [PATCH 03/19] bump version --- configure.ac | 4 ++-- src/clientversion.h | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 216f612bf..16766d197 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, 3) -define(_CLIENT_VERSION_MINOR, 6) -define(_CLIENT_VERSION_REVISION, 3) +define(_CLIENT_VERSION_MINOR, 7) +define(_CLIENT_VERSION_REVISION, 0) define(_CLIENT_VERSION_BUILD, 50) 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/clientversion.h b/src/clientversion.h index b2f606f64..4f64435bc 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -3,6 +3,7 @@ // Copyright (c) 2016-2021 The Hush developers // Distributed under the GPLv3 software license, see the accompanying // file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html +// What happened to the SuperNET developers, who cared about privacy? /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * @@ -28,8 +29,8 @@ //! These need to be macros, as clientversion.cpp's and bitcoin*-res.rc's voodoo requires it // Must be kept in sync with configure.ac , ugh! #define CLIENT_VERSION_MAJOR 3 -#define CLIENT_VERSION_MINOR 6 -#define CLIENT_VERSION_REVISION 3 +#define CLIENT_VERSION_MINOR 7 +#define CLIENT_VERSION_REVISION 0 #define CLIENT_VERSION_BUILD 50 //! Set to true for release, false for prerelease or test build From 26b340c8cf275cfb5b2a3c4455b9b2d90c4179a7 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 27 Mar 2021 07:59:10 -0400 Subject: [PATCH 04/19] man pages --- doc/man/hush-cli.1 | 8 ++++---- doc/man/hush-tx.1 | 8 ++++---- doc/man/hushd.1 | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/doc/man/hush-cli.1 b/doc/man/hush-cli.1 index 9cb47f7a1..7c381a192 100644 --- a/doc/man/hush-cli.1 +++ b/doc/man/hush-cli.1 @@ -1,9 +1,9 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.6. -.TH HUSH-CLI "1" "February 2021" "hush-cli v3.6.3" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10. +.TH HUSH-CLI "1" "March 2021" "hush-cli v3.7.0" "User Commands" .SH NAME -hush-cli \- manual page for hush-cli v3.6.3 +hush-cli \- manual page for hush-cli v3.7.0 .SH DESCRIPTION -Hush RPC client version v3.6.3\-e1d5c5b73 +Hush RPC client version v3.7.0\-af5f461d0 .PP In order to ensure you are adequately protecting your privacy when using Hush, please see . diff --git a/doc/man/hush-tx.1 b/doc/man/hush-tx.1 index c382b4cff..daba9cb8e 100644 --- a/doc/man/hush-tx.1 +++ b/doc/man/hush-tx.1 @@ -1,9 +1,9 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.6. -.TH HUSH-TX "1" "February 2021" "hush-tx v3.6.3" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10. +.TH HUSH-TX "1" "March 2021" "hush-tx v3.7.0" "User Commands" .SH NAME -hush-tx \- manual page for hush-tx v3.6.3 +hush-tx \- manual page for hush-tx v3.7.0 .SH DESCRIPTION -hush\-tx utility version v3.6.3\-e1d5c5b73 +hush\-tx utility version v3.7.0\-af5f461d0 .SS "Usage:" .TP hush\-tx [options] [commands] diff --git a/doc/man/hushd.1 b/doc/man/hushd.1 index 3f9d28186..5b443aab1 100644 --- a/doc/man/hushd.1 +++ b/doc/man/hushd.1 @@ -1,9 +1,9 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.6. -.TH HUSHD "1" "February 2021" "hushd v3.6.3" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10. +.TH HUSHD "1" "March 2021" "hushd v3.7.0" "User Commands" .SH NAME -hushd \- manual page for hushd v3.6.3 +hushd \- manual page for hushd v3.7.0 .SH DESCRIPTION -Hush Daemon version v3.6.3\-e1d5c5b73 +Hush Daemon version v3.7.0\-af5f461d0 .PP In order to ensure you are adequately protecting your privacy when using Hush, please see . @@ -75,7 +75,7 @@ limit applied) .HP \fB\-par=\fR .IP -Set the number of script verification threads (\fB\-16\fR to 16, 0 = auto, <0 = +Set the number of script verification threads (\fB\-8\fR to 16, 0 = auto, <0 = leave that many cores free, default: 0) .HP \fB\-pid=\fR From bae63f7674a38657911264a3978537869559e6d4 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 27 Mar 2021 18:55:48 -0400 Subject: [PATCH 05/19] Change default daa fork height --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 01b51a0f9..87ddc9669 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5033,7 +5033,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta assert(pindexPrev); - int daaForkHeight = GetArg("-daaforkheight", 448450); + int daaForkHeight = GetArg("-daaforkheight", 450000); int nHeight = pindexPrev->GetHeight()+1; bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false; // Check Proof-of-Work difficulty From d74fc51d2f3ccab32e889ce84a68092327f8a0a5 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 27 Mar 2021 19:11:25 -0400 Subject: [PATCH 06/19] Update checkpoints --- src/chainparams.cpp | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index e44b1643c..ee44d6664 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -728,10 +728,41 @@ void *chainparams_commandline() { (437000, uint256S("0x00000003ce6d4b0ea02f483633abae9da2b71e62e14e08f20af13452ab6814a7")) (438000, uint256S("0x0000000d845b717aec3b273f9cb2d894d3caa05f91b3ad41b6581adfd90b267c")) (439000, uint256S("0x000000099a44794ccf54bcba10780b163b6a369292263df1d8d62d2d58cc7cea")) - (440000, uint256S("0x0000000b741bda60e14a5d668581f60bfb852b09249428ca7c3a59b01db31af0")), - (int64_t) 1614333866, // time of last checkpointed block - (int64_t) 759609, // total txs - (double) 1606 // txs in the last day before block 440133 + (440000, uint256S("0x0000000b741bda60e14a5d668581f60bfb852b09249428ca7c3a59b01db31af0")) + (441000, uint256S("0x000000150189ff4e6b3292d9feaebc1ed741a6c0534f1050cc152ad65d30906a")) + (442000, uint256S("0x0000000fd26b6822fbda02990619e1729b7f8e7cf1c39178b6040893b92a2cc9")) + (443000, uint256S("0x0000000ce6172397f985d9e3bec3d06c87d5606969a602eff9bae3a6a0e0eeae")) + (444000, uint256S("0x00000011997fb375389ecaecca589e722f9e6fbc147570cb39e88db51811d2fb")) + (445000, uint256S("0x0000000643bf6fd35088aecbebca66d313c4e153176b5da42102197164fef65c")) + (446000, uint256S("0x0000000441b5fb7d9c59fc75fb77cbf9b455dc5b4562bae0ce356500d7f422fd")) + (447000, uint256S("0x0000001978b57b5c4e49a03687a9e002a782548263918b6636cdcc36cdb11627")) + (448000, uint256S("0x0000001f1aa382c9ff75b41da17185a61db07569a4d1afa5040b836dbf7e38b0")) + (449000, uint256S("0x0000001bd53db30e282b94504a8fdb36ede55e3d3ce71336ef844df45b25d51a")) + (450000, uint256S("0x0000001648e3028682b133bc209c2538c6c776bd7d3d4b275dffef75db7bb9f4")) + (451000, uint256S("0x0000001c60e7abdebf883831bd899c5dbd8cac1ea68bb0957701e5595c8011b5")) + (452000, uint256S("0x0000000add6e6c36ec20a4e3091195c052a8f9d6498e1e85dbb10c45b70c08d3")) + (453000, uint256S("0x0000000a2bb73fff81add4d521655fe4566b6c656a9790cd2846f6f1ac7061d1")) + (454000, uint256S("0x000000059a0f7d5f1a381c20d485a1ce2bb41cfc8bc5abcbbf736a236732c3e8")) + (455000, uint256S("0x00000008542e9c1e83fdf4f71ad758ae0d372f95d486d93aaa1c448c529f1e6b")) + (456000, uint256S("0x000000093c40dcbb7152bc2561fdee97d0ddd202348db723755e8e47e10a1cf1")) + (457000, uint256S("0x000000176c7bd888c00198072ff533dd5daa7f0dd1991ee478c97ce2576a544f")) + (458000, uint256S("0x00000012f38a317148fa969062776ad7b30362b1901565f07af3045a324df8c5")) + (459000, uint256S("0x00000008f68f2b3b355f3d6c94d3eb2979e000a3817ae8089b4994d0a04ae13e")) + (460000, uint256S("0x0000001220f5bd3de5167b332268f52d056c5943b9334513d4ee138b97782759")) + (461000, uint256S("0x000000017d7c3a8b03f0b761ad56c1f6678d2642fb1d6a1a286e95fb47a43235")) + (462000, uint256S("0x00000001adb35a7234f02de06199ecd27f857b1304655ff9c37bd2c80c7e82c5")) + (463000, uint256S("0x00000015ee085765078c7c32770f4f6d8c38e25b1f16d3e4f3cea6da27a9e026")) + (464000, uint256S("0x000000165b10b74fa665df705954d8eae919bf6e8912fc8a9a4adb90179a4858")) + (465000, uint256S("0x000000051bd8d780ce69151738f6d4a81ea8b93305dd873396bff24835e9e6fb")) + (466000, uint256S("0x00000006cea7acd52ca5e0bbe0b759b5e26ee1d1f65eddd6b545020c4bd5f4a0")) + (467000, uint256S("0x00000018df5117519d46a4b825c2603927fd62a13d180474135a97af6b5a02dd")) + (468000, uint256S("0x0000000acb30c045fa367e947e1785b9bd65c06d5b67494529450f1ebff3f303")) + (469000, uint256S("0x000000097152a491ad065423de4324ada41f3612de5b80ffb585e28d2a11d2c6")) + (470000, uint256S("0x000000043ed32a85a784f1adf8328f80350b3960698c73345951d99ab369275f")) + (471000, uint256S("0x0000000dabe6173ccc2e8be79774c0aed930c8f24a311e466e543b3bbf36be3f")), + (int64_t) 1616870169, // time of last checkpointed block + (int64_t) 797083, // total txs + (double) 2733 // txs in the last day before block 471190 }; } else { checkpointData = //(Checkpoints::CCheckpointData) From 84ac805f1196e2ecee8ac9a3fe800f5eeaa71e13 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 29 Mar 2021 00:43:24 -0400 Subject: [PATCH 07/19] wolfssl 4.7.0 --- depends/packages/wolfssl.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/depends/packages/wolfssl.mk b/depends/packages/wolfssl.mk index d1e9ac08c..aabca3d71 100644 --- a/depends/packages/wolfssl.mk +++ b/depends/packages/wolfssl.mk @@ -1,9 +1,9 @@ package=wolfssl -$(package)_version=4.6.0 +$(package)_version=4.7.0 $(package)_download_path=https://github.com/wolfSSL/wolfssl/archive $(package)_download_file=v$($(package)_version)-stable.tar.gz $(package)_file_name=wolfssl-$($(package)_version).tar.gz -$(package)_sha256_hash=053aefbb02d0b06b27c5e2df6875b4b587318755b7db9d6aa8d72206b310a848 +$(package)_sha256_hash=b0e740b31d4d877d540ad50cc539a8873fc41af02bd3091c4357b403f7106e31 define $(package)_set_vars $(package)_config_env=AR="$($(package)_ar)" RANLIB="$($(package)_ranlib)" CC="$($(package)_cc)" From fe0d371165d885861d340a1d9c7bebe5fe6416dd Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 29 Mar 2021 09:57:03 -0400 Subject: [PATCH 08/19] Improve TLS error reporting --- src/hush/tlsmanager.cpp | 5 ++++- src/hush/utiltls.cpp | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/hush/tlsmanager.cpp b/src/hush/tlsmanager.cpp index 0f38d96fe..75fb17b1f 100644 --- a/src/hush/tlsmanager.cpp +++ b/src/hush/tlsmanager.cpp @@ -425,8 +425,11 @@ bool TLSManager::CheckKeyCert() return false; } - if (wolfSSL_X509_verify(mycert, mykey) == WOLFSSL_SUCCESS) { + int err = wolfSSL_X509_verify(mycert, mykey); + if (err == WOLFSSL_SUCCESS) { return true; + } else { + LogPrintf("%s: x509 verification error: %d = %s\n", __func__, err); } LogPrintf("Generated key and certificate do not match!!!\n"); diff --git a/src/hush/utiltls.cpp b/src/hush/utiltls.cpp index ec8e81c3b..bfddb3724 100644 --- a/src/hush/utiltls.cpp +++ b/src/hush/utiltls.cpp @@ -43,6 +43,7 @@ WOLFSSL_EVP_PKEY* GenerateEcKey(int nid) WOLFSSL_X509* GenerateCertificate(WOLFSSL_EVP_PKEY *keypair) { if (!keypair) { + LogPrintf("%s: Null keypair!\n", __func__); return NULL; } @@ -60,12 +61,17 @@ WOLFSSL_X509* GenerateCertificate(WOLFSSL_EVP_PKEY *keypair) // private key from keypair is used; signature will be set inside of the cert bCertSigned = wolfSSL_X509_sign(cert, keypair, wolfSSL_EVP_sha512()); } + } else { + LogPrintf("%s: Unable to alloc rand bytes!\n", __func__); } if (!bCertSigned) { + LogPrintf("%s: TLS cert not signed correctly!\n", __func__); wolfSSL_X509_free(cert); cert = NULL; } + } else { + LogPrintf("%s: Unable to create x509 cert!\n", __func__); } return cert; From 276c7d6432932de03aa3acec3ee279e6a3d65a54 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 29 Mar 2021 09:58:02 -0400 Subject: [PATCH 09/19] Revert "wolfssl 4.7.0" This reverts commit 84ac805f1196e2ecee8ac9a3fe800f5eeaa71e13. --- depends/packages/wolfssl.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/depends/packages/wolfssl.mk b/depends/packages/wolfssl.mk index aabca3d71..d1e9ac08c 100644 --- a/depends/packages/wolfssl.mk +++ b/depends/packages/wolfssl.mk @@ -1,9 +1,9 @@ package=wolfssl -$(package)_version=4.7.0 +$(package)_version=4.6.0 $(package)_download_path=https://github.com/wolfSSL/wolfssl/archive $(package)_download_file=v$($(package)_version)-stable.tar.gz $(package)_file_name=wolfssl-$($(package)_version).tar.gz -$(package)_sha256_hash=b0e740b31d4d877d540ad50cc539a8873fc41af02bd3091c4357b403f7106e31 +$(package)_sha256_hash=053aefbb02d0b06b27c5e2df6875b4b587318755b7db9d6aa8d72206b310a848 define $(package)_set_vars $(package)_config_env=AR="$($(package)_ar)" RANLIB="$($(package)_ranlib)" CC="$($(package)_cc)" From 78a9f55a82bffef40ce2c0b14669a408bb7b14b6 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 29 Mar 2021 09:59:31 -0400 Subject: [PATCH 10/19] typo --- DEVELOPING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEVELOPING.md b/DEVELOPING.md index 0a10da9f6..0aae790f5 100644 --- a/DEVELOPING.md +++ b/DEVELOPING.md @@ -19,7 +19,7 @@ Divide how many GBs of RAM you have by 2, subtract one. Use that many jobs. ## Dealing with dependency changes -Let's say you change a dependency and want the compile the notice. If your +Let's say you change a dependency and want the compile to notice. If your change is outside of the main Hush source code, in ./src, simply running `make` will not notice, and sometimes not even `build.sh`. You can always do a fresh clone or `make clean`, but that will take a lot of time. Those From fe46773bed010c5ac3a5c24354106d8d8fae4fc7 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 29 Mar 2021 17:46:35 -0400 Subject: [PATCH 11/19] Log more data about incorrect diffbits --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 87ddc9669..dd152dadb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5050,9 +5050,9 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta // " " << block.nBits << " block.nBits vs. calc " << nNextWork << // " " << block.GetHash().ToString() << " @ " << block.GetBlockTime() << endl; - return state.DoS(100, error("%s: Incorrect diffbits at height %d", __func__, nHeight), REJECT_INVALID, "bad-diffbits"); + return state.DoS(100, error("%s: Incorrect diffbits at height %d: %lu vs %lu ", __func__, nHeight, nNextWork, block.nBits), REJECT_INVALID, "bad-diffbits"); } else { - //LogPrintf("%s: Ignoring nbits calc : %lu vs block %lu\n",__func__, nNextWork, block.nBits ); + LogPrintf("%s: Ignoring nbits calc : %lu vs block %lu\n",__func__, nNextWork, block.nBits ); cout << "Ignoring nbits for height=" << nHeight << endl; } } From 84dffacdea32201e469f033728909faa76e0b401 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 29 Mar 2021 17:51:56 -0400 Subject: [PATCH 12/19] More details about invalid RPC replies --- src/bitcoin-cli.cpp | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index bb3c93ace..dbf2e82e9 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -1,9 +1,8 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers -// Copyright (c) 2016-2020 The Hush developers +// Copyright (c) 2016-2021 The Hush developers // Distributed under the GPLv3 software license, see the accompanying // file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html - /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * @@ -18,17 +17,14 @@ * Removal or modification of this copyright notice is prohibited. * * * ******************************************************************************/ - #include "chainparamsbase.h" #include "clientversion.h" #include "rpc/client.h" #include "rpc/protocol.h" #include "util.h" #include "utilstrencodings.h" - #include #include - #include #include #include "support/events.h" @@ -63,15 +59,8 @@ std::string HelpMessageCli() return strUsage; } -////////////////////////////////////////////////////////////////////////////// -// -// Start -// - -// // Exception thrown on connection error. This error is used to determine // when to wait if -rpcwait is given. -// class CConnectionFailed : public std::runtime_error { public: @@ -82,19 +71,15 @@ public: }; -// // This function returns either one of EXIT_ codes when it's expected to stop the process or // CONTINUE_EXECUTION when it's expected to continue further. -// static int AppInitRPC(int argc, char* argv[]) { static_assert(CONTINUE_EXECUTION != EXIT_FAILURE, "CONTINUE_EXECUTION should be different from EXIT_FAILURE"); static_assert(CONTINUE_EXECUTION != EXIT_SUCCESS, "CONTINUE_EXECUTION should be different from EXIT_SUCCESS"); - // // Parameters - // ParseParameters(argc, argv); std:string name; name = GetArg("-ac_name",""); @@ -144,7 +129,6 @@ static int AppInitRPC(int argc, char* argv[]) return CONTINUE_EXECUTION; } - /** Reply structure for request_done to fill in */ struct HTTPReply { @@ -277,7 +261,7 @@ UniValue CallRPC(const std::string& strMethod, const UniValue& params) // Parse reply UniValue valReply(UniValue::VSTR); if (!valReply.read(response.body)) - throw std::runtime_error("couldn't parse reply from server"); + throw std::runtime_error(strprintf("couldn't parse reply from server: %s",response.body)); const UniValue& reply = valReply.get_obj(); if (reply.empty()) throw std::runtime_error("expected reply to have result, error and id properties"); From c051631f6b9846dcc776a988a5b26b4cd55b3f57 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 30 Mar 2021 16:11:13 -0400 Subject: [PATCH 13/19] Log all nbits data and the delta in csv --- src/main.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index dd152dadb..2c7a8d4c0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5043,16 +5043,15 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta // changing at run-time, from Consensus::Params being a const struct unsigned int nNextWork = GetNextWorkRequired(pindexPrev, &block, consensusParams); + LogPrintf("%s: nbits ,%d,%lu,%lu,%d\n",__func__, nHeight, nNextWork, block.nBits, nNextWork - block.nBits ); if (block.nBits != nNextWork) { // Enforce correct nbits at DAA fork height, before that, ignore - if (nHeight > daaForkHeight) { + if (0 && nHeight > daaForkHeight) { //cout << "Incorrect HUSH diffbits at height " << nHeight << // " " << block.nBits << " block.nBits vs. calc " << nNextWork << // " " << block.GetHash().ToString() << " @ " << block.GetBlockTime() << endl; - return state.DoS(100, error("%s: Incorrect diffbits at height %d: %lu vs %lu ", __func__, nHeight, nNextWork, block.nBits), REJECT_INVALID, "bad-diffbits"); } else { - LogPrintf("%s: Ignoring nbits calc : %lu vs block %lu\n",__func__, nNextWork, block.nBits ); cout << "Ignoring nbits for height=" << nHeight << endl; } } From 93a931bbd271f81258bd09f6b1027add3e691fc6 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 30 Mar 2021 20:12:06 -0400 Subject: [PATCH 14/19] Hush has no JoinSplits --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 2c7a8d4c0..9b314281c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3160,7 +3160,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin int32_t futureblock; CAmount blockReward = GetBlockSubsidy(pindex->GetHeight(), chainparams.GetConsensus()); uint64_t notarypaycheque = 0; - // Check it again to verify JoinSplit proofs, and in case a previous version let a bad block in + + // Check it again to verify ztx proofs, and in case a previous version let a bad block in if ( !CheckBlock(&futureblock,pindex->GetHeight(),pindex,block, state, fExpensiveChecks ? verifier : disabledVerifier, fCheckPOW, !fJustCheck) || futureblock != 0 ) { //fprintf(stderr,"checkblock failure in connectblock futureblock.%d\n",futureblock); From 869169570e78598bedc209e2fdc4688bc7d6b104 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 31 Mar 2021 14:22:10 -0400 Subject: [PATCH 15/19] Calculate nBits correctly when checking the first block header we see after startup --- src/main.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 9b314281c..76a825d1e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5039,6 +5039,13 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false; // Check Proof-of-Work difficulty if (ishush3) { + + // Difficulty (nBits) relies on the current blocktime of this block + if ((ASSETCHAINS_BLOCKTIME != 75) && (nHeight >= nFirstHalvingHeight)) { + LogPrintf("%s: Blocktime halving to 75s at height %d!\n",__func__,nHeight); + ASSETCHAINS_BLOCKTIME = 75; + hush_changeblocktime(); + } // The change of blocktime from 150s to 75s caused incorrect AWT of 34 blocks instead of 17 // caused by the fact that Difficulty Adjustment Algorithms do not take into account blocktime // changing at run-time, from Consensus::Params being a const struct From d202b05d552a3616db824b353fb1554c7e25ec9b Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 31 Mar 2021 14:47:46 -0400 Subject: [PATCH 16/19] Enforce nBits starting at daaForkHeight --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 76a825d1e..9f1310cc7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5054,7 +5054,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta LogPrintf("%s: nbits ,%d,%lu,%lu,%d\n",__func__, nHeight, nNextWork, block.nBits, nNextWork - block.nBits ); if (block.nBits != nNextWork) { // Enforce correct nbits at DAA fork height, before that, ignore - if (0 && nHeight > daaForkHeight) { + if (nHeight > daaForkHeight) { //cout << "Incorrect HUSH diffbits at height " << nHeight << // " " << block.nBits << " block.nBits vs. calc " << nNextWork << // " " << block.GetHash().ToString() << " @ " << block.GetBlockTime() << endl; From bb67868a5bb3498267993dc80fd09e6d7687c266 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 31 Mar 2021 14:48:44 -0400 Subject: [PATCH 17/19] Remove dead code --- src/main.cpp | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9f1310cc7..476d87a36 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5381,33 +5381,6 @@ static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned void hush_currentheight_set(int32_t height); -CBlockIndex *komodo_ensure(CBlock *pblock, uint256 hash) -{ - CBlockIndex *pindex = 0; - BlockMap::iterator miSelf = mapBlockIndex.find(hash); - if ( miSelf != mapBlockIndex.end() ) - { - if ( (pindex = miSelf->second) == 0 ) // create pindex so first Accept block doesnt fail - { - miSelf->second = AddToBlockIndex(*pblock); - //fprintf(stderr,"Block header %s is already known, but without pindex -> ensured %p\n",hash.ToString().c_str(),miSelf->second); - } - /*if ( hash != Params().GetConsensus().hashGenesisBlock ) - { - miSelf = mapBlockIndex.find(pblock->hashPrevBlock); - if ( miSelf != mapBlockIndex.end() ) - { - if ( miSelf->second == 0 ) - { - miSelf->second = InsertBlockIndex(pblock->hashPrevBlock); - fprintf(stderr,"autocreate previndex %s\n",pblock->hashPrevBlock.ToString().c_str()); - } - } - }*/ - } - return(pindex); -} - bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNode* pfrom, CBlock* pblock, bool fForceProcessing, CDiskBlockPos *dbp) { // Preliminary checks From 187933077a18aa948974722ce603d2f160c95032 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 31 Mar 2021 15:45:24 -0400 Subject: [PATCH 18/19] Require -debug for CalculateNextWorkRequired details --- src/pow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pow.cpp b/src/pow.cpp index ad83a65a5..ab38f1174 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -557,11 +557,11 @@ unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg, LogPrint("pow", "AveragingWindowTimespan = %d nActualTimespan = %d\n", AWT, nActualTimespan); LogPrint("pow", "Current average: %08x %s\n", bnAvg.GetCompact(), bnAvg.ToString()); LogPrint("pow", "After: %08x %s\n", bnNew.GetCompact(), bnNew.ToString()); - //if(fDebug) { + if(fDebug) { fprintf(stderr, "%s: nbits Current average: %08x %s\n", __func__, bnAvg.GetCompact(), bnAvg.ToString().c_str()); fprintf(stderr, "%s: bits After: %08x %s\n", __func__, bnNew.GetCompact(), bnNew.ToString().c_str()); fprintf(stderr,"%s: AWT=%lu ActualTimeSpan=%li MinActual=%li MaxActual=%li\n",__func__, AWT, nActualTimespan, params.MinActualTimespan(), params.MaxActualTimespan()); - //} + } return bnNew.GetCompact(); } From 585bf3443207a68133d30c3beefc7f847b407f59 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 31 Mar 2021 15:47:12 -0400 Subject: [PATCH 19/19] Checkpoints --- src/chainparams.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index ee44d6664..955996a6f 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -759,10 +759,14 @@ void *chainparams_commandline() { (468000, uint256S("0x0000000acb30c045fa367e947e1785b9bd65c06d5b67494529450f1ebff3f303")) (469000, uint256S("0x000000097152a491ad065423de4324ada41f3612de5b80ffb585e28d2a11d2c6")) (470000, uint256S("0x000000043ed32a85a784f1adf8328f80350b3960698c73345951d99ab369275f")) - (471000, uint256S("0x0000000dabe6173ccc2e8be79774c0aed930c8f24a311e466e543b3bbf36be3f")), - (int64_t) 1616870169, // time of last checkpointed block - (int64_t) 797083, // total txs - (double) 2733 // txs in the last day before block 471190 + (471000, uint256S("0x0000000dabe6173ccc2e8be79774c0aed930c8f24a311e466e543b3bbf36be3f")) + (472000, uint256S("0x0000001f727ffbe5b1ad17206c060aa77e9b20257f1764f1ac018a0f64f19bd1")) + (473000, uint256S("0x0000000b7ee1e1d0f6b577c02a924733d2c4d6d5805daa51e44e543eadacba8b")) + (474000, uint256S("0x0000001260b7935e520244a3591cb6b37de3b36c45dae5318f0bb7eda6847e17")) + (475000, uint256S("0x0000000db956f0dcecc58ccfc8463f49910d455fc3c223ab36a93c5c468513cc")), + (int64_t) 1617173192, // time of last checkpointed block + (int64_t) 809511, // total txs + (double) 3228 // txs in the last day before block 475640 }; } else { checkpointData = //(Checkpoints::CCheckpointData)