From a6924bb0618605c5e615d903412db1267dafb246 Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 23 Apr 2023 06:29:48 -0700 Subject: [PATCH 01/45] Give a useful message if autoconf is not installed --- util/build.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/util/build.sh b/util/build.sh index 4af38908f..3f45f1b59 100755 --- a/util/build.sh +++ b/util/build.sh @@ -11,6 +11,12 @@ if ! [ -x "$(command -v cmake)" ]; then exit 1 fi +if ! [ -x "$(command -v autoreconf)" ]; then + echo 'Error: autoconf is not installed. Install autoconf and try again.' >&2 + echo 'On Debian-like systems: apt install autoconf' >&2 + exit 1 +fi + function cmd_pref() { if type -p "$2" > /dev/null; then eval "$1=$2" From b3a6c2bee18a41342db83eb64feebf502e8be8c9 Mon Sep 17 00:00:00 2001 From: jahway603 Date: Mon, 15 May 2023 13:47:05 -0400 Subject: [PATCH 02/45] Import RandomX from https://github.com/tevador/RandomX/commit/040f4500a6e79d54d84a668013a94507045e786f without audits/ directory --- src/RandomX/CMakeLists.txt | 2 +- src/RandomX/src/allocator.cpp | 9 ++-- src/RandomX/src/configuration.h | 10 ++-- src/RandomX/src/dataset.cpp | 2 +- src/RandomX/src/intrin_portable.h | 72 ++++++++++++++-------------- src/RandomX/src/jit_compiler_a64.cpp | 4 +- src/RandomX/src/jit_compiler_x86.cpp | 4 +- src/RandomX/src/randomx.cpp | 12 +++-- src/RandomX/src/tests/utility.hpp | 1 + 9 files changed, 65 insertions(+), 51 deletions(-) diff --git a/src/RandomX/CMakeLists.txt b/src/RandomX/CMakeLists.txt index f41f606b9..4b6ba9e6e 100644 --- a/src/RandomX/CMakeLists.txt +++ b/src/RandomX/CMakeLists.txt @@ -39,7 +39,7 @@ src/bytecode_machine.cpp src/cpu.cpp src/dataset.cpp src/soft_aes.cpp -src/virtual_memory.cpp +src/virtual_memory.c src/vm_interpreted.cpp src/allocator.cpp src/assembly_generator_x86.cpp diff --git a/src/RandomX/src/allocator.cpp b/src/RandomX/src/allocator.cpp index 4c6d86e05..bcee0f6b6 100644 --- a/src/RandomX/src/allocator.cpp +++ b/src/RandomX/src/allocator.cpp @@ -29,7 +29,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include "allocator.hpp" #include "intrin_portable.h" -#include "virtual_memory.hpp" +#include "virtual_memory.h" #include "common.hpp" namespace randomx { @@ -50,11 +50,14 @@ namespace randomx { template struct AlignedAllocator; void* LargePageAllocator::allocMemory(size_t count) { - return allocLargePagesMemory(count); + void *mem = allocLargePagesMemory(count); + if (mem == nullptr) + throw std::bad_alloc(); + return mem; } void LargePageAllocator::freeMemory(void* ptr, size_t count) { freePagedMemory(ptr, count); }; -} \ No newline at end of file +} diff --git a/src/RandomX/src/configuration.h b/src/RandomX/src/configuration.h index f74a74a4c..84400ddce 100644 --- a/src/RandomX/src/configuration.h +++ b/src/RandomX/src/configuration.h @@ -32,13 +32,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define RANDOMX_ARGON_MEMORY 262144 //Number of Argon2d iterations for Cache initialization. -#define RANDOMX_ARGON_ITERATIONS 5 +#define RANDOMX_ARGON_ITERATIONS 3 //Number of parallel lanes for Cache initialization. #define RANDOMX_ARGON_LANES 1 //Argon2d salt -#define RANDOMX_ARGON_SALT "RandomXHUSH\x03" +#define RANDOMX_ARGON_SALT "RandomX\x03" //Number of random Cache accesses per Dataset item. Minimum is 2. #define RANDOMX_CACHE_ACCESSES 8 @@ -53,13 +53,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define RANDOMX_DATASET_EXTRA_SIZE 33554368 //Number of instructions in a RandomX program. Must be divisible by 8. -#define RANDOMX_PROGRAM_SIZE 512 +#define RANDOMX_PROGRAM_SIZE 256 //Number of iterations during VM execution. -#define RANDOMX_PROGRAM_ITERATIONS 4096 +#define RANDOMX_PROGRAM_ITERATIONS 2048 //Number of chained VM executions per hash. -#define RANDOMX_PROGRAM_COUNT 16 +#define RANDOMX_PROGRAM_COUNT 8 //Scratchpad L3 size in bytes. Must be a power of 2. #define RANDOMX_SCRATCHPAD_L3 2097152 diff --git a/src/RandomX/src/dataset.cpp b/src/RandomX/src/dataset.cpp index 675c5abc5..7ebf1bca4 100644 --- a/src/RandomX/src/dataset.cpp +++ b/src/RandomX/src/dataset.cpp @@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "common.hpp" #include "dataset.hpp" -#include "virtual_memory.hpp" +#include "virtual_memory.h" #include "superscalar.hpp" #include "blake2_generator.hpp" #include "reciprocal.h" diff --git a/src/RandomX/src/intrin_portable.h b/src/RandomX/src/intrin_portable.h index 05f6cd33b..8c09ae885 100644 --- a/src/RandomX/src/intrin_portable.h +++ b/src/RandomX/src/intrin_portable.h @@ -337,19 +337,19 @@ FORCE_INLINE int rx_vec_i128_w(rx_vec_i128 a) { return _a.i32[3]; } -FORCE_INLINE rx_vec_i128 rx_set_int_vec_i128(int _I3, int _I2, int _I1, int _I0) { - return (rx_vec_i128)((__m128li){_I0,_I1,_I2,_I3}); +FORCE_INLINE rx_vec_i128 rx_set_int_vec_i128(int i3, int i2, int i1, int i0) { + return (rx_vec_i128)((__m128li){i0,i1,i2,i3}); }; -FORCE_INLINE rx_vec_i128 rx_xor_vec_i128(rx_vec_i128 _A, rx_vec_i128 _B) { - return (rx_vec_i128)vec_xor(_A,_B); +FORCE_INLINE rx_vec_i128 rx_xor_vec_i128(rx_vec_i128 a, rx_vec_i128 b) { + return (rx_vec_i128)vec_xor(a,b); } -FORCE_INLINE rx_vec_i128 rx_load_vec_i128(rx_vec_i128 const *_P) { +FORCE_INLINE rx_vec_i128 rx_load_vec_i128(rx_vec_i128 const *p) { #if defined(NATIVE_LITTLE_ENDIAN) - return *_P; + return *p; #else - uint32_t* ptr = (uint32_t*)_P; + uint32_t* ptr = (uint32_t*)p; vec_u c; c.u32[0] = load32(ptr + 0); c.u32[1] = load32(ptr + 1); @@ -359,13 +359,13 @@ FORCE_INLINE rx_vec_i128 rx_load_vec_i128(rx_vec_i128 const *_P) { #endif } -FORCE_INLINE void rx_store_vec_i128(rx_vec_i128 *_P, rx_vec_i128 _B) { +FORCE_INLINE void rx_store_vec_i128(rx_vec_i128 *p, rx_vec_i128 b) { #if defined(NATIVE_LITTLE_ENDIAN) - *_P = _B; + *p = b; #else - uint32_t* ptr = (uint32_t*)_P; + uint32_t* ptr = (uint32_t*)p; vec_u B; - B.i = _B; + B.i = b; store32(ptr + 0, B.u32[0]); store32(ptr + 1, B.u32[1]); store32(ptr + 2, B.u32[2]); @@ -487,12 +487,12 @@ FORCE_INLINE int rx_vec_i128_w(rx_vec_i128 a) { return vgetq_lane_s32(vreinterpretq_s32_u8(a), 3); } -FORCE_INLINE rx_vec_i128 rx_set_int_vec_i128(int _I3, int _I2, int _I1, int _I0) { +FORCE_INLINE rx_vec_i128 rx_set_int_vec_i128(int i3, int i2, int i1, int i0) { int32_t data[4]; - data[0] = _I0; - data[1] = _I1; - data[2] = _I2; - data[3] = _I3; + data[0] = i0; + data[1] = i1; + data[2] = i2; + data[3] = i3; return vreinterpretq_u8_s32(vld1q_s32(data)); }; @@ -662,29 +662,29 @@ FORCE_INLINE int rx_vec_i128_w(rx_vec_i128 a) { return a.u32[3]; } -FORCE_INLINE rx_vec_i128 rx_set_int_vec_i128(int _I3, int _I2, int _I1, int _I0) { +FORCE_INLINE rx_vec_i128 rx_set_int_vec_i128(int i3, int i2, int i1, int i0) { rx_vec_i128 v; - v.u32[0] = _I0; - v.u32[1] = _I1; - v.u32[2] = _I2; - v.u32[3] = _I3; + v.u32[0] = i0; + v.u32[1] = i1; + v.u32[2] = i2; + v.u32[3] = i3; return v; }; -FORCE_INLINE rx_vec_i128 rx_xor_vec_i128(rx_vec_i128 _A, rx_vec_i128 _B) { +FORCE_INLINE rx_vec_i128 rx_xor_vec_i128(rx_vec_i128 a, rx_vec_i128 b) { rx_vec_i128 c; - c.u32[0] = _A.u32[0] ^ _B.u32[0]; - c.u32[1] = _A.u32[1] ^ _B.u32[1]; - c.u32[2] = _A.u32[2] ^ _B.u32[2]; - c.u32[3] = _A.u32[3] ^ _B.u32[3]; + c.u32[0] = a.u32[0] ^ b.u32[0]; + c.u32[1] = a.u32[1] ^ b.u32[1]; + c.u32[2] = a.u32[2] ^ b.u32[2]; + c.u32[3] = a.u32[3] ^ b.u32[3]; return c; } -FORCE_INLINE rx_vec_i128 rx_load_vec_i128(rx_vec_i128 const*_P) { +FORCE_INLINE rx_vec_i128 rx_load_vec_i128(rx_vec_i128 const* p) { #if defined(NATIVE_LITTLE_ENDIAN) - return *_P; + return *p; #else - uint32_t* ptr = (uint32_t*)_P; + uint32_t* ptr = (uint32_t*)p; rx_vec_i128 c; c.u32[0] = load32(ptr + 0); c.u32[1] = load32(ptr + 1); @@ -694,15 +694,15 @@ FORCE_INLINE rx_vec_i128 rx_load_vec_i128(rx_vec_i128 const*_P) { #endif } -FORCE_INLINE void rx_store_vec_i128(rx_vec_i128 *_P, rx_vec_i128 _B) { +FORCE_INLINE void rx_store_vec_i128(rx_vec_i128 *p, rx_vec_i128 b) { #if defined(NATIVE_LITTLE_ENDIAN) - *_P = _B; + *p = b; #else - uint32_t* ptr = (uint32_t*)_P; - store32(ptr + 0, _B.u32[0]); - store32(ptr + 1, _B.u32[1]); - store32(ptr + 2, _B.u32[2]); - store32(ptr + 3, _B.u32[3]); + uint32_t* ptr = (uint32_t*)p; + store32(ptr + 0, b.u32[0]); + store32(ptr + 1, b.u32[1]); + store32(ptr + 2, b.u32[2]); + store32(ptr + 3, b.u32[3]); #endif } diff --git a/src/RandomX/src/jit_compiler_a64.cpp b/src/RandomX/src/jit_compiler_a64.cpp index e45774e93..91e31d640 100644 --- a/src/RandomX/src/jit_compiler_a64.cpp +++ b/src/RandomX/src/jit_compiler_a64.cpp @@ -31,7 +31,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "superscalar.hpp" #include "program.hpp" #include "reciprocal.h" -#include "virtual_memory.hpp" +#include "virtual_memory.h" namespace ARMV8A { @@ -93,6 +93,8 @@ JitCompilerA64::JitCompilerA64() , literalPos(ImulRcpLiteralsEnd) , num32bitLiterals(0) { + if (code == nullptr) + throw std::runtime_error("allocMemoryPages"); memset(reg_changed_offset, 0, sizeof(reg_changed_offset)); memcpy(code, (void*) randomx_program_aarch64, CodeSize); diff --git a/src/RandomX/src/jit_compiler_x86.cpp b/src/RandomX/src/jit_compiler_x86.cpp index e75f76328..96c6492fc 100644 --- a/src/RandomX/src/jit_compiler_x86.cpp +++ b/src/RandomX/src/jit_compiler_x86.cpp @@ -34,7 +34,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "superscalar.hpp" #include "program.hpp" #include "reciprocal.h" -#include "virtual_memory.hpp" +#include "virtual_memory.h" namespace randomx { /* @@ -225,6 +225,8 @@ namespace randomx { JitCompilerX86::JitCompilerX86() { code = (uint8_t*)allocMemoryPages(CodeSize); + if (code == nullptr) + throw std::runtime_error("allocMemoryPages"); memcpy(code, codePrologue, prologueSize); memcpy(code + epilogueOffset, codeEpilogue, epilogueSize); } diff --git a/src/RandomX/src/randomx.cpp b/src/RandomX/src/randomx.cpp index 7d239f6fa..7daaa46df 100644 --- a/src/RandomX/src/randomx.cpp +++ b/src/RandomX/src/randomx.cpp @@ -113,6 +113,10 @@ extern "C" { cache = nullptr; } } + if (cache && cache->memory == nullptr) { + randomx_release_cache(cache); + cache = nullptr; + } return cache; } @@ -130,9 +134,7 @@ extern "C" { void randomx_release_cache(randomx_cache* cache) { assert(cache != nullptr); - if (cache->memory != nullptr) { - cache->dealloc(cache); - } + cache->dealloc(cache); delete cache; } @@ -162,6 +164,10 @@ extern "C" { dataset = nullptr; } } + if (dataset && dataset->memory == nullptr) { + randomx_release_dataset(dataset); + dataset = nullptr; + } return dataset; } diff --git a/src/RandomX/src/tests/utility.hpp b/src/RandomX/src/tests/utility.hpp index 92723b979..ceb33d9fd 100644 --- a/src/RandomX/src/tests/utility.hpp +++ b/src/RandomX/src/tests/utility.hpp @@ -32,6 +32,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include constexpr char hexmap[] = "0123456789abcdef"; inline void outputHex(std::ostream& os, const char* data, int length) { From c902701715d4d29774ca3e2d1feabe0f3c5ba7a4 Mon Sep 17 00:00:00 2001 From: jahway603 Date: Mon, 15 May 2023 13:55:20 -0400 Subject: [PATCH 03/45] unfuxing to fix https://git.hush.is/hush/hush3/issues/293 --- src/RandomX/CMakeLists.txt | 2 +- src/RandomX/src/allocator.cpp | 2 +- src/RandomX/src/configuration.h | 10 +++++----- src/RandomX/src/dataset.cpp | 2 +- src/RandomX/src/jit_compiler_a64.cpp | 2 +- src/RandomX/src/jit_compiler_x86.cpp | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/RandomX/CMakeLists.txt b/src/RandomX/CMakeLists.txt index 4b6ba9e6e..f41f606b9 100644 --- a/src/RandomX/CMakeLists.txt +++ b/src/RandomX/CMakeLists.txt @@ -39,7 +39,7 @@ src/bytecode_machine.cpp src/cpu.cpp src/dataset.cpp src/soft_aes.cpp -src/virtual_memory.c +src/virtual_memory.cpp src/vm_interpreted.cpp src/allocator.cpp src/assembly_generator_x86.cpp diff --git a/src/RandomX/src/allocator.cpp b/src/RandomX/src/allocator.cpp index bcee0f6b6..6b48a7e70 100644 --- a/src/RandomX/src/allocator.cpp +++ b/src/RandomX/src/allocator.cpp @@ -29,7 +29,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include "allocator.hpp" #include "intrin_portable.h" -#include "virtual_memory.h" +#include "virtual_memory.hpp" #include "common.hpp" namespace randomx { diff --git a/src/RandomX/src/configuration.h b/src/RandomX/src/configuration.h index 84400ddce..f74a74a4c 100644 --- a/src/RandomX/src/configuration.h +++ b/src/RandomX/src/configuration.h @@ -32,13 +32,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define RANDOMX_ARGON_MEMORY 262144 //Number of Argon2d iterations for Cache initialization. -#define RANDOMX_ARGON_ITERATIONS 3 +#define RANDOMX_ARGON_ITERATIONS 5 //Number of parallel lanes for Cache initialization. #define RANDOMX_ARGON_LANES 1 //Argon2d salt -#define RANDOMX_ARGON_SALT "RandomX\x03" +#define RANDOMX_ARGON_SALT "RandomXHUSH\x03" //Number of random Cache accesses per Dataset item. Minimum is 2. #define RANDOMX_CACHE_ACCESSES 8 @@ -53,13 +53,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define RANDOMX_DATASET_EXTRA_SIZE 33554368 //Number of instructions in a RandomX program. Must be divisible by 8. -#define RANDOMX_PROGRAM_SIZE 256 +#define RANDOMX_PROGRAM_SIZE 512 //Number of iterations during VM execution. -#define RANDOMX_PROGRAM_ITERATIONS 2048 +#define RANDOMX_PROGRAM_ITERATIONS 4096 //Number of chained VM executions per hash. -#define RANDOMX_PROGRAM_COUNT 8 +#define RANDOMX_PROGRAM_COUNT 16 //Scratchpad L3 size in bytes. Must be a power of 2. #define RANDOMX_SCRATCHPAD_L3 2097152 diff --git a/src/RandomX/src/dataset.cpp b/src/RandomX/src/dataset.cpp index 7ebf1bca4..675c5abc5 100644 --- a/src/RandomX/src/dataset.cpp +++ b/src/RandomX/src/dataset.cpp @@ -42,7 +42,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "common.hpp" #include "dataset.hpp" -#include "virtual_memory.h" +#include "virtual_memory.hpp" #include "superscalar.hpp" #include "blake2_generator.hpp" #include "reciprocal.h" diff --git a/src/RandomX/src/jit_compiler_a64.cpp b/src/RandomX/src/jit_compiler_a64.cpp index 91e31d640..fc4634868 100644 --- a/src/RandomX/src/jit_compiler_a64.cpp +++ b/src/RandomX/src/jit_compiler_a64.cpp @@ -31,7 +31,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "superscalar.hpp" #include "program.hpp" #include "reciprocal.h" -#include "virtual_memory.h" +#include "virtual_memory.hpp" namespace ARMV8A { diff --git a/src/RandomX/src/jit_compiler_x86.cpp b/src/RandomX/src/jit_compiler_x86.cpp index 96c6492fc..5587e6afb 100644 --- a/src/RandomX/src/jit_compiler_x86.cpp +++ b/src/RandomX/src/jit_compiler_x86.cpp @@ -34,7 +34,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "superscalar.hpp" #include "program.hpp" #include "reciprocal.h" -#include "virtual_memory.h" +#include "virtual_memory.hpp" namespace randomx { /* From 121ec4b9d43b8a122141499496fbea5409d425d4 Mon Sep 17 00:00:00 2001 From: jahway603 Date: Tue, 16 May 2023 17:29:13 -0400 Subject: [PATCH 04/45] successfully built with gcc13.x --- src/util/string.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/util/string.h b/src/util/string.h index a10a59df7..13a6154a8 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -15,6 +15,7 @@ #include #include #include +#include [[nodiscard]] inline std::string TrimString(const std::string& str, const std::string& pattern = " \f\n\r\t\v") { From 95080951861e7756f7e9fcb58a20cc174deee2e9 Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 29 Jun 2023 11:48:30 -0400 Subject: [PATCH 05/45] Remove unused code --- src/cc/CCMarmara.h | 53 --------------------------------------------- src/cc/CCcustom.cpp | 12 ---------- 2 files changed, 65 deletions(-) delete mode 100644 src/cc/CCMarmara.h diff --git a/src/cc/CCMarmara.h b/src/cc/CCMarmara.h deleted file mode 100644 index 58b8072b6..000000000 --- a/src/cc/CCMarmara.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) 2016-2023 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. * - * * - * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * - * the top-level directory of this distribution for the individual copyright * - * holder information and the developer policies on copyright and licensing. * - * * - * Unless otherwise agreed in a custom licensing agreement, no part of the * - * SuperNET software, including this file may be copied, modified, propagated * - * or distributed except according to the terms contained in the LICENSE file * - * * - * Removal or modification of this copyright notice is prohibited. * - * * - ******************************************************************************/ - - -#ifndef CC_MARMARA_H -#define CC_MARMARA_H - -/* - -#include "CCinclude.h" -#include "../hush_cJSON.h" - -#define MARMARA_GROUPSIZE 60 -#define MARMARA_MINLOCK (1440 * 3 * 30) -#define MARMARA_MAXLOCK (1440 * 24 * 30) -#define MARMARA_VINS 16 -#define EVAL_MARMARA 0xef - -extern uint8_t ASSETCHAINS_MARMARA; -uint64_t hush_block_prg(uint32_t nHeight); -int32_t MarmaraGetcreatetxid(uint256 &createtxid,uint256 txid); -int32_t MarmaraGetbatontxid(std::vector &creditloop,uint256 &batontxid,uint256 txid); -UniValue MarmaraCreditloop(uint256 txid); -UniValue MarmaraSettlement(uint64_t txfee,uint256 batontxid); -UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height); - -UniValue MarmaraPoolPayout(uint64_t txfee,int32_t firstheight,double perc,char *jsonstr); // [[pk0, shares0], [pk1, shares1], ...] -UniValue MarmaraReceive(uint64_t txfee,CPubKey senderpk,int64_t amount,std::string currency,int32_t matures,uint256 batontxid,bool automaticflag); -UniValue MarmaraIssue(uint64_t txfee,uint8_t funcid,CPubKey receiverpk,int64_t amount,std::string currency,int32_t matures,uint256 approvaltxid,uint256 batontxid); -UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_t minamount,int64_t maxamount,std::string currency); - -bool MarmaraValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); - -// CCcustom -UniValue MarmaraInfo(); -*/ - -#endif diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index b463df52b..005fb1def 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -30,7 +30,6 @@ #include "CCOracles.h" #include "CCPrices.h" #include "CCPegs.h" -#include "CCMarmara.h" #include "CCPayments.h" #include "CCGateways.h" #include "CCtokens.h" @@ -192,17 +191,6 @@ uint8_t PegsCCpriv[32] = { 0x52, 0x56, 0x4c, 0x78, 0x87, 0xf7, 0xa2, 0x39, 0xb0, #undef FUNCNAME #undef EVALCODE -// Marmara -#define FUNCNAME IsMarmaraInput -#define EVALCODE EVAL_MARMARA -const char *MarmaraCCaddr = "RGLSRDnUqTB43bYtRtNVgmwSSd1sun2te8"; -const char *MarmaraNormaladdr = "RMN25Tn8NNzcyQDiQNuMp8UmwLMFd9thYc"; -char MarmaraCChexstr[67] = { "03afc5be570d0ff419425cfcc580cc762ab82baad88c148f5b028d7db7bfeee61d" }; -uint8_t MarmaraCCpriv[32] = { 0x7c, 0x0b, 0x54, 0x9b, 0x65, 0xd4, 0x89, 0x57, 0xdf, 0x05, 0xfe, 0xa2, 0x62, 0x41, 0xa9, 0x09, 0x0f, 0x2a, 0x6b, 0x11, 0x2c, 0xbe, 0xbd, 0x06, 0x31, 0x8d, 0xc0, 0xb9, 0x96, 0x76, 0x3f, 0x24 }; -#include "CCcustom.inc" -#undef FUNCNAME -#undef EVALCODE - // Payments #define FUNCNAME IsPaymentsInput #define EVALCODE EVAL_PAYMENTS From 03071ef0cdf4cb1d854b3fcffbddde787f24a86e Mon Sep 17 00:00:00 2001 From: nullfekt <118863467+nullfekt@users.noreply.github.com> Date: Thu, 29 Jun 2023 20:23:28 -0400 Subject: [PATCH 06/45] Bump version --- configure.ac | 2 +- src/clientversion.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index aa424d534..728795f41 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 3) dnl Must be kept in sync with src/clientversion.h , ugh! define(_CLIENT_VERSION_MINOR, 9) -define(_CLIENT_VERSION_REVISION, 3) +define(_CLIENT_VERSION_REVISION, 4) 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 86489bafb..235661630 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -30,7 +30,7 @@ // Must be kept in sync with configure.ac , ugh! #define CLIENT_VERSION_MAJOR 3 #define CLIENT_VERSION_MINOR 9 -#define CLIENT_VERSION_REVISION 3 +#define CLIENT_VERSION_REVISION 4 #define CLIENT_VERSION_BUILD 50 //! Set to true for release, false for prerelease or test build From 27b2a4974078cb037bd5539289ce3add953d0b46 Mon Sep 17 00:00:00 2001 From: nullfekt <118863467+nullfekt@users.noreply.github.com> Date: Thu, 29 Jun 2023 20:38:09 -0400 Subject: [PATCH 07/45] Update README.md --- doc/relnotes/README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/doc/relnotes/README.md b/doc/relnotes/README.md index 39c56e213..2de5dc92a 100644 --- a/doc/relnotes/README.md +++ b/doc/relnotes/README.md @@ -10,6 +10,27 @@ and no longer on Github, since they banned Duke Leto and also because they censor many people around the world and work with evil organizations. +# Hush 3.9.4 "Maniacal Manticore" + +This is an OPTIONAL release. It is recommended for exchanges, solo miners and mining pools to update to this release. + + * New features and improvements + * DragonX now has checkpoints for faster syncing. + * Rate limiting for the processing of incoming addr messages for increased security. + * Removed unused function CWalletTx::GetRequestCount + * Removed mapRequest tracking that only affects Qt display. + * Randomized message processing peer order for increased privacy. + * Removed BIP35 mempool p2p message for increased privacy. + * Build Improvements + * Use custom jobs param when compiling boost for faster compile times + * Now builds with gcc13 thanks to testing from jahway + * We have an aarch64 deb now thanks to jahway + * Bug fixes: + * -stratumallowip works with CIDR and netmask ranges again for solo miners + * Detect missing autoreconf in build.sh + * Various assertions removed from BIP155 changes in previous release. + + # Hush 3.9.3 "Lateral Larvacean" ``` From 44595d5abe6cbf9ed8e74d9e74cc0cdd70725ed0 Mon Sep 17 00:00:00 2001 From: nullfekt <118863467+nullfekt@users.noreply.github.com> Date: Thu, 29 Jun 2023 20:54:20 -0400 Subject: [PATCH 08/45] Add additional community seed node --- contrib/seeds/nodes_main.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contrib/seeds/nodes_main.txt b/contrib/seeds/nodes_main.txt index 9cd90fe9e..0d5e68fd4 100644 --- a/contrib/seeds/nodes_main.txt +++ b/contrib/seeds/nodes_main.txt @@ -16,6 +16,9 @@ # lite.hushpool.is 149.28.102.219 +# lite2.hushpool.is +155.138.228.68 + # wtfistheinternet.hush.is 107.174.70.251 From b7359ef70e0d736c4584d9e6863656acd6cbd5ed Mon Sep 17 00:00:00 2001 From: fekt Date: Thu, 29 Jun 2023 21:16:46 -0400 Subject: [PATCH 09/45] Update chainparamsseeds.h --- src/chainparamsseeds.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/chainparamsseeds.h b/src/chainparamsseeds.h index 1fd92af93..54125e3c4 100644 --- a/src/chainparamsseeds.h +++ b/src/chainparamsseeds.h @@ -17,6 +17,7 @@ static const uint8_t chainparams_seed_main[] = { 0x01,0x04,0x57,0xfb,0x4c,0x21,0x00,0x00, // 87.251.76.33 0x01,0x04,0x89,0x4a,0x04,0xc6,0x00,0x00, // 137.74.4.198 0x01,0x04,0x95,0x1c,0x66,0xdb,0x00,0x00, // 149.28.102.219 + 0x01,0x04,0x9b,0x8a,0xe4,0x44,0x00,0x00, // 155.138.228.68 0x01,0x04,0x6b,0xae,0x46,0xfb,0x00,0x00, // 107.174.70.251 0x04,0x20,0xef,0xad,0x0c,0x95,0x3e,0x61,0xee,0x69,0x57,0x67,0xdb,0x4f,0xb7,0x8d,0xc2,0x35,0x1c,0x6b,0x96,0xf4,0x1f,0x7a,0xb4,0x06,0x09,0x3a,0x64,0x33,0xf4,0x0b,0x2c,0x94,0x00,0x00, // 56wqzfj6mhxgsv3h3nh3pdocguogxfxud55libqjhjsdh5alfsko2iqd.onion 0x04,0x20,0x3d,0x24,0x7a,0xec,0xfe,0x60,0x6e,0x3d,0x3d,0xf3,0x4f,0x35,0x12,0x29,0xdb,0x48,0x89,0x71,0x19,0xb9,0xee,0x6a,0xfd,0xb2,0x02,0xa7,0x99,0x89,0xbb,0x69,0x39,0xdb,0x00,0x00, // hushv3h6mbxd2pptj42reko3jcexcgnz5zvp3mqcu6myto3jhhn4yzyd.onion From 9e524663e28cfbdeb1c246a54f646206cb612946 Mon Sep 17 00:00:00 2001 From: fekt Date: Thu, 29 Jun 2023 22:28:39 -0400 Subject: [PATCH 10/45] Update manpages --- 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 235409cac..a82565e74 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.13. -.TH HUSH-CLI "1" "February 2023" "hush-cli v3.9.3" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.6. +.TH HUSH-CLI "1" "June 2023" "hush-cli v3.9.4" "User Commands" .SH NAME -hush-cli \- manual page for hush-cli v3.9.3 +hush-cli \- manual page for hush-cli v3.9.4 .SH DESCRIPTION -Hush RPC client version v3.9.3\-1313d39a7 +Hush RPC client version v3.9.4\-44595d5ab .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 0d930a9a4..a4bc4033b 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.13. -.TH HUSH-TX "1" "February 2023" "hush-tx v3.9.3" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.6. +.TH HUSH-TX "1" "June 2023" "hush-tx v3.9.4" "User Commands" .SH NAME -hush-tx \- manual page for hush-tx v3.9.3 +hush-tx \- manual page for hush-tx v3.9.4 .SH DESCRIPTION -hush\-tx utility version v3.9.3\-1313d39a7 +hush\-tx utility version v3.9.4\-44595d5ab .SS "Usage:" .TP hush\-tx [options] [commands] diff --git a/doc/man/hushd.1 b/doc/man/hushd.1 index aad7da4d9..627c9c651 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.13. -.TH HUSHD "1" "February 2023" "hushd v3.9.3" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.6. +.TH HUSHD "1" "June 2023" "hushd v3.9.4" "User Commands" .SH NAME -hushd \- manual page for hushd v3.9.3 +hushd \- manual page for hushd v3.9.4 .SH DESCRIPTION -Hush Daemon version v3.9.3\-1313d39a7 +Hush Daemon version v3.9.4\-44595d5ab .PP In order to ensure you are adequately protecting your privacy when using Hush, please see . @@ -78,7 +78,7 @@ applied) .HP \fB\-par=\fR .IP -Set the number of script verification threads (\fB\-8\fR to 16, 0 = auto, <0 = +Set the number of script verification threads (\fB\-6\fR to 16, 0 = auto, <0 = leave that many cores free, default: 0) .HP \fB\-pid=\fR From 20ee425ece5c8668ca738dd9b0dc44b47cb34a6a Mon Sep 17 00:00:00 2001 From: fekt Date: Thu, 29 Jun 2023 23:31:53 -0400 Subject: [PATCH 11/45] Updated checkpoints --- src/chainparams.cpp | 168 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 165 insertions(+), 3 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index ef9213bb4..ef7ab5d70 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -1547,9 +1547,171 @@ void *chainparams_commandline() { (1249000, uint256S("0x00000001170d6ae54d494bd2dbf29c5ab7f560f51874987d7dbe129d549c097f")) (1250000, uint256S("0x000000033226eef40d094c8aa88d03bbc9146856c52248760e28c45426787352")) (1251000, uint256S("0x0000000281c7f7ef75ac6539791e26b9744cccd59414b04ddc4697bcd3595209")) - ,(int64_t) 1675926362, // time of last checkpointed block - (int64_t) 2022392, // total txs - (double) 1371 // txs in the last day before block 1251770 + + // Generated at 1688095440 via hush3 util/checkpoints.pl by fekt + (1252000, uint256S("0x00000002a23866c4bc24b6d14b8039eb38530936fd7ba230cd41bbffe457c0eb")) + (1253000, uint256S("0x000000021fb79ebfda0aa2dde15ef1fc669003911bc771d1700f8b6785d86aa9")) + (1254000, uint256S("0x000000020083112cbd6ac00fff2dbbd4c72e3c1d2636138cd42a63b7fc0af798")) + (1255000, uint256S("0x00000000247e68c0c4bd2cffedf9dff84dc67e49f9c90b6df073d4c6e913856a")) + (1256000, uint256S("0x00000002556455ce2059602aa43b7dc0ed5014bc157e78e9283bc2610946720e")) + (1257000, uint256S("0x00000003119deacf7b787311ef767abb173594d22979797a58a2ad01b7bda0a5")) + (1258000, uint256S("0x000000024edab00216ccb7ef39dd16b782e14179f90aace0d812b33ecbefdde0")) + (1259000, uint256S("0x00000003016ee9e404906afe5542afa1b614be768187d8a9f9c7ebf598d76695")) + (1260000, uint256S("0x00000000b7fc90789fca4e53b5966707642d1d9ffcccc99c28fd194135d08618")) + (1261000, uint256S("0x00000001e43bbacba953a662435791e7f4bc1c3fada97d8a279c8b26598fecc7")) + (1262000, uint256S("0x00000002993a7913e93d68bf44bd0f5c0102a7ab196ed6ee4ae9ea790b197854")) + (1263000, uint256S("0x000000016bf7677b49e8df24d03c3ba6ab060356c72501de94938ad2e7be946c")) + (1264000, uint256S("0x00000002c616eed07db9e4695ac9cee6989e42a76c6f61a4e0ebe0bb5abf692f")) + (1265000, uint256S("0x000000024d31a0ef0a466f573bb7c0e0970fc52e895c3b01d95b5b38e81322ca")) + (1266000, uint256S("0x000000011e54e3519dd6ea6af0443e309c8e226e2ccd775b28cc4f12f08c0d39")) + (1267000, uint256S("0x0000000393da90dc30fde8005d7f2d2318f8785e2a32bc865bf8383f7c8ffea8")) + (1268000, uint256S("0x000000027f04b7efb776bd8420de4cc0228561aa773d59cb0b2e9f6025389322")) + (1269000, uint256S("0x000000061807ebcde0469dd2c3b3bf682864b593da8bc8c64d354108961a6514")) + (1270000, uint256S("0x00000000041c198471a04f305344aeae7650140175c97d62765861d6416a4ed1")) + (1271000, uint256S("0x00000001f0e911e3ce304f9785f4c43ae7087eca9c4cadc677c4f49659b121dc")) + (1272000, uint256S("0x000000035098a7b17ae7be1c6decf88dbca85562137c8d2200bd84cb59148788")) + (1273000, uint256S("0x00000005d5d27e58ecb84658d2c3f2d8c87bae08ee0d81c6d4cdfc347ec13ec9")) + (1274000, uint256S("0x00000001623cd2acb0005393f2378a2d1ed5603511ee806b1e04f4e677b7531b")) + (1275000, uint256S("0x0000000140a568b0870d2c6853fe3fdcd94193652ef61ba9d430989e9a521a77")) + (1276000, uint256S("0x000000046e660edfdbae93511bb48f335df7523bae3cd5bfcb77cd81525585bb")) + (1277000, uint256S("0x000000022c296e5406126bbd6040316b2706c489c58d2b7593e1ec1637d31432")) + (1278000, uint256S("0x000000012b5d649609b503398d7af1fa7e14e9e58bd8e6746d6f44bbeb311270")) + (1279000, uint256S("0x000000039deede9e29ba8c7178df43374e83d6691556103a337c58822f2501fc")) + (1280000, uint256S("0x0000000172d327c94631b30e851ada193ad0d4b05a659db7e92cdaf4a5859841")) + (1281000, uint256S("0x00000002cf093cdd98e566534b7b5aaa91ee125e71283d654a75b878f08ba015")) + (1282000, uint256S("0x0000000306c146a88cd6a2cce453ac72d632a9bebf49abf27c684b4957f8380a")) + (1283000, uint256S("0x00000004738db155d0d8b5d95abd4484962c16a40eab2047b5b20fa4c5df890e")) + (1284000, uint256S("0x00000001bba05b8445a32d3856a1e4dbe9f65a96c39ca92c654ac01e675b1076")) + (1285000, uint256S("0x00000002fbc4853d6183b848e5ad32637478358521e87a7c1febfde93c4dcaa8")) + (1286000, uint256S("0x00000002fd09e8f12b1ade668a238b4badda452869f770c20bf3edd0c9a2b984")) + (1287000, uint256S("0x0000000568e3a41c8ac6e4d5ed59630a1aeff0b957494388a4c939f206ecac0c")) + (1288000, uint256S("0x000000024cf90a1150d224e167503dd79d2261de0e5e7a7e35b04949c95b8fd6")) + (1289000, uint256S("0x00000004ecdab6f1bf5f2cfd924afefb167160a49d5aa9a2b4790b4fce190427")) + (1290000, uint256S("0x0000000305db71205f1c622693cc55fee7c3b7c26400e13e82b3855a13c40df7")) + (1291000, uint256S("0x000000032d1115be00930015cb1f6fe824349bd4ff367ec675c4c92d7b268904")) + (1292000, uint256S("0x00000000a0fa63c1264eadb0fd86f1f420c74c2b5593604897c6ebe4aa4691b5")) + (1293000, uint256S("0x00000002bfd681e56afbb24664cd056812d1347bab971b44ff957a7ecd4a54ce")) + (1294000, uint256S("0x00000000ba8ac906a4fea8b779d6272e2648a30a488c4c390f1c761fbf53e76d")) + (1295000, uint256S("0x00000000859df3b6859bdd415b8d1b1fb8c396a279c8ddd6b1f39d41cec89579")) + (1296000, uint256S("0x000000008e62f687dc9899200671a9c595e1626e29477080ab052be584349ba5")) + (1297000, uint256S("0x00000003e9d6c1cce45b1d76a775f3d6e6ebbd5caa62427ae015e954e1f14d05")) + (1298000, uint256S("0x00000000fa5a495e60cfe2c8de8d8e52c2bb1ddf335a891f69be2c7eae901dcc")) + (1299000, uint256S("0x0000000326ff88c4546f65313522fe9466b33e96af50e6a6db09dfe59193bc63")) + (1300000, uint256S("0x00000003f498d56accc70c7257bfd708a22128dda0a038499f0c984f3e9ba2c0")) + (1301000, uint256S("0x00000001313da1129ba7de5f415d211ea1e3f51ae9d910abb2624aeae15b4a56")) + (1302000, uint256S("0x000000034cdf6686f4350dcc4f1f0887bb128746afd7cc3aeba5bf8b000c636f")) + (1303000, uint256S("0x00000003dffb121ae41569ca13d851f3c45668e8ee351680c2db1871f251eb3e")) + (1304000, uint256S("0x00000000c5bb42d8bfe94087c5d129fafe2677e62edadfaa7415b8a7bb4277ff")) + (1305000, uint256S("0x0000000046e1db3cc0047a85b815b745c4a0f4af4244b79d90a57cfafdf85699")) + (1306000, uint256S("0x00000004418d213a0ecced05de5b1fcaca70fe272d37773377e02c1873d27068")) + (1307000, uint256S("0x00000001cce1afda2c61046fd571edf01bdcc5a09260fcc7727caca8e3eb6ed6")) + (1308000, uint256S("0x00000000a453c4fd6f537776b730e5b8ae4d238c2f9215ed4f6e709b8aa177ac")) + (1309000, uint256S("0x000000009c9d7cb8f66d9ccdb7ce77a3c36c8d7df74e21326ef86000627091d4")) + (1310000, uint256S("0x00000000cd97fe334d3be6f3fda419589ebf643bffab3194d5cdeb7d324d123c")) + (1311000, uint256S("0x00000004fd9a887ae0db3333544e3027fe79f59fbdf8116ca516650e165bcd52")) + (1312000, uint256S("0x0000000349b8956bf4cf1b9566580e7362dfdd512ac5f7ef6a300ce2c0cf343e")) + (1313000, uint256S("0x000000030a692fe283bdbc7e1e11f8827da5a1e7b4aa3cca3c089803af547025")) + (1314000, uint256S("0x000000034e3ff90ae3436af4d7e1caec9604c5d347bded5fc6e0b05f3d0902f8")) + (1315000, uint256S("0x000000011044536fe0741ffb747e3b0f0cf826b3103d50b41f392772ed55607c")) + (1316000, uint256S("0x000000022ca70a448e4f6693aafeb5f0eac948064188933a01cd15db835e1bc3")) + (1317000, uint256S("0x00000005b8f471f902a540463c5a8ce962a34da30157bb4c094bbfee85b3ad36")) + (1318000, uint256S("0x000000020bada11214b8cf7784286aa4e5120c14b5b5e47516f619e6411badc0")) + (1319000, uint256S("0x00000001642ce9e76b5ebe167b03fdd00d0e6d595abb09ee9bd6c033f947f2db")) + (1320000, uint256S("0x00000000995d4bafd5b3e9bcc709cf0623090008aa34c9ee6b44c815ad08bc48")) + (1321000, uint256S("0x00000001bd0fff7aff0e313d8b458568a65a395d037b6d2999328798c441d8d3")) + (1322000, uint256S("0x000000015cd85c1fc0fc6877cb6c9ff4d9ab99bc7ece23d96c468c549ee3e368")) + (1323000, uint256S("0x000000033cdd6bc9051d956dc774e7c8066ae6f2272f2cbd23a5cb34a6f21947")) + (1324000, uint256S("0x00000001feaf5da15ade7a2a7f039ef95f506dfa7c8d7a3077dc6b77106a4aa9")) + (1325000, uint256S("0x00000002ed58d3afaa3044dde92a4af3908c154895651c46b8ad24bdcd702021")) + (1326000, uint256S("0x0000000377de030a756db011af1cf8d6ea1cabec0ad4957055de3435ee1102bf")) + (1327000, uint256S("0x00000002b68d85dc8783068c6878f128c048aa85dae10c5e0495768e76b153a8")) + (1328000, uint256S("0x000000022c5ea4c4f470006d99898a1de5d783967dfc4f0759835f60a0f376d9")) + (1329000, uint256S("0x0000000448c2f62ad26c51c3481b702615acf71f40631dc384e081e579993bf2")) + (1330000, uint256S("0x000000004bfdeafb2dcdbb7b0a214c62fc4f03583f3f6f27bbe2dd78c083bc6a")) + (1331000, uint256S("0x0000000008f29e6bfeedea18387ec2df4f1518f03de03073bd402d3d84daa40d")) + (1332000, uint256S("0x00000003b6b0fdb24bcd5b132ab25d97ce116d4fce4edc70037848340f9cd6a0")) + (1333000, uint256S("0x0000000540eb80533c3ad5fb11028ef74e41cf66afeeb49d38c8e91e1b9be071")) + (1334000, uint256S("0x000000024e829222c6b338723ea69a1aaf8ca426db6f1dc5ed6a508aa4eba324")) + (1335000, uint256S("0x00000001c34ef432a6d7c5b537e4157bcdc6a2f4c3d30d25cb9bb47ff395b5a6")) + (1336000, uint256S("0x000000011cda647d4405fbcffc35ce161a057911bc551290848a56a832835c14")) + (1337000, uint256S("0x0000000297dddb61d28cd456b11c6683f5c040ea1d798462cba45ff4d9acb7aa")) + (1338000, uint256S("0x000000031a44d98fee4c721d7cf692b5c6d49c72b9e514a9eea8d7a3a980cb42")) + (1339000, uint256S("0x000000016a3b0d888eaaf488fe99202db0cadabcace4f5606e13a8021e208beb")) + (1340000, uint256S("0x0000000296642fe481256d81da12afbbfc867a6e56f7e88ee575376171a2eb2b")) + (1341000, uint256S("0x000000047f7f7df7d25d0f93873e81f317b4c59970021ff99097b90662b34886")) + (1342000, uint256S("0x00000003dee60bf850c721422ead96876a6479c0e249252cd7a0819756f214f0")) + (1343000, uint256S("0x0000000479b89d6106880dd554c9f0839893680f6aaf1d17bdd353b5ff3b690d")) + (1344000, uint256S("0x000000043e08866b7b3a2fb729934e38ed68a7158aae743dbd67e915cbbe25fa")) + (1345000, uint256S("0x000000010d28f703987f82d284a6ab34eeb9c6cdf528cfd8ea9467377b48f978")) + (1346000, uint256S("0x000000047577df762e1b9d1d36efd124d7c587e8a1b04992d012b48e1da03d1c")) + (1347000, uint256S("0x000000050e60e964649507f0abaa9041969bc292e762179cc48e370d1e85109f")) + (1348000, uint256S("0x0000000458aac55b9a6a7610abf79769ccbd21bccabe262d49313b637f360b7d")) + (1349000, uint256S("0x00000001b36d5248c6632d6f353376991a3d7ce4b6730cd777042e8eef4c2050")) + (1350000, uint256S("0x0000000040bdf5b1900a2d20f6fb7824f7f0ad2117a357ac212388bbe5238f40")) + (1351000, uint256S("0x00000004a5e89800bd3e433dc1c3f36370b14523a219ccc513e9451c6354bb86")) + (1352000, uint256S("0x000000025bda557523475832f119f8d5ebdd02f131c0004f529b0e6b16343a8e")) + (1353000, uint256S("0x000000012e20cd31e7f6eda7d0e1d1777fde4a312a4c2ce6948d629e10b196ab")) + (1354000, uint256S("0x0000000247ea366ee0719df82303d8e74aec615b2c006bb1b7d37c1d42366785")) + (1355000, uint256S("0x0000000038f84260adf0773fa051af3467e0e4bf17adf73c4a9f8cc0ae0eb52f")) + (1356000, uint256S("0x00000001b109fae9d09d98e829e273037a6209d29347485ffdee066f8f32d070")) + (1357000, uint256S("0x00000002c9047e284ad3699ee0ccd158c141ad281fe7c78bcb8cae0012e2a7a5")) + (1358000, uint256S("0x000000046e5f2a9d1b043840165ba292042ca4a6927f9451d8eb379e9f6b479f")) + (1359000, uint256S("0x00000001fe154c692d9a7255fa9657023d213d3a2b0c6025bc2942452ff0bfa7")) + (1360000, uint256S("0x00000002e0a212bc285eef4232f6805f95ef054582a43fd4b926ed23e75ec378")) + (1361000, uint256S("0x0000000170ffed44b6503976cf15289556ec5ac785c63f371990dc1dcd01c0c1")) + (1362000, uint256S("0x00000004b0a51f49dc942a4dac1c8cb7ebc3b5dc70c27488b950033543de9188")) + (1363000, uint256S("0x00000002d39b32395989ff7065d238a9e6ca9643dde76f2c4fa090da64a9dfb0")) + (1364000, uint256S("0x00000003fe2c6dafe4f7c45c2a07307864a85c649738a68fa9736990385aa1b6")) + (1365000, uint256S("0x000000006a96f8887cb0b261ff9c0947ec9a35e388354a088012e0f3587a915d")) + (1366000, uint256S("0x00000000b19f6e3ea6282cad35d25bd45f4a90799ca30de76ebfaa58360102b3")) + (1367000, uint256S("0x00000005a4c7746ba3aa321bf6d0d939b65053fd7b8993541c4382d81b1df164")) + (1368000, uint256S("0x00000005a2f3fac3d68493253cc28762ed0e7d8be207b72e9b3eba49b1301661")) + (1369000, uint256S("0x00000001d963d93ec5f029920cd5ca0f8bfca9c85ce99f84585062d2c08edca3")) + (1370000, uint256S("0x000000033c971fbcf50d26531667597acd4abf989473c10a7ecd23cd4546dc05")) + (1371000, uint256S("0x00000002a277717fd9f5b05370e9c610662ffdb6f5489e96b96bc587dc22dc70")) + (1372000, uint256S("0x00000001ef0f457f58b3523ec79d6ec265928ba5aaec6a5ee282242334883e15")) + (1373000, uint256S("0x000000005911ed4432d3077e7254e35767ca8b00a674a1b047fd0dcc12bb1e6f")) + (1374000, uint256S("0x0000000538363b8b3a25dce0a88990b96dff9787c2ec8189b70b13222008adfc")) + (1375000, uint256S("0x000000021d15ac7123e2dc7ae2de2f045165911151b898063768eca1c27e31fa")) + (1376000, uint256S("0x000000047928c3ff4ca5dec8dd99087df4770abd50469ce2bd3328346858373f")) + (1377000, uint256S("0x0000000271c0b5532f810a9ffb563d09bf74b959fb1939c741dc140ec1874d09")) + (1378000, uint256S("0x0000000048678a71baf3fdb3c5f905a78a75b6ffb02018b186693e87d8172eb4")) + (1379000, uint256S("0x00000003460b8c58481e205f842eb3fda43f313a87a303f64a8f971268fba367")) + (1380000, uint256S("0x000000023a6ce85edc04e5af620930477bea1aaf31ee262678968976717d176e")) + (1381000, uint256S("0x0000000436b6c757c06b32648e510c4249b88928921f4d0bc39371600d0d0824")) + (1382000, uint256S("0x00000001c7fd7b29c040c9c56d641ca219800d234e1eb8c640d86663de6cb335")) + (1383000, uint256S("0x00000002b9cb3b2aca628572ae964b334efc22acc8ed50500d76e834cecb264f")) + (1384000, uint256S("0x0000000550b1b189873d81707719eb1be9e2492f3897f59cf39aad447d12fe7d")) + (1385000, uint256S("0x00000002c778e98b2871165ee43f441496ed6c50e6cd97bccc82448498ca3a2b")) + (1386000, uint256S("0x000000037b6d4f8ed38297729f65b7dda39a0e297d0dff2b7ab11c31b784b5ce")) + (1387000, uint256S("0x00000002aa3edc372bb3030959ee6eda0fc188b0837d8409c073553124e31ca3")) + (1388000, uint256S("0x00000004c2ad445251b1faf327fcc6d4364d941e8b95377588d764845ce98e14")) + (1389000, uint256S("0x00000003730f20a59c6c6bfb8ee168145113eab1db437a1683c782ad59a593cc")) + (1390000, uint256S("0x00000001f4f78ddb8d92d00fea207be21bed937c632a70681a522f2b21257f30")) + (1391000, uint256S("0x0000000252c913ab26a7d67b1ef969399edc40c0cb89c564a90bca7478511d06")) + (1392000, uint256S("0x00000001a4fd677cd1510d2253223d62f3c1adc493ce88178663698aaae85ad4")) + (1393000, uint256S("0x0000000326c759d56837a8ded29af2f0628c89ea018f45f44ccc27539cda123c")) + (1394000, uint256S("0x00000006e8c60ec3bf6dbe664da6b86e29c0a6220706617b8bc024f313f600e5")) + (1395000, uint256S("0x00000001a089c52a4740433d3395e9faedca3d80bba38a5c1d51bfa5d61a82a7")) + (1396000, uint256S("0x00000009cb3a07fbfb926a75481ab04db3d1a108c73782272e184a66d55e5de9")) + (1397000, uint256S("0x00000004aa55ca33c9e6fc43f9ddd0b0f32cade6a3c0dc120c7faf60d72903ff")) + (1398000, uint256S("0x00000006091fd1a0d34b6dd29c590ba69569f910b96bcbc8434758c177f04022")) + (1399000, uint256S("0x00000003c85038020294c7c58ea8a4bec845cf6494bdf63222b31f4748fea77a")) + (1400000, uint256S("0x00000008d0941b9a5b394d19cff188a665cb8a57b89de8ad06f58fd08c6fcb8e")) + (1401000, uint256S("0x000000013a5e8cd206aad4b6b1c256e567def77a371254f2b33096f315f401f9")) + (1402000, uint256S("0x000000016587d0e9753056f74305dc05d818904248512bdc87dadc624e0be6dc")) + (1403000, uint256S("0x000000015575532cb246eb7c065b955921104a246d4fef43f14009bf2da0d9eb")) + (1404000, uint256S("0x000000055c93b66f7be3213b21f2f77eaf5e76c43060125d6cb3a91ca5ba8bd3")) + (1405000, uint256S("0x00000003df2e2b33cbeeb78d320e273880df4d6deb0e661b576052ddcaccb11c")) + (1406000, uint256S("0x00000003a9e7a1b897857b1df59931eae36855a66e39c4fe872c68440b8a77b6")) + (1407000, uint256S("0x000000007f74d842e9a2923f32a0d64bdf3bfdf9bd742bcd689a8647b487de60")) + (1408000, uint256S("0x000000004a021a23c0c31f2fcd82d757e20f2d7257880dec999061546c0309c9")) + (1409000, uint256S("0x0000000078be552c979aaf660ef8b2d6a7f3d6878975f49f6d24c0c4d70fbe07")) + (1410000, uint256S("0x000000071ffa758ba71f243c8b4106cdabaaa5ec0df9247af03f5dc9221b58b2")) + (1411000, uint256S("0x00000007be4b7695ad2a5ef100899a22efad8b142ecbc8b93d5f8d553f9286d4")) + ,(int64_t) 1688026050, // time of last checkpointed block + (int64_t) 0, // total txs + (double) 2304 // txs in the last day before block 1411911 }; // END HUSH mainnet checkpoint data From 0ee828805e29be670272bb0b03e7209518182502 Mon Sep 17 00:00:00 2001 From: fekt Date: Thu, 29 Jun 2023 23:39:33 -0400 Subject: [PATCH 12/45] Update README --- doc/relnotes/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/relnotes/README.md b/doc/relnotes/README.md index 2de5dc92a..92a20220b 100644 --- a/doc/relnotes/README.md +++ b/doc/relnotes/README.md @@ -12,6 +12,10 @@ evil organizations. # Hush 3.9.4 "Maniacal Manticore" +``` +67 files changed, 1295 insertions(+), 1343 deletions(-) +``` + This is an OPTIONAL release. It is recommended for exchanges, solo miners and mining pools to update to this release. * New features and improvements @@ -21,6 +25,7 @@ This is an OPTIONAL release. It is recommended for exchanges, solo miners and mi * Removed mapRequest tracking that only affects Qt display. * Randomized message processing peer order for increased privacy. * Removed BIP35 mempool p2p message for increased privacy. + * Additional community seed node * Build Improvements * Use custom jobs param when compiling boost for faster compile times * Now builds with gcc13 thanks to testing from jahway From d3cc17e9bd935848df4a97b8748500a5eff01b00 Mon Sep 17 00:00:00 2001 From: Duke Date: Fri, 30 Jun 2023 06:37:37 -0400 Subject: [PATCH 13/45] Update relnotes for 3.9.4 --- doc/relnotes/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/relnotes/README.md b/doc/relnotes/README.md index 92a20220b..4dfbc01dc 100644 --- a/doc/relnotes/README.md +++ b/doc/relnotes/README.md @@ -19,7 +19,9 @@ evil organizations. This is an OPTIONAL release. It is recommended for exchanges, solo miners and mining pools to update to this release. * New features and improvements - * DragonX now has checkpoints for faster syncing. + * Hush and DragonX nodes will now sync much faster + * DragonX now has checkpoints for faster better chain security + * Updated to the latest RandomX code * Rate limiting for the processing of incoming addr messages for increased security. * Removed unused function CWalletTx::GetRequestCount * Removed mapRequest tracking that only affects Qt display. From 7017d8e06c5a64a3da1126b272201a6a95d3f8b1 Mon Sep 17 00:00:00 2001 From: Duke Date: Fri, 30 Jun 2023 06:42:33 -0400 Subject: [PATCH 14/45] Add info about DRAGONX checkpoints to release process --- doc/release-process.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/release-process.md b/doc/release-process.md index bd0d70633..93fec2434 100644 --- a/doc/release-process.md +++ b/doc/release-process.md @@ -76,6 +76,7 @@ Install deps on Linux: - Comment out the HUSHVER line and uncomment the line above it with a hardcoded version number - PROTIP: Man page creation must be done after updating the version number and recompiling and before Debian package creation - Update checkpoints in src/chainparams.cpp via util/checkpoints.pl + - Run "./util/checkpoints.pl help" to get example usage - hushd must be running to run this script, since it uses hush-cli to get the data - Look for line which says "END HUSH mainnet checkpoint data" near line 560 in chainparams.cpp , that is where checkpoint data ends - Find the highest block height of checkpoint data, let's call it HEIGHT @@ -95,6 +96,7 @@ Install deps on Linux: - They only provide limited security, because they talk about the past, not future block heights. - Try to generate checkpoints as close to the release as possible, so you can have a recent block height be protected. - For instance, don't update checkpoints and then do a release a month later. You can always update checkpoint data again or multiple times + - DRAGONX now has checkpoints, you can generate them with: `./util/checkpoints.pl 1000 1 DRAGONX` - Update copyright years if applicable. Example: `./util/update-copyrights.h 2022 2023` - Update doc/relnotes/README.md - To get the stats of file changes: `git diff --stat master...dev` From 2ba2122b2636bd90e339c0f50bd8d60b305b5bf6 Mon Sep 17 00:00:00 2001 From: fekt Date: Sun, 2 Jul 2023 11:26:54 -0400 Subject: [PATCH 15/45] Update relnotes --- doc/relnotes/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/relnotes/README.md b/doc/relnotes/README.md index 4dfbc01dc..294f3d299 100644 --- a/doc/relnotes/README.md +++ b/doc/relnotes/README.md @@ -13,7 +13,7 @@ evil organizations. # Hush 3.9.4 "Maniacal Manticore" ``` -67 files changed, 1295 insertions(+), 1343 deletions(-) +68 files changed, 1304 insertions(+), 1343 deletions(-) ``` This is an OPTIONAL release. It is recommended for exchanges, solo miners and mining pools to update to this release. From 8969a9d8fe500e01cb584d3d92aea247fcc16f02 Mon Sep 17 00:00:00 2001 From: Duke Date: Tue, 4 Jul 2023 11:14:56 -0400 Subject: [PATCH 16/45] Put binaries into a properly named subdirectory, fixes #311 --- util/gen-linux-binary-release.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/util/gen-linux-binary-release.sh b/util/gen-linux-binary-release.sh index 3a2b4e235..c9dde8589 100755 --- a/util/gen-linux-binary-release.sh +++ b/util/gen-linux-binary-release.sh @@ -8,7 +8,8 @@ set -x #hardcode and uncomment if hushd is not running on this machine #VERSION=3.6.3 VERSION=$(./src/hushd --version|grep version|cut -d' ' -f4|cut -d- -f1|sed 's/v//g') -FILE="hush-$VERSION-linux-amd64.tar" +DIR="hush-$VERSION-linux-amd64" +FILE="$DIR.tar" TIME=$(perl -e 'print time') if [ -d "build" ] @@ -17,14 +18,17 @@ then echo "Moved existing build/ dir to build.$TIME" fi mkdir build -echo "Created new build/ dir" -cp contrib/asmap/asmap.dat build/ -cp sapling*.params build/ +BUILD="build/$DIR" +mkdir $BUILD +echo "Created new build dir $BUILD" +cp contrib/asmap/asmap.dat $BUILD +cp sapling*.params $BUILD cd src -cp hushd hush-cli hush-tx hush-smart-chain dragonx-cli dragonxd ../build -cd ../build +cp hushd hush-cli hush-tx hush-smart-chain dragonx-cli dragonxd ../$BUILD +cd ../$BUILD strip hushd hush-cli hush-tx -tar -f $FILE -c * +cd .. +tar -f $FILE -c hush-$VERSION-linux-amd64/* gzip -9 $FILE sha256sum *.gz du -sh *.gz From 803e1d0f216ad8718b6d42551e4c494bbb143082 Mon Sep 17 00:00:00 2001 From: fekt Date: Wed, 5 Jul 2023 13:29:36 -0400 Subject: [PATCH 17/45] Use older version of cURL for Windows --- depends/packages/libcurl.mk | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/depends/packages/libcurl.mk b/depends/packages/libcurl.mk index 1ece9ce64..473d8c34f 100644 --- a/depends/packages/libcurl.mk +++ b/depends/packages/libcurl.mk @@ -1,9 +1,17 @@ package=libcurl + +ifeq ($(host_os),mingw32) +$(package)_version=7.67.0 +$(package)_file_name=curl-$($(package)_version).tar.gz +$(package)_sha256_hash=52af3361cf806330b88b4fe6f483b6844209d47ae196ac46da4de59bb361ab02 +else $(package)_version=7.77.0 -$(package)_dependencies=wolfssl -$(package)_download_path=https://curl.haxx.se/download $(package)_file_name=curl-$($(package)_version).tar.gz $(package)_sha256_hash=b0a3428acb60fa59044c4d0baae4e4fc09ae9af1d8a3aa84b2e3fbcd99841f77 +endif + +$(package)_dependencies=wolfssl +$(package)_download_path=https://curl.haxx.se/download $(package)_config_opts_linux=--disable-shared --enable-static --with-wolfssl --without-ssl --prefix=$(host_prefix) --host=$(host) $(package)_config_opts_mingw32=--enable-mingw --disable-shared --enable-static --with-wolfssl --without-ssl --prefix=$(host_prefix) --host=x86_64-w64-mingw32 $(package)_config_opts_darwin=--disable-shared --enable-static --with-wolfssl --without-ssl --prefix=$(host_prefix) From e53220b5f155ce679776624054f9baced13b867c Mon Sep 17 00:00:00 2001 From: fekt Date: Sun, 9 Jul 2023 11:49:55 -0400 Subject: [PATCH 18/45] Save checkpoints as individual .json files --- contrib/sda_checkpoints.pl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) mode change 100644 => 100755 contrib/sda_checkpoints.pl diff --git a/contrib/sda_checkpoints.pl b/contrib/sda_checkpoints.pl old mode 100644 new mode 100755 index ab468af86..e93c497e7 --- a/contrib/sda_checkpoints.pl +++ b/contrib/sda_checkpoints.pl @@ -12,8 +12,8 @@ my $hush = "./src/hush-cli"; my $getblock= "$hush getblock"; my $gethash = "$hush getblockhash"; my $gettree = "$hush getblockmerkletree"; -my $start = shift || 1190000; -my $end = shift || 1260000; +my $start = shift || 1390000; +my $end = shift || 1422000; my $stride = shift || 10000; my $blocks = qx{$hush getblockcount}; @@ -41,8 +41,12 @@ while (1) { chomp $merkle; chomp $blockhash; chomp $blocktime; - $blocktime =~ s/^\s+|\s+$//g ; - print qq{{\n\t"network": "main",\n\t"height": "$block",\n\t"hash": "$blockhash",\n\t$blocktime\n\t"saplingTree": "$merkle"\n},\n}; + $blocktime =~ s/^\s+|\s+$//g; + my $checkpoint = qq{{\n\t"network": "main",\n\t"height": "$block",\n\t"hash": "$blockhash",\n\t$blocktime\n\t"saplingTree": "$merkle"\n}\n}; + my $filename = "$block.json"; + open(FH, '>', $filename) or die $!; + print FH $checkpoint; + close(FH); $block += $stride; } From 4d3d880036bfc823a1f9dff43f465f392043e7a4 Mon Sep 17 00:00:00 2001 From: Duke Date: Tue, 8 Aug 2023 15:40:52 -0400 Subject: [PATCH 19/45] Add docs for adding a new PoW algo --- doc/developer-notes.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/doc/developer-notes.md b/doc/developer-notes.md index 77233221c..eca281a0c 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -104,6 +104,27 @@ We should also check a recent block height to verify it's working correctly. The * If you stop a node, and restart, are the stats from `getchaintxtstats` correct, i.e. the anonset stats? For instance, `shielded_pool_size` should be close to 500000, if it's close to or exactly 0, something is wrong. * Is there a new file called `zindex.dat` in `~/.hush/HUSH3/` ? * Is `zindex.dat` 149 bytes ? + +# Adding a PoW algorithm + +We will describe here the high-level ideas on how to add a new PoW algorithm to +the Hush codebase. Adding a new PoW algo means adding a new option to the `-ac_algo` +CLI param for HSC's. + + * Add the new value to the end of the `ASSETCHAINS_ALGORITHMS` array in `src/hush_utils.h` + * You cannot add it to the front because the first element is the default "equihash" + * Increase the value of `ASSETCHAINS_NUMALGOS` by one + * This value cannot be automatically be determined by the length of the above array because Equihash has different supported variants of (N,K) values + * Add the new PoW mining library to a subdirectory in src, such as RandomX official code being in `src/RandomX` + * The largest part of adding a new PoW algo is adding a new class to src/miner.cpp + * Originally there was only BitcoinMiner, which was modified from a double-sha256 miner to an equihash miner, without changing the name + * When RandomX was added as an option, many big internals changes were needed to support more than a single miner class + * It is now easier to add PoW algos because the internals support using different miner classes + * Currently BitcoinMiner and RandomXMiner classes have a lot of duplicated code, but this is intentional + * In theory we could refactor the miner classes to share more code, but this means changes to one miner could break another and it is very challenging to test every possibile edge case for mining code + * So code duplication is purposeful, because it isolates the risk of breaking one PoW by changing another. We tried very hard to not break Equihash mining when adding RandomX mining. + * When adding a new mining class, copying the RandomXMiner class is best, since it's newer and does not contain various legacy code that still exists in BitcoinMiner + * So copy RandomXMiner to your new FooMiner, delete all the randomx-specific stuff and add in the PoW mining code # Coding From c6859b676e1198fc27d0b9377fc4a3387ab70086 Mon Sep 17 00:00:00 2001 From: duke Date: Wed, 9 Aug 2023 00:05:00 +0000 Subject: [PATCH 20/45] Update 'doc/developer-notes.md' --- doc/developer-notes.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/developer-notes.md b/doc/developer-notes.md index eca281a0c..d8027f38e 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -113,6 +113,7 @@ CLI param for HSC's. * Add the new value to the end of the `ASSETCHAINS_ALGORITHMS` array in `src/hush_utils.h` * You cannot add it to the front because the first element is the default "equihash" + * You will also need to add a new constant, such as `ASSETCHAINS_FOOHASH` to `src/hush_globals.h` * Increase the value of `ASSETCHAINS_NUMALGOS` by one * This value cannot be automatically be determined by the length of the above array because Equihash has different supported variants of (N,K) values * Add the new PoW mining library to a subdirectory in src, such as RandomX official code being in `src/RandomX` @@ -125,6 +126,8 @@ CLI param for HSC's. * So code duplication is purposeful, because it isolates the risk of breaking one PoW by changing another. We tried very hard to not break Equihash mining when adding RandomX mining. * When adding a new mining class, copying the RandomXMiner class is best, since it's newer and does not contain various legacy code that still exists in BitcoinMiner * So copy RandomXMiner to your new FooMiner, delete all the randomx-specific stuff and add in the PoW mining code + * Some other changes to src/miner.cpp will be needed + * Update `GenerateBitcoins` function to start mining threads with your new algo with `else if(ASSETCHAINS_ALGO == ASSETCHAINS_FOOHASH) { minerThreads->create_thread(&FooMiner)}` # Coding From a90f03ce6dd3347689229fa4bff1116e838f309e Mon Sep 17 00:00:00 2001 From: Duke Date: Wed, 16 Aug 2023 10:37:23 -0400 Subject: [PATCH 21/45] Fix build-debian-package.sh docs and document how to make an aarch64 deb --- doc/release-process.md | 2 ++ util/build-debian-package.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/release-process.md b/doc/release-process.md index 93fec2434..08cedae03 100644 --- a/doc/release-process.md +++ b/doc/release-process.md @@ -122,3 +122,5 @@ Install deps on Linux: ## Platform-specific notes Use `./util/build-mac.sh` to compile on Apple/Mac systems, use `./util/build-win.sh` to build on Windows and `./util/build-arm.sh` to build on ARMv8 systems. + +Use `./util/build-debian-package.sh aarch64` to build a Debian package for aarch64 . diff --git a/util/build-debian-package.sh b/util/build-debian-package.sh index 11e9c1073..595118d19 100755 --- a/util/build-debian-package.sh +++ b/util/build-debian-package.sh @@ -4,7 +4,7 @@ # file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html ## Usages: ## ./util/build-debian-package.sh # build amd64 package -## ARCH=aarch64 ./util/build-debian-package.sh # build package for specific archiecture +## ./util/build-debian-package.sh aarch64 # build package for specific archiecture ARCH=${1:-amd64} echo "Let There Be Hush Debian Packages" From bacc08e81743aca5b7b31f6346268c3a44e9fa7b Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 3 Sep 2023 08:37:19 -0400 Subject: [PATCH 22/45] Remove sprout data from valuePools This codebase does not support sprout, the data will always be zero/empty and is essentially useless cruft, so we delete it. --- src/rpc/blockchain.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 7bdf840da..6f34bbc80 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -324,7 +324,6 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx result.push_back(Pair("blocktype", "mined")); UniValue valuePools(UniValue::VARR); - valuePools.push_back(ValuePoolDesc("sprout", blockindex->nChainSproutValue, blockindex->nSproutValue)); valuePools.push_back(ValuePoolDesc("sapling", blockindex->nChainSaplingValue, blockindex->nSaplingValue)); result.push_back(Pair("valuePools", valuePools)); @@ -1310,14 +1309,10 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp, const CPubKey& my obj.push_back(Pair("chainwork", chainActive.LastTip()->chainPower.chainWork.GetHex())); obj.push_back(Pair("pruned", fPruneMode)); - //SproutMerkleTree tree; - //pcoinsTip->GetSproutAnchorAt(pcoinsTip->GetBestAnchor(SPROUT), tree); - //obj.push_back(Pair("commitments", static_cast(tree.size()))); obj.push_back(Pair("commitments", 0)); CBlockIndex* tip = chainActive.LastTip(); UniValue valuePools(UniValue::VARR); - valuePools.push_back(ValuePoolDesc("sprout", tip->nChainSproutValue, boost::none)); valuePools.push_back(ValuePoolDesc("sapling", tip->nChainSaplingValue, boost::none)); obj.push_back(Pair("valuePools", valuePools)); From bd38a125129de4bd18a9c9b7e2c49cc35d2c6753 Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 3 Sep 2023 08:40:06 -0400 Subject: [PATCH 23/45] Remove useless sprout key from coinsupply RPC --- src/rpc/misc.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index a65c020c2..20fd31147 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -429,7 +429,6 @@ UniValue coinsupply(const UniValue& params, bool fHelp, const CPubKey& mypk) " \"height\" : 420, (integer) The height of this coin supply data\n" " \"supply\" : \"555.0\", (float) The transparent coin supply\n" " \"zfunds\" : \"0.55555\", (float) The shielded coin supply (in zaddrs)\n" - " \"sprout\" : \"0.000\", (float) The sprout coin supply (in zcaddrs)\n" " \"total\" : \"555.55555\", (float) The total coin supply, i.e. sum of supply + zfunds\n" "}\n" "\nExamples:\n" @@ -449,7 +448,6 @@ UniValue coinsupply(const UniValue& params, bool fHelp, const CPubKey& mypk) result.push_back(Pair("height", (int)height)); result.push_back(Pair("supply", ValueFromAmount(supply))); result.push_back(Pair("zfunds", ValueFromAmount(zfunds))); - result.push_back(Pair("sprout", ValueFromAmount(sproutfunds))); result.push_back(Pair("total", ValueFromAmount(zfunds + supply))); if ( ASSETCHAINS_BLOCKTIME > 0 ) { From e2521ac2fac01577cd53b5e40e24d5ad31434ec9 Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 3 Sep 2023 08:48:06 -0400 Subject: [PATCH 24/45] Remove unused sproutfunds argument --- src/hush_bitcoind.h | 15 ++++++--------- src/rpc/misc.cpp | 12 ++++++------ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/hush_bitcoind.h b/src/hush_bitcoind.h index b09c756ad..712c6854e 100644 --- a/src/hush_bitcoind.h +++ b/src/hush_bitcoind.h @@ -1790,9 +1790,9 @@ int32_t hush_scpublic(uint32_t tiptime) return 0; } -int64_t hush_newcoins(int64_t *zfundsp,int64_t *sproutfundsp,int32_t nHeight,CBlock *pblock) +int64_t hush_newcoins(int64_t *zfundsp,int32_t nHeight,CBlock *pblock) { - CTxDestination address; int32_t i,j,m,n,vout; uint8_t *script; uint256 txid,hashBlock; int64_t zfunds=0,vinsum=0,voutsum=0,sproutfunds=0; + CTxDestination address; int32_t i,j,m,n,vout; uint8_t *script; uint256 txid,hashBlock; int64_t zfunds=0,vinsum=0,voutsum=0; n = pblock->vtx.size(); for (i=0; i 100000*SATOSHIDEN || voutsum-vinsum+zfunds < 0 ) @@ -1840,11 +1839,11 @@ int64_t hush_newcoins(int64_t *zfundsp,int64_t *sproutfundsp,int32_t nHeight,CBl return(voutsum - vinsum); } -int64_t hush_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height) +int64_t hush_coinsupply(int64_t *zfundsp,int32_t height) { - CBlockIndex *pindex; CBlock block; int64_t zfunds=0,sproutfunds=0,supply = 0; + CBlockIndex *pindex; CBlock block; int64_t zfunds=0,supply = 0; //fprintf(stderr,"coinsupply %d\n",height); - *zfundsp = *sproutfundsp = 0; + *zfundsp = 0; if ( (pindex= hush_chainactive(height)) != 0 ) { while ( pindex != 0 && pindex->GetHeight() > 0 ) @@ -1852,7 +1851,7 @@ int64_t hush_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height) if ( pindex->newcoins == 0 && pindex->zfunds == 0 ) { if ( hush_blockload(block,pindex) == 0 ) { - pindex->newcoins = hush_newcoins(&pindex->zfunds,&pindex->sproutfunds,pindex->GetHeight(),&block); + pindex->newcoins = hush_newcoins(&pindex->zfunds,pindex->GetHeight(),&block); } else { fprintf(stderr,"error loading block.%d\n",pindex->GetHeight()); return(0); @@ -1860,13 +1859,11 @@ int64_t hush_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height) } supply += pindex->newcoins; zfunds += pindex->zfunds; - sproutfunds += pindex->sproutfunds; //printf("start ht.%d new %.8f -> supply %.8f zfunds %.8f -> %.8f\n",pindex->GetHeight(),dstr(pindex->newcoins),dstr(supply),dstr(pindex->zfunds),dstr(zfunds)); pindex = pindex->pprev; } } *zfundsp = zfunds; - *sproutfundsp = sproutfunds; return(supply); } diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 20fd31147..fcc44d2b9 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -65,7 +65,7 @@ int32_t hush_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); extern int32_t HUSH_LASTMINED,HUSH_LONGESTCHAIN,IS_HUSH_NOTARY,HUSH_INSYNC; extern char SMART_CHAIN_SYMBOL[HUSH_SMART_CHAIN_MAXLEN]; uint32_t hush_segid32(char *coinaddr); -int64_t hush_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height); +int64_t hush_coinsupply(int64_t *zfundsp,int32_t height); int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *hushnotarized_heightp); uint64_t hush_notarypayamount(int32_t nHeight, int64_t notarycount); int32_t hush_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); @@ -416,7 +416,7 @@ public: UniValue coinsupply(const UniValue& params, bool fHelp, const CPubKey& mypk) { - int32_t height = 0; int32_t currentHeight; int64_t blocks_per_year,zf1,zf3,zf12,sf1,sf3,sf12,sproutfunds,zfunds,supply1,supply3,supply12,supply = 0; UniValue result(UniValue::VOBJ); + int32_t height = 0; int32_t currentHeight; int64_t blocks_per_year,zf1,zf3,zf12,zfunds,supply1,supply3,supply12,supply = 0; UniValue result(UniValue::VOBJ); if (fHelp || params.size() > 1) throw runtime_error("coinsupply \n" "\nReturn coin supply information at a given block height. If no height is given, the current height is used.\n" @@ -441,7 +441,7 @@ UniValue coinsupply(const UniValue& params, bool fHelp, const CPubKey& mypk) currentHeight = chainActive.Height(); if (height >= 0 && height <= currentHeight) { - if ( (supply= hush_coinsupply(&zfunds,&sproutfunds,height)) > 0 ) + if ( (supply= hush_coinsupply(&zfunds,height)) > 0 ) { result.push_back(Pair("result", "success")); result.push_back(Pair("coin", SMART_CHAIN_SYMBOL[0] == 0 ? "HUSH" : SMART_CHAIN_SYMBOL)); @@ -454,9 +454,9 @@ UniValue coinsupply(const UniValue& params, bool fHelp, const CPubKey& mypk) blocks_per_year = 24*3600*365 / ASSETCHAINS_BLOCKTIME; if ( height > blocks_per_year ) { - supply1 = hush_coinsupply(&zf1,&sf1,height - blocks_per_year/12); - supply3 = hush_coinsupply(&zf3,&sf3,height - blocks_per_year/4); - supply12 = hush_coinsupply(&zf12,&sf12,height - blocks_per_year); + supply1 = hush_coinsupply(&zf1,height - blocks_per_year/12); + supply3 = hush_coinsupply(&zf3,height - blocks_per_year/4); + supply12 = hush_coinsupply(&zf12,height - blocks_per_year); if ( supply1 != 0 && supply3 != 0 && supply12 != 0 ) { result.push_back(Pair("lastmonth", ValueFromAmount(supply1+zf1))); From 1c45a71b05abea9f5a984316941b9420d44a7344 Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 3 Sep 2023 08:52:28 -0400 Subject: [PATCH 25/45] Remove dead code --- src/hush_bitcoind.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/hush_bitcoind.h b/src/hush_bitcoind.h index 712c6854e..8d7756430 100644 --- a/src/hush_bitcoind.h +++ b/src/hush_bitcoind.h @@ -1786,7 +1786,7 @@ int32_t hush_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height) int32_t hush_scpublic(uint32_t tiptime) { - // HUSH does not support public blockchains, go use something else if you want no privacy + // HUSH does not support surveillance coins, go use something else if you want no privacy return 0; } @@ -1832,8 +1832,6 @@ int64_t hush_newcoins(int64_t *zfundsp,int32_t nHeight,CBlock *pblock) zfunds -= tx.valueBalance; } *zfundsp = zfunds; - if ( SMART_CHAIN_SYMBOL[0] == 0 && (voutsum-vinsum) == 100003*SATOSHIDEN ) // 15 times - return(3 * SATOSHIDEN); //if ( voutsum-vinsum+zfunds > 100000*SATOSHIDEN || voutsum-vinsum+zfunds < 0 ) //. fprintf(stderr,"ht.%d vins %.8f, vouts %.8f -> %.8f zfunds %.8f\n",nHeight,dstr(vinsum),dstr(voutsum),dstr(voutsum)-dstr(vinsum),dstr(zfunds)); return(voutsum - vinsum); From 96ae2d61ca5a392cb476da4c7f6ab1f638839a7f Mon Sep 17 00:00:00 2001 From: Duke Date: Mon, 4 Sep 2023 08:22:12 -0400 Subject: [PATCH 26/45] z_getstats RPC that calculates various stats about ztxs in a block range --- src/wallet/rpcwallet.cpp | 144 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index cdf16c695..b10650137 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3636,6 +3636,149 @@ UniValue z_listsentbyaddress(const UniValue& params, bool fHelp,const CPubKey&) return ret; } +UniValue z_getstats(const UniValue& params, bool fHelp, const CPubKey& mypk) +{ + if (!EnsureWalletIsAvailable(fHelp)) + return NullUniValue; + + if (fHelp || params.size() < 1 || params.size() > 2) + throw runtime_error( + "z_getstats\n" + "\nReturns statistics about ztxs in block height or block height range\n" + "\nArguments:\n" + "1. \"height\" (number, required) The block height\n" + "1. \"end_height\" (number, optional) The ending block height\n" + "\nResult:\n" + "\njson\n" + "\nExamples:\n" + + HelpExampleCli("z_getstats 123", "456") + + HelpExampleRpc("z_getstats 123", "456") + ); + + LOCK2(cs_main, pwalletMain->cs_wallet); + std::string strHeight = params[0].get_str(); + int nHeight = -1; + try { + nHeight = std::stoi(strHeight); + } catch (const std::exception &e) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block height parameter"); + } + + if (nHeight < 0 || nHeight > chainActive.Height()) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); + } + auto strHash = chainActive[nHeight]->GetBlockHash().GetHex(); + uint256 hash(uint256S(strHash)); + + if (mapBlockIndex.count(hash) == 0) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); + + CBlock block; + CBlockIndex* pblockindex = mapBlockIndex[hash]; + + if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0) + throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)"); + + if(!ReadBlockFromDisk(block, pblockindex,1)) + throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); + + int total_ztxs, total_zins, total_zouts = 0; + int largest_zins, largest_zouts = 0; + + // given a single block height, we calculate stats for that height + if (params.size() == 1) { + BOOST_FOREACH(const CTransaction&tx, block.vtx) + { + int num_zins, num_zouts = 0; + // ignore coinbase txs which have no zins or zouts + if(!tx.IsCoinBase()) { + num_zouts = tx.vShieldedOutput.size(); + num_zins = tx.vShieldedSpend.size(); + // tx must have some zins and zouts to count towards our stats, + // which ignores shielding coinbase txs, which have only transparent inputs + // This mostly will only count "z2z" txs but also counts (z,t)=>z and z=>(z,t) + // which are possible but unlikely, since RPCs will not create them + if(num_zins > 0 && num_zouts > 0) { + total_ztxs++; + total_zins += num_zins; + total_zouts += num_zouts; + if (num_zins > largest_zins) { + largest_zins = num_zins; + } + if (num_zouts > largest_zouts) { + largest_zouts = num_zouts; + } + } + } + } + } else { + // given two blocks, we calculate delta for that range + std::string strHeight2 = params[1].get_str(); + int nHeight2 = -1; + try { + nHeight2 = std::stoi(strHeight2); + } catch (const std::exception &e) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid ending block height parameter"); + } + + if (nHeight2 <= nHeight) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Ending block height must be larger than starting height"); + } + + if (nHeight2 < 0 || nHeight2 > chainActive.Height()) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Ending block height out of range"); + } + + // get the delta for every block in the range + for(int currentHeight = nHeight; currentHeight <= nHeight2; currentHeight++) { + auto strHash = chainActive[currentHeight]->GetBlockHash().GetHex(); + uint256 hash(uint256S(strHash)); + + if (mapBlockIndex.count(hash) == 0) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); + + CBlock block; + CBlockIndex* pblockindex = mapBlockIndex[hash]; + + if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0) + throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)"); + + if(!ReadBlockFromDisk(block, pblockindex,1)) + throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); + + BOOST_FOREACH(const CTransaction&tx, block.vtx) + { + int num_zins, num_zouts = 0; + // ignore coinbase txs which have no zins or zouts + if(!tx.IsCoinBase()) { + num_zouts = tx.vShieldedOutput.size(); + num_zins = tx.vShieldedSpend.size(); + if(num_zins > 0 && num_zouts > 0) { + total_ztxs++; + total_zins += num_zins; + total_zouts += num_zouts; + } + if (num_zins > largest_zins) { + largest_zins = num_zins; + } + if (num_zouts > largest_zouts) { + largest_zouts = num_zouts; + } + } + } + } + } + UniValue ret(UniValue::VOBJ); + double avg_zins = total_ztxs > 0 ? total_zins / total_ztxs : 0.0; + double avg_zouts = total_ztxs > 0 ? total_zouts / total_ztxs : 0.0; + ret.pushKV("total_ztxs", total_ztxs); + ret.pushKV("avg_zins", avg_zins); + ret.pushKV("avg_zouts", avg_zouts); + ret.pushKV("largest_zins", largest_zins); + ret.pushKV("largest_zouts", largest_zouts); + return ret; +} + UniValue z_anonsetblockdelta(const UniValue& params, bool fHelp, const CPubKey& mypk) { if (!EnsureWalletIsAvailable(fHelp)) @@ -8489,6 +8632,7 @@ static const CRPCCommand commands[] = { "wallet", "z_listunspent", &z_listunspent, false }, { "wallet", "z_getbalance", &z_getbalance, false }, { "wallet", "z_getbalances", &z_getbalances, false }, + { "wallet", "z_getstats", &z_getstats, true }, { "wallet", "z_anonsettxdelta", &z_anonsettxdelta, true }, { "wallet", "z_anonsetblockdelta", &z_anonsetblockdelta, true }, { "wallet", "z_gettotalbalance", &z_gettotalbalance, false }, From 0f4956dcd54d715e4881db74bfa51a092193b7b6 Mon Sep 17 00:00:00 2001 From: Duke Date: Mon, 4 Sep 2023 08:50:05 -0400 Subject: [PATCH 27/45] Initialize variables in z_getstats correctly --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b10650137..01c379ecd 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3682,8 +3682,8 @@ UniValue z_getstats(const UniValue& params, bool fHelp, const CPubKey& mypk) if(!ReadBlockFromDisk(block, pblockindex,1)) throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); - int total_ztxs, total_zins, total_zouts = 0; - int largest_zins, largest_zouts = 0; + int total_ztxs = 0, total_zins = 0, total_zouts = 0; + int largest_zins = 0, largest_zouts = 0; // given a single block height, we calculate stats for that height if (params.size() == 1) { From 8eaba566fdf4732bdddfd42eac2ebb56e9dbba14 Mon Sep 17 00:00:00 2001 From: Duke Date: Mon, 4 Sep 2023 08:57:23 -0400 Subject: [PATCH 28/45] Force avg zins/zouts to be a double --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 01c379ecd..7c52b744e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3769,8 +3769,8 @@ UniValue z_getstats(const UniValue& params, bool fHelp, const CPubKey& mypk) } } UniValue ret(UniValue::VOBJ); - double avg_zins = total_ztxs > 0 ? total_zins / total_ztxs : 0.0; - double avg_zouts = total_ztxs > 0 ? total_zouts / total_ztxs : 0.0; + double avg_zins = total_ztxs > 0 ? (double) total_zins / total_ztxs : 0.0; + double avg_zouts = total_ztxs > 0 ? (double) total_zouts / total_ztxs : 0.0; ret.pushKV("total_ztxs", total_ztxs); ret.pushKV("avg_zins", avg_zins); ret.pushKV("avg_zouts", avg_zouts); From 7ea88bb303372eb91bebb0da908ce6ac0c484de0 Mon Sep 17 00:00:00 2001 From: Duke Date: Mon, 4 Sep 2023 09:03:06 -0400 Subject: [PATCH 29/45] Return total zins+zouts in json --- src/wallet/rpcwallet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 7c52b744e..d88a7a4d0 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3772,6 +3772,8 @@ UniValue z_getstats(const UniValue& params, bool fHelp, const CPubKey& mypk) double avg_zins = total_ztxs > 0 ? (double) total_zins / total_ztxs : 0.0; double avg_zouts = total_ztxs > 0 ? (double) total_zouts / total_ztxs : 0.0; ret.pushKV("total_ztxs", total_ztxs); + ret.pushKV("total_zins", total_zins); + ret.pushKV("total_zouts", total_zouts); ret.pushKV("avg_zins", avg_zins); ret.pushKV("avg_zouts", avg_zouts); ret.pushKV("largest_zins", largest_zins); From ff7a5970325e1f0417a28dcfdd1257703608c5cf Mon Sep 17 00:00:00 2001 From: Duke Date: Tue, 5 Sep 2023 00:35:11 -0400 Subject: [PATCH 30/45] Lots of more data for z_getstats --- src/wallet/rpcwallet.cpp | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d88a7a4d0..90997e6ce 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3683,7 +3683,9 @@ UniValue z_getstats(const UniValue& params, bool fHelp, const CPubKey& mypk) throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); int total_ztxs = 0, total_zins = 0, total_zouts = 0; + int total_ztxs_10_or_more_zins = 0, total_ztxs_10_or_more_zouts = 0; int largest_zins = 0, largest_zouts = 0; + std::string largest_zins_txid = "", largest_zouts_txid = ""; // given a single block height, we calculate stats for that height if (params.size() == 1) { @@ -3695,24 +3697,33 @@ UniValue z_getstats(const UniValue& params, bool fHelp, const CPubKey& mypk) num_zouts = tx.vShieldedOutput.size(); num_zins = tx.vShieldedSpend.size(); // tx must have some zins and zouts to count towards our stats, - // which ignores shielding coinbase txs, which have only transparent inputs + // which ignores shielding coinbase txs, which have only transparent inputs. // This mostly will only count "z2z" txs but also counts (z,t)=>z and z=>(z,t) - // which are possible but unlikely, since RPCs will not create them + // which are possible but unlikely, since RPCs cannot currently create (z,t)=>z txs + // and z=>(z,t) are disallowed when ac_private=1 if(num_zins > 0 && num_zouts > 0) { total_ztxs++; total_zins += num_zins; total_zouts += num_zouts; if (num_zins > largest_zins) { largest_zins = num_zins; + largest_zins_txid = tx.GetHash().ToString(); } if (num_zouts > largest_zouts) { largest_zouts = num_zouts; + largest_zouts_txid = tx.GetHash().ToString(); + } + if (num_zins >= 10) { + total_ztxs_10_or_more_zins++; + } + if (num_zouts >= 10) { + total_ztxs_10_or_more_zouts++; } } } } } else { - // given two blocks, we calculate delta for that range + // given two blocks, we calculate stats for that range std::string strHeight2 = params[1].get_str(); int nHeight2 = -1; try { @@ -3729,7 +3740,7 @@ UniValue z_getstats(const UniValue& params, bool fHelp, const CPubKey& mypk) throw JSONRPCError(RPC_INVALID_PARAMETER, "Ending block height out of range"); } - // get the delta for every block in the range + // get the stats for every block in the range for(int currentHeight = nHeight; currentHeight <= nHeight2; currentHeight++) { auto strHash = chainActive[currentHeight]->GetBlockHash().GetHex(); uint256 hash(uint256S(strHash)); @@ -3760,9 +3771,17 @@ UniValue z_getstats(const UniValue& params, bool fHelp, const CPubKey& mypk) } if (num_zins > largest_zins) { largest_zins = num_zins; + largest_zins_txid = tx.GetHash().ToString(); } if (num_zouts > largest_zouts) { largest_zouts = num_zouts; + largest_zouts_txid = tx.GetHash().ToString(); + } + if (num_zins >= 10) { + total_ztxs_10_or_more_zins++; + } + if (num_zouts >= 10) { + total_ztxs_10_or_more_zouts++; } } } @@ -3774,10 +3793,14 @@ UniValue z_getstats(const UniValue& params, bool fHelp, const CPubKey& mypk) ret.pushKV("total_ztxs", total_ztxs); ret.pushKV("total_zins", total_zins); ret.pushKV("total_zouts", total_zouts); + ret.pushKV("total_ztxs_10_or_more_zins", total_ztxs_10_or_more_zins); + ret.pushKV("total_ztxs_10_or_more_zouts", total_ztxs_10_or_more_zouts); ret.pushKV("avg_zins", avg_zins); ret.pushKV("avg_zouts", avg_zouts); ret.pushKV("largest_zins", largest_zins); + ret.pushKV("largest_zins_txid", largest_zins_txid); ret.pushKV("largest_zouts", largest_zouts); + ret.pushKV("largest_zouts_txid", largest_zouts_txid); return ret; } From 4aca3493e39910d5e75bf84f5455a16303180ea2 Mon Sep 17 00:00:00 2001 From: Duke Date: Tue, 5 Sep 2023 11:30:27 -0400 Subject: [PATCH 31/45] Even more zstats Example data for the entire history of the current HUSH mainnet : ./src/hush-cli z_getstats 1 1487622 { "total_ztxs": 414962, "total_zins": 798083, "total_zouts": 3312131, "total_ztxs_10_or_more_zins": 6789, "total_ztxs_25_or_more_zins": 1779, "total_ztxs_50_or_more_zins": 688, "total_ztxs_100_or_more_zins": 174, "total_ztxs_10_or_more_zouts": 2855, "total_ztxs_25_or_more_zouts": 394, "total_ztxs_50_or_more_zouts": 314, "total_ztxs_100_or_more_zouts": 208, "avg_zins": 1.923267672702561, "avg_zouts": 7.981769415030774, "largest_zins": 517, "largest_zins_txid": "69f126edd5a0189fbbe84b0824eb48e16eddf180e7d5d4f34c4296d0f868ac7f", "largest_zouts": 210, "largest_zouts_txid": "2a3155f73fab9191978e77e03be8ec7167372c4549113a6eb3f8a9d343f749ba" } --- src/wallet/rpcwallet.cpp | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 90997e6ce..0be79dd3d 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3684,6 +3684,9 @@ UniValue z_getstats(const UniValue& params, bool fHelp, const CPubKey& mypk) int total_ztxs = 0, total_zins = 0, total_zouts = 0; int total_ztxs_10_or_more_zins = 0, total_ztxs_10_or_more_zouts = 0; + int total_ztxs_25_or_more_zins = 0, total_ztxs_25_or_more_zouts = 0; + int total_ztxs_50_or_more_zins = 0, total_ztxs_50_or_more_zouts = 0; + int total_ztxs_100_or_more_zins = 0, total_ztxs_100_or_more_zouts = 0; int largest_zins = 0, largest_zouts = 0; std::string largest_zins_txid = "", largest_zouts_txid = ""; @@ -3715,10 +3718,30 @@ UniValue z_getstats(const UniValue& params, bool fHelp, const CPubKey& mypk) } if (num_zins >= 10) { total_ztxs_10_or_more_zins++; + if (num_zins >= 25) { + total_ztxs_25_or_more_zins++; + if (num_zins >= 50) { + total_ztxs_50_or_more_zins++; + if (num_zins >= 100) { + total_ztxs_100_or_more_zins++; + } + } + } } if (num_zouts >= 10) { total_ztxs_10_or_more_zouts++; + if (num_zouts >= 25) { + total_ztxs_25_or_more_zouts++; + if (num_zouts >= 50) { + total_ztxs_50_or_more_zouts++; + if (num_zouts >= 100) { + total_ztxs_100_or_more_zouts++; + } + } + } } + + } } } @@ -3779,9 +3802,27 @@ UniValue z_getstats(const UniValue& params, bool fHelp, const CPubKey& mypk) } if (num_zins >= 10) { total_ztxs_10_or_more_zins++; + if (num_zins >= 25) { + total_ztxs_25_or_more_zins++; + if (num_zins >= 50) { + total_ztxs_50_or_more_zins++; + if (num_zins >= 100) { + total_ztxs_100_or_more_zins++; + } + } + } } if (num_zouts >= 10) { total_ztxs_10_or_more_zouts++; + if (num_zouts >= 25) { + total_ztxs_25_or_more_zouts++; + if (num_zouts >= 50) { + total_ztxs_50_or_more_zouts++; + if (num_zouts >= 100) { + total_ztxs_100_or_more_zouts++; + } + } + } } } } @@ -3794,7 +3835,13 @@ UniValue z_getstats(const UniValue& params, bool fHelp, const CPubKey& mypk) ret.pushKV("total_zins", total_zins); ret.pushKV("total_zouts", total_zouts); ret.pushKV("total_ztxs_10_or_more_zins", total_ztxs_10_or_more_zins); + ret.pushKV("total_ztxs_25_or_more_zins", total_ztxs_25_or_more_zins); + ret.pushKV("total_ztxs_50_or_more_zins", total_ztxs_50_or_more_zins); + ret.pushKV("total_ztxs_100_or_more_zins", total_ztxs_100_or_more_zins); ret.pushKV("total_ztxs_10_or_more_zouts", total_ztxs_10_or_more_zouts); + ret.pushKV("total_ztxs_25_or_more_zouts", total_ztxs_25_or_more_zouts); + ret.pushKV("total_ztxs_50_or_more_zouts", total_ztxs_50_or_more_zouts); + ret.pushKV("total_ztxs_100_or_more_zouts", total_ztxs_100_or_more_zouts); ret.pushKV("avg_zins", avg_zins); ret.pushKV("avg_zouts", avg_zouts); ret.pushKV("largest_zins", largest_zins); From 7c45e66fbeefa354c4169ce230eb061b92c3adbe Mon Sep 17 00:00:00 2001 From: Duke Date: Fri, 8 Sep 2023 08:28:14 -0400 Subject: [PATCH 32/45] Also return start and ending height in z_getstats json --- src/wallet/rpcwallet.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 0be79dd3d..8467c0453 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3689,6 +3689,8 @@ UniValue z_getstats(const UniValue& params, bool fHelp, const CPubKey& mypk) int total_ztxs_100_or_more_zins = 0, total_ztxs_100_or_more_zouts = 0; int largest_zins = 0, largest_zouts = 0; std::string largest_zins_txid = "", largest_zouts_txid = ""; + UniValue ret(UniValue::VOBJ); + ret.pushKV("start_height", nHeight); // given a single block height, we calculate stats for that height if (params.size() == 1) { @@ -3763,6 +3765,8 @@ UniValue z_getstats(const UniValue& params, bool fHelp, const CPubKey& mypk) throw JSONRPCError(RPC_INVALID_PARAMETER, "Ending block height out of range"); } + ret.pushKV("end_height", nHeight2); + // get the stats for every block in the range for(int currentHeight = nHeight; currentHeight <= nHeight2; currentHeight++) { auto strHash = chainActive[currentHeight]->GetBlockHash().GetHex(); @@ -3828,7 +3832,6 @@ UniValue z_getstats(const UniValue& params, bool fHelp, const CPubKey& mypk) } } } - UniValue ret(UniValue::VOBJ); double avg_zins = total_ztxs > 0 ? (double) total_zins / total_ztxs : 0.0; double avg_zouts = total_ztxs > 0 ? (double) total_zouts / total_ztxs : 0.0; ret.pushKV("total_ztxs", total_ztxs); From 09555fbee29ece5f35c39b77d189a3ebee32fe81 Mon Sep 17 00:00:00 2001 From: Duke Date: Mon, 18 Sep 2023 12:43:27 -0400 Subject: [PATCH 33/45] Allow abortrescan during RPC warmup If we don't, we can get the hilarious error message that the node is Rescanning... when trying to run abortrescan when the node automatically does a rescan on boot. --- src/rpc/server.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 703cdc7b9..679e6ffc2 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -832,7 +832,8 @@ UniValue CRPCTable::execute(const std::string &strMethod, const UniValue ¶ms pcmd->name != "getnotarysendmany" && pcmd->name != "geterablockheights" && pcmd->name != "getaddressesbyaccount" && pcmd->name != "listaddresses" && pcmd->name != "z_exportwallet" && pcmd->name != "notaries" && pcmd->name != "signmessage" && pcmd->name != "decoderawtransaction" && - pcmd->name != "dumpprivkey" && pcmd->name != "getpeerinfo" && pcmd->name != "getnetworkinfo" ) { + pcmd->name != "dumpprivkey" && pcmd->name != "getpeerinfo" && pcmd->name != "getnetworkinfo" && + pcmd->name != "abortrescan") { throw JSONRPCError(RPC_IN_WARMUP, rpcWarmupStatus); } } From 2308db22eec78d0a10bde0f674243b2700d59e4a Mon Sep 17 00:00:00 2001 From: Duke Date: Mon, 18 Sep 2023 12:58:03 -0400 Subject: [PATCH 34/45] Antispam defenses This code is inspired by https://github.com/PirateNetwork/pirate/commit/db292a49ddc13374f43b8c16217e171316be53d7 with various improvements that will be documented below. The largest improvement is that this code will defend against a spammer using shielded inputs (zins) or shielded outputs (zouts) while the Pirate code only defends against zout spam. We wrote a new RPC called z_getstats to study exactly what the distribution of shielded inputs (zins) and shielded outputs (zouts) look like on HUSH mainnet. Sietch will never make a ztx that contains more than 9 zouts and so transactions with 10 or more zouts are extremely rare. They correspond to custom transactions created via code or CLI or mining pool payouts. We allow at most one of these per block. If there are two, one will remain in the mempool and be mined in the subsequent block. Our code is more strict, as Pirate will allow up to 6 of these transactions in a single block. Transactions with many shielded inputs do occur normally when users spend many small shielded unspent outputs (zutxos) in one transaction, but we determined that a cutoff of 50 zins is quite rare. Between blocks 14000000 and 15000000 only 27 ztxs had 50 or more zins, which is 0.03% . We allow at most one of these per block and if there are more, they will wait to be mined in a subsequent block. Also note that a transaction can match both criteria of having large zins and large zouts, so for instance, if there is a transaction with 50 zins and 10 zouts, it counts towards both requirements and no other transactions with >=50 zins or >=10 zouts will be mined in that block. If >=200 transactions with either large zins or large zouts are broadcast to the network it will take at least 200 blocks for them to be mined and so via existing rules for ztx expiration they will expire and be removed from the mempool, since by default all ztxs expire after 200 blocks. Since normal ztxs that match these criteria are very rare, the only case when this might happen is during a spam attack and so the attackers transactions expiring is another part of these defenses. Other improvements are that we log txids of transactions with large zins or zouts and we do not support a command line option to turn this protection off. This forces a potential attacker to compile their own custom code if they want to subvert these protections on their own node and blocks they mine. Similar to Pirate, these changes are not consensus changes but may be made consensus requirements in the future. These protections are not specific to HUSH and are enabled for all HSC's, including DragonX. --- src/miner.cpp | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index ee85a52eb..227ba999b 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -279,11 +279,16 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 vecPriority.reserve(mempool.mapTx.size() + 1); //fprintf(stderr,"%s: going to add txs from mempool\n", __func__); - // now add transactions from the mem pool + // now add transactions from the mempool int32_t Notarizations = 0; uint64_t txvalue; + uint32_t large_zins = 0; // number of ztxs with large number of inputs in block + uint32_t large_zouts = 0; // number of ztxs with large number of outputs in block + const uint32_t LARGE_ZINS_MAX = 1; // max ztxs with large zins per block + const uint32_t LARGE_ZOUTS_MAX = 1; // max ztxs with large zouts per block + const uint32_t LARGE_ZINS_THRESHOLD = 50; // min number of zins to be considered large + const uint32_t LARGE_ZOUTS_THRESHOLD = 10; // min number of zouts to be considered large for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin(); - mi != mempool.mapTx.end(); ++mi) - { + mi != mempool.mapTx.end(); ++mi) { const CTransaction& tx = mi->GetTx(); int64_t nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) @@ -466,6 +471,18 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 // fprintf(stderr,"%s: compared first tx from priority queue\n", __func__); vecPriority.pop_back(); + if(tx.vShieldedSpend.size() >= LARGE_ZINS_THRESHOLD && large_zins >= LARGE_ZINS_MAX) { + LogPrintf("%s: skipping ztx %s with %d zins because there are already %d ztxs with large zins\n", + __func__, tx.GetHash().ToString().c_str(), tx.vShieldedSpend.size(), LARGE_ZINS_MAX); + continue; + } + + if(tx.vShieldedOutput.size() >= LARGE_ZOUTS_THRESHOLD && large_zouts >= LARGE_ZOUTS_MAX) { + LogPrintf("%s: skipping ztx %s with %d zouts because there are already %d ztxs with large zouts\n", + __func__, tx.GetHash().ToString().c_str(), tx.vShieldedOutput.size(), LARGE_ZOUTS_MAX); + continue; + } + // Size limits unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); // fprintf(stderr,"%s: nTxSize = %u\n", __func__, nTxSize); @@ -576,6 +593,18 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 nBlockSigOps += nTxSigOps; nFees += nTxFees; + if(tx.vShieldedOutput.size() >= LARGE_ZOUTS_THRESHOLD) { + large_zouts++; + LogPrintf("%s: txid=%s has large zouts=%d (%d large zouts in block)\n", __func__, tx.GetHash().ToString().c_str(), + tx.vShieldedOutput.size(), large_zouts ); + } + + if(tx.vShieldedSpend.size() >= LARGE_ZINS_THRESHOLD) { + large_zins++; + LogPrintf("%s: txid=%s has large zins=%d (%d large zouts in block)\n", __func__, tx.GetHash().ToString().c_str(), + tx.vShieldedSpend.size(), large_zins ); + } + if (fPrintPriority) { LogPrintf("priority %.1f fee %s txid %s\n",dPriority, feeRate.ToString(), tx.GetHash().ToString()); From d7cbdcab2839277a3a11308be60e42e1494ec59e Mon Sep 17 00:00:00 2001 From: Duke Date: Mon, 18 Sep 2023 20:44:16 -0400 Subject: [PATCH 35/45] Always log when skipping a zaddr during z_importwallet --- src/wallet/rpcdump.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 79463087d..39b5caf38 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -515,14 +515,15 @@ UniValue importwallet_impl(const UniValue& params, bool fHelp, bool fImportZKeys auto addResult = boost::apply_visitor( AddSpendingKeyToWallet(pwalletMain, Params().GetConsensus(), nTime, hdKeypath, seedFpStr, true), spendingkey); if (addResult == KeyAlreadyExists){ - LogPrint("zrpc", "Skipping import of zaddr (key already present)\n"); + LogPrintf("%s: Skipping import of zaddr (key already present)\n", __func__); } else if (addResult == KeyNotAdded) { // Something went wrong fGood = false; + LogPrintf("%s: Skipping import of zaddr (something went wrong)\n", __func__); } continue; } else { - LogPrint("zrpc", "Importing detected an error: invalid spending key. Trying as a transparent key...\n"); + LogPrintf("%s: Importing detected an error: invalid spending key. Trying as a transparent key...\n",__func__); // Not a valid spending key, so carry on and see if it's a Hush transparent address } } From aa5cbee69cc284aa343239f2dd0e0330f9efe8e5 Mon Sep 17 00:00:00 2001 From: Duke Date: Mon, 18 Sep 2023 20:57:47 -0400 Subject: [PATCH 36/45] Remove dead code --- src/main.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 2c037297b..55b26b70b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1863,8 +1863,6 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa view.GetBestBlock(); nValueIn = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime); - if ( 0 && interest != 0 ) - fprintf(stderr,"add interest %.8f\n",(double)interest/COIN); // we have all inputs cached now, so switch back to dummy, so we don't need to keep lock on mempool view.SetBackend(dummy); } From c8a88e116835e5ae736936b2b8c2abe7214b2a3a Mon Sep 17 00:00:00 2001 From: Duke Date: Sat, 7 Oct 2023 14:07:34 -0400 Subject: [PATCH 37/45] Check null randomx dataset before calling randomx_dataset_item_count --- src/miner.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index ee85a52eb..2f372483c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1072,14 +1072,14 @@ void static RandomXMiner() randomx_dataset *randomxDataset = randomx_alloc_dataset(flags); rxdebug("%s: created dataset\n"); - auto datasetItemCount = randomx_dataset_item_count(); - rxdebug("%s: dataset items=%lu\n", datasetItemCount); - if( randomxDataset == nullptr) { LogPrintf("%s: allocating randomx dataset failed!\n", __func__); return; } + auto datasetItemCount = randomx_dataset_item_count(); + rxdebug("%s: dataset items=%lu\n", datasetItemCount); + char randomxHash[RANDOMX_HASH_SIZE]; rxdebug("%s: created randomxHash of size %d\n", RANDOMX_HASH_SIZE); char randomxKey[82]; // randomx spec says keysize of >60 bytes is implementation-specific From b386cd1acf78d4d6079eedf66e3b23e36009fc1e Mon Sep 17 00:00:00 2001 From: Duke Date: Sat, 7 Oct 2023 14:15:12 -0400 Subject: [PATCH 38/45] Scripts to test this branch --- antispam | 4 ++++ qa/pull-tester/rpc-tests.sh | 1 + qa/pull-tester/tests-config.sh.in | 1 - qa/rpc-tests/test_framework/util.py | 28 ++++++++++++++++++---------- qa/rpc-tests/wallet_sapling.py | 6 +++--- test_antispam | 9 +++++++++ 6 files changed, 35 insertions(+), 14 deletions(-) create mode 100755 antispam create mode 100755 test_antispam diff --git a/antispam b/antispam new file mode 100755 index 000000000..a9d3572a9 --- /dev/null +++ b/antispam @@ -0,0 +1,4 @@ +#!/bin/sh + +echo "./src/hush-cli -ac_name=ANTISPAM $@" +./src/hush-cli -ac_name=ANTISPAM $@ diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh index b1cbabec9..bed1a5417 100755 --- a/qa/pull-tester/rpc-tests.sh +++ b/qa/pull-tester/rpc-tests.sh @@ -14,6 +14,7 @@ export BITCOIND=${REAL_BITCOIND} #Run the tests testScripts=( + 'antispam.py' 'dpow.py' 'dpowconfs.py' 'ac_private.py' diff --git a/qa/pull-tester/tests-config.sh.in b/qa/pull-tester/tests-config.sh.in index 5122ba085..47546707b 100755 --- a/qa/pull-tester/tests-config.sh.in +++ b/qa/pull-tester/tests-config.sh.in @@ -11,7 +11,6 @@ EXEEXT="@EXEEXT@" @ENABLE_WALLET_TRUE@ENABLE_WALLET=1 @BUILD_BITCOIN_UTILS_TRUE@ENABLE_UTILS=1 @BUILD_BITCOIND_TRUE@ENABLE_BITCOIND=1 -@ENABLE_PROTON_TRUE@ENABLE_PROTON=1 REAL_BITCOIND="$BUILDDIR/src/hushd${EXEEXT}" REAL_BITCOINCLI="$BUILDDIR/src/hush-cli${EXEEXT}" diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index a0b409970..3280be573 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -104,10 +104,10 @@ def initialize_datadir(dirname, n): f.write("showmetrics=0\n"); f.write("rpcuser=hush\n"); f.write("rpcpassword=puppy\n"); - #f.write("port="+str(p2p_port(n))+"\n"); - #rpcport = str(rpc_port(n)) - #f.write("rpcport="+rpcport+"\n"); - #print "RPC port=" + rpcport + f.write("port="+str(p2p_port(n))+"\n"); + rpcport = str(rpc_port(n)) + f.write("rpcport="+rpcport+"\n"); + print "RPC port=" + rpcport f.write("listenonion=0\n"); # TODO: maybe make these optional, via arg to initialize_datadir, defaulted to on for now f.write("addressindex=1\n"); @@ -148,7 +148,7 @@ def initialize_chain(test_dir): rpcs = [] for i in range(4): try: - url = "http://rt:rt@127.0.0.1:%d"%(rpc_port(i),) + url = "http://hush:puppy@127.0.0.1:%d"%(rpc_port(i),) rpcs.append(AuthServiceProxy(url)) except: sys.stderr.write("Error connecting to "+url+"\n") @@ -165,11 +165,13 @@ def initialize_chain(test_dir): for j in range(25): set_node_times(rpcs, block_time) rpcs[peer].generate(1) - block_time += 10*60 + # TODO: HUSH3 has 75s blocktime, other HSCs could be different + block_time += 10*75 # Must sync before next peer starts generating blocks sync_blocks(rpcs) # Shut them down, and clean up cache directories: + print("Stopping nodes") stop_nodes(rpcs) wait_bitcoinds() for i in range(4): @@ -182,8 +184,9 @@ def initialize_chain(test_dir): for i in range(4): from_dir = os.path.join("cache", "node"+str(i)) to_dir = os.path.join(test_dir, "node"+str(i)) + print("Copying " + from_dir + " to " + to_dir) shutil.copytree(from_dir, to_dir) - initialize_datadir(test_dir, i) # Overwrite port/rpcport in hush.conf + initialize_datadir(test_dir, i) # Overwrite port/rpcport in HUSH3.conf def initialize_chain_clean(test_dir, num_nodes): """ @@ -218,9 +221,10 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary= """ Start a hushd and return RPC connection to it """ + print("Starting node " + str(i)) datadir = os.path.join(dirname, "node"+str(i)) # creating special config in case of cryptocondition asset chain test - if extra_args[0] == '-ac_name=REGTEST': + if len(extra_args) > 0 and extra_args[0] == '-ac_name=REGTEST': configpath = datadir + "/REGTEST.conf" with open(configpath, "w+") as config: config.write("regtest=1\n") @@ -259,7 +263,8 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary= if os.getenv("PYTHON_DEBUG", ""): print "start_node: calling hush-cli -rpcwait getblockcount returned" devnull.close() - port = extra_args[3] + #port = extra_args[3] + port = rpc_port(i) username = rpc_username() password = rpc_password() url = "http://%s:%s@%s:%d" % (username, password, rpchost or '127.0.0.1', int(port[9:])) @@ -276,6 +281,7 @@ def start_nodes(num_nodes, dirname, extra_args=None, rpchost=None, binary=None): """ Start multiple hushds, return RPC connections to them """ + print("Starting " + str(num_nodes) + " nodes") if extra_args is None: extra_args = [ None for i in range(num_nodes) ] if binary is None: binary = [ None for i in range(num_nodes) ] return [ start_node(i, dirname, extra_args[i], rpchost, binary=binary[i]) for i in range(num_nodes) ] @@ -288,6 +294,7 @@ def check_node(i): return bitcoind_processes[i].returncode def stop_node(node, i): + print("Stopping node " + i) node.stop() bitcoind_processes[i].wait() del bitcoind_processes[i] @@ -298,11 +305,12 @@ def stop_nodes(nodes): del nodes[:] # Emptying array closes connections as a side effect def set_node_times(nodes, t): + print("Setting nodes time to " + t) for node in nodes: node.setmocktime(t) def wait_bitcoinds(): - # Wait for all bitcoinds to cleanly exit + print("Waiting for all nodes to cleanly exit") for bitcoind in bitcoind_processes.values(): bitcoind.wait() bitcoind_processes.clear() diff --git a/qa/rpc-tests/wallet_sapling.py b/qa/rpc-tests/wallet_sapling.py index c9e796b72..cca928c44 100755 --- a/qa/rpc-tests/wallet_sapling.py +++ b/qa/rpc-tests/wallet_sapling.py @@ -19,9 +19,9 @@ class WalletSaplingTest(BitcoinTestFramework): def setup_nodes(self): return start_nodes(4, self.options.tmpdir, [[ - '-nuparams=5ba81b19:201', # Overwinter - '-nuparams=76b809bb:203', # Sapling - '-experimentalfeatures', '-zmergetoaddress', + #'-nuparams=5ba81b19:201', # Overwinter + #'-nuparams=76b809bb:203', # Sapling + #'-experimentalfeatures', '-zmergetoaddress', ]] * 4) def run_test(self): diff --git a/test_antispam b/test_antispam new file mode 100755 index 000000000..b51d802fe --- /dev/null +++ b/test_antispam @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# any CLI args given to this script will be passed along +# example: ./test_antispam -debug=blah +./src/hushd -ac_name=ANTISPAM -ac_private=1 -ac_blocktime=180 -ac_reward=500000000 -ac_supply=55555 -gen=1 -genproclimit=1 -testnode=1 $@ + +# to run via the debugger +# type "run" when gdb prompt appears +#gdb --args ./src/hushd -- -ac_algo=randomx -ac_name=ANTISPAM -ac_private=1 -ac_blocktime=180 -ac_reward=500000000 -ac_supply=55555 -gen=1 -genproclimit=1 -testnode=1 From 84a0c2c35ec9298ee6baa86f9210ed6dcd028103 Mon Sep 17 00:00:00 2001 From: Duke Date: Sat, 7 Oct 2023 14:16:59 -0400 Subject: [PATCH 39/45] antispam test --- qa/rpc-tests/antispam.py | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 qa/rpc-tests/antispam.py diff --git a/qa/rpc-tests/antispam.py b/qa/rpc-tests/antispam.py new file mode 100755 index 000000000..9913eef56 --- /dev/null +++ b/qa/rpc-tests/antispam.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python2 +# Copyright (c) 2016-2023 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 + +from test_framework.test_framework import BitcoinTestFramework +from test_framework.authproxy import JSONRPCException +from test_framework.util import ( + assert_equal, + start_nodes, + wait_and_assert_operationid_status, +) + +from decimal import Decimal + +class AntispamTest(BitcoinTestFramework): + + def setup_nodes(self): + return start_nodes(2, self.options.tmpdir, [[ ]] * 2) + + def run_test(self): + # Sanity-check the test harness + assert_equal(self.nodes[0].getblockcount(), 200) + + # make sure we can mine a block + self.nodes[1].generate(1) + self.sync_all() + + # make a new zaddr on each node + saplingAddr0 = self.nodes[0].z_getnewaddress() + saplingAddr1 = self.nodes[1].z_getnewaddress() + + # Verify addresses + assert(saplingAddr0 in self.nodes[0].z_listaddresses()) + assert(saplingAddr1 in self.nodes[1].z_listaddresses()) + assert_equal(self.nodes[0].z_validateaddress(saplingAddr0)['type'], 'sapling') + assert_equal(self.nodes[0].z_validateaddress(saplingAddr1)['type'], 'sapling') + + # Verify balance + assert_equal(self.nodes[0].z_getbalance(saplingAddr0), Decimal('0')) + assert_equal(self.nodes[1].z_getbalance(saplingAddr1), Decimal('0')) + +if __name__ == '__main__': + AntispamTest().main() From b200dcb2c7807886b01fc26d4a83e2411664c159 Mon Sep 17 00:00:00 2001 From: Duke Date: Tue, 10 Oct 2023 12:03:41 -0400 Subject: [PATCH 40/45] Update test_antispam --- test_antispam | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test_antispam b/test_antispam index b51d802fe..5ccfb4752 100755 --- a/test_antispam +++ b/test_antispam @@ -2,8 +2,9 @@ # any CLI args given to this script will be passed along # example: ./test_antispam -debug=blah -./src/hushd -ac_name=ANTISPAM -ac_private=1 -ac_blocktime=180 -ac_reward=500000000 -ac_supply=55555 -gen=1 -genproclimit=1 -testnode=1 $@ +#./src/hushd -ac_name=ANTISPAM -ac_private=1 -ac_blocktime=180 -ac_reward=500000000 -ac_supply=55555 -gen=1 -genproclimit=1 -testnode=1 $@ +./src/hushd -ac_name=ANTISPAM -ac_private=1 -ac_blocktime=180 -ac_reward=500000000 -ac_supply=55555 $@ # to run via the debugger # type "run" when gdb prompt appears #gdb --args ./src/hushd -- -ac_algo=randomx -ac_name=ANTISPAM -ac_private=1 -ac_blocktime=180 -ac_reward=500000000 -ac_supply=55555 -gen=1 -genproclimit=1 -testnode=1 From 7db6745056683a07d0851dc40846dbcb961c1f7e Mon Sep 17 00:00:00 2001 From: Duke Date: Tue, 10 Oct 2023 12:05:53 -0400 Subject: [PATCH 41/45] s/zouts/zins/ in debug log --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 768e6f397..01b907e80 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -601,7 +601,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if(tx.vShieldedSpend.size() >= LARGE_ZINS_THRESHOLD) { large_zins++; - LogPrintf("%s: txid=%s has large zins=%d (%d large zouts in block)\n", __func__, tx.GetHash().ToString().c_str(), + LogPrintf("%s: txid=%s has large zins=%d (%d large zins in block)\n", __func__, tx.GetHash().ToString().c_str(), tx.vShieldedSpend.size(), large_zins ); } From 963ce1e444bcb9d8a4ab43179c2a70c251f07193 Mon Sep 17 00:00:00 2001 From: Duke Date: Tue, 10 Oct 2023 22:04:15 -0400 Subject: [PATCH 42/45] Release randomx dataset+cache when mining is interrupted or errors --- src/miner.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/miner.cpp b/src/miner.cpp index 01b907e80..b1a4b917f 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1424,12 +1424,24 @@ void static RandomXMiner() } catch (const boost::thread_interrupted&) { miningTimer.stop(); c.disconnect(); + + randomx_release_dataset(randomxDataset); + rxdebug("%s: released dataset\n"); + randomx_release_cache(randomxCache); + rxdebug("%s: released cache\n"); + LogPrintf("HushRandomXMiner terminated\n"); throw; } catch (const std::runtime_error &e) { miningTimer.stop(); c.disconnect(); fprintf(stderr,"RandomXMiner: runtime error: %s\n", e.what()); + + randomx_release_dataset(randomxDataset); + rxdebug("%s: released dataset\n"); + randomx_release_cache(randomxCache); + rxdebug("%s: released cache\n"); + return; } From fc6745129d5087a2dd5ab102ecf15594366785bb Mon Sep 17 00:00:00 2001 From: Duke Date: Wed, 11 Oct 2023 12:07:40 -0400 Subject: [PATCH 43/45] Fix randomx memory leak but create some mining errors This change lifts the declaration of the randomx VM out of an inner loop into the main function body of RandomXMiner(), which allows us to destroy it later on when catching exceptions. We cannot lift the allocation of it's memory (randomx_create_vm) because it depends on things that change in every iteration of the inner loop. Otherwise, the VM will only sometimes be destroyed, which is what I think causes the memleak. But this seems to create one invalid block when mining each block height : STDOUT: TestBlockValidity: failure C checkPOW=1 RandomXMiner: Invalid randomx block mined, try again 05f30f419133b2d862106b89c20059967639e4f2699dd5afc5d2b0832f1ac76a debug.log: 2023-10-11 16:10:41 CreateNewBlock(): total size 1000 blocktime.1697040642 nBits.200e77d1 2023-10-11 16:10:41 Running HushRandomXMiner with 1 transactions in block (260 bytes) 2023-10-11 16:10:41 ERROR: ContextualCheckBlock: block height mismatch in coinbase Mining does seem to continue normally when testing with -testnode=1 --- src/miner.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index b1a4b917f..cae77d46a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1122,6 +1122,7 @@ void static RandomXMiner() int randomxInterval = GetArg("-ac_randomx_interval",1024); // This lag is 80 mins for 75s blocktime and 64 mins for 60s (default) blocktime for HSCs int randomxBlockLag = GetArg("-ac_randomx_lag", 64); + randomx_vm *myVM = nullptr; try { // fprintf(stderr,"RandomXMiner: mining %s with randomx\n",SMART_CHAIN_SYMBOL); @@ -1198,7 +1199,7 @@ void static RandomXMiner() // randomx_init_dataset(randomxDataset, randomxCache, 0, datasetItemCount); rxdebug("%s: dataset initialized\n"); - randomx_vm *myVM = randomx_create_vm(flags, nullptr, randomxDataset); + myVM = randomx_create_vm(flags, nullptr, randomxDataset); if(myVM == NULL) { LogPrintf("RandomXMiner: Cannot create RandomX VM, aborting!\n"); return; @@ -1425,6 +1426,8 @@ void static RandomXMiner() miningTimer.stop(); c.disconnect(); + randomx_destroy_vm(myVM); + LogPrintf("%s: destroyed vm\n", __func__); randomx_release_dataset(randomxDataset); rxdebug("%s: released dataset\n"); randomx_release_cache(randomxCache); @@ -1437,6 +1440,8 @@ void static RandomXMiner() c.disconnect(); fprintf(stderr,"RandomXMiner: runtime error: %s\n", e.what()); + randomx_destroy_vm(myVM); + LogPrintf("%s: destroyed vm\n", __func__); randomx_release_dataset(randomxDataset); rxdebug("%s: released dataset\n"); randomx_release_cache(randomxCache); From 80bd3f262c66e7e55fdcf6e8defc2c8d1931f0bb Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 12 Oct 2023 10:01:01 -0400 Subject: [PATCH 44/45] Verbosify randomx debug logging in case that helps debug mismatched height coinbase issue --- src/miner.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index cae77d46a..11aae8122 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1427,11 +1427,11 @@ void static RandomXMiner() c.disconnect(); randomx_destroy_vm(myVM); - LogPrintf("%s: destroyed vm\n", __func__); + LogPrintf("%s: destroyed vm via thread interrupt\n", __func__); randomx_release_dataset(randomxDataset); - rxdebug("%s: released dataset\n"); + rxdebug("%s: released dataset via thread interrupt\n"); randomx_release_cache(randomxCache); - rxdebug("%s: released cache\n"); + rxdebug("%s: released cache via thread interrupt\n"); LogPrintf("HushRandomXMiner terminated\n"); throw; @@ -1441,19 +1441,19 @@ void static RandomXMiner() fprintf(stderr,"RandomXMiner: runtime error: %s\n", e.what()); randomx_destroy_vm(myVM); - LogPrintf("%s: destroyed vm\n", __func__); + LogPrintf("%s: destroyed vm because of error\n", __func__); randomx_release_dataset(randomxDataset); - rxdebug("%s: released dataset\n"); + rxdebug("%s: released dataset because of error\n"); randomx_release_cache(randomxCache); - rxdebug("%s: released cache\n"); + rxdebug("%s: released cache because of error\n"); return; } randomx_release_dataset(randomxDataset); - rxdebug("%s: released dataset\n"); + rxdebug("%s: released dataset in normal exit\n"); randomx_release_cache(randomxCache); - rxdebug("%s: released cache\n"); + rxdebug("%s: released cache in normal exit\n"); miningTimer.stop(); c.disconnect(); } From 14d3ae17851615a69c33cb7eed623b904b140e3d Mon Sep 17 00:00:00 2001 From: Duke Date: Fri, 13 Oct 2023 04:22:24 -0700 Subject: [PATCH 45/45] Reject ztxs with duplicate zkproofs This is a greatly simplified and slightly tweaked version of https://github.com/PirateNetwork/pirate/commit/af2e3713e286d61353edffd0b4c89c931b455cb4 Their version will detect duplicate zkproofs across transactions while this code will only detect duplicate zkproofs in a single ztx. If dupes are found, the tx will be denied entry into the mempool. This provides most of the benefit (increased CPU cost to attackers) with the least code change and no annoyance to full node operators. Detecting duplicate zkproofs across transactions requires a one-time reindex of all of history, which means significant downtime for nodes. Since Hush + HSCs have a much more strict policy on number of shielded outputs and shielded inputs, only detecting duplicate zkproofs in individual ztxs seems sufficient for now. No correctly functioning node or wallet will ever create duplicate zkproofs, so there is no worry of this accidentally affecting normal users. Currently this is not a consensus rule but it could become one in the future. --- src/consensus/validation.h | 2 ++ src/main.cpp | 26 +++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/consensus/validation.h b/src/consensus/validation.h index 8ae53c89a..f3d7b3b31 100644 --- a/src/consensus/validation.h +++ b/src/consensus/validation.h @@ -29,6 +29,8 @@ static const unsigned char REJECT_MALFORMED = 0x01; static const unsigned char REJECT_INVALID = 0x10; static const unsigned char REJECT_OBSOLETE = 0x11; static const unsigned char REJECT_DUPLICATE = 0x12; +static const unsigned char REJECT_DUPLICATE_OUTPUT_PROOF = 0x13; +static const unsigned char REJECT_DUPLICATE_SPEND_PROOF = 0x14; static const unsigned char REJECT_NONSTANDARD = 0x40; static const unsigned char REJECT_DUST = 0x41; static const unsigned char REJECT_INSUFFICIENTFEE = 0x42; diff --git a/src/main.cpp b/src/main.cpp index 55b26b70b..0d132f952 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1751,7 +1751,31 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa { return error("AcceptToMemoryPool: CheckTransaction failed"); } - + + // Reject duplicate output proofs in a single ztx in mempool + // Migrate this to CheckTransaction() to make it a consensus requirement + { + set vSaplingOutputProof; + BOOST_FOREACH(const OutputDescription& output, tx.vShieldedOutput) + { + if (vSaplingOutputProof.count(output.zkproof)) + return state.Invalid(error("AcceptToMemoryPool: duplicate output proof"),REJECT_DUPLICATE_OUTPUT_PROOF, "bad-txns-duplicate-output-proof"); + vSaplingOutputProof.insert(output.zkproof); + } + } + + // Reject duplicate spend proofs in a single ztx in mempool + // Migrate this to CheckTransaction() to make it a consensus requirement + { + set vSaplingSpendProof; + BOOST_FOREACH(const SpendDescription& spend, tx.vShieldedSpend) + { + if (vSaplingSpendProof.count(spend.zkproof)) + return state.Invalid(error("AcceptToMemoryPool: duplicate spend proof"),REJECT_DUPLICATE_SPEND_PROOF, "bad-txns-duplicate-spend-proof"); + vSaplingSpendProof.insert(spend.zkproof); + } + } + // DoS level set to 10 to be more forgiving. // Check transaction contextually against the set of consensus rules which apply in the next block to be mined. if (!ContextualCheckTransaction(0,0,0,tx, state, nextBlockHeight, (dosLevel == -1) ? 10 : dosLevel))