From 8126e706c6856b6cc1a380f7d12bb25710787984 Mon Sep 17 00:00:00 2001 From: Duke Date: Fri, 24 Mar 2023 10:22:31 -0700 Subject: [PATCH 01/78] Optional OP_RETURN in z_sendmany --- src/wallet/asyncrpcoperation_sendmany.cpp | 9 +++++++-- src/wallet/asyncrpcoperation_sendmany.h | 5 ++++- src/wallet/rpcwallet.cpp | 14 ++++++++++++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index b54a9b5de..d1573e02f 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -65,8 +65,9 @@ AsyncRPCOperation_sendmany::AsyncRPCOperation_sendmany( std::vector zOutputs, int minDepth, CAmount fee, - UniValue contextInfo) : - tx_(contextualTx), fromaddress_(fromAddress), t_outputs_(tOutputs), z_outputs_(zOutputs), mindepth_(minDepth), fee_(fee), contextinfo_(contextInfo) + UniValue contextInfo, + CScript opret) : + tx_(contextualTx), fromaddress_(fromAddress), t_outputs_(tOutputs), z_outputs_(zOutputs), mindepth_(minDepth), fee_(fee), contextinfo_(contextInfo), opret_(opret) { assert(fee_ >= 0); @@ -469,6 +470,10 @@ bool AsyncRPCOperation_sendmany::main_impl() { } } + // Add optional OP_RETURN if it exists + if ( opret_ != CScript() ) { + builder_.AddOpRet(opret_); + } // Build the transaction auto maybe_tx = builder_.Build(); if (!maybe_tx) { diff --git a/src/wallet/asyncrpcoperation_sendmany.h b/src/wallet/asyncrpcoperation_sendmany.h index 696cf1761..162680e20 100644 --- a/src/wallet/asyncrpcoperation_sendmany.h +++ b/src/wallet/asyncrpcoperation_sendmany.h @@ -62,7 +62,9 @@ public: std::vector zOutputs, int minDepth, CAmount fee = ASYNC_RPC_OPERATION_DEFAULT_MINERS_FEE, - UniValue contextInfo = NullUniValue); + UniValue contextInfo = NullUniValue, + CScript opret = CScript() + ); virtual ~AsyncRPCOperation_sendmany(); // We don't want to be copied or moved around @@ -92,6 +94,7 @@ private: CTxDestination fromtaddr_; PaymentAddress frompaymentaddress_; SpendingKey spendingkey_; + CScript opret_ = CScript(); uint256 joinSplitPubKey_; unsigned char joinSplitPrivKey_[crypto_sign_SECRETKEYBYTES]; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 97c89b97d..87d8ed64f 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5001,6 +5001,8 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) std::vector taddrRecipients; std::vector zaddrRecipients; CAmount nTotalOut = 0; + // Optional OP_RETURN data + CScript opret; bool containsSaplingOutput = false; @@ -5011,8 +5013,9 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) // sanity check, report error if unknown key-value pairs for (const string& name_ : o.getKeys()) { std::string s = name_; - if (s != "address" && s != "amount" && s!="memo") + if (s != "address" && s != "amount" && s!="memo" && s!="opreturn") { throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, unknown key: ")+s); + } } string address = find_value(o, "address").get_str(); @@ -5034,6 +5037,13 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) // throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+address); setAddress.insert(address); + UniValue opretValue = find_value(o, "opreturn"); + + // Create the CScript representation of the OP_RETURN + if (!opretValue.isNull()) { + opret << OP_RETURN << ParseHex(opretValue.get_str().c_str()); + } + UniValue memoValue = find_value(o, "memo"); string memo; if (!memoValue.isNull()) { @@ -5207,7 +5217,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) // Create operation and add to global queue std::shared_ptr q = getAsyncRPCQueue(); - std::shared_ptr operation( new AsyncRPCOperation_sendmany(builder, contextualTx, fromaddress, taddrRecipients, zaddrRecipients, nMinDepth, nFee, contextInfo) ); + std::shared_ptr operation( new AsyncRPCOperation_sendmany(builder, contextualTx, fromaddress, taddrRecipients, zaddrRecipients, nMinDepth, nFee, contextInfo, opret) ); q->addOperation(operation); if(fZdebug) LogPrintf("%s: Submitted to async queue\n", __FUNCTION__); From 98ee2a6a4fee216874f09b49fb3b29a825475e1d Mon Sep 17 00:00:00 2001 From: Duke Date: Wed, 5 Apr 2023 19:24:30 -0700 Subject: [PATCH 02/78] Declare various CBlockTreeDB methods as const Ported from https://github.com/zcash/zcash/commit/fb66589022df4a0eff6ff244aa6b713c3a2bb2dd which has some methods we do not yet have. --- src/txdb.cpp | 14 +++++++------- src/txdb.h | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/txdb.cpp b/src/txdb.cpp index 1035f3070..dbba3654f 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -203,7 +203,7 @@ bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins, CBlockTreeDB::CBlockTreeDB(size_t nCacheSize, bool fMemory, bool fWipe, bool compression, int maxOpenFiles) : CDBWrapper(GetDataDir() / "blocks" / "index", nCacheSize, fMemory, fWipe, compression, maxOpenFiles) { } -bool CBlockTreeDB::ReadBlockFileInfo(int nFile, CBlockFileInfo &info) { +bool CBlockTreeDB::ReadBlockFileInfo(int nFile, CBlockFileInfo &info) const { return Read(make_pair(DB_BLOCK_FILES, nFile), info); } @@ -214,12 +214,12 @@ bool CBlockTreeDB::WriteReindexing(bool fReindexing) { return Erase(DB_REINDEX_FLAG); } -bool CBlockTreeDB::ReadReindexing(bool &fReindexing) { +bool CBlockTreeDB::ReadReindexing(bool &fReindexing) const { fReindexing = Exists(DB_REINDEX_FLAG); return true; } -bool CBlockTreeDB::ReadLastBlockFile(int &nFile) { +bool CBlockTreeDB::ReadLastBlockFile(int &nFile) const { return Read(DB_LAST_BLOCK, nFile); } @@ -293,7 +293,7 @@ bool CBlockTreeDB::EraseBatchSync(const std::vector& blockin return WriteBatch(batch, true); } -bool CBlockTreeDB::ReadTxIndex(const uint256 &txid, CDiskTxPos &pos) { +bool CBlockTreeDB::ReadTxIndex(const uint256 &txid, CDiskTxPos &pos) const { return Read(make_pair(DB_TXINDEX, txid), pos); } @@ -304,7 +304,7 @@ bool CBlockTreeDB::WriteTxIndex(const std::vector return WriteBatch(batch); } -bool CBlockTreeDB::ReadSpentIndex(CSpentIndexKey &key, CSpentIndexValue &value) { +bool CBlockTreeDB::ReadSpentIndex(CSpentIndexKey &key, CSpentIndexValue &value) const { return Read(make_pair(DB_SPENTINDEX, key), value); } @@ -625,7 +625,7 @@ bool CBlockTreeDB::WriteTimestampBlockIndex(const CTimestampBlockIndexKey &block return WriteBatch(batch); } -bool CBlockTreeDB::ReadTimestampBlockIndex(const uint256 &hash, unsigned int <imestamp) { +bool CBlockTreeDB::ReadTimestampBlockIndex(const uint256 &hash, unsigned int <imestamp) const { CTimestampBlockIndexValue(lts); if (!Read(std::make_pair(DB_BLOCKHASHINDEX, hash), lts)) @@ -639,7 +639,7 @@ bool CBlockTreeDB::WriteFlag(const std::string &name, bool fValue) { return Write(std::make_pair(DB_FLAG, name), fValue ? '1' : '0'); } -bool CBlockTreeDB::ReadFlag(const std::string &name, bool &fValue) { +bool CBlockTreeDB::ReadFlag(const std::string &name, bool &fValue) const { char ch; if (!Read(std::make_pair(DB_FLAG, name), ch)) return false; diff --git a/src/txdb.h b/src/txdb.h index f96f73650..68042880a 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -93,13 +93,13 @@ private: public: bool WriteBatchSync(const std::vector >& fileInfo, int nLastFile, const std::vector& blockinfo); bool EraseBatchSync(const std::vector& blockinfo); - bool ReadBlockFileInfo(int nFile, CBlockFileInfo &fileinfo); - bool ReadLastBlockFile(int &nFile); + bool ReadBlockFileInfo(int nFile, CBlockFileInfo &fileinfo) const; + bool ReadLastBlockFile(int &nFile) const; bool WriteReindexing(bool fReindex); - bool ReadReindexing(bool &fReindex); + bool ReadReindexing(bool &fReindex) const; bool ReadTxIndex(const uint256 &txid, CDiskTxPos &pos); bool WriteTxIndex(const std::vector > &list); - bool ReadSpentIndex(CSpentIndexKey &key, CSpentIndexValue &value); + bool ReadSpentIndex(CSpentIndexKey &key, CSpentIndexValue &value) const; bool UpdateSpentIndex(const std::vector >&vect); bool UpdateAddressUnspentIndex(const std::vector >&vect); bool ReadAddressUnspentIndex(uint160 addressHash, int type, @@ -112,9 +112,9 @@ public: bool WriteTimestampIndex(const CTimestampIndexKey ×tampIndex); bool ReadTimestampIndex(const unsigned int &high, const unsigned int &low, const bool fActiveOnly, std::vector > &vect); bool WriteTimestampBlockIndex(const CTimestampBlockIndexKey &blockhashIndex, const CTimestampBlockIndexValue &logicalts); - bool ReadTimestampBlockIndex(const uint256 &hash, unsigned int &logicalTS); + bool ReadTimestampBlockIndex(const uint256 &hash, unsigned int &logicalTS) const; bool WriteFlag(const std::string &name, bool fValue); - bool ReadFlag(const std::string &name, bool &fValue); + bool ReadFlag(const std::string &name, bool &fValue) const; bool LoadBlockIndexGuts(); bool blockOnchainActive(const uint256 &hash); UniValue Snapshot(int top); From 0b68ea2a2069ec62b3bd0a8fdc6a9a87454d0bac Mon Sep 17 00:00:00 2001 From: Duke Date: Wed, 5 Apr 2023 19:31:15 -0700 Subject: [PATCH 03/78] Disable rust docs to speed up build times --- depends/packages/rust.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/depends/packages/rust.mk b/depends/packages/rust.mk index 6fbdda037..6bae892a2 100644 --- a/depends/packages/rust.mk +++ b/depends/packages/rust.mk @@ -46,12 +46,12 @@ define $(package)_extract_cmds endef define $(package)_stage_cmds - bash ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig && \ - ../$(canonical_host)/install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig + bash ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig --without=rust-docs && \ + ../$(canonical_host)/install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig --without=rust-docs endef else define $(package)_stage_cmds - bash ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig + bash ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig --without=rust-docs endef endif From b4be7aa19b56156ec1163838853a874316b0a12a Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 6 Apr 2023 05:40:30 -0700 Subject: [PATCH 04/78] malloc_trim does not seem to exist on FreeBSD --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 75ca325d0..36a907df5 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2516,7 +2516,7 @@ void CWallet::DeleteTransactions(std::vector &removeTxs) { } } //TODO: the build system should check for malloc_trim support -#if defined(__unix__) +#if defined(__linux__) malloc_trim(0); #else // On Mac and Win memory isn't kept back upon vector or list member erase, different garbage collector strategy. No need to force trimming. From 8c8f451be8a14d5b5d8f4f41a37d53c7ba4b38e6 Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 6 Apr 2023 12:37:10 -0400 Subject: [PATCH 05/78] Remove dead code from CheckTransaction() --- src/main.cpp | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 8559372ca..ef0fcfbba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1422,26 +1422,6 @@ bool ContextualCheckTransaction(int32_t slowflag,const CBlock *block, CBlockInde bool CheckTransaction(uint32_t tiptime,const CTransaction& tx, CValidationState &state, libzcash::ProofVerifier& verifier,int32_t txIndex, int32_t numTxs) { - static uint256 array[64]; static int32_t numbanned,indallvouts; int32_t j,k,n; - if ( *(int32_t *)&array[0] == 0 ) - numbanned = hush_bannedset(&indallvouts,array,(int32_t)(sizeof(array)/sizeof(*array))); - n = tx.vin.size(); - if ( SMART_CHAIN_SYMBOL[0] == 0 ) - { - for (j=0; j= indallvouts) ) - { - static uint32_t counter; - if ( counter++ < 100 ) - printf("MEMPOOL: banned tx.%d being used at ht.%d vout.%d\n",k,(int32_t)chainActive.Tip()->GetHeight(),j); - return(false); - } - } - } - } // Don't count coinbase transactions because mining skews the count if (!tx.IsCoinBase()) { transactionsValidated.increment(); From 4c5649454b5143ea6bad72d1eb4cc219c59fefc1 Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 6 Apr 2023 12:44:30 -0400 Subject: [PATCH 06/78] Fix const-ness of ReadTxIndex --- src/txdb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/txdb.h b/src/txdb.h index 68042880a..0b0ac376c 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -97,7 +97,7 @@ public: bool ReadLastBlockFile(int &nFile) const; bool WriteReindexing(bool fReindex); bool ReadReindexing(bool &fReindex) const; - bool ReadTxIndex(const uint256 &txid, CDiskTxPos &pos); + bool ReadTxIndex(const uint256 &txid, CDiskTxPos &pos) const; bool WriteTxIndex(const std::vector > &list); bool ReadSpentIndex(CSpentIndexKey &key, CSpentIndexValue &value) const; bool UpdateSpentIndex(const std::vector >&vect); From f0ee52a94ded338f8209e9c97420abd997f52716 Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 6 Apr 2023 12:44:37 -0400 Subject: [PATCH 07/78] Remove dead code --- src/hush_gateway.h | 94 +--------------------------------------------- src/hush_globals.h | 1 - 2 files changed, 1 insertion(+), 94 deletions(-) diff --git a/src/hush_gateway.h b/src/hush_gateway.h index 0002e69a9..8be1f7c39 100644 --- a/src/hush_gateway.h +++ b/src/hush_gateway.h @@ -624,38 +624,6 @@ int32_t hush_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t toko return(0); } -const char *banned_txids[] = -{ - "78cb4e21245c26b015b888b14c4f5096e18137d2741a6de9734d62b07014dfca", // vout1 only 233559 - "00697be658e05561febdee1aafe368b821ca33fbb89b7027365e3d77b5dfede5", //234172 - "e909465788b32047c472d73e882d79a92b0d550f90be008f76e1edaee6d742ea", //234187 - "f56c6873748a327d0b92b8108f8ec8505a2843a541b1926022883678fb24f9dc", //234188 - "abf08be07d8f5b3a433ddcca7ef539e79a3571632efd6d0294ec0492442a0204", //234213 - "3b854b996cc982fba8c06e76cf507ae7eed52ab92663f4c0d7d10b3ed879c3b0", //234367 - "fa9e474c2cda3cb4127881a40eb3f682feaba3f3328307d518589024a6032cc4", //234635 - "ca746fa13e0113c4c0969937ea2c66de036d20274efad4ce114f6b699f1bc0f3", //234662 - "43ce88438de4973f21b1388ffe66e68fda592da38c6ef939be10bb1b86387041", //234697 - "0aeb748de82f209cd5ff7d3a06f65543904c4c17387c9d87c65fd44b14ad8f8c", //234899 - "bbd3a3d9b14730991e1066bd7c626ca270acac4127131afe25f877a5a886eb25", //235252 - "fa9943525f2e6c32cbc243294b08187e314d83a2870830180380c3c12a9fd33c", //235253 - "a01671c8775328a41304e31a6693bbd35e9acbab28ab117f729eaba9cb769461", //235265 - "2ef49d2d27946ad7c5d5e4ab5c089696762ff04e855f8ab48e83bdf0cc68726d", //235295 - "c85dcffb16d5a45bd239021ad33443414d60224760f11d535ae2063e5709efee", //235296 - // all vouts banned - "c4ea1462c207547cd6fb6a4155ca6d042b22170d29801a465db5c09fec55b19d", //246748 - "305dc96d8bc23a69d3db955e03a6a87c1832673470c32fe25473a46cc473c7d1", //247204 - //"43416a0c4da6b1a5c1d375bdbe8f7dc8d44d8f60df593d3376aa8221ec66357e", // vout0 only - //"1eb295ed54c47f35cbccd7e7e40d03041f1853581da6d41102a9d8813782b6cb", - //"db121e4012222adfc841824984a2a90b7e5b018dd71307822537d58160195e43", - //"28f95b8148ac4ae6e09c7380e34422fab41d568a411e53dc94823e36a3d6f386", - //"01d8c839463bda2f2f6400ede4611357913684927a767422a8560ead1b22557c", - //"6e4980a9e1bd669f4df04732dc6f11b7773b6de88d1abcf89a6b9007d72ef9ac", - //"6cc1d0495170bc0e11fd3925297623562e529ea1336b66ea61f8a1159041aed2", - //"250875424cece9bcd98cb226b09da7671625633d6958589e3a462bad89ad87cc", // missed - //"ea8659011de52f4dac42cda12326064b7b5013b8492f88e33159884ca299aa05", // missed - //"ce567928b5490a17244167af161b1d8dd6ff753fef222fe6855d95b2278a35b3", // missed -}; - int32_t hush_checkvout(int32_t vout,int32_t k,int32_t indallvouts) { if ( k < indallvouts ) @@ -665,29 +633,12 @@ int32_t hush_checkvout(int32_t vout,int32_t k,int32_t indallvouts) else return(vout == 0); } -int32_t hush_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max) -{ - int32_t i; - if ( sizeof(banned_txids)/sizeof(*banned_txids) > max ) - { - fprintf(stderr,"hush_bannedset: buffer too small %d vs %d\n",(int32_t)(sizeof(banned_txids)/sizeof(*banned_txids)),max); - StartShutdown(); - } - for (i=0; i 1 && block.vtx[txn_count-1].vout.size() > 0 && block.vtx[txn_count-1].vout[0].nValue == 5000 ) - { - /* - if ( block.vtx[txn_count-1].vin.size() == 1 && GetTransaction(block.vtx[txn_count-1].vin[0].prevout.hash,tx,hash,false) && block.vtx[0].vout[0].scriptPubKey == tx.vout[block.vtx[txn_count-1].vin[0].prevout.n].scriptPubKey ) - notmatched = 1; - */ - if ( block.vtx[txn_count-1].vin.size() == 1 ) { - uint256 hashNotaryProofVin = block.vtx[txn_count-1].vin[0].prevout.hash; - int fNotaryProofVinTxFound = GetTransaction(hashNotaryProofVin,tx,hash,false); - if (!fNotaryProofVinTxFound) { - // try to search in the same block - BOOST_FOREACH(const CTransaction &txInThisBlock, block.vtx) { - if (txInThisBlock.GetHash() == hashNotaryProofVin) { - fNotaryProofVinTxFound = 1; - tx = txInThisBlock; - hash = block.GetHash(); - break; - } - } - } - if ( fNotaryProofVinTxFound && block.vtx[0].vout[0].scriptPubKey == tx.vout[block.vtx[txn_count-1].vin[0].prevout.n].scriptPubKey ) - { - notmatched = 1; - } - } - } - n = block.vtx[i].vin.size(); - for (j=0; j= indallvouts) ) - { - printf("banned tx.%d being used at ht.%d txi.%d vini.%d\n",k,height,i,j); - return(-1); - } - } - } - } - } + if ( SMART_CHAIN_SYMBOL[0] == 0 || ((ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD) && height > 1) || NetworkUpgradeActive(height, Params().GetConsensus(), Consensus::UPGRADE_SAPLING) ) diff --git a/src/hush_globals.h b/src/hush_globals.h index 9bfb59302..4ac3060b6 100644 --- a/src/hush_globals.h +++ b/src/hush_globals.h @@ -30,7 +30,6 @@ int32_t hush_isrealtime(int32_t *hushheightp); uint64_t hush_paxtotal(); int32_t hush_longestchain(); uint64_t hush_maxallowed(int32_t baseid); -int32_t hush_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max); int32_t hush_checkvout(int32_t vout,int32_t k,int32_t indallvouts); pthread_mutex_t hush_mutex; From 15aaf4af44030bbab0c9d74143e3bee44c4911c0 Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 6 Apr 2023 12:59:31 -0400 Subject: [PATCH 08/78] Remove mempool p2p message #284 --- src/main.cpp | 25 ------------------------- src/protocol.cpp | 2 -- src/protocol.h | 6 ------ 3 files changed, 33 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ef0fcfbba..20ea1112f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7672,31 +7672,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, Misbehaving(pfrom->GetId(), nDoS); } } - - } else if (strCommand == NetMsgType::MEMPOOL) { - LOCK2(cs_main, pfrom->cs_filter); - //LogPrintf("%s: mempool request from %s",__func__, pfrom->addr.ToString().c_str()); - // TODO: limit mempool requests per time and per peer - - std::vector vtxid; - mempool.queryHashes(vtxid); - vector vInv; - BOOST_FOREACH(uint256& hash, vtxid) { - CInv inv(MSG_TX, hash); - if (pfrom->pfilter) { - CTransaction tx; - bool fInMemPool = mempool.lookup(hash, tx); - if (!fInMemPool) continue; // another thread removed since queryHashes, maybe... - if (!pfrom->pfilter->IsRelevantAndUpdate(tx)) continue; - } - vInv.push_back(inv); - if (vInv.size() == MAX_INV_SZ) { - pfrom->PushMessage(NetMsgType::INV, vInv); - vInv.clear(); - } - } - if (vInv.size() > 0) - pfrom->PushMessage(NetMsgType::INV, vInv); } else if (strCommand == NetMsgType::ALERT) { // Small DoS penalty so peers that send us lots of // duplicate/expired/invalid-signature/whatever alerts diff --git a/src/protocol.cpp b/src/protocol.cpp index 5aa3a7dd6..326cb6193 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -51,7 +51,6 @@ const char *TX="tx"; //used const char *HEADERS="headers"; //used const char *BLOCK="block"; //used const char *GETADDR="getaddr"; //used -const char *MEMPOOL="mempool"; //used const char *PING="ping"; //used const char *PONG="pong"; //used const char *NOTFOUND="notfound"; //used @@ -96,7 +95,6 @@ const static std::string allNetMessageTypes[] = { NetMsgType::HEADERS, NetMsgType::BLOCK, NetMsgType::GETADDR, - NetMsgType::MEMPOOL, NetMsgType::PING, NetMsgType::PONG, NetMsgType::NOTFOUND, diff --git a/src/protocol.h b/src/protocol.h index 3cd06fc88..f91e5e70e 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -158,12 +158,6 @@ extern const char* BLOCK; * preferably one with lots of IP addresses of other receiving nodes. */ extern const char* GETADDR; -/** - * The mempool message requests the TXIDs of transactions that the receiving - * node has verified as valid but which have not yet appeared in a block. - * @since protocol version 60002. - */ -extern const char* MEMPOOL; /** * The ping message is sent periodically to help confirm that the receiving * peer is still connected. From c69a47dd6192057f2ac5a3cd9b3134141c966a59 Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 6 Apr 2023 13:05:20 -0400 Subject: [PATCH 09/78] Remove dead code relating to interest --- src/wallet/wallet.cpp | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 36a907df5..e19152f38 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3303,7 +3303,7 @@ CAmount CWallet::GetImmatureWatchOnlyBalance() const void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const CCoinControl *coinControl, bool fIncludeZeroValue, bool fIncludeCoinBase) const { - uint64_t interest,*ptr; + uint64_t *ptr; vCoins.clear(); { @@ -3336,34 +3336,8 @@ void CWallet::AvailableCoins(vector& vCoins, bool fOnlyConfirmed, const !IsLockedCoin((*it).first, i) && (pcoin->vout[i].nValue > 0 || fIncludeZeroValue) && (!coinControl || !coinControl->HasSelected() || coinControl->IsSelected((*it).first, i))) { - if ( 1 ) { - uint32_t locktime; int32_t txheight; CBlockIndex *tipindex; - if ( SMART_CHAIN_SYMBOL[0] == 0 && chainActive.LastTip() != 0 && chainActive.LastTip()->GetHeight() >= 60000 ) - { - if ( pcoin->vout[i].nValue >= 10*COIN ) - { - if ( (tipindex= chainActive.LastTip()) != 0 ) - { - interest = 0; - } else interest = 0; - if ( interest != 0 ) - { - ptr = (uint64_t *)&pcoin->vout[i].interest; - (*ptr) = interest; - //pcoin->vout[i].nValue += interest; - } else { - ptr = (uint64_t *)&pcoin->vout[i].interest; - (*ptr) = 0; - } - } else { - ptr = (uint64_t *)&pcoin->vout[i].interest; - (*ptr) = 0; - } - } else { - ptr = (uint64_t *)&pcoin->vout[i].interest; - (*ptr) = 0; - } - } + ptr = (uint64_t *)&pcoin->vout[i].interest; + (*ptr) = 0; vCoins.push_back(COutput(pcoin, i, nDepth, (mine & ISMINE_SPENDABLE) != ISMINE_NO)); } } From 533356ce63832928b97c6c234c47daabc0624eba Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 6 Apr 2023 13:22:20 -0400 Subject: [PATCH 10/78] Remove more dead code related to interest --- src/wallet/wallet.cpp | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index e19152f38..96d01260d 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3773,26 +3773,12 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt //a chance at a free transaction. //But mempool inputs might still be in the mempool, so their age stays 0 //fprintf(stderr,"nCredit %.8f interest %.8f\n",(double)nCredit/COIN,(double)pcoin.first->vout[pcoin.second].interest/COIN); - if ( SMART_CHAIN_SYMBOL[0] == 0 ) - { - interest2 += pcoin.first->vout[pcoin.second].interest; - //fprintf(stderr,"%.8f ",(double)pcoin.first->vout[pcoin.second].interest/COIN); - } int age = pcoin.first->GetDepthInMainChain(); if (age != 0) age += 1; dPriority += (double)nCredit * age; } - //TODO: delete this - if ( SMART_CHAIN_SYMBOL[0] == 0 && DONATION_PUBKEY.size() == 66 && interest2 > 5000 ) - { - CScript scriptDonation = CScript() << ParseHex(DONATION_PUBKEY) << OP_CHECKSIG; - CTxOut newTxOut(interest2,scriptDonation); - int32_t nDonationPosRet = txNew.vout.size() - 1; // dont change first or last - vector::iterator position = txNew.vout.begin()+nDonationPosRet; - txNew.vout.insert(position, newTxOut); - interest2 = 0; - } + CAmount nChange = (nValueIn - nValue + interest2); //fprintf(stderr,"wallet change %.8f (%.8f - %.8f) interest2 %.8f total %.8f\n",(double)nChange/COIN,(double)nValueIn/COIN,(double)nValue/COIN,(double)interest2/COIN,(double)nTotalValue/COIN); if (nSubtractFeeFromAmount == 0) From fba0d4136daec21810cfe0319f2a0ce3e0b13464 Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 6 Apr 2023 13:28:14 -0400 Subject: [PATCH 11/78] Remove code for unsupported chains --- src/cc/assets.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index ebc977dc0..d2ec4f21b 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -150,20 +150,6 @@ bool AssetsValidate(struct CCcontract_info *cpAssets,Eval* eval,const CTransacti outputsDummy = inputs = 0; preventCCvins = preventCCvouts = -1; - // add specific chains exceptions for old token support: - if (strcmp(SMART_CHAIN_SYMBOL, "SEC") == 0 && chainActive.Height() <= 144073) - return true; - - if (strcmp(SMART_CHAIN_SYMBOL, "MGNX") == 0 && chainActive.Height() <= 210190) - return true; - - // add specific chains exceptions for old token support: - if (strcmp(SMART_CHAIN_SYMBOL, "SEC") == 0 && chainActive.Height() <= 144073) - return true; - - if (strcmp(SMART_CHAIN_SYMBOL, "MGNX") == 0 && chainActive.Height() <= 210190) - return true; - if (numvouts == 0) return eval->Invalid("AssetValidate: no vouts"); From c1ec1b0e9529a6d5f117aafaf035b5f56c8b5478 Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 6 Apr 2023 13:31:07 -0400 Subject: [PATCH 12/78] Remove dead code --- src/hush_nSPV_superlite.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/hush_nSPV_superlite.h b/src/hush_nSPV_superlite.h index 84b6aa6cd..418957e57 100644 --- a/src/hush_nSPV_superlite.h +++ b/src/hush_nSPV_superlite.h @@ -1,5 +1,4 @@ // Copyright (c) 2016-2023 The Hush developers - /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * @@ -392,8 +391,6 @@ UniValue NSPV_utxoresp_json(struct NSPV_utxoresp *utxos,int32_t numutxos) item.push_back(Pair("txid",utxos[i].txid.GetHex())); item.push_back(Pair("vout",(int64_t)utxos[i].vout)); item.push_back(Pair("value",(double)utxos[i].satoshis/COIN)); - if ( SMART_CHAIN_SYMBOL[0] == 0 ) - item.push_back(Pair("interest",(double)utxos[i].extradata/COIN)); array.push_back(item); } return(array); @@ -409,8 +406,6 @@ UniValue NSPV_utxosresp_json(struct NSPV_utxosresp *ptr) result.push_back(Pair("height",(int64_t)ptr->nodeheight)); result.push_back(Pair("numutxos",(int64_t)ptr->numutxos)); result.push_back(Pair("balance",(double)ptr->total/COIN)); - if ( SMART_CHAIN_SYMBOL[0] == 0 ) - result.push_back(Pair("interest",(double)ptr->interest/COIN)); result.push_back(Pair("filter",(int64_t)ptr->filter)); result.push_back(Pair("lastpeer",NSPV_lastpeer)); return(result); From 852f747cbfb6b4af4abef2ffc5cd294da4457cff Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 6 Apr 2023 13:39:42 -0400 Subject: [PATCH 13/78] Remove dead code --- src/cc/import.cpp | 3 --- src/hush_utils.h | 10 +++++----- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/cc/import.cpp b/src/cc/import.cpp index bb88e8831..98cd3f30c 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -672,9 +672,6 @@ bool Eval::ImportCoin(const std::vector params, const CTransaction &imp LOGSTREAM("importcoin", CCLOG_DEBUG1, stream << "Validating import tx..., txid=" << importTx.GetHash().GetHex() << std::endl); - if (strcmp(SMART_CHAIN_SYMBOL, "CFEKDIMXY6") == 0 && chainActive.Height() <= 44693) - return true; - if (importTx.vout.size() < 2) return Invalid("too-few-vouts"); // params diff --git a/src/hush_utils.h b/src/hush_utils.h index 07cac8b08..94eb61374 100644 --- a/src/hush_utils.h +++ b/src/hush_utils.h @@ -2460,8 +2460,6 @@ void hush_args(char *argv0) } } else BITCOIND_RPCPORT = GetArg("-rpcport", BaseParams().RPCPort()); HUSH_DPOWCONFS = GetArg("-dpowconfs",dpowconfs); - if ( strcmp(SMART_CHAIN_SYMBOL,"CA333LIES") == 0 ) - HUSH_EXTRASATOSHI = 1; } void hush_nameset(char *symbol,char *dest,char *source) @@ -2478,11 +2476,13 @@ void hush_nameset(char *symbol,char *dest,char *source) struct hush_state *hush_stateptrget(char *base) { int32_t baseid; - if ( base == 0 || base[0] == 0 || strcmp(base,(char *)"KYCSELLOUTS") == 0 ) + if ( base == 0 || base[0] == 0 ) { return(&HUSH_STATES[33]); - else if ( (baseid= hush_baseid(base)) >= 0 ) + } else if ( (baseid= hush_baseid(base)) >= 0 ) { return(&HUSH_STATES[baseid+1]); - else return(&HUSH_STATES[0]); + } else { + return(&HUSH_STATES[0]); + } } struct hush_state *hush_stateptr(char *symbol,char *dest) From 053e9156a7a22bc263b830819cfcc7f8c22ffb34 Mon Sep 17 00:00:00 2001 From: Duke Date: Wed, 12 Apr 2023 10:08:09 -0400 Subject: [PATCH 14/78] Fix progress estimate for HUSH at startup --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 20ea1112f..8226e1d9c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5960,7 +5960,7 @@ bool static LoadBlockIndexDB() PruneBlockIndexCandidates(); double progress; - if ( SMART_CHAIN_SYMBOL[0] == 0 ) { + if ( ishush3 ) { progress = Checkpoints::GuessVerificationProgress(chainparams.Checkpoints(), chainActive.LastTip()); } else { int32_t longestchain = hush_longestchain(); From 7102d50a477eccca06ea2166a6ae8a9e87cd76e3 Mon Sep 17 00:00:00 2001 From: Duke Date: Sat, 22 Apr 2023 15:54:13 -0700 Subject: [PATCH 15/78] Try to prevent #266 We seem to have a bug that we don't find a peer when looking for a peer in peers.dat . Instead of doing an assertion and crashing the node, just keep iterating in the loop. The code which computes nId may have an off-by-one error, such that it looks up an incorrect bucket position and doesn't find a valid nId. --- src/addrman.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/addrman.cpp b/src/addrman.cpp index 60f27347a..535151c2a 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -499,7 +499,12 @@ CAddrInfo CAddrMan::Select_(bool newOnly) MilliSleep(kRetrySleepInterval); } int nId = vvTried[nKBucket][nKBucketPos]; - assert(mapInfo.count(nId) == 1); + // assert(mapInfo.count(nId) == 1); + if(mapInfo.count(nId) != 1) { + fprintf(stderr,"%s: Could not find tried node with nId=%d=vvTried[%d][%d], mapInfo.count(%d)=%d\n", __func__, nId, nKBucket, nKBuckedPos, nId, mapInfo.count(nId) ); + continue; + } + CAddrInfo& info = mapInfo[nId]; if (info.IsReachableNetwork()) { //deprioritize unreachable networks @@ -534,7 +539,12 @@ CAddrInfo CAddrMan::Select_(bool newOnly) MilliSleep(kRetrySleepInterval); } int nId = vvNew[nUBucket][nUBucketPos]; - assert(mapInfo.count(nId) == 1); + + if(mapInfo.count(nId) != 1) { + fprintf(stderr,"%s: Could not find new node with nId=%d=vvNew[%d][%d], mapInfo.count(%d)=%d\n", __func__, nId, nUBucket, nUBuckedPos, nId, mapInfo.count(nId) ); + continue; + } + // assert(mapInfo.count(nId) == 1); CAddrInfo& info = mapInfo[nId]; if (info.IsReachableNetwork()) { //deprioritize unreachable networks From fbda7b8dec0d69c9807ecd60643b8e87fd79f7a7 Mon Sep 17 00:00:00 2001 From: Duke Date: Sat, 22 Apr 2023 19:28:24 -0400 Subject: [PATCH 16/78] Fix compile issues --- src/addrman.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/addrman.cpp b/src/addrman.cpp index 535151c2a..15ced2f61 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -501,7 +501,7 @@ CAddrInfo CAddrMan::Select_(bool newOnly) int nId = vvTried[nKBucket][nKBucketPos]; // assert(mapInfo.count(nId) == 1); if(mapInfo.count(nId) != 1) { - fprintf(stderr,"%s: Could not find tried node with nId=%d=vvTried[%d][%d], mapInfo.count(%d)=%d\n", __func__, nId, nKBucket, nKBuckedPos, nId, mapInfo.count(nId) ); + fprintf(stderr,"%s: Could not find tried node with nId=%d=vvTried[%d][%d], mapInfo.count(%d)=%lu\n", __func__, nId, nKBucket, nKBucketPos, nId, mapInfo.count(nId) ); continue; } @@ -541,7 +541,7 @@ CAddrInfo CAddrMan::Select_(bool newOnly) int nId = vvNew[nUBucket][nUBucketPos]; if(mapInfo.count(nId) != 1) { - fprintf(stderr,"%s: Could not find new node with nId=%d=vvNew[%d][%d], mapInfo.count(%d)=%d\n", __func__, nId, nUBucket, nUBuckedPos, nId, mapInfo.count(nId) ); + fprintf(stderr,"%s: Could not find new node with nId=%d=vvNew[%d][%d], mapInfo.count(%d)=%lu\n", __func__, nId, nUBucket, nUBucketPos, nId, mapInfo.count(nId) ); continue; } // assert(mapInfo.count(nId) == 1); From d840a0ec62dd068b84be8fe197e764ae197b2e65 Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 23 Apr 2023 06:56:19 -0700 Subject: [PATCH 17/78] Only log nbits in ContextualCheckBlockHeader if -debug --- src/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 20ea1112f..6ac591353 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5114,7 +5114,9 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta // changing at run-time, from Consensus::Params being a const struct unsigned int nNextWork = GetNextWorkRequired(pindexPrev, &block, consensusParams); - LogPrintf("%s: nbits ,%d,%lu,%lu,%d\n",__func__, nHeight, nNextWork, block.nBits, nNextWork - block.nBits ); + if (fDebug) { + LogPrintf("%s: nbits ,%d,%lu,%lu,%d\n",__func__, nHeight, nNextWork, block.nBits, nNextWork - block.nBits ); + } if (block.nBits != nNextWork) { // Enforce correct nbits at DAA fork height, before that, ignore if (nHeight > daaForkHeight) { From 519743f704769ec2013c87324e3b943fc25a0f32 Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 23 Apr 2023 07:03:05 -0700 Subject: [PATCH 18/78] Only log to stderr in CalculateNextWorkRequired and GetNextWorkRequired if -debug --- src/pow.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pow.cpp b/src/pow.cpp index 260785860..9ac8ef80e 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -503,8 +503,9 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead nbits = bnTarget.GetCompact(); nbits = (nbits & 0xfffffffc) | zawyflag; } - //if(fDebug) + if(fDebug) { fprintf(stderr,"%s: nbits=%d\n", __func__, nbits); + } return(nbits); } @@ -537,11 +538,15 @@ unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg, if ( ASSETCHAINS_ADAPTIVEPOW <= 0 ) { if (nActualTimespan < params.MinActualTimespan()) { - fprintf(stderr,"%s: Adjusting nActualTimespan up to min value %li\n", __func__, params.MinActualTimespan() ); + if(fDebug) { + fprintf(stderr,"%s: Adjusting nActualTimespan up to min value %li\n", __func__, params.MinActualTimespan() ); + } nActualTimespan = params.MinActualTimespan(); } if (nActualTimespan > params.MaxActualTimespan()) { - fprintf(stderr,"%s: Adjusting nActualTimespan down to max value %li\n", __func__, params.MaxActualTimespan() ); + if(fDebug) { + fprintf(stderr,"%s: Adjusting nActualTimespan down to max value %li\n", __func__, params.MaxActualTimespan() ); + } nActualTimespan = params.MaxActualTimespan(); } } From b3a6c2bee18a41342db83eb64feebf502e8be8c9 Mon Sep 17 00:00:00 2001 From: jahway603 Date: Mon, 15 May 2023 13:47:05 -0400 Subject: [PATCH 19/78] 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 20/78] 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 21/78] 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 04c28e3eef00427751d3cd5aecd05858910ba1c8 Mon Sep 17 00:00:00 2001 From: Duke Date: Sat, 20 May 2023 06:12:40 -0700 Subject: [PATCH 22/78] Disable run-time asserts in addrman Run-time asserts are a horrible anti-pattern littered across code inherited from BTC. One could maybe argue they are the right thing to do in some situations but not when managing the peer database. Crashing our full node and potentially corrupting our wallet or block index is INSANE in the case of some inconsistencies in peers.dat . --- src/addrman.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/addrman.cpp b/src/addrman.cpp index 15ced2f61..a832ffc4c 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -143,15 +143,17 @@ void CAddrMan::SwapRandom(unsigned int nRndPos1, unsigned int nRndPos2) if (nRndPos1 == nRndPos2) return; - assert(nRndPos1 < vRandom.size() && nRndPos2 < vRandom.size()); + // assert(nRndPos1 < vRandom.size() && nRndPos2 < vRandom.size()); int nId1 = vRandom[nRndPos1]; int nId2 = vRandom[nRndPos2]; const auto it_1{mapInfo.find(nId1)}; const auto it_2{mapInfo.find(nId2)}; - assert(it_1 != mapInfo.end()); - assert(it_2 != mapInfo.end()); + + if( (it_1 == mapInfo.end()) || (it_2 == mapInfo.end())) { + return; + } it_1->second.nRandomPos = nRndPos2; it_2->second.nRandomPos = nRndPos1; @@ -167,8 +169,8 @@ void CAddrMan::Delete(int nId) const auto it{mapInfo.find(nId)}; if (it != mapInfo.end()) { CAddrInfo& info = (*it).second; - assert(!info.fInTried); - assert(info.nRefCount == 0); + // assert(!info.fInTried); + // assert(info.nRefCount == 0); SwapRandom(info.nRandomPos, vRandom.size() - 1); vRandom.pop_back(); @@ -189,7 +191,10 @@ void CAddrMan::ClearNew(int nUBucket, int nUBucketPos) const auto it{mapInfo.find(nIdDelete)}; if (it != mapInfo.end()) { CAddrInfo& infoDelete = (*it).second; - assert(infoDelete.nRefCount > 0); + // assert(infoDelete.nRefCount > 0); + if (infoDelete.nRefCount == 0) { + return; + } infoDelete.nRefCount--; vvNew[nUBucket][nUBucketPos] = -1; if (infoDelete.nRefCount == 0) { @@ -217,7 +222,7 @@ void CAddrMan::MakeTried(CAddrInfo& info, int nId) } nNew--; - assert(info.nRefCount == 0); + //assert(info.nRefCount == 0); // which tried bucket to move the entry to int nKBucket = info.GetTriedBucket(nKey, m_asmap); @@ -227,7 +232,7 @@ void CAddrMan::MakeTried(CAddrInfo& info, int nId) if (vvTried[nKBucket][nKBucketPos] != -1) { // find an item to evict int nIdEvict = vvTried[nKBucket][nKBucketPos]; - assert(mapInfo.count(nIdEvict) == 1); + //assert(mapInfo.count(nIdEvict) == 1); CAddrInfo& infoOld = mapInfo[nIdEvict]; // Remove the to-be-evicted item from the tried set. @@ -239,14 +244,14 @@ void CAddrMan::MakeTried(CAddrInfo& info, int nId) int nUBucket = infoOld.GetNewBucket(nKey, m_asmap); int nUBucketPos = infoOld.GetBucketPosition(nKey, true, nUBucket); ClearNew(nUBucket, nUBucketPos); - assert(vvNew[nUBucket][nUBucketPos] == -1); + //assert(vvNew[nUBucket][nUBucketPos] == -1); // Enter it into the new set again. infoOld.nRefCount = 1; vvNew[nUBucket][nUBucketPos] = nIdEvict; nNew++; } - assert(vvTried[nKBucket][nKBucketPos] == -1); + //assert(vvTried[nKBucket][nKBucketPos] == -1); vvTried[nKBucket][nKBucketPos] = nId; nTried++; @@ -665,7 +670,7 @@ void CAddrMan::GetAddr_(std::vector& vAddr, bool wants_addrv2) if (vAddr.size() >= nNodes) break; - assert(mapInfo.count(vRandom[n]) == 1); + // assert(mapInfo.count(vRandom[n]) == 1); const CAddrInfo& ai = mapInfo[vRandom[n]]; if (!ai.IsTerrible()) { From fc921eba57cdd5b98ad2122c81b60b4b0a2c95db Mon Sep 17 00:00:00 2001 From: Duke Date: Fri, 9 Jun 2023 00:00:42 -0400 Subject: [PATCH 23/78] Remove dead code --- src/miner.cpp | 60 +-------------------------------------------------- 1 file changed, 1 insertion(+), 59 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 4e5e01216..ee85a52eb 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -628,8 +628,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 else txNew.nLockTime = std::max((int64_t)(pindexPrev->nTime+1), GetTime()); - if ( SMART_CHAIN_SYMBOL[0] == 0 && IS_HUSH_NOTARY != 0 && My_notaryid >= 0 ) - txNew.vout[0].nValue += 5000; pblock->vtx[0] = txNew; if ( nHeight > 1 && SMART_CHAIN_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0) && (commission= the_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 ) @@ -1442,8 +1440,6 @@ void static BitcoinMiner() if ( hush_baseid(SMART_CHAIN_SYMBOL) < 0 ) break; } - if ( SMART_CHAIN_SYMBOL[0] == 0 ) - hush_chosennotary(¬aryid,chainActive.LastTip()->GetHeight(),NOTARY_PUBKEY33,(uint32_t)chainActive.LastTip()->GetBlockTime()); if ( notaryid != My_notaryid ) My_notaryid = notaryid; std::string solver; @@ -1573,61 +1569,7 @@ void static BitcoinMiner() savebits = pblock->nBits; HASHTarget = arith_uint256().SetCompact(savebits); roundrobin_delay = ROUNDROBIN_DELAY; - if ( SMART_CHAIN_SYMBOL[0] == 0 && notaryid >= 0 ) - { - j = 65; - if ( (Mining_height >= 235300 && Mining_height < 236000) || (Mining_height % HUSH_DPOW_GAP) > 64 || (Mining_height % HUSH_DPOW_GAP) == 0 || Mining_height > 1000000 ) - { - int32_t dispflag = 0; - if ( notaryid <= 3 || notaryid == 32 || (notaryid >= 43 && notaryid <= 45) || notaryid == 51 || notaryid == 52 || notaryid == 56 || notaryid == 57 ) - dispflag = 1; - hush_eligiblenotary(pubkeys,mids,blocktimes,&nonzpkeys,pindexPrev->GetHeight()); - if ( nonzpkeys > 0 ) - { - for (i=0; i<33; i++) - if( pubkeys[0][i] != 0 ) - break; - if ( i == 33 ) - externalflag = 1; - else externalflag = 0; - if ( IS_HUSH_NOTARY != 0 ) - { - for (i=1; i<66; i++) - if ( memcmp(pubkeys[i],pubkeys[0],33) == 0 ) - break; - if ( externalflag == 0 && i != 66 && mids[i] >= 0 ) - printf("VIOLATION at %d, notaryid.%d\n",i,mids[i]); - for (j=gpucount=0; j<65; j++) - { - if ( dispflag != 0 ) - { - if ( mids[j] >= 0 ) - { - if ( mids[j] == notaryid ) - fprintf(stderr,"--<%d>-- ",mids[j]); - else - fprintf(stderr,"%d ",mids[j]); - } else fprintf(stderr,"GPU "); - } - if ( mids[j] == -1 ) - gpucount++; - } - if ( dispflag != 0 ) - fprintf(stderr," <- prev minerids from ht.%d notary.%d gpucount.%d %.2f%% t.%u\n",pindexPrev->GetHeight(),notaryid,gpucount,100.*(double)gpucount/j,(uint32_t)time(NULL)); - } - for (j=0; j<65; j++) - if ( mids[j] == notaryid ) - break; - if ( j == 65 ) - HUSH_LASTMINED = 0; - } else fprintf(stderr,"no nonz pubkeys\n"); - if ( (Mining_height >= 235300 && Mining_height < 236000) || (j == 65 && Mining_height > HUSH_MAYBEMINED+1 && Mining_height > HUSH_LASTMINED+64) ) - { - HASHTarget = arith_uint256().SetCompact(HUSH_MINDIFF_NBITS); - fprintf(stderr,"I am the chosen one for %s ht.%d\n",SMART_CHAIN_SYMBOL,pindexPrev->GetHeight()+1); - } //else fprintf(stderr,"duplicate at j.%d\n",j); - } else Mining_start = 0; - } else Mining_start = 0; + Mining_start = 0; //else if ( ASSETCHAINS_ADAPTIVEPOW > 0 ) // HASHTarget_POW = hush_adaptivepow_target(Mining_height,HASHTarget,pblock->nTime); From 18f06896953d96390d925060d6756a50ab3cd94b Mon Sep 17 00:00:00 2001 From: Duke Date: Mon, 12 Jun 2023 07:55:45 -0700 Subject: [PATCH 24/78] Avoid ztx validation during IBD if height is less than latest checkpoint --- src/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 18769e520..a54d03ada 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1363,6 +1363,11 @@ bool ContextualCheckTransaction(int32_t slowflag,const CBlock *block, CBlockInde REJECT_INVALID, "bad-txns-invalid-script-data-for-coinbase-time-lock"); } + // Avoid ztx validation during IBD if height is less than latest checkpoint + if (fCheckpointsEnabled && (nHeight < Checkpoints::GetTotalBlocksEstimate(Params().Checkpoints())) ) { + return true; + } + if (!tx.vShieldedSpend.empty() || !tx.vShieldedOutput.empty()) { From 487fff149c17cab8a70f312d56f4c52e7174e81c Mon Sep 17 00:00:00 2001 From: Duke Date: Mon, 12 Jun 2023 07:59:53 -0700 Subject: [PATCH 25/78] Remove dead code related to invalid joinsplit sigs --- src/main.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a54d03ada..98b77dda8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1340,22 +1340,6 @@ bool ContextualCheckTransaction(int32_t slowflag,const CBlock *block, CBlockInde } - if (!(tx.IsMint() || tx.vjoinsplit.empty())) - { - BOOST_STATIC_ASSERT(crypto_sign_PUBLICKEYBYTES == 32); - - // We rely on libsodium to check that the signature is canonical. - // https://github.com/jedisct1/libsodium/commit/62911edb7ff2275cccd74bf1c8aefcc4d76924e0 - if (crypto_sign_verify_detached(&tx.joinSplitSig[0], - dataToBeSigned.begin(), 32, - tx.joinSplitPubKey.begin() - ) != 0) { - return state.DoS(isInitBlockDownload() ? 0 : 100, - error("CheckTransaction(): invalid joinsplit signature"), - REJECT_INVALID, "bad-txns-invalid-joinsplit-signature"); - } - } - if (tx.IsCoinBase()) { if (!ContextualCheckCoinbaseTransaction(slowflag,block,previndex,tx, nHeight,validateprices)) From 67c763206218c49f1a228ec69c482b76644929b0 Mon Sep 17 00:00:00 2001 From: Duke Date: Mon, 12 Jun 2023 19:06:41 -0400 Subject: [PATCH 26/78] Remove dead code --- src/hush_nSPV_wallet.h | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/hush_nSPV_wallet.h b/src/hush_nSPV_wallet.h index da8038fb6..af098407d 100644 --- a/src/hush_nSPV_wallet.h +++ b/src/hush_nSPV_wallet.h @@ -383,12 +383,7 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a mtx.nExpiryHeight = 0; mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; mtx.nVersion = SAPLING_TX_VERSION; - if ( SMART_CHAIN_SYMBOL[0] == 0 ) { - if ( !hush_hardfork_active((uint32_t)chainActive.LastTip()->nTime) ) - mtx.nLockTime = (uint32_t)time(NULL) - 777; - else - mtx.nLockTime = (uint32_t)chainActive.Tip()->GetMedianTimePast(); - } + mtx.nLockTime = (uint32_t)chainActive.Tip()->GetMedianTimePast(); memset(used,0,sizeof(used)); @@ -402,14 +397,6 @@ UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis) // what its a return(result); } hex = NSPV_signtx(rewardsum,interestsum,retcodes,mtx,txfee,opret,used); - if ( SMART_CHAIN_SYMBOL[0] == 0 ) - { - char numstr[64]; - sprintf(numstr,"%.8f",(double)interestsum/COIN); - result.push_back(Pair("rewards",numstr)); - sprintf(numstr,"%.8f",(double)rewardsum/COIN); - result.push_back(Pair("validated",numstr)); - } if ( hex.size() > 0 ) { if ( DecodeHexTx(tx,hex) != 0 ) From 5f9bb80873f7900fe49c2f2a6f948e4e13fda052 Mon Sep 17 00:00:00 2001 From: Duke Date: Mon, 12 Jun 2023 19:06:50 -0400 Subject: [PATCH 27/78] Remove unused function --- src/hush_gateway.h | 101 --------------------------------------------- src/main.cpp | 1 - 2 files changed, 102 deletions(-) diff --git a/src/hush_gateway.h b/src/hush_gateway.h index 8be1f7c39..b040d3d48 100644 --- a/src/hush_gateway.h +++ b/src/hush_gateway.h @@ -635,107 +635,6 @@ int32_t hush_checkvout(int32_t vout,int32_t k,int32_t indallvouts) void hush_passport_iteration(); -int32_t hush_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime) // verify above block is valid pax pricing -{ - int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,notmatched=0,matched=0,hushheights[256],otherheights[256]; uint256 hash,txids[256]; char symbol[HUSH_SMART_CHAIN_MAXLEN],base[HUSH_SMART_CHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,seed; int64_t checktoshis,values[256],srcvalues[256]; struct pax_transaction *pax; struct hush_state *sp; CTransaction tx; - activation = 235300; - memset(baseids,0xff,sizeof(baseids)); - memset(values,0,sizeof(values)); - memset(srcvalues,0,sizeof(srcvalues)); - memset(rmd160s,0,sizeof(rmd160s)); - memset(hushheights,0,sizeof(hushheights)); - memset(otherheights,0,sizeof(otherheights)); - txn_count = block.vtx.size(); - - if ( SMART_CHAIN_SYMBOL[0] == 0 || - ((ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD) && height > 1) || - NetworkUpgradeActive(height, Params().GetConsensus(), Consensus::UPGRADE_SAPLING) ) - { - n = block.vtx[0].vout.size(); - int64_t val,prevtotal = 0; int32_t strangeout=0,overflow = 0; - total = 0; - for (i=1; i= MAX_MONEY ) - { - overflow = 1; - break; - } - if ( i > 1 && script[0] != 0x6a && val < 5000 ) - strangeout++; - total += val; - if ( total < prevtotal || (val != 0 && total == prevtotal) ) - { - overflow = 1; - break; - } - prevtotal = total; - } - if ( SMART_CHAIN_SYMBOL[0] == 0 ) - { - if ( overflow != 0 || total > COIN/10 ) - { - if ( height >= activation ) - { - if ( height > 800000 ) - fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); - return(-1); - } - } - else if ( block.nBits == HUSH_MINDIFF_NBITS && total > 0 ) // to deal with fee stealing - { - fprintf(stderr,"notary mined ht.%d with extra %.8f\n",height,dstr(total)); - if ( height > HUSH_NOTARIES_HEIGHT1 ) - return(-1); - } - if ( strangeout != 0 || notmatched != 0 ) - { - if ( 0 && strcmp(NOTARY_PUBKEY.c_str(),"03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828") == 0 ) - fprintf(stderr,">>>>>>>>>>>>> DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",height,strangeout,notmatched); - if ( height > 1000000 && strangeout != 0 ) - return(-1); - } - else if ( height > 814000 ) - { - script = (uint8_t *)&block.vtx[0].vout[0].scriptPubKey[0]; - //int32_t notary = hush_electednotary(&num,script+1,height,0); - //if ( (-1 * (hush_electednotary(&num,script+1,height,0) >= 0) * (height > 1000000)) < 0 ) - // fprintf(stderr, ">>>>>>> FAILED BLOCK.%d notary.%d insync.%d\n",height,notary,HUSH_INSYNC); - //else - // fprintf(stderr, "<<<<<<< VALID BLOCK.%d notary.%d insync.%d\n",height,notary,HUSH_INSYNC); - return(-1 * (hush_electednotary(&num,script+1,height,0) >= 0) * (height > 1000000)); - } - } - else - { - checktoshis = 0; - if ( (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD) && height > 1 ) - { - if ( (checktoshis= hush_checkcommission((CBlock *)&block,height)) < 0 ) - { - fprintf(stderr,"ht.%d checktoshis %.8f overflow.%d total %.8f strangeout.%d\n",height,dstr(checktoshis),overflow,dstr(total),strangeout); - return(-1); - } - } - if ( height > 1 && checktoshis == 0 ) - { - checktoshis = ((uint64_t)GetBlockSubsidy(height, Params().GetConsensus()) - block.vtx[0].vout[0].nValue); - // some pools will need to change their pool fee to be (poolfee % - txfees) - //checktoshis += txn_count * 0.001; // rely on higher level validations to prevent emitting more coins than actual txfees - } - if ( height >= 2 && (overflow != 0 || total > checktoshis || strangeout != 0) ) - { - fprintf(stderr,"checkdeposit: ht.%d checktoshis %.8f overflow.%d total %.8f strangeout.%d\n",height,dstr(checktoshis),overflow,dstr(total),strangeout); - if ( strangeout != 0 ) - fprintf(stderr,">>>>>>>>>>>>> %s DUST ht.%d strangeout.%d notmatched.%d <<<<<<<<<\n",SMART_CHAIN_SYMBOL,height,strangeout,notmatched); - return(-1); - } - } - } - return(0); -} - const char *hush_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout,char *source) { uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,hushheight,otherheights[64],hushheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,puposhis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct hush_state *basesp; double diff; diff --git a/src/main.cpp b/src/main.cpp index 98b77dda8..2c037297b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4981,7 +4981,6 @@ bool CheckBlockHeader(int32_t *futureblockp,int32_t height,CBlockIndex *pindex, return true; } -int32_t hush_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime); int32_t hush_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height); bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const CBlock& block, CValidationState& state, From 79f126be431fdb07cc81502df716da36b7a10d56 Mon Sep 17 00:00:00 2001 From: Duke Date: Tue, 13 Jun 2023 22:43:16 -0400 Subject: [PATCH 28/78] Use default jobs number when compiling boost According to current boost docs, not specifying -j parameter will default to using all cores to compile, so removing these should speed up compiling boost. This code dates back to 2014 when the default may have been a single core, so it was specified. --- depends/packages/boost.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 11c235489..fde0c92c3 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -38,16 +38,16 @@ endef ifeq ($(host_os),linux) define $(package)_build_cmds - ./b2 -d2 -j2 -d1 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) cxxflags=-std=c++11 stage + ./b2 -d2 -d1 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) cxxflags=-std=c++11 stage endef define $(package)_stage_cmds - ./b2 -d0 -j4 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) cxxflags=-std=c++11 install + ./b2 -d0 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) cxxflags=-std=c++11 install endef else define $(package)_build_cmds - ./b2 -d2 -j2 -d1 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) stage + ./b2 -d2 -d1 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) stage endef define $(package)_stage_cmds - ./b2 -d0 -j4 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) install + ./b2 -d0 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) install endef endif From c9f1fe4cf351817f89cf9dd68a6e3e206ca1ba14 Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 15 Jun 2023 10:13:01 -0400 Subject: [PATCH 29/78] Support arbitrary -ac_name in checkpoints.pl --- util/checkpoints.pl | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/util/checkpoints.pl b/util/checkpoints.pl index a79ba2753..be6bf28be 100755 --- a/util/checkpoints.pl +++ b/util/checkpoints.pl @@ -7,16 +7,16 @@ use strict; # Generate checkpoint data for use in src/chainparams.cpp my $perday = 1152; -my $hush = "./src/hush-cli"; -my $gethash = "$hush getblockhash"; +my $cli = "./src/hush-cli"; +my $gethash = "$cli getblockhash"; my $stride = shift || 1000; if ($stride =~ m/help/) { print "To generate checkpoint data every 1000 blocks: $0 &> checkpoints.txt\n"; print "To generate checkpoint data every X blocks: $0 X &> checkpoints.txt\n"; print "To generate checkpoint data every X blocks starting at height Y: $0 X Y &> checkpoints.txt\n"; + print "To generate checkpoint data every X blocks starting at height Y for -ac_name CHAIN: $0 X Y CHAIN &> checkpoints.txt\n"; exit 0; } - unless ($stride == int($stride) and $stride >= 0) { print "Invalid stride! Must be an integer > 0\n"; exit 1; @@ -28,8 +28,17 @@ unless ($start_height == int($start_height) and $start_height >= 0) { exit 1; } +my $acname = shift; +if ($acname) { + # TODO: is acname valid? + $cli .= " -ac_name=$acname"; + # TODO: assumes all HSC's will have a blocktime of 60s + $perday = 1440; +} + + my $count = 0; -my $blocks = qx{$hush getblockcount}; +my $blocks = qx{$cli getblockcount}; if($?) { print "ERROR, exiting...\n"; exit 1; @@ -53,7 +62,7 @@ while (1) { chomp $blockhash; print qq{($block, uint256S("0x$blockhash"))\n}; } -my $time = qx{$hush getblock $last |grep time|cut -d: -f2| sed 's/,//g'}; +my $time = qx{$cli getblock $last |grep time|cut -d: -f2| sed 's/,//g'}; chomp($time); # TODO: This is Linux-only and assumes new (not legacy) dir my $line1 = qx{grep --text height=$prev ~/.hush/HUSH3/debug.log}; From b8ae39ccc7c0fda99cd22c68626ba0f327525a62 Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 15 Jun 2023 10:25:59 -0400 Subject: [PATCH 30/78] Enable the option for dragonx checkpoints --- src/chainparams.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 6eb1368ff..787148986 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -1553,7 +1553,17 @@ void *chainparams_commandline() { }; // END HUSH mainnet checkpoint data + } else if (strcmp(SMART_CHAIN_SYMBOL,"DRAGONX") == 0) { + checkpointData = //(Checkpoints::CCheckpointData) + { + boost::assign::map_list_of + (0, pCurrentParams->consensus.hashGenesisBlock), + (int64_t)1231006505, + (int64_t)1, + (double)2555 + }; } else { + // all other HSC's with no checkpoints checkpointData = //(Checkpoints::CCheckpointData) { boost::assign::map_list_of From f12bfeb7f4728527e99ca52de3691517ffa45691 Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 15 Jun 2023 15:38:16 -0400 Subject: [PATCH 31/78] Fix bug where it uses the wrong -ac_name --- util/checkpoints.pl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/util/checkpoints.pl b/util/checkpoints.pl index be6bf28be..910f0abae 100755 --- a/util/checkpoints.pl +++ b/util/checkpoints.pl @@ -8,7 +8,6 @@ use strict; # Generate checkpoint data for use in src/chainparams.cpp my $perday = 1152; my $cli = "./src/hush-cli"; -my $gethash = "$cli getblockhash"; my $stride = shift || 1000; if ($stride =~ m/help/) { print "To generate checkpoint data every 1000 blocks: $0 &> checkpoints.txt\n"; @@ -36,7 +35,7 @@ if ($acname) { $perday = 1440; } - +my $gethash = "$cli getblockhash"; my $count = 0; my $blocks = qx{$cli getblockcount}; if($?) { From 1f0b53854054b635f1ebef9b060a59f4e21dbe64 Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 15 Jun 2023 15:43:08 -0400 Subject: [PATCH 32/78] Take into account ac_name to calculate total txs --- util/checkpoints.pl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/util/checkpoints.pl b/util/checkpoints.pl index 910f0abae..cb8301d61 100755 --- a/util/checkpoints.pl +++ b/util/checkpoints.pl @@ -33,6 +33,8 @@ if ($acname) { $cli .= " -ac_name=$acname"; # TODO: assumes all HSC's will have a blocktime of 60s $perday = 1440; +} else { + $acname = 'HUSH3'; } my $gethash = "$cli getblockhash"; @@ -64,8 +66,8 @@ while (1) { my $time = qx{$cli getblock $last |grep time|cut -d: -f2| sed 's/,//g'}; chomp($time); # TODO: This is Linux-only and assumes new (not legacy) dir -my $line1 = qx{grep --text height=$prev ~/.hush/HUSH3/debug.log}; -my $line2 = qx{grep --text height=$blocks ~/.hush/HUSH3/debug.log}; +my $line1 = qx{grep --text height=$prev ~/.hush/$acname/debug.log}; +my $line2 = qx{grep --text height=$blocks ~/.hush/$acname/debug.log}; my $txs_per_day = 2 * $perday; # default estimate is 2 txs per block, on average my $total_txs = 0; #print "line1: $line1\n"; From 97c7e814cffae13bc1de06cba214f4026f9b01e5 Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 15 Jun 2023 15:47:14 -0400 Subject: [PATCH 33/78] Add checkpoints for DRAGONX --- src/chainparams.cpp | 520 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 516 insertions(+), 4 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 787148986..ef9213bb4 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -1557,10 +1557,522 @@ void *chainparams_commandline() { checkpointData = //(Checkpoints::CCheckpointData) { boost::assign::map_list_of - (0, pCurrentParams->consensus.hashGenesisBlock), - (int64_t)1231006505, - (int64_t)1, - (double)2555 + // Generated at 1686858269 via hush3 util/checkpoints.pl by Duke Leto + (1000, uint256S("0x000bffdae30339fad4ed82a2d2bfc0846f12fb9aeef5e33bb563f4cdd376dc08")) + (2000, uint256S("0x0003578c68350c7afacdc940c87ea9255681a135a0a9b2c13a075485d96155ed")) + (3000, uint256S("0x0001fef5443794fe61e0d397897f0a45a66c5473a70819608504f1395aed1d8c")) + (4000, uint256S("0x000197510698c8fc50133971744d1dd49aae371366d3986c412a189e9c617974")) + (5000, uint256S("0x00000094754d610b08b801545dbdbf57433e7c4d2a48818ff499f8fab05b0927")) + (6000, uint256S("0x0002116377d2d0c04344f0ed7eec63814b54bae740562ccede0c3d9404900cdb")) + (7000, uint256S("0x0001c74d83479bf05a3d9181555ff4ed373a642b1b4cb9cc633c090a522c10e0")) + (8000, uint256S("0x00011c3cd9aeadb039ba28547f232391ded0329ab6b7ec454aeb671246c94b58")) + (9000, uint256S("0x00005b1b0187ba523b6670e65262d1b028a140582301c7ea65065cd47a679c6d")) + (10000, uint256S("0x0000f32ac2bd4581ef4b651f72b27d92dfca04d4dc721c505214f113e209b10e")) + (11000, uint256S("0x000086e271117d75ac85fd00fbec94bbc53a5b990ccb362a8a2f064a97cdf7b2")) + (12000, uint256S("0x000098431effc021e44f867cffa2e309d7bbcc34201ea8d3bc7b08faeca556e3")) + (13000, uint256S("0x000194c6d37ebd00f7746536a7f3a891866954c1020f61be5573b055ea991fa1")) + (14000, uint256S("0x0001102d2b0c1efe8c07768b3bd540e8b2ef8c03e2f8271a58def634a51c576f")) + (15000, uint256S("0x0000c616068d8730adbd87b2bc9d4d5322610e52da6806b9cb2f1894af37d933")) + (16000, uint256S("0x0000049f6a5818a48aafb52781f91f8eca4d05c29c537a85c34b6fa342996a27")) + (17000, uint256S("0x000079bf17272dc67ca18df9f7c5b817c37bd2d103ee76d3b2271511c5aa0b82")) + (18000, uint256S("0x00005f4d742dc1b0e12200c4da8080d75973b18b6d2bdf748f149be72a313627")) + (19000, uint256S("0x0000368eaee2a6f22d64c66c0e3cfc7fe2709f7ced31a589ac8b4c461eca2fff")) + (20000, uint256S("0x0001b4057aebdc835c63dfb581235d5917af697fff962ecfe47e8a26c0b3ac55")) + (21000, uint256S("0x00010a339a0830471d384741ff24161252fdfab8ecfb493b6e8d1f1e7ce342b7")) + (22000, uint256S("0x000013c834a72926969cf8ed88b79175aa3ea952e67b7054c4fa06cc4e5209c4")) + (23000, uint256S("0x0000386a639d79d35972576b55787a80986a27c7415949dc645dc50522f6487a")) + (24000, uint256S("0x000075055db90559920ac02c2de8e1622533b7532b84fe702baf05082161e011")) + (25000, uint256S("0x0001b866113317839d2f6fa608f98f798db1570b4f84e36789126edda9b75d35")) + (26000, uint256S("0x00012ce8394b99c4fff5c052a0abb142c8c1eaa58b830699222a8eacb95298af")) + (27000, uint256S("0x000058bbe34298518632e0522d3ba10e050a5a31e2c4fd862a576f300e9f5c1d")) + (28000, uint256S("0x000163c608d28f1c3a10f8425b5469099b7fff50e25424659887e011d2c0281e")) + (29000, uint256S("0x0000c3baca291f20849d96de3436dad0efc24aa5b44bbdd466ea841b28d70a2e")) + (30000, uint256S("0x000075d2e08eafd62f4633cc1cabf281de17e7e0bba7965db75f3cf268b9a980")) + (31000, uint256S("0x00010cc563eef842749ea14412e922bad6e3515c049f639612a07b221aff4de2")) + (32000, uint256S("0x000150dee2380f76bb144f8c5433bd27e049c54feaaeadeb8bfc3948293453a9")) + (33000, uint256S("0x0000ec245f9808c6792915ae2a467593a1675efce42a2d0ee486e091913159d8")) + (34000, uint256S("0x000166dbcd4f262032e7a981207ac709f7be88a037650ca454db43018286c8f8")) + (35000, uint256S("0x0001a5c13dd9333a4ec60bc6af488ef7e3738aaf2170c70b716a30597b8e2d70")) + (36000, uint256S("0x00018e4fe65c96f0e187c265fa3faa49156ad07991284920beaef3b3b499dcbe")) + (37000, uint256S("0x00017e952f47ea070893b41a76468fee7db3073184eab10c960e2aead6fddf7e")) + (38000, uint256S("0x00010e3c64c0127fb995ab10d45bb281e5c78239c0303c825d81bb4cf994c7c0")) + (39000, uint256S("0x0001db8de504639d87029c9be04acdfef038601af58ea38ba307a7cc0ce8fdf7")) + (40000, uint256S("0x00015fc2f6953e67578c6484c3a5342d883fd3ef051456edc55064e544f04df2")) + (41000, uint256S("0x000200e23bc81ee9e9a9b29eb9c478c035d52de845c118a1645a3876d0f0f7ec")) + (42000, uint256S("0x00018b8b952e0268ee7007ca2bfe3499f1c78911e5d308d877aa3829a8ddfa95")) + (43000, uint256S("0x00005cc6dc81cdd3ad3c1bc5675064b8d6d01ac85348c116f4db28c61df5cb52")) + (44000, uint256S("0x0002a71c4a45353eeed81519d1f4b78e4be13702907bc872fd605c094eb5c8fe")) + (45000, uint256S("0x00005c3e9bdb78fa205f39a6f4fff5c547775ee90e79fedebecb17336c03e868")) + (46000, uint256S("0x00024017e7985c841e8b607624f74f3efe46f915d272f9f8c07a93353858d92b")) + (47000, uint256S("0x0000d29c58bb338aa55bb017d8fbbe3b7c3bed83f212094a18ef7fde7f8eb675")) + (48000, uint256S("0x00024b1c2d6131f7ec9748c763c3168d2d761c7617e10d09fb93aff2b4a29ca3")) + (49000, uint256S("0x000120f81110878ca7ec75d155badf2348bda20a9034b24b8317ba0f16568788")) + (50000, uint256S("0x000207bddb3ebb7cb8000f84e63ae7be40e74dde52c8bfa4f0cc913b048e5767")) + (51000, uint256S("0x0001c8554ac45a19684c7328056420d7b27c1c5c9f03059c095ca4a2749b29f4")) + (52000, uint256S("0x000104d93b769e9e7190b031f6250445b05750a36231f8ea7f2dce8c8a0487be")) + (53000, uint256S("0x00002ab5a1e72ef163242f4be6a26063f26cef6f1eccb4cfe44a099ba710fdc4")) + (54000, uint256S("0x000117645f0ee76f12601abe5554729ca9241c65e49cbefae77e67d18204795f")) + (55000, uint256S("0x0000ab7cf81435f26f56b9687b8f6feaaed95ed8090a1dac8a690a39b9a89c8b")) + (56000, uint256S("0x000134d8809fb2222a3ed76958f998589ac69d6d08d534309ecf569b6d448cb3")) + (57000, uint256S("0x00003daaec8c3d9c31b32163cef47c4883ad9b12b85a641eefbd02b06c4b6083")) + (58000, uint256S("0x000096456c3f1af39489df84dbf0a0975c9cc29fa1f524e72cf4421fd6465b82")) + (59000, uint256S("0x00016202a3cdcb3b0c27e75f84cebcf576bc7869abf0fab13c68abd3b111fb9e")) + (60000, uint256S("0x000071cd818c3fa9f155ec8ac65333f43e0d86b4f6ea98fc702ae0fe1ec3126f")) + (61000, uint256S("0x0000d1654355ba77105cc07e7cf024e0200f39646ea3cbf816737e621857ff36")) + (62000, uint256S("0x0000f1e6a09effa09329175ee4d8b42fdae3c365f1232fd440d0d41b6c090dc9")) + (63000, uint256S("0x0000ffbceee7b86cb04a37fefeb0452de8305aef4c37b6bfa84cffe4dba168be")) + (64000, uint256S("0x00002db24701b3d6c0d7547c1636b0aae754c050915ba607da1022e859bf0a07")) + (65000, uint256S("0x000102bfa6361b71cc51e231b87c653dfd21a865284fe013d65bac8fb2d96878")) + (66000, uint256S("0x000061e9bf36f9b2d110d7d545d9fa1deaaf39ce91d2d5e3f51b5e8eec37d820")) + (67000, uint256S("0x00000128e4528bae30aae739e7d1d1528e366739878878bdec5e5d5f5639de21")) + (68000, uint256S("0x0000c45a027fe81eb60c60573bffa4558b3d187f7144131eff0b97fc52d8fbcf")) + (69000, uint256S("0x00005fc22d9c90e1c88c5724ea8b45d2b198bd03d77931c4d328e88313d9080e")) + (70000, uint256S("0x0000bbfd71d248074239456adf756eff007bcbe004b8c02eed8dd1b1656d9270")) + (71000, uint256S("0x00003f2d633d303c935554a414ec99443e01f5e626522159d97b7774f939158f")) + (72000, uint256S("0x0001514d0a98b94dbc81f70c59d29ae437a4690beb464d1b92abe7bd1e055a35")) + (73000, uint256S("0x0000807fe075a08da2bb07b8f4bb9a02b7e450fe6e5be062c21b15beed210dfa")) + (74000, uint256S("0x00006bf606a3c548c55c079343183caaebaa2c23d8580abb9eedf2a7e9b2a453")) + (75000, uint256S("0x00016da1e267ef35372482c84a37012e74c136fea0015b48ac7e039a5025b71e")) + (76000, uint256S("0x000029e02c641075abe8adabdb3b59e3696611f37c3da3f3bfcad72a705e7a3c")) + (77000, uint256S("0x000105f3af93470b7076fdfb9a0e9714f596ca4366deb3c35333648257464d67")) + (78000, uint256S("0x000144235c2eb2e871e11eca2ef9c051432bce4e9a1bb346b0b895e8e559286b")) + (79000, uint256S("0x0000b73f9f1a91cacb3c93638fe7ef6fa91072fd76d91cb51f34e794941f7325")) + (80000, uint256S("0x00001d995acdf7ac796829dcc869dae073258e5c608a8daa709b4c512c3a3343")) + (81000, uint256S("0x0000b163da6072538fc53a789dc47228a691b734a74e551e0e2e9e0d26fdbcff")) + (82000, uint256S("0x00012e9491a6d4d2b32f1869eb44672e1833ab718e580bf5609d7f9c58bc0af3")) + (83000, uint256S("0x00017280176966d19319f3c4d67440759e072e0c8b66b93d1f87921743b99fd1")) + (84000, uint256S("0x0000f62cd78630155998d1a64104c2f66328a586988b18874e99364eb60fc0d9")) + (85000, uint256S("0x00000d6fe7b9dec442628066442bd0558ceaa1a8d664d82f122790b2c917f950")) + (86000, uint256S("0x000029a1d545e5b7fdd28617de6195347d719524d5626f12d19924921e7f2359")) + (87000, uint256S("0x000138aea3caee3827eacfea9efd4d41f74958992c3b17a19599c28932aec442")) + (88000, uint256S("0x0000ace521b7b212027faf886832a3858b6b1391face5d9bfa21a58d08577f17")) + (89000, uint256S("0x000054190734e754a5aa58f1cb70753fcba0a88f512185578b8d772918dbf549")) + (90000, uint256S("0x0000d841407e0ac42c190ca65319bf2c4ec056724c75774bbfaaaf28fc022fec")) + (91000, uint256S("0x0000d95e5a72eb25762fd65ed7901ee7c5365d1b7ada72080743f95fe9bfd308")) + (92000, uint256S("0x0000c77b274f557cca7a381b64ccba1412a4f927ae850cc5e0ea3b3fe6a85947")) + (93000, uint256S("0x000006ce04d80995709a8a93da2eaa6c00a7b0c15e7f409a1cbfa64f92ec4aee")) + (94000, uint256S("0x0000e610317357e75beadac9a249f9b1847e26d98dfde191f9e421df0ac009ec")) + (95000, uint256S("0x000039e0566bdb30c72857c5e05afeefefcb4fea69ee24e86fb3506c93c4169a")) + (96000, uint256S("0x00007707c899da1d86457bc55fc614cef6dfc73216d04f26b500728c57b8b7c6")) + (97000, uint256S("0x000133c725bdbbf3c4c3669e32f459f3d0cb6c473b5a9dcfac06c486e1ece294")) + (98000, uint256S("0x00001d75a7c92f3586045b534f5a80c474b9b1ba463acd1462b9494bc9dbc12d")) + (99000, uint256S("0x000070946880c634b930804e55cc2f380fbd897d4d1713e6ab0a86ec66299f44")) + (100000, uint256S("0x00005af032270f04bc9be8072ee0b70820b88303dc25770a8dfb5c6f00341ae8")) + (101000, uint256S("0x00015739048f9cd91a5f5da04d9b1f0b220d719c13a6b03577d60027ba0cf130")) + (102000, uint256S("0x0000ae124051763e3ccdc1beff5d4ba304715e06f6a54124ee4ce4a4424e2925")) + (103000, uint256S("0x0000b46bd79314799b28964e5bc9cfbfd4481fd4148c4775337cc7a3458f411f")) + (104000, uint256S("0x0000546d926811aeaa19b14fb06c919174d73ceb41800f21e8856b940ea0d51e")) + (105000, uint256S("0x00006f831295c6d417a10268beda28ef058a646d68dcf53f6c5197c7c0071144")) + (106000, uint256S("0x0000aa4f504584b2e604186eb4edc1d60caa757ef25db86a35aca9b9e03bab02")) + (107000, uint256S("0x0000e945fef42d3eb4cc606aa888cb9908a9778592470e6630035821b83bf32a")) + (108000, uint256S("0x000042b833a40904ba608c715efca50f3b351924cddc50793af26be698b791b4")) + (109000, uint256S("0x00008b8778ff887a3ae0dc04a9cc546408c8b7cc4f23668b2e38ade6fbe31487")) + (110000, uint256S("0x00007558a72be2b93ff9c32a3c8c8896f4fd7b8d59430a1917755412307bbcde")) + (111000, uint256S("0x00005fcd2934faee4f6cf128a272a03c7001be0f59abe873c4ef5dbd469fee67")) + (112000, uint256S("0x0000ea01486382afa2787d723f80d1073bd8924181f9e0aba2e4a253e4fb571d")) + (113000, uint256S("0x00002e5f65baec8b526c5096351a30bc33cee3692ed4e3b4144229cf9ca6dc83")) + (114000, uint256S("0x0000177996f4e8f436672b0405b1de6bb7335bdc32cea1635d6122c4d6af7563")) + (115000, uint256S("0x00011891d2d508824de7657981c754372a2c2985b2d483fc48003de27f9b5716")) + (116000, uint256S("0x000088d8381d4a1c3b468bedbf6320e7dba41285ae99bcaf0b4750ca9cada4bb")) + (117000, uint256S("0x0000b0dacbd93ed6feb0c83af3f8b57598ca9b59b87c4a0f6f8b7738b37ba280")) + (118000, uint256S("0x000141aa854c151264db40b7fb065d5d6402c03786d1201a428bdb2f3cf4be0d")) + (119000, uint256S("0x00001dcec0e976c13fa307ee80f37a7d188e80b7e18c6aa744948139090ee4c6")) + (120000, uint256S("0x000159aac0c2854248eeaa7717b5f9defed70ec7eb56225f74650e2e4dd14ab0")) + (121000, uint256S("0x0000ffaabd57940430c76493f65b2ea9588ea5d218bf4ab8cd7986a4f36d85ed")) + (122000, uint256S("0x00004997285f83bdf2b84e906a5427d1246d2a9576fe70ba98db0fb1906e2a81")) + (123000, uint256S("0x00011189d192349030a4d667504557de1c6f321c2d2b433f279d83aefd49a88d")) + (124000, uint256S("0x000021e928fa16624a41e6d5d3275ecbf15d4f2e7ac529f411c071090b01a501")) + (125000, uint256S("0x0001678ffaaf26a44aacadf79d4312a1a3269e110df6a25b00371575574c5fd5")) + (126000, uint256S("0x00014435157bc5cf46047a2080a3fac7680635b4bd269404297581b884f26aff")) + (127000, uint256S("0x00005b0ee65fba4d6eb0902766eadf515fb252b86140e9093d249d8f9a54a128")) + (128000, uint256S("0x000021b7d3534640ec2854c0fcc08b1342162770a4e1c37870e9cf0030582d85")) + (129000, uint256S("0x00009fb144dfe588c1ae56ba6e17a6d6b1565c1b27464c5cba79c918b56a1760")) + (130000, uint256S("0x0000674dcced99276e684e9ac19eb2412e55c968a2bb524069384647cb45eefc")) + (131000, uint256S("0x0000ad841440e59715c68856f4011e854031cad19788438bdceaa4ca161f06a1")) + (132000, uint256S("0x00002789aed78f0b29396c9d654c1599b35cae19704d1b15e4f266af109c1f8c")) + (133000, uint256S("0x00002a422e40e72b7a35d4818a59297bfdcc5efcaeaa30d54d1d290e85a6f1de")) + (134000, uint256S("0x00003628a789756f15bb46fd8de99f9baab50f19a935716785dcae0275bf4a05")) + (135000, uint256S("0x000075517e8be4c0ed800d66ad00dd67346ea2b34348e594b769fa9bac3fecb5")) + (136000, uint256S("0x00002b4196ca58d9e2b7c75f1e8de291cf22b7bbc4be8dc2cfb29f54c256d3ba")) + (137000, uint256S("0x0000180d66e02d24330e9ef3d49813136eac06802e2989fa379d7a88e4067e01")) + (138000, uint256S("0x0000ad0a51cac855e0b162fbf069b560cd8d21fb5275f9d06304a740129bc809")) + (139000, uint256S("0x0000219d48ec853516f9262b41d84c5fbc5417b604e3b9001769bd5ac3f59b28")) + (140000, uint256S("0x00012475b06db9b0c4befe66ed3de054b993bc787092488df2383c566155921e")) + (141000, uint256S("0x000061896c62d282efc098341741a1a67c4d9c87fec6f1948a2225bc56c44c78")) + (142000, uint256S("0x0000444880b2e2b46b874fbb0acd44675ce257d2bac4eade4b9b9929a7b39b08")) + (143000, uint256S("0x0000509c13924e0733c5d6fc3bc7a270d2dd3b4c82db7fdfcaf02a410103ca78")) + (144000, uint256S("0x0000dd507d1b7059fb9c41c103ff43190425d567a661a59d704563c9dce1a1c9")) + (145000, uint256S("0x000097e5ebd34461ebcb5fdd3beb6e973fa752817f2ebe9fd3d57a56537e1ec0")) + (146000, uint256S("0x0000afb0eab0639d2623a15d8454cc7464c83f677fa7461259a445304fc3d3a8")) + (147000, uint256S("0x000123ce32adbc6c65e490bcc21554b0afda1476b2a6da11a28e264f1964cda6")) + (148000, uint256S("0x00016278bed29b081e4986de9c6422a89d8aa719dd1ab422c1ea7fa10284094b")) + (149000, uint256S("0x0001484305013531de1e5abda094fb453d5c5fb0d35812327ea01517c9149cdc")) + (150000, uint256S("0x0000da3a58875dc171e5bb9747cff5dfa2880d39e244d3f10acccf5232aac81b")) + (151000, uint256S("0x000006f333c55d2b6ab5f334a6d05f96fe74e301d4110ac92807239873f25671")) + (152000, uint256S("0x00008844695c54bee8e1711ec7e80f474c7a3bf1b78aa272553ca233746c912f")) + (153000, uint256S("0x00011c8bc4ffe00ea899ae19daa572e61e4cb951a594229d67e2af19d6388d21")) + (154000, uint256S("0x000111aaabb95e1cb1a225e5e8b2a6727c11da97c7391800618c7ba11c6ad669")) + (155000, uint256S("0x0001011a4d88acf916da949572a7f1c208bd7d31e0598d4337980c48ed88b18f")) + (156000, uint256S("0x0000651ee0d6bdaeec5bf585fa628e4336e7238974ca90461d38506c34d6f00b")) + (157000, uint256S("0x0000d2ecfe64aa069aeba21fb1bd8995cfad455c296670e3dec13fde989aa1c5")) + (158000, uint256S("0x000113b2ab0d24a2bac410a0155ca9d2fa6b2923c0042c228dd86fe37ad04469")) + (159000, uint256S("0x0000b1741e1d0b841bf0c0d5b3a0b9a906cde8e630e10b71ebfdf18ae5197d9f")) + (160000, uint256S("0x0000419b54cbe8a842b92201996bd74382b63db7ab0b1989b932ecb19bdd6f4a")) + (161000, uint256S("0x000076eac68434f40b6921b251fc2ec5de4748044d849887a70116f344f1477c")) + (162000, uint256S("0x0000fb948303f30cde6c2ed932915e0f6aaa932dc3dec324851b256e82f4f2a0")) + (163000, uint256S("0x000025244341c537faf365bb46626f0283a2fc0cd668c93cb9771da7f7c6be56")) + (164000, uint256S("0x000046fc2919f8ae4b88c1faecea97f6301a27a9a16184934d70b0b305891a14")) + (165000, uint256S("0x000116cc086ac32a24092d39089d2bcf5977bbc08ad916a8fac2aaefb48f2220")) + (166000, uint256S("0x0000dc6455e6eaae079ba6592fe0d5688c696955f00d33dbfc0cf76aac48e10a")) + (167000, uint256S("0x00012685e23a0997797098d047631fe7da1849e763dda0c7a00f47c7dfd13366")) + (168000, uint256S("0x0000b28813965516fe96909418dc72a4ce126401cd7a03919b9888d0da3b37d3")) + (169000, uint256S("0x00014522bcc0fa9995c6b1b6e6ba3ddd4298b0dd59854d25e713c43778d93d77")) + (170000, uint256S("0x0000f8e02172873f12b2b1adf8709b5d1990ef64b674fb0e5ed1ea08db9b6a48")) + (171000, uint256S("0x0000b0d9d1cced1c0396bab1f1003c9a009dc47da63c8220fc23bb3948a82ed2")) + (172000, uint256S("0x000099c8db9b14c2d5f7c685ee8569755bc50306397f749c7e0e31e709bfc4f3")) + (173000, uint256S("0x00007c422bc9f8295deeb35ea5225bc4f8021fee412c9a5127b6067582b356fa")) + (174000, uint256S("0x0001127a0d14aec0b5ba96dfb606cb9a562d5dafe79646076b9c0a7f7bbc8ffa")) + (175000, uint256S("0x000091c16ae7ffb036f716ac975bf6a9572fd9d439abef21036d18c3be0f90c7")) + (176000, uint256S("0x0000f4e7f4a42a9bf0dfe831764ccf9a8116f98e8158d072b8034d6b7a1e0400")) + (177000, uint256S("0x00006a9efe8a6d93dc8d16757a425c2cb8b910195f08fa210bb0bb3daec47080")) + (178000, uint256S("0x000065fdff26f07f13a0e9db44f6847161b360a6dea1cb7ef810c93a62043025")) + (179000, uint256S("0x0001a0a5300ed334e0ada6eb53d762ebcb1bf7ad0b6312905257f7698477ed51")) + (180000, uint256S("0x000131b050c745484f85e2c8422bf4624f23c69969d1c7d2f6760ef62a864746")) + (181000, uint256S("0x0000cf46ed02cc030fa3209a7fdca35a99249a17b241d30849ea094cdc827a49")) + (182000, uint256S("0x0000b16cd4ef9db7e929372be056e12d8422575891d032298cc17853d043a6e8")) + (183000, uint256S("0x0000d5d53dbb045bedbd997855eb931d7e671740e2aa37a84e184b43b90cf1a5")) + (184000, uint256S("0x00010f06fdae2de13519604475ff9412eb67731f9d4d0420c00b1f2530a5fd91")) + (185000, uint256S("0x000145be18021effbc081d0ca8fd549317766b57d828bc946436e84325b17c7c")) + (186000, uint256S("0x00006e592793a9bb5795a4f76b5ed47af4ce51b0d2e6730888c2c38dca5864b2")) + (187000, uint256S("0x0000438bdd8a024ccc008726a1690873039153df76ed254d2d773e55def68742")) + (188000, uint256S("0x00010108fe7c2543e5b258ee511ded17e12f3ed1688164ef78526684c1ea193e")) + (189000, uint256S("0x00005cc59b9b2116afa0e6ecc12769ee5f91efa91d245fc64bfda90479f8c9a7")) + (190000, uint256S("0x0000572751fda233f466c6ad237184ff6a7a15f8d84e5471e3dc5288ad74f592")) + (191000, uint256S("0x0000b5bb7236376176640e75308466cec3c3fa7bde6f24b1d12c96e94df2bb58")) + (192000, uint256S("0x0000620eaa310878ce85d6cd90d2b4724b36236575ff26c2ed6e34c93f6a8625")) + (193000, uint256S("0x00003a8b7d4cc3a92bb3b5301f9d7ca91941150e5bbc10f1204ec0175053bae2")) + (194000, uint256S("0x00007144b1bd53defd4cc1e78832a2bec8d66e094a0f03c22276e846cf8b598e")) + (195000, uint256S("0x00010530fcae36dc749c679366101df5d344243238e0e6dff2cbf57f9e25d5ce")) + (196000, uint256S("0x00002d2b003cc4851f4950cdfe7996f55b26c7564e60feb6e19597db49dd998b")) + (197000, uint256S("0x00011545798a62155ff5aa047a1cb59c0860b187a59bce8976b57f9c3bb35184")) + (198000, uint256S("0x000061433820de56f44eb774c2f54181b0e6d1e6b27e4a8eefef90039bbecd07")) + (199000, uint256S("0x0000403ced11ef43d8324070ddc30fc69a0c2d8186e4551c140a9378f0312d34")) + (200000, uint256S("0x00009ca9950079d5cd882b615fc068df25beed137642b751b224d6a939a87c69")) + (201000, uint256S("0x000015eb67778c671b0fd29016482d42758cc2edd8361f30788ab95c8328efa5")) + (202000, uint256S("0x0000c6e1a58b63e282fdedf31c1da7cc6d8b0a6dad82fc425672ac0eaf737c84")) + (203000, uint256S("0x000078e0e23fa6f7ccf5e8bb8d6703e0d70b7a86fc0c7493f61ef57e945a8250")) + (204000, uint256S("0x0000451704df4c8a94edd50b78540e8852bb55eef42bf2da3e19a173b8c246d5")) + (205000, uint256S("0x0000309772c01eeda1979e18f93a8721bfdd08c1796ea3a5861011c3de0f9fc1")) + (206000, uint256S("0x00001ba8aa17a23a2c6af771063cbe0afba5bed5b9a7b6c12d3cf0240277fa39")) + (207000, uint256S("0x0000bc3893889caddd09c6117bbd6dd044ebff10b28e008f19f7c43a496592fc")) + (208000, uint256S("0x0000684467ca15f917315fbab3fc3f2907c5f30153c5b884d0298a0d1e77815a")) + (209000, uint256S("0x0000a4f86f394beec9c9241e6dcb05b49393653bc5eaf35820403e54a23bcab6")) + (210000, uint256S("0x000097146b9280bac0344dc886cc4c77141b7467e2ef68e657525d789a9cdcc1")) + (211000, uint256S("0x0000298926d49fc5da4f866133c5c1d1e48d10a17b384eac616022057a7a46c9")) + (212000, uint256S("0x0000eca72307d64a15d234ee372e18862a46d6fc7fd2d0ef3d35c0e5ac836cfa")) + (213000, uint256S("0x0000d89ced1ffc0a9fbc0763d6d090bb19e2657f93c43144b359c16804778a89")) + (214000, uint256S("0x00010f939491f8393ddf82118d72bf420c3ebe01788d3cc69163865bcd848738")) + (215000, uint256S("0x00006ad713ab44526e84e11d0400e5619c2415773cf5068f4946d52bf9633f10")) + (216000, uint256S("0x00008410e6c8ecde65179424ec6443ec1b2215d2403d8b6f779da51136ec02a1")) + (217000, uint256S("0x000020ee6b9a6228bbb57a3dbfab949740801149096f7d0633066026e6792ee5")) + (218000, uint256S("0x0000d38defba9427c17c1cb43398593528af10ae6fbec1d445ce2533c4a0228d")) + (219000, uint256S("0x00001066c0c557ad46f0228c6b8ca18f17979032c55ae24ddab15394080987da")) + (220000, uint256S("0x00010f0dfb2aa26bcd90f8769709a91e0948c03b56ca24740a94f59d5822a815")) + (221000, uint256S("0x000058f2dc34a3060aa22edeb91d3a389f0732e479dc2c0d33696fe61ef1c9f0")) + (222000, uint256S("0x0000533b7f73d91cbe609c8626083dc44e8ce65ddc723729a16e9469030ba263")) + (223000, uint256S("0x0000f81efaff06d9a57c42026bc5aabe52a0ff81a37220e16c4c84904e7cab64")) + (224000, uint256S("0x000130f784b48728fa8f619617996b7e99dfb430176f9ba894a68630a851cd4f")) + (225000, uint256S("0x00003c810725d91c1c489ec513ae71f29562fbc4292719babfcc78dcb293a9e2")) + (226000, uint256S("0x0000dd323efe5d0e9adc1389e4c9eb1c4070fb38d932683032910aba746b3c2e")) + (227000, uint256S("0x000132092774885d1ce3ec989f1b199bdc178b7d406ad9b0d23d3e4e6720d3ca")) + (228000, uint256S("0x0000cf429d0c05ce9e009e501d724d8929fc40027a2f78f7e67ec7d86e91cd57")) + (229000, uint256S("0x000061b40ec34dab4fa83698ace103b6caf9271cbca2b8c7ead55fd299f23f1d")) + (230000, uint256S("0x0000ca632b73f5b1ca9d60ede2010290712fc2f2d28d08ecb31b0affc5b8284f")) + (231000, uint256S("0x000025ffb1c37889da722af7ecfe87e3897c813e4b948d30e1647d44f1a2439a")) + (232000, uint256S("0x0000147749add04281819da29a8c6d7d7e30fa9e8307738519d33605bb26772d")) + (233000, uint256S("0x0000b9ef9879f18d47d7248a8404b2f2b38490f1ea2272e2ab5d10e57e687698")) + (234000, uint256S("0x000006a82f41ac94661d4e0a3dd8d5ef790b5c7c3f68b3bbf9b2c0749ff3171d")) + (235000, uint256S("0x000088d9f88a14a5fefcba4bb61c05e43518806bbb489ea4ea3c53e48ed8262b")) + (236000, uint256S("0x000036c1032ea9f7091faa0ba289ef025926e4f012e19a65476ad061d61343dc")) + (237000, uint256S("0x000016076e6dfd0f0de47d77f975823d286c9458f0e9ce851b8a585e442d1503")) + (238000, uint256S("0x0000b228ebfb020faedd5db874ff7c20bf50f33e0ed824ce30da871ef8859a30")) + (239000, uint256S("0x000098f1ed04960ba6dada245c1d954dda785a250f1365b1d46934514b513e6e")) + (240000, uint256S("0x00004827b75431d480812d39ca8e0925e44889c18b08778b2171c78aacc800f9")) + (241000, uint256S("0x000047f75806dff17a4fbdf87a2361ebf325eb3043d3e7cee86cacabc81394d4")) + (242000, uint256S("0x000027fb57cd69593cc13f6e4ba8cc32bf5982f301c2a9e04474abac8313ced6")) + (243000, uint256S("0x0000d6fb59a655b9402dddd35f09e25085ba1a472e3c344b392d5b3ee293db81")) + (244000, uint256S("0x0000913dc99d2bc33a75deae45a155e2b8dd7953dcd87be10be4943d1b20a82f")) + (245000, uint256S("0x000041e52aed642e547ec8895d84d25203b296f871b50a1f0250ca00c5cf01ea")) + (246000, uint256S("0x00000dbbaad4e01e63b8e068a25d0210ad2c5f656f6d77da241b980fbf77932b")) + (247000, uint256S("0x00010edbb33cf3df1dc924eac96ced741f3a735394bc9fed3b8c1ad3692b3ec5")) + (248000, uint256S("0x00008e0bfb7b326a4bfc6a2995a14f357a27f5725d930a62d2d3ba80f59b2ee0")) + (249000, uint256S("0x00000cf51bb1334a730b924430908700a6f6a995bd9dd252d77b7f94a014c8a8")) + (250000, uint256S("0x000090c5798405d73f400657dcc5685172c6b2608809a9ec2e82297716e5f5cd")) + (251000, uint256S("0x000082d84ca93a2211bb870b3dc2865092fba3b772acbe934cb0a6ff99338762")) + (252000, uint256S("0x000090f2de1badb88177db6c3682f0f223196f51a3e054fe6b06caa5d5e914e3")) + (253000, uint256S("0x0000e0f97c745975bbe5050af8fe92637a7d0cd458cd1706221d34af719f995c")) + (254000, uint256S("0x0000b8eb6c3ec95367882780cba0369222a9acbdbd626bbdc2efa5e9806309ee")) + (255000, uint256S("0x00003f05f5e1dbdc2038158fe47ec02994e8cc643a710a513f8f489dd58f61e8")) + (256000, uint256S("0x0000d31f04b719ad5681f7e1b517daccd9694fbc9409ccd286f558455982d261")) + (257000, uint256S("0x0000ed07ac5882e040bb9de0f4ad4d4527ca5c73c4f1a88eb53dc0651ecbd1b4")) + (258000, uint256S("0x000097e6df4db5049fcff2e691c02570d82c7dbd168189c06f31dd94949ba8b1")) + (259000, uint256S("0x0000e2e8b741d28d9a097229d6e5a2ba1732a82fa2ddcfb41f20eebd94c76c32")) + (260000, uint256S("0x0000263c2baec9d5575580a30787d4893c1517b64ff7294e41f2efb16d21ef85")) + (261000, uint256S("0x00008b142681d8cfc53df1ea806f828f9bdf64789eddd8ee3d031bb8ef8acba8")) + (262000, uint256S("0x0000d2482da09b9d9f76fea70205c1de1029074f2b352ce4b44e86188139daef")) + (263000, uint256S("0x00007ab5c28f261713ec133b8543393d556c1a259ca05968bd3075792aab3ca8")) + (264000, uint256S("0x0000a75e0af3d8f54950cdbe04a0d083eab58c4aa5c83151883f1e4ed3b81364")) + (265000, uint256S("0x0000189eb94df3a9cbc293fb896cdd2c0a11a96c6312ebc48dabcc87c1ce77d5")) + (266000, uint256S("0x00006843e067df56f2eda15d3d2f2b0a3ce1f9ccca76267b43b355939538d94f")) + (267000, uint256S("0x000061e5f1d6bec772831bfcdf02331a6cb8824a2cca249ffa49737d19782447")) + (268000, uint256S("0x00007f909a3f437fbef9702678e510ab70af79371ea7810af0ae12fc5e9e014b")) + (269000, uint256S("0x00007de818cb26675fd9edef889f228985951c8654354ff50671f672bc868815")) + (270000, uint256S("0x000027590b1638a77fbcf91aa46bb6fe044bf24a63a79ad6cc74b46d2318368c")) + (271000, uint256S("0x000066e889f46e219dcf0b4406ad481e8fc400bc65bc4de757f8a2cc946ce9cd")) + (272000, uint256S("0x0000380a032fc737f0d643ad61ba707f4c6fe939a2b430b10fa581f5a0679100")) + (273000, uint256S("0x0000126824caa6aae226452aab57a114ffb6afbf8cf261963a3961318a28b419")) + (274000, uint256S("0x00005c4c0b084a1d192dfe12783aa91c778f1e709457e73cf76f5889cc26bb78")) + (275000, uint256S("0x00007dc532c6b377c64462a8b8c16b3eff0096fbd9c6b4006c752ce7d653989e")) + (276000, uint256S("0x000010f0388da6d99966cf52ea61c27d687ebe07e8235725df251ad15ead0dee")) + (277000, uint256S("0x00003e8d6d6063171e835af9113f880af2a5907712d3c0e96350d3851961856c")) + (278000, uint256S("0x000037ba4dbfc93957ec601b00835a98c16ad2ed58c26c61ce4b9c2a3d333ec2")) + (279000, uint256S("0x00006717a9b460b220defcd60216be89ee2c433a2d888bfcab850ad5f209d94c")) + (280000, uint256S("0x000041384c4c769143b1501c7c6f892a4ae5e295ca471499e08c8299f5162099")) + (281000, uint256S("0x00000b03c4c5ebafada3fa92aee6703ddaefaab554f48bb204e358ac0aa97add")) + (282000, uint256S("0x00006be32af84c330c5d7d2d97684f1e3fac9e1f298784cb15b35df6bc606f8a")) + (283000, uint256S("0x00000dc131bd64e0911950eccc6ce708ac27bd7388da64e19d4cf23ef888b5c7")) + (284000, uint256S("0x000075deef6c427d641f480805c5ddcf260481983924be5f6a22af7a934ddaf0")) + (285000, uint256S("0x00007a019cb2e868b90a7c30debd7de1bfb5440e06c5bd8187f921358c7ae781")) + (286000, uint256S("0x00001095ccb8ef1028bf4ef8df40467441167280b6a7a15384ba60708ca4ed29")) + (287000, uint256S("0x000085d7c734a13bebb8057beff8deec794a930bd6300af1becd7de50d425fa4")) + (288000, uint256S("0x00001d8395c53c0fc68e536df49fe942caa67f6d8a3f91cdcc018d15b3fe0593")) + (289000, uint256S("0x000050cee8c1581b2d8214d43f9a8c888bdb390b91352fd5347b48df92828b8b")) + (290000, uint256S("0x00004240e011ef34f0b6015698b4baa2728b2885a69284afab0424fc6b09877d")) + (291000, uint256S("0x00007c90a0da5bd891f8de0a7a09d1b8af3831143926d02e90d29d9d1934b5e6")) + (292000, uint256S("0x000015965fa7e60705a11e595a18875ed065d8b11d8030880e59a5d474e458f0")) + (293000, uint256S("0x00008981da5387cdfb537ec9d4eb8e8bc81bf5f18938eaf04889acf011c96749")) + (294000, uint256S("0x00003810c0f915b3fc12207edc99f7b9226f5572f491e7349e79b228c8e7469a")) + (295000, uint256S("0x000087f128604abe37b8fefd2f098b0e0984e6e7a65e2151889a302a68c06eca")) + (296000, uint256S("0x000062a42664d4c4e88bbdbd991e7fee35f779c126dd27386e5225d2237dc2d7")) + (297000, uint256S("0x00001c42f5f24b38f202527e3c2cfec3f5621ad87e75253b5d431452d786d4c4")) + (298000, uint256S("0x0000198517575016a98ee8b54deb7232c2312f017d60959280060ea3cf92e4f2")) + (299000, uint256S("0x00003a9031fb5b7e9a318c08588f63e52a6c91845b444e515bfde4c9b88bffe0")) + (300000, uint256S("0x00000c72234e026b3ac4be4a972889fe48810cb27d551058b77d4c5e9b32575c")) + (301000, uint256S("0x000099dff2afc7600c8b724dfc3202d0d29d38ebef21ffc02f4e2f2a66ccea99")) + (302000, uint256S("0x000085a79dd00da9a21cff9b4266a8fe5c2e90b5ea53ec1c7792295192a2e37e")) + (303000, uint256S("0x00005798b40b3eb295eeb9be6af8ca5007784beda82d04a4a8b9c3a2ac0b1096")) + (304000, uint256S("0x00004eedbf20eec4f279484eb5c13c266d463475ad2fdbb7447bf0a8acb7ac6c")) + (305000, uint256S("0x000029cab3bf30d2b12ef99eb43ed67bf6f81399938cde4f061dcf1d3a3b8282")) + (306000, uint256S("0x000030648c81f681bc962e698a27f587da62182e555579910c456f723109b42f")) + (307000, uint256S("0x0000085e26e0618a933a35267273dbeec35ef76f83d7543443cd55a2ca0e233c")) + (308000, uint256S("0x0000239ea91faaf5425f65fc585e7fac6dc518869a1a7091450f90ee8bdb2fd1")) + (309000, uint256S("0x00001b62fdf4af7be68cd70b1f982d29260dd1e667ef349314a4bddd73d55496")) + (310000, uint256S("0x0000765eb51eaa30265211672e8311dd40e265ad4142f4a03efd2f4089d9e186")) + (311000, uint256S("0x0000140c77cdf8f9d4b289aebc0310305693f970ec409f2b828c3ed513f3e58e")) + (312000, uint256S("0x00003f6e2f0e82c242e5b0a7e126ad210e53fb0dfbe794ff2d7e1cdd3873e818")) + (313000, uint256S("0x00002e678cd8a3a18a1cdc5c957b6c0c880acc21b801c68cc4d7b37110a83f22")) + (314000, uint256S("0x0000198bbbeec4927abfc60f2becfb96a5b0846962d65b32de3f9243bdf39af8")) + (315000, uint256S("0x00006c90b93d54587dfd63105e063f6ddf43cff500aa9968622df5c93a5b0798")) + (316000, uint256S("0x00004c21c397bf276a5cd62d960e308fcb098ec45bd60a4f1bf023b6edf2e6ad")) + (317000, uint256S("0x000036b7f6b9e2dea52a6067a94f2e2704bc1824c8e11bd300a841c46e7dd2c2")) + (318000, uint256S("0x000025029ef96a105a50a7030fb0d61edeceea25e4effb02b3ce8eb4c6205782")) + (319000, uint256S("0x00003537409e025a8075526fa097882f919ee169606a9368d8c3db2d33119e14")) + (320000, uint256S("0x000023b752e4c077f231d05026220244ca10a603324035b885e1b0dd6443c148")) + (321000, uint256S("0x000003411062d7ec945c786237575766c5ce2e48c4f94ca04f28b1404ba86097")) + (322000, uint256S("0x000022447ebbb48e06508a70746f87b2e55f026b8ae3052a168f29848d3e2aa7")) + (323000, uint256S("0x000057eac2e6c611398b43e8a72b83f5863b104fa66120e707df6e3e6fa1ba8e")) + (324000, uint256S("0x00006fa40d2be13a2ba910156769754eab5d55059729597a02194e5e0f84b336")) + (325000, uint256S("0x000007fcd4dab7c2cfcfea47ce88932d3ced21fa9264c1c8ed9cbf3fee08635e")) + (326000, uint256S("0x000017fdd022300e952d9274c63cffd8c791dcaa4d82e5d1c9615464df19ae13")) + (327000, uint256S("0x00006739a0fc2ad8788ef615aa26d6a9c7c6d6adf9a9e84f7ae68379eca2a0b3")) + (328000, uint256S("0x0000777de98944635470c99ec1652aa2c15ce3ff4b19de17eed5373d2474a6ab")) + (329000, uint256S("0x000042206ddb76bd7efdb14b694543b685771c6c341089f5bd1dbfa04d6eace2")) + (330000, uint256S("0x000069d6c21607c368128d4586255f315c55380759a766f961acc35a2e9cb166")) + (331000, uint256S("0x00005b19671f21015db7011c9702a420bab766d8bb7cf25b8525429eeff36b45")) + (332000, uint256S("0x00002d62d1f4d13ec708f65c04937b86cf86a36f68caec269f598e8835ca362f")) + (333000, uint256S("0x000013ef2283eae4c9631b4bbbe80b4fb06b663e25a569336326d7897d80a9f8")) + (334000, uint256S("0x000018b4c8d94267953a1df06439a1393c903255a58c9152593eb2d369d87399")) + (335000, uint256S("0x000022628e5db36faec4fe5f107deab56c47c61bb29a51177ecd6f86939d83c1")) + (336000, uint256S("0x00000f22f49242eb151276aa5fc84debb67bc632197c448dd23a501923f6cdc9")) + (337000, uint256S("0x00004aea6cad4849f27af16c298a990e242b77e249eff52fc9c955c121d5ea62")) + (338000, uint256S("0x000064b79a8fd98e2c57184d6ac67daad8278419aee044bec13c7d8de0baebba")) + (339000, uint256S("0x00007ed65e7fe77d691f91d1ed0fbc40413f277770c8a5aa389505b2a179f428")) + (340000, uint256S("0x00002d001410cef77057d66b49c1949ca1367e11297a595b13f17ff1676e55e9")) + (341000, uint256S("0x0000544668ada85a8429537011fa53be0a2c2801c6c022289b8b056ee54e96ef")) + (342000, uint256S("0x0000311ec160ae645fdbffa2eccbdd4212d6c7a5de7e78786d37e9341d531f75")) + (343000, uint256S("0x000010a8f4eefa8040add659396d269e245441439e33154a3b7324ba8884a6fa")) + (344000, uint256S("0x0000500a9df05634fe8987d437cd3ccb502fc36c00fdc73195bbce7d63d1a7a9")) + (345000, uint256S("0x000002a979e67ec52d92b87c4637f166c694378a9a57e3f8103c7d8a084f551a")) + (346000, uint256S("0x000026662841a071a8c0cc28bd560b42af3b739db3d494dc9bf2754bba021da5")) + (347000, uint256S("0x000031d4a32cf5e1c4f1b7d7e3556a2ce8de88ad3f5307f5b20cd7e40a2d1401")) + (348000, uint256S("0x00000f91efbd01c0cd21b1ab0e0daf2d014a7e6bab3fda7ef480ab35c80a2421")) + (349000, uint256S("0x0000460718b2aee973f80306a37506f9cbf40123fd1205c26c33b0d9749d524b")) + (350000, uint256S("0x00005953abe841392b72e8fab12e3cbceb18c128f73e1aa4406defd18543fe4c")) + (351000, uint256S("0x000018647cfc45a1524168193e67e6af22e8677ba3428dde5f6a2f76c199532d")) + (352000, uint256S("0x00004d0d3fc72f9d7f9a6712c098eb6cef0a7756886011f036736de200fbe5c9")) + (353000, uint256S("0x00007948b8f6bb2433088cffb4bb18ca1d03aad3068a7ea923475f1aa108fd20")) + (354000, uint256S("0x00000a0072325a23f9afcaff49a8c3bcb04f1fcb01612de33bcb9f0f20ebb356")) + (355000, uint256S("0x00003e0133ccefae6723c9f14bfd290a7aaf60c2bc962c293fb58b5957ed1a2e")) + (356000, uint256S("0x000005b41a41a8ec5c60cad85a03d9fa5025b5d9a088a6bbc2ebd1d8e858189e")) + (357000, uint256S("0x000021655f02625c28257183e5c4639841b11661cf40f00fc5ac4bcfcf1eb072")) + (358000, uint256S("0x00007c3fe61dca2d5c52bd5e9090c91812bab9c6a7407e32ed0a930b421f5b80")) + (359000, uint256S("0x000063f8390cad7ad17cbd18983b923e18a1469d5730dec7a62e12914c66df9c")) + (360000, uint256S("0x00000f11a3a78c71d8a7c722cfb52f51006b3656b707cf94c0b08a80c4fd4dc9")) + (361000, uint256S("0x000008e76b1c141b783936c946af3f121d5b96fb8766d83c58ea7f7602c78386")) + (362000, uint256S("0x00000c92d4b3163c33c0efa3feaf6f4c170f9d6288d2435a09435eac87d04e09")) + (363000, uint256S("0x0000567379ab1430696266da7ee6dd1e7ba0eb91bba09c85f558c181e01625e5")) + (364000, uint256S("0x00000712954e172eef571e8297ea1843aba0a762b31b5b2b40ca2027e7c0b1ec")) + (365000, uint256S("0x0000627358770bbc0bf614acb3d02d996f220562f083d08c75e71aa2e83a7870")) + (366000, uint256S("0x0000404c17107474c2a0704c9920ee16e502c8119581f4707e0959af3004746a")) + (367000, uint256S("0x00006c5d54ad2b5279842e8ee726359064c72a034c5c3d5f261413c2cc6a4e6f")) + (368000, uint256S("0x00000df9f5d119afd39c0654010f1ff492f8e04dc1dbe1cc0d3ad5767601c91b")) + (369000, uint256S("0x00004e47d205ac774a1f6d7d8bcc29d6eba6f11005b75aee6dedca1e46a1c1db")) + (370000, uint256S("0x0000810057e4efa124db97d9433372af35b93ae61ea4b620f7ac3ac26658a5aa")) + (371000, uint256S("0x00007e49d0ae73df2647b33550aad63d79c05e40b08fc1c25cb9450ad2b5e8f3")) + (372000, uint256S("0x0000076bfad90f3f5befd763f0abdfd05077821099e0c33bc3947ed853d0b928")) + (373000, uint256S("0x00000d03d70c31a5ae2d32b66a3528981c88d361cc165512a3d9278ebace0589")) + (374000, uint256S("0x00003e477b6dd1ffc2218862bc18b5a651c82122cdcec0c455613d1891e9a727")) + (375000, uint256S("0x000012ad562f8b65a93cb2eb5f708d55e4c3ac689d2020843c55b34099755233")) + (376000, uint256S("0x0000556b17a0197dbaba33c7f58fee2cc9219b6918d925a4146fa7fd5de0e94b")) + (377000, uint256S("0x00005f1ac71e07fcc4f44fdfef693983a872be58f5b1bc04d13873408a54f2e2")) + (378000, uint256S("0x000014e65f4e30b3097d2ebb33c11ada6abaf81e8ac3ffc2e0b6d4756b59822a")) + (379000, uint256S("0x000021418aa5de171ac72097abad42b7f1af1a2f7e19b4c98c7174d5164fa5bc")) + (380000, uint256S("0x000046b214d061a9c237e42bf42493f9792cf80b95f89ef10f432cacee23eba6")) + (381000, uint256S("0x000068f06f5bf5b288e78d694775cb76cf1ed473f95da29790e4b60133d6bb87")) + (382000, uint256S("0x000008c5632f8e3f8e61aebd686b624c7ad644227639d320c3ad286f71d4e14d")) + (383000, uint256S("0x00003b7fffa7e988b90e05d94d24153b0a22e01d9ee0c56e04e9263c88c558ee")) + (384000, uint256S("0x0000083022ca686c81f5f403743dba37334a0e96f96d3c8bed7353a1bd11e58b")) + (385000, uint256S("0x0000485dc4369a16c2c8bde7577ce99ffd0a15a1d21cdf61c01f0bee17b36b2a")) + (386000, uint256S("0x00006da0099b6f9edb40dab855231677bf4f97b0e7643fccad05cd97a8b76397")) + (387000, uint256S("0x000063ff38ec555dc089900fe0ff5648488421918db713941d6c24cfebad37fe")) + (388000, uint256S("0x000069ca27290d71648678a0c5ebd379a17ffc895fea7b23837093a337563060")) + (389000, uint256S("0x00004a1e13ef7557c9dfe0c7daf3e7483e7d1420afff64a5325af7d5bfe49994")) + (390000, uint256S("0x00001dce3a9cdd42f97d3268d29bdad179375f61f7d4e729919450996917c583")) + (391000, uint256S("0x0000071173926b7f9492e35cf48185c2cb57ffcaff2149dcef5c40148a55255d")) + (392000, uint256S("0x00007c3336097b98f2fbc46dcd4f981e73ddb93c8096015282eba490b773cda4")) + (393000, uint256S("0x00000738869c9b8cf66aaa075ebefc5209c90a0f225b405e1850b0b00343bc2e")) + (394000, uint256S("0x0000537c3d2b6794fc5c2636a3311e1cdb34c019ae2dc09778d0c500e1593f2f")) + (395000, uint256S("0x00000dad4673f1db54a434d106a69af55f494ac29a428ff37f4e4aa3b734a37d")) + (396000, uint256S("0x0000514b509a25edc24df6d94e24e2aac5727c18d361fdd7e64356f2233016b2")) + (397000, uint256S("0x00000eaaf35e4358bee2a8c5981683b15214d7ecc03701438f94f5306d10c6c3")) + (398000, uint256S("0x00007cb707f7132454c53ba8410dbb588c3b23e7d731f824d58da21f4ac62330")) + (399000, uint256S("0x00000cc6edba6cf9dd44204502309c781a1f769e019e42306c785dfd2d3614eb")) + (400000, uint256S("0x000023fc6e679339fa72280568217dee1ea0c26790c13f80d0092f9b12ed5f38")) + (401000, uint256S("0x00004ee2b9c7df597e26a4ee85b56c0842380adf5d15b9f6667a132f7cb0b07c")) + (402000, uint256S("0x000073b711054a260c45b4ad63796949d2a00a0baca00e1a68ed16fc98f45d70")) + (403000, uint256S("0x000070b43d9d52a1f896a13bfdfb445fcc3b1374b7ef123b0cce1488f551a954")) + (404000, uint256S("0x00007864734f9e3f3596d9d92df853d3a9b1172ff747fe5983e09028114404c3")) + (405000, uint256S("0x000075ff54f6af74e69cb36dfd7634dace0c68e00d309da017f81ea5dcc9480d")) + (406000, uint256S("0x00008b908deffb33856ccd1ef6afa73cf8bd01e8c3b5be502829dd64157e3f7e")) + (407000, uint256S("0x000023d28f6b13c134285247c6d8191f16a94463ccd84a506c99ba52706b67e6")) + (408000, uint256S("0x0000723a9c35577d2e56749861ad4e9d3c61b1c650e0c7c832cb1d60346fb46c")) + (409000, uint256S("0x000021a04d41834edb1ebf0c3c09488fb1e3da4c30acfda07ef154de955dbfc0")) + (410000, uint256S("0x00007b63162192a0b9c1015a227df9fe264591b5842aab61a637c06768a5e3d7")) + (411000, uint256S("0x0000064165fbcae2b8c44549630ec47c9504c77ddd0aaea91e846539ce023c6d")) + (412000, uint256S("0x000048d4879eb955e516485f822f2f52fa078f02396fcdbd1e0fc0698a90d577")) + (413000, uint256S("0x00006df51ae354366835450d019ea8a7a59a34060dec74de630bdf8004bbbd18")) + (414000, uint256S("0x0000113f9fa68a6a1acc32aeab61e8ca15e1f53e9f43b9e77bca85fecc7871d8")) + (415000, uint256S("0x000003ec7bf286218a52ceea9a5b8ec460a5a77211679c2b8d1d1e4ff96c03fe")) + (416000, uint256S("0x00000c4a34784e10158b231baa9c35b6aca1cb1d967f65bdeed7480f55df869d")) + (417000, uint256S("0x00004462829936ef1967f6604d00c0e034588642dacc1ec827ec3b4468202ab0")) + (418000, uint256S("0x00005debf20584e6e0adb8c05a73bf4b30484451964d39536f50bb02b426b0b1")) + (419000, uint256S("0x00006357b1afbb6aebcfc778c06ed1fc51fbb51a7fc9b882c4c9bb4a35e0b4ed")) + (420000, uint256S("0x000040207b5dc0f5e2509b1216b549672c58d68bac8224f67492aa803b2f2570")) + (421000, uint256S("0x000042124fbfa2ba3db57f39bfd4f5986969c5c4faf8b1c06cf470a5ea001788")) + (422000, uint256S("0x00003c97f3bdafac16b245ea1f3b941c52388be5bec9c087186ac17088d5cbf5")) + (423000, uint256S("0x00005068310436b42ace3d987e8a10eb858b4a23321dfeeefaef22e9446fa2b0")) + (424000, uint256S("0x00005ef6829528a3504565070d82e425614426ab25b45bca04aa4af3d7e0e29c")) + (425000, uint256S("0x000024123c6a896dfb002e50b4574037d07bb94e0a0e9544e67f8a2e090b6b89")) + (426000, uint256S("0x00004f641099594d32e1880080931343420e8597be3939a4f6628969d4c94a4d")) + (427000, uint256S("0x000078d2859474d6b72acaa6060ced2386028e457743bad4cd9b0ced3f8ab154")) + (428000, uint256S("0x000087e3b407861303f6b32015910f4a3dd0f1f78a4e53f178ca442e9275c317")) + (429000, uint256S("0x000060b5c76252c68f358202b6f6c421d5ca9c705dd28240882258df8a809174")) + (430000, uint256S("0x0000305e76e05f96396d96187e6d35e900a4d735aeee6f105168eb45846d7055")) + (431000, uint256S("0x00002181db7f434ad47bfc295f8ebf8caa382f13829ff70b06263648e0e033ad")) + (432000, uint256S("0x00003e3f8d3848689893840e239619e875db02745d68709a533e30fef16fe9b1")) + (433000, uint256S("0x00007ec0e6150fdeee913a18f5c8f3d7099bc744a218dc6a01c63580aa9c8eb1")) + (434000, uint256S("0x0000415b347418526dbbce15098f2d8d1b5a1dd0446151efcfdd3318d5861351")) + (435000, uint256S("0x0000663b475c89a1ead8cc41c1ed10c8fcdbf417d007a6f0b95580a1165eaa1a")) + (436000, uint256S("0x00001783f2a7362a81e0b49cfdeb7dbb032e6e9ab4f66b3cefb4e52f1c5dfb34")) + (437000, uint256S("0x00008486eaa2a91c1ef5c530065431dbbb0c4240dea7a2101ab0582484003280")) + (438000, uint256S("0x00004fd678f5f493ea4e9ec5b54dd66749350fcd325c5ec677c154bcbca88799")) + (439000, uint256S("0x00009244e5e34e05cfcf1bbf619c8a8b43ceb538fabfa7843be9796a295e49e8")) + (440000, uint256S("0x000036b5b2b13908454ede21c5826af6331b728a66da7fc67bfedca910ff9b80")) + (441000, uint256S("0x000034367b426ed559bb7d0b1046eec735a850c53fce26f8b0716198ff90051e")) + (442000, uint256S("0x000059583a267d919d5bc4c65abf8c304150e45a336b9f34bb35ddaf0bcb1787")) + (443000, uint256S("0x00004f414772200bfaf67651fbc4cc103367a5108a35fe026850a4bfd92d38ff")) + (444000, uint256S("0x00001b9bc79d27709c34a96a5dbd6a259fa1495afdf8fd05c23a2d659602620c")) + (445000, uint256S("0x000061e49c4d2d995a43a2d2b491a023444b70aba5150ee4d2789cfca6018710")) + (446000, uint256S("0x000051f2bc3eb24aa77017476494528e0096a0a1cb1e29b4318ce9b3410c6751")) + (447000, uint256S("0x00002979121255c18f58c5ec1a4267104585577b91e2e61682b44d65930400f5")) + (448000, uint256S("0x00001122c7a9f21b96941e6e074122ce55cb412d659ffbfad8a0bebcbd487533")) + (449000, uint256S("0x00005ed4ab8507e94702e24ce16b257e8eac754be1eb3e743b430bdbe3e2eb14")) + (450000, uint256S("0x00001579df12ce8d38b8f4416f221964af6aa54bd065201c578bee6e03596463")) + (451000, uint256S("0x000057eae48d40b8b59a16f65fa4b5902b27dbe0bb5470cd27214f4045172d87")) + (452000, uint256S("0x00006e7bbad31584a17b7bae4b7555a4807ce276cd5046a309d79f0a402cdbd9")) + (453000, uint256S("0x0000011e661360329ac1ba58e11f2358731abd884d1c590525d074195bfc8ddd")) + (454000, uint256S("0x000065acdfbb8d1e0d66b358f81acd99711adedb85f37fd522b8b515184a073c")) + (455000, uint256S("0x000026888730aacaf408c7b6cdd5a4ebce04f4c2aea22061f5ee832a65c52b24")) + (456000, uint256S("0x0000602cca1d31d8a750c84cda243b6d454d4d93bcc2241cf0ae6982a4716755")) + (457000, uint256S("0x00002d7fd2ac55de783d6f69270fd9e499789185e98eca4561bcfb13be663cee")) + (458000, uint256S("0x000015971c8c8c0d2b2ba9b9c0dd5c97091b77e3bd747cd8f5a1396d7cbc39d0")) + (459000, uint256S("0x00008473ea08a574ab72f3246462ca97fed87478c6e5fb39bb9b340f6c8b0f44")) + (460000, uint256S("0x00006487396edc5cb9bf6f5cd62491d1d5a47e89257ac0286cbcc8f428239fb7")) + (461000, uint256S("0x00004579751a959bf33a7418c872ee533c11dd0db764bdbf800317fcca50db74")) + (462000, uint256S("0x00005e57d635a75aae751e87aa9081218babed5522861be57ca55ea5d91e5cc3")) + (463000, uint256S("0x00000fb2816e0c45b5414b72aa67a918c1ffc6a5e114d4f4aa2c1863f9d7ea7a")) + (464000, uint256S("0x00003c2985800d71f2875169d86d911bbf3ede85eaec083869bcb817d5930407")) + (465000, uint256S("0x000037d41b8dcc82d16da8907512e4c0dd4d98e5f8e1985f6c418d62fe38bf20")) + (466000, uint256S("0x000034e51cc154129c394b6130d3711bf930c47a0943c0e08598353565781e8e")) + (467000, uint256S("0x00004c2bd9c0a4414e9c689b21a8266dcd0ea9f0363559940c77f53dac76a746")) + (468000, uint256S("0x0000097d658883238e26170d0244759a6a0fb53204e392bd5607bff329e52580")) + (469000, uint256S("0x000068c832e7335fa8b095693ede2161463e250a6857171efb34e8b2c858f0cc")) + (470000, uint256S("0x000016f55342090f2f7dd1013c1780daea3e18331b9e481e44cc969e42267c9a")) + (471000, uint256S("0x00002544263ac1d071b15575a1be34f3e220e97b631bbd0a37ca2211da3be579")) + (472000, uint256S("0x000082479a6d345f52f2f6a3a7f8b3e1bde3e31bdf6971ae7e17a4e9ceb9f3d8")) + (473000, uint256S("0x00006af93834d09ba9e22c0e9bcf041df511fa73adc7c3b90b20930c14dc3afc")) + (474000, uint256S("0x000009f5395a0e10bd3467d49468f22a17b96cc56f133742b4b94f81d055a1ed")) + (475000, uint256S("0x00000732dfcbe6c20963da08712f407c0137c686c2c5b8199be7ab93533ca75e")) + (476000, uint256S("0x0000212ee23e893f853ef49641d748435b3a783c12eccfaa9d113ed1039a59aa")) + (477000, uint256S("0x00002eb7f121312d1702a95d23e6058d305bc2fcec6b665918d1f61ccdce3d8a")) + (478000, uint256S("0x00007c3f92685d1ab3a31d4462286825e1edf247b74f0f2acf203cfda160b4b6")) + (479000, uint256S("0x0000387969e04687fa879ecc4b7ef42e94d7702b2adc5c895b91036f2b2b32a5")) + (480000, uint256S("0x00004fcf6a8c13044beef7a176c1b872bbec53cc00aee74a4cbc9f7cb332ad29")) + (481000, uint256S("0x000071ff0caf576084563d6bc15fe7887b261a22cd7f2540a047486dc97cd961")) + (482000, uint256S("0x00000d18b5deb42f4a383a510d5ce92e4ffe84cf12556adb09cfc381eae9343a")) + (483000, uint256S("0x00003045108fd460198ab5db9154df288f796e4714d78bfc030bf32a0d72ece4")) + (484000, uint256S("0x000077ab6ef56dc32d8d78340e0f69e9666914ce0299c16d80c9ed44b95cc74c")) + (485000, uint256S("0x00005641dd3b8af4af4328e7240b2f614d4f9bc02d941f1cb753fd9b9e648ac3")) + (486000, uint256S("0x000045d840594db850fdf19c03b29b2587b225f7c17009b6bc92c3a95d913714")) + (487000, uint256S("0x0000428e6bef96b2cfa2a512d10ff22f459e1c81dfd833935bd2bec9a9401c70")) + (488000, uint256S("0x00004b7a10c67d0bd09058183babec02861c0722b09b75038d3779a586bcee48")) + (489000, uint256S("0x000023557e9510f58a398eeaf0c36753b93ade77ce885f8736011f5eba399340")) + (490000, uint256S("0x000021e70faa40c6b1cd9ed3f91b8ad43e2570a00e34c54c5ed74218ac33bf72")) + (491000, uint256S("0x00002edd58e2126702485fddda9eb55d1d39880c44de8d8c0efdcdecdae2722c")) + (492000, uint256S("0x00004f00c0831ebd6675da2aa83a3352e79affee2786a26dab96cda9336b7ccc")) + (493000, uint256S("0x000064438694b83dc959b20b82cd5da3f4622186404753b97340450be0a15755")) + (494000, uint256S("0x00003607262aef0da4f84721222cfb5cbb915db323ec95e1b4e70bf3ce860c6b")) + (495000, uint256S("0x000024c603dbf750c01c2975ab60624bfe5ed2e44532649917d9645ae6209ebf")) + (496000, uint256S("0x0000191661868f098c37178cebe1c4eea37f311eaeb82e5148f1452b26d1fbca")) + (497000, uint256S("0x000029b3502c67a39247b646f286d925af7d0501f994c4367d8769dadaa9ab1b")) + (498000, uint256S("0x00003e7be1463cf709a8a1fc6b431c442de0f5e972b8b2444fcb2d275287d36c")) + (499000, uint256S("0x00000d00e2075b9de577c9f2b21927ea21f4bc6719734888073e039a43e3f30c")) + (500000, uint256S("0x000038889c413584ecab16aaf0ae8f050fec136484416084187a2fa27ed1efc4")) + (501000, uint256S("0x00003e0981fdee677dbfdffbf5910ab8ccab4d91e2e3f10594668cad35e0fe1b")) + (502000, uint256S("0x00000e08e2495364b7cdd48cd2999e568e92f4ca9b27343af4240f9adc194f9d")) + (503000, uint256S("0x000014996d031f6c0b0d3e0268d22c75ee9bed7e9f845f81b8df5dd38b195995")) + (504000, uint256S("0x0000041a7d55d6e9344faff6af6a60608a4572f3c12adb79a326606e5b168cd2")) + (505000, uint256S("0x00002df16f23a38f3bf6e3e42f5f14ff44bb357a975c8eb43d4985f16e4a7628")) + (506000, uint256S("0x000042c9adeb835a1105e772a9fc637d156cc8eff5d71a78243dbf3fe0ab096f")) + (507000, uint256S("0x000001c27a7bf812eb8ba21e6ce59591b2eaaf50121e5c98fd740629d00a4e2b")) + (508000, uint256S("0x00000716bb09e7513f50d5ea46d15324d892c305a11267306c009c720f51d3bb")) + (509000, uint256S("0x00007358b4d32fac5362839bf3bebdd938905766ef3e853d00ebf8557a724239")) + (510000, uint256S("0x000045c957443966535795a08bc5feffee0f0c59b55d7ba727593dbc459a1c34")) + (511000, uint256S("0x00001d9b8898a1a26bec928ded3b3650b6e0b6cf6589f95072fbff5586057716")) + (512000, uint256S("0x00006c49e4544ce19a6b3e4a4e82e05fbc3ef1ce9d3dee203cf09f047ec92d30")) + ,(int64_t) 1686842247, // time of last checkpointed block + (int64_t) 523914, // total txs + (double) 1454 // txs in the last day before block 512445 }; } else { // all other HSC's with no checkpoints From 5abc550af7c8312519fe543a796599cb7c02a7ad Mon Sep 17 00:00:00 2001 From: Duke Date: Sat, 17 Jun 2023 09:52:12 -0400 Subject: [PATCH 34/78] Dragonx has a blocktime of 36s not 60s --- util/checkpoints.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/checkpoints.pl b/util/checkpoints.pl index cb8301d61..153c2dcba 100755 --- a/util/checkpoints.pl +++ b/util/checkpoints.pl @@ -31,8 +31,10 @@ my $acname = shift; if ($acname) { # TODO: is acname valid? $cli .= " -ac_name=$acname"; - # TODO: assumes all HSC's will have a blocktime of 60s + # HSC's by default have a blocktime of 60s $perday = 1440; + # Dragonx has a blocktime of 36s + $perday = 2400 if ($acname == 'DRAGONX'); } else { $acname = 'HUSH3'; } From 31cc5ee901c621b3bde2e4987c69c3906a039586 Mon Sep 17 00:00:00 2001 From: Duke Date: Sat, 17 Jun 2023 21:22:41 -0400 Subject: [PATCH 35/78] Remove unused code --- src/hush_gateway.h | 97 +---------------- src/hush_globals.h | 1 - src/hush_pax.h | 259 +-------------------------------------------- src/hush_utils.h | 1 - 4 files changed, 2 insertions(+), 356 deletions(-) diff --git a/src/hush_gateway.h b/src/hush_gateway.h index b040d3d48..8068b3259 100644 --- a/src/hush_gateway.h +++ b/src/hush_gateway.h @@ -18,40 +18,9 @@ // paxdeposit equivalent in reverse makes opreturn and HUSH does the same in reverse #include "hush_defs.h" -/*#include "secp256k1/include/secp256k1.h" -#include "secp256k1/include/secp256k1_schnorrsig.h" -#include "secp256k1/include/secp256k1_musig.h" -int32_t dummy_linker_tricker() -{ - secp256k1_context *ctx = 0; std::vector musig64; CPubKey pk; secp256k1_schnorrsig musig; secp256k1_pubkey combined_pk; - if ( secp256k1_schnorrsig_parse((const secp256k1_context *)ctx,&musig,(const uint8_t *)&musig64[0]) > 0 && secp256k1_ec_pubkey_parse(ctx,&combined_pk,pk.begin(),33) > 0 ) - return(1); -}*/ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base) { - int32_t baseid; struct hush_state *sp; int64_t netliability,maxallowed,maxval; - *available = *deposited = *issued = *withdrawn = *approved = *redeemed = 0; - if ( (baseid= hush_baseid(base)) >= 0 ) - { - if ( (sp= hush_stateptrget(base)) != 0 ) - { - *deposited = sp->deposited; - *issued = sp->issued; - *withdrawn = sp->withdrawn; - *approved = sp->approved; - *redeemed = sp->redeemed; - maxval = sp->approved; - if ( sp->withdrawn > maxval ) - maxval = sp->withdrawn; - netliability = (sp->issued - maxval) - sp->shorted; - maxallowed = hush_maxallowed(baseid); - if ( netliability < maxallowed ) - *available = (maxallowed - netliability); - //printf("%llu - %llu %s %.8f %.8f %.8f %.8f %.8f\n",(long long)maxallowed,(long long)netliability,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); - return(0); - } else printf("pax_fiatstatus cant get basesp.%s\n",base); - } // else printf("pax_fiatstatus illegal base.%s\n",base); return(-1); } @@ -210,71 +179,7 @@ int32_t hush_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transaction int32_t hush_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t *values,int64_t *srcvalues,int32_t *hushheights,int32_t *otherheights,int8_t *baseids,uint8_t *rmd160s,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo) { - struct pax_transaction p,*pax; int32_t i,n=0,j,len=0,incr,height,otherheight; uint8_t type,rmd160[20]; uint64_t fiatoshis; char symbol[HUSH_SMART_CHAIN_MAXLEN]; - //if ( HUSH_PAX == 0 ) - // return(0); - incr = 34 + (iskomodo * (2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4)); - //41e77b91cb68dc2aa02fa88550eae6b6d44db676a7e935337b6d1392d9718f03cb0200305c90660400000000fbcbeb1f000000bde801006201000058e7945ad08ddba1eac9c9b6c8e1e97e8016a2d152 - - // 41e94d736ec69d88c08b5d238abeeca609c02357a8317e0d56c328bcb1c259be5d0200485bc80200000000404b4c000000000059470200b80b000061f22ba7d19fe29ac3baebd839af8b7127d1f9075553440046bb4cc7a3b5cd39dffe7206507a3482a00780e617f68b273cce9817ed69298d02001069ca1b0000000080f0fa02000000005b470200b90b000061f22ba7d19fe29ac3baebd839af8b7127d1f90755 - - //for (i=0; i>>>>>> %s: (%s) fiat %.8f hushheight.%d other.%d -> %s %.8f\n",type=='A'?"approvedA":"issuedX",baseids[n]>=0?CURRENCIES[baseids[n]]:"???",dstr(p.fiatoshis),hushheights[n],otherheights[n],coinaddr,dstr(values[n])); - } - } - } - else - { - for (i=0; i<4; i++) - base[i] = opretbuf[opretlen-4+i]; - for (j=0; j<32; j++) - { - ((uint8_t *)&txids[n])[j] = opretbuf[len++]; - //printf("%02x",((uint8_t *)&txids[n])[j]); - } - vouts[n] = opretbuf[len++]; - vouts[n] = (opretbuf[len++] << 8) | vouts[n]; - baseids[n] = hush_baseid(base); - if ( (pax= hush_paxfinds(txids[n],vouts[n])) != 0 ) - { - values[n] = (strcmp("HUSH3",base) == 0) ? pax->puposhis : pax->fiatoshis; - srcvalues[n] = (strcmp("HUSH3",base) == 0) ? pax->fiatoshis : pax->puposhis; - hushheights[n] = pax->height; - otherheights[n] = pax->otherheight; - memcpy(&rmd160s[n * 20],pax->rmd160,20); - } - } - //printf(" hush_issued_opreturn issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen); - } - } - return(n); + return 0; } int32_t hush_paxcmp(char *symbol,int32_t hushheight,uint64_t value,uint64_t checkvalue,uint64_t seed) diff --git a/src/hush_globals.h b/src/hush_globals.h index 4ac3060b6..e307f774c 100644 --- a/src/hush_globals.h +++ b/src/hush_globals.h @@ -29,7 +29,6 @@ int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,ui int32_t hush_isrealtime(int32_t *hushheightp); uint64_t hush_paxtotal(); int32_t hush_longestchain(); -uint64_t hush_maxallowed(int32_t baseid); int32_t hush_checkvout(int32_t vout,int32_t k,int32_t indallvouts); pthread_mutex_t hush_mutex; diff --git a/src/hush_pax.h b/src/hush_pax.h index 9289ce15d..eba734593 100644 --- a/src/hush_pax.h +++ b/src/hush_pax.h @@ -18,213 +18,13 @@ #include "hush_defs.h" -#define USD 0 -#define EUR 1 -#define JPY 2 -#define GBP 3 -#define AUD 4 -#define CAD 5 -#define CHF 6 -#define NZD 7 - -#define CNY 8 -#define RUB 9 -#define MXN 10 -#define BRL 11 -#define INR 12 -#define HKD 13 -#define TRY 14 -#define ZAR 15 - -#define PLN 16 -#define NOK 17 -#define SEK 18 -#define DKK 19 -#define CZK 20 -#define HUF 21 -#define ILS 22 -#define KRW 23 - -#define MYR 24 -#define PHP 25 -#define RON 26 -#define SGD 27 -#define THB 28 -#define BGN 29 -#define IDR 30 -#define HRK 31 - -#define MAX_CURRENCIES 32 -extern char CURRENCIES[][8]; - -uint64_t M1SUPPLY[] = { 3317900000000, 6991604000000, 667780000000000, 1616854000000, 331000000000, 861909000000, 584629000000, 46530000000, // major currencies - 45434000000000, 16827000000000, 3473357229000, 306435000000, 27139000000000, 2150641000000, 347724099000, 1469583000000, 749543000000, 1826110000000, 2400434000000, 1123925000000, 3125276000000, 13975000000000, 317657000000, 759706000000000, 354902000000, 2797061000000, 162189000000, 163745000000, 1712000000000, 39093000000, 1135490000000000, 80317000000, - 100000000 }; - -#define MIND 1000 -uint32_t MINDENOMS[] = { MIND, MIND, 100*MIND, MIND, MIND, MIND, MIND, MIND, // major currencies - 10*MIND, 100*MIND, 10*MIND, MIND, 100*MIND, 10*MIND, MIND, 10*MIND, MIND, 10*MIND, 10*MIND, 10*MIND, 10*MIND, 100*MIND, MIND, 1000*MIND, MIND, 10*MIND, MIND, MIND, 10*MIND, MIND, 10000*MIND, 10*MIND, // end of currencies -10*MIND, -}; - -int32_t Peggy_inds[539] = {289, 404, 50, 490, 59, 208, 87, 508, 366, 288, 13, 38, 159, 440, 120, 480, 361, 104, 534, 195, 300, 362, 489, 108, 143, 220, 131, 244, 133, 473, 315, 439, 210, 456, 219, 352, 153, 444, 397, 491, 286, 479, 519, 384, 126, 369, 155, 427, 373, 360, 135, 297, 256, 506, 322, 425, 501, 251, 75, 18, 420, 537, 443, 438, 407, 145, 173, 78, 340, 240, 422, 160, 329, 32, 127, 128, 415, 495, 372, 522, 60, 238, 129, 364, 471, 140, 171, 215, 378, 292, 432, 526, 252, 389, 459, 350, 233, 408, 433, 51, 423, 19, 62, 115, 211, 22, 247, 197, 530, 7, 492, 5, 53, 318, 313, 283, 169, 464, 224, 282, 514, 385, 228, 175, 494, 237, 446, 105, 150, 338, 346, 510, 6, 348, 89, 63, 536, 442, 414, 209, 216, 227, 380, 72, 319, 259, 305, 334, 236, 103, 400, 176, 267, 355, 429, 134, 257, 527, 111, 287, 386, 15, 392, 535, 405, 23, 447, 399, 291, 112, 74, 36, 435, 434, 330, 520, 335, 201, 478, 17, 162, 483, 33, 130, 436, 395, 93, 298, 498, 511, 66, 487, 218, 65, 309, 419, 48, 214, 377, 409, 462, 139, 349, 4, 513, 497, 394, 170, 307, 241, 185, 454, 29, 367, 465, 194, 398, 301, 229, 212, 477, 303, 39, 524, 451, 116, 532, 30, 344, 85, 186, 202, 517, 531, 515, 230, 331, 466, 147, 426, 234, 304, 64, 100, 416, 336, 199, 383, 200, 166, 258, 95, 188, 246, 136, 90, 68, 45, 312, 354, 184, 314, 518, 326, 401, 269, 217, 512, 81, 88, 272, 14, 413, 328, 393, 198, 226, 381, 161, 474, 353, 337, 294, 295, 302, 505, 137, 207, 249, 46, 98, 27, 458, 482, 262, 253, 71, 25, 0, 40, 525, 122, 341, 107, 80, 165, 243, 168, 250, 375, 151, 503, 124, 52, 343, 371, 206, 178, 528, 232, 424, 163, 273, 191, 149, 493, 177, 144, 193, 388, 1, 412, 265, 457, 255, 475, 223, 41, 430, 76, 102, 132, 96, 97, 316, 472, 213, 263, 3, 317, 324, 274, 396, 486, 254, 205, 285, 101, 21, 279, 58, 467, 271, 92, 538, 516, 235, 332, 117, 500, 529, 113, 445, 390, 358, 79, 34, 488, 245, 83, 509, 203, 476, 496, 347, 280, 12, 84, 485, 323, 452, 10, 146, 391, 293, 86, 94, 523, 299, 91, 164, 363, 402, 110, 321, 181, 138, 192, 469, 351, 276, 308, 277, 428, 182, 260, 55, 152, 157, 382, 121, 507, 225, 61, 431, 31, 106, 327, 154, 16, 49, 499, 73, 70, 449, 460, 187, 24, 248, 311, 275, 158, 387, 125, 67, 284, 35, 463, 190, 179, 266, 376, 221, 42, 26, 290, 357, 268, 43, 167, 99, 374, 242, 156, 239, 403, 339, 183, 320, 180, 306, 379, 441, 20, 481, 141, 77, 484, 69, 410, 502, 172, 417, 118, 461, 261, 47, 333, 450, 296, 453, 368, 359, 437, 421, 264, 504, 281, 270, 114, 278, 56, 406, 448, 411, 521, 418, 470, 123, 455, 148, 356, 468, 109, 204, 533, 365, 8, 345, 174, 370, 28, 57, 11, 2, 231, 310, 196, 119, 82, 325, 44, 342, 37, 189, 142, 222, 9, 54, }; - -uint64_t peggy_smooth_coeffs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)] = // numprimes.13 -{ - 962714545, 962506087, 962158759, 961672710, 961048151, 960285354, 959384649, 958346426, 957171134, // x.8 - 955859283, 954411438, 952828225, 951110328, 949258485, 947273493, 945156207, 942907532, 940528434, // x.17 - 938019929, 935383089, 932619036, 929728945, 926714044, 923575608, 920314964, 916933485, 913432593, // x.26 - 909813756, 906078486, 902228342, 898264923, 894189872, 890004874, 885711650, 881311964, 876807614, // x.35 - 872200436, 867492300, 862685110, 857780804, 852781347, 847688737, 842505000, 837232189, 831872382, // x.44 - 826427681, 820900212, 815292123, 809605581, 803842772, 798005901, 792097186, 786118864, 780073180, // x.53 - 773962395, 767788778, 761554609, 755262175, 748913768, 742511686, 736058231, 729555707, 723006417, // x.62 - 716412665, 709776755, 703100984, 696387648, 689639036, 682857428, 676045100, 669204315, 662337327, // x.71 - 655446378, 648533696, 641601496, 634651978, 627687325, 620709702, 613721256, 606724115, 599720386, // x.80 - 592712154, 585701482, 578690411, 571680955, 564675105, 557674825, 550682053, 543698699, 536726645, // x.89 - 529767743, 522823816, 515896658, 508988029, 502099660, 495233249, 488390461, 481572928, 474782249, // x.98 - 468019988, 461287675, 454586804, 447918836, 441285195, 434687268, 428126409, 421603932, 415121117, // x.107 - 408679208, 402279408, 395922888, 389610779, 383344175, 377124134, 370951677, 364827785, 358753406, // x.116 - 352729449, 346756785, 340836251, 334968645, 329154729, 323395230, 317690838, 312042206, 306449955, // x.125 - 300914667, 295436891, 290017141, 284655897, 279353604, 274110676, 268927490, 263804394, 258741701, // x.134 - 253739694, 248798623, 243918709, 239100140, 234343077, 229647649, 225013957, 220442073, 215932043, // x.143 - 211483883, 207097585, 202773112, 198510404, 194309373, 190169909, 186091877, 182075118, 178119452, // x.152 - 174224676, 170390565, 166616873, 162903335, 159249664, 155655556, 152120688, 148644718, 145227287, // x.161 - 141868021, 138566528, 135322401, 132135218, 129004542, 125929924, 122910901, 119946997, 117037723, // x.170 - 114182582, 111381062, 108632643, 105936795, 103292978, 100700645, 98159238, 95668194, 93226942, // x.179 - 90834903, 88491495, 86196126, 83948203, 81747126, 79592292, 77483092, 75418916, 73399150, // x.188 - 71423178, 69490383, 67600142, 65751837, 63944844, 62178541, 60452305, 58765515, 57117547, // x.197 - 55507781, 53935597, 52400377, 50901505, 49438366, 48010349, 46616844, 45257246, 43930951, // x.206 - 42637360, 41375878, 40145912, 38946876, 37778185, 36639262, 35529533, 34448428, 33395384, // x.215 - 32369842, 31371249, 30399057, 29452725, 28531717, 27635503, 26763558, 25915365, 25090413, // x.224 - 24288196, 23508216, 22749980, 22013003, 21296806, 20600917, 19924870, 19268206, 18630475, // x.233 - 18011231, 17410035, 16826458, 16260073, 15710466, 15177224, 14659944, 14158231, 13671694, // x.242 - 13199950, 12742625, 12299348, 11869759, 11453500, 11050225, 10659590, 10281262, 9914910, // x.251 - 9560213, 9216856, 8884529, 8562931, 8251764, 7950739, 7659571, 7377984, 7105706, // x.260 - 6842471, 6588020, 6342099, 6104460, 5874861, 5653066, 5438844, 5231969, 5032221, // x.269 - 4839386, 4653254, 4473620, 4300287, 4133059, 3971747, 3816167, 3666139, 3521488, // x.278 - 3382043, 3247640, 3118115, 2993313, 2873079, 2757266, 2645728, 2538325, 2434919, // x.287 - 2335380, 2239575, 2147382, 2058677, 1973342, 1891262, 1812325, 1736424, 1663453, // x.296 - 1593311, 1525898, 1461118, 1398879, 1339091, 1281666, 1226519, 1173569, 1122736, // x.305 - 1073944, 1027117, 982185, 939076, 897725, 858065, 820033, 783568, 748612, // x.314 - 715108, 682999, 652233, 622759, 594527, 567488, 541597, 516808, 493079, // x.323 - 470368, 448635, 427841, 407948, 388921, 370725, 353326, 336692, 320792, // x.332 - 305596, 291075, 277202, 263950, 251292, 239204, 227663, 216646, 206130, // x.341 - 196094, 186517, 177381, 168667, 160356, 152430, 144874, 137671, 130806, // x.350 - 124264, 118031, 112093, 106437, 101050, 95921, 91039, 86391, 81968, // x.359 - 77759, 73755, 69945, 66322, 62877, 59602, 56488, 53528, 50716, // x.368 - 48043, 45505, 43093, 40803, 38629, 36564, 34604, 32745, 30980, // x.377 - 29305, 27717, 26211, 24782, 23428, 22144, 20927, 19774, 18681, // x.386 - 17646, 16665, 15737, 14857, 14025, 13237, 12491, 11786, 11118, // x.395 - 10487, 9890, 9325, 8791, 8287, 7810, 7359, 6933, 6531, // x.404 - 6151, 5792, 5453, 5133, 4831, 4547, 4278, 4024, 3785, // x.413 - 3560, 3347, 3147, 2958, 2779, 2612, 2454, 2305, 2164, // x.422 - 2032, 1908, 1791, 1681, 1577, 1480, 1388, 1302, 1221, // x.431 - 1145, 1073, 1006, 942, 883, 827, 775, 725, 679, // x.440 - 636, 595, 557, 521, 487, 456, 426, 399, 373, // x.449 - 348, 325, 304, 284, 265, 248, 231, 216, 202, // x.458 - 188, 175, 164, 153, 142, 133, 124, 115, 107, // x.467 - 100, 93, 87, 81, 75, 70, 65, 61, 56, // x.476 - 53, 49, 45, 42, 39, 36, 34, 31, 29, // x.485 - 27, 25, 23, 22, 20, 19, 17, 16, 15, // x.494 - 14, 13, 12, 11, 10, 9, 9, 8, 7, // x.503 - 7, 6, 6, 5, 5, 5, 4, 4, 4, // x.512 - 3, 3, 3, 3, 2, 2, 2, 2, 2, // x.521 - 2, 2, 1, 1, 1, 1, 1, 1, 1, // x.530 - 1, 1, 1, 1, 1, 1, 0, 0, // isum 100000000000 -}; - -uint64_t hush_maxallowed(int32_t baseid) -{ - uint64_t mult,val = COIN * (uint64_t)10000; - if ( baseid < 0 || baseid >= 32 ) - return(0); - if ( baseid < 10 ) - val *= 4; - mult = MINDENOMS[baseid] / MIND; - return(mult * val); -} - -uint64_t hush_paxvol(uint64_t volume,uint64_t price) -{ - if ( volume < 10000000000 ) - return((volume * price) / 1000000000); - else if ( volume < (uint64_t)10 * 10000000000 ) - return((volume * (price / 10)) / 100000000); - else if ( volume < (uint64_t)100 * 10000000000 ) - return(((volume / 10) * (price / 10)) / 10000000); - else if ( volume < (uint64_t)1000 * 10000000000 ) - return(((volume / 10) * (price / 100)) / 1000000); - else if ( volume < (uint64_t)10000 * 10000000000 ) - return(((volume / 100) * (price / 100)) / 100000); - else if ( volume < (uint64_t)100000 * 10000000000 ) - return(((volume / 100) * (price / 1000)) / 10000); - else if ( volume < (uint64_t)1000000 * 10000000000 ) - return(((volume / 1000) * (price / 1000)) / 1000); - else if ( volume < (uint64_t)10000000 * 10000000000 ) - return(((volume / 1000) * (price / 10000)) / 100); - else return(((volume / 10000) * (price / 10000)) / 10); -} - -void pax_rank(uint64_t *ranked,uint32_t *pvals) -{ - int32_t i; uint64_t vals[32],sum = 0; - for (i=0; i<32; i++) - { - vals[i] = hush_paxvol(M1SUPPLY[i] / MINDENOMS[i],pvals[i]); - sum += vals[i]; - } - for (i=0; i<32; i++) - { - ranked[i] = (vals[i] * 1000000000) / sum; - //printf("%.6f ",(double)ranked[i]/1000000000.); - } - //printf("sum %llu\n",(long long)sum); -}; - -#define BTCFACTOR_HEIGHT 466266 - -double PAX_BTCUSD(int32_t height,uint32_t btcusd) -{ - double btcfactor,BTCUSD; - if ( height >= BTCFACTOR_HEIGHT ) - btcfactor = 100000.; - else btcfactor = 1000.; - BTCUSD = ((double)btcusd / (1000000000. / btcfactor)); - if ( height >= BTCFACTOR_HEIGHT && height < 500000 && BTCUSD > 20000 && btcfactor == 100000. ) - BTCUSD /= 100; - return(BTCUSD); -} - int32_t PAX_pubkey(int32_t rwflag,uint8_t *pubkey33,uint8_t *addrtypep,uint8_t rmd160[20],char fiat[4],uint8_t *shortflagp,int64_t *fiatoshisp) { - if ( rwflag != 0 ) - { - memset(pubkey33,0,33); - pubkey33[0] = 0x02 | (*shortflagp != 0); - memcpy(&pubkey33[1],fiat,3); - dragon_rwnum(rwflag,&pubkey33[4],sizeof(*fiatoshisp),(void *)fiatoshisp); - pubkey33[12] = *addrtypep; - memcpy(&pubkey33[13],rmd160,20); - } - else - { - *shortflagp = (pubkey33[0] == 0x03); - memcpy(fiat,&pubkey33[1],3); - fiat[3] = 0; - dragon_rwnum(rwflag,&pubkey33[4],sizeof(*fiatoshisp),(void *)fiatoshisp); - if ( *shortflagp != 0 ) - *fiatoshisp = -(*fiatoshisp); - *addrtypep = pubkey33[12]; - memcpy(rmd160,&pubkey33[13],20); - } return(33); } double PAX_val(uint32_t pval,int32_t baseid) { - //printf("PAX_val baseid.%d pval.%u\n",baseid,pval); - if ( baseid >= 0 && baseid < MAX_CURRENCIES ) - return(((double)pval / 1000000000.) / MINDENOMS[baseid]); return(0.); } @@ -234,64 +34,7 @@ void hush_pvals(int32_t height,uint32_t *pvals,uint8_t numpvals) uint64_t hush_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) { - int32_t i,j,k,ind,zeroes,wt,nonz; int64_t delta; uint64_t lastprice,tolerance,den,densum,sum=0; - for (sum=i=zeroes=nonz=0; i> 2) ) - return(0); - sum /= nonz; - lastprice = sum; - for (i=0; i (numvotes >> 1) ) - break; - } - } - } - } - if ( wt > (numvotes >> 1) ) - { - ind = i; - for (densum=sum=j=0; j= 0 && baseid < 32 ) { - //hush_maxallowed(baseid); if(fDebug) printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,SMART_CHAIN_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); } From b03c8f3108adf837c682cc0ddcf8f36828fc9e65 Mon Sep 17 00:00:00 2001 From: Duke Date: Sat, 17 Jun 2023 21:31:05 -0400 Subject: [PATCH 36/78] Remove unused code --- src/rpc/blockchain.cpp | 71 ----------------------------------- src/rpc/client.cpp | 3 -- src/rpc/server.cpp | 3 -- src/rpc/server.h | 5 --- src/wallet/rpcwallet.cpp | 81 ---------------------------------------- 5 files changed, 163 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 1c34cd1b0..7bdf840da 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1061,79 +1061,8 @@ UniValue notaries(const UniValue& params, bool fHelp, const CPubKey& mypk) } int32_t hush_pending_withdraws(char *opretstr); -int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base); extern char CURRENCIES[][8]; -UniValue paxpending(const UniValue& params, bool fHelp, const CPubKey& mypk) -{ - UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR); char opretbuf[10000*2]; int32_t opretlen,baseid; uint64_t available,deposited,issued,withdrawn,approved,redeemed; - if ( fHelp || params.size() != 0 ) - throw runtime_error("paxpending needs no args\n"); - LOCK(cs_main); - if ( (opretlen= hush_pending_withdraws(opretbuf)) > 0 ) - ret.push_back(Pair("withdraws", opretbuf)); - else ret.push_back(Pair("withdraws", (char *)"")); - for (baseid=0; baseid<32; baseid++) - { - UniValue item(UniValue::VOBJ); UniValue obj(UniValue::VOBJ); - if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,CURRENCIES[baseid]) == 0 ) - { - if ( deposited != 0 || issued != 0 || withdrawn != 0 || approved != 0 || redeemed != 0 ) - { - item.push_back(Pair("available", ValueFromAmount(available))); - item.push_back(Pair("deposited", ValueFromAmount(deposited))); - item.push_back(Pair("issued", ValueFromAmount(issued))); - item.push_back(Pair("withdrawn", ValueFromAmount(withdrawn))); - item.push_back(Pair("approved", ValueFromAmount(approved))); - item.push_back(Pair("redeemed", ValueFromAmount(redeemed))); - obj.push_back(Pair(CURRENCIES[baseid],item)); - a.push_back(obj); - } - } - } - ret.push_back(Pair("fiatstatus", a)); - return ret; -} - -UniValue paxprice(const UniValue& params, bool fHelp, const CPubKey& mypk) -{ - if ( fHelp || params.size() > 4 || params.size() < 2 ) - throw runtime_error("paxprice \"base\" \"rel\" height\n"); - LOCK(cs_main); - UniValue ret(UniValue::VOBJ); uint64_t basevolume=0,relvolume,seed; - std::string base = params[0].get_str(); - std::string rel = params[1].get_str(); - int32_t height; - if ( params.size() == 2 ) - height = chainActive.LastTip()->GetHeight(); - else height = atoi(params[2].get_str().c_str()); - //if ( params.size() == 3 || (basevolume= COIN * atof(params[3].get_str().c_str())) == 0 ) - basevolume = 100000; - relvolume = hush_paxprice(&seed,height,(char *)base.c_str(),(char *)rel.c_str(),basevolume); - ret.push_back(Pair("base", base)); - ret.push_back(Pair("rel", rel)); - ret.push_back(Pair("height", height)); - char seedstr[32]; - sprintf(seedstr,"%llu",(long long)seed); - ret.push_back(Pair("seed", seedstr)); - if ( height < 0 || height > chainActive.Height() ) - throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); - else - { - CBlockIndex *pblockindex = chainActive[height]; - if ( pblockindex != 0 ) - ret.push_back(Pair("timestamp", (int64_t)pblockindex->nTime)); - if ( basevolume != 0 && relvolume != 0 ) - { - ret.push_back(Pair("price",((double)relvolume / (double)basevolume))); - ret.push_back(Pair("invprice",((double)basevolume / (double)relvolume))); - ret.push_back(Pair("basevolume",ValueFromAmount(basevolume))); - ret.push_back(Pair("relvolume",ValueFromAmount(relvolume))); - } else ret.push_back(Pair("error", "overflow or error in one or more of parameters")); - } - return ret; -} - UniValue gettxout(const UniValue& params, bool fHelp, const CPubKey& mypk) { if (fHelp || params.size() < 2 || params.size() > 3) diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 9e9178f25..563864c12 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -154,9 +154,6 @@ static const CRPCConvertParam vRPCConvertParams[] = { "z_shieldcoinbase", 3}, { "z_getoperationstatus", 0}, { "z_getoperationresult", 0}, - { "paxprice", 4 }, - { "paxprices", 3 }, - { "paxpending", 0 }, { "notaries", 2 }, { "minerids", 1 }, { "kvsearch", 1 }, diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index e81ad19e6..703cdc7b9 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -332,9 +332,6 @@ static const CRPCCommand vRPCCommands[] = { "blockchain", "gettxoutsetinfo", &gettxoutsetinfo, true }, { "blockchain", "verifychain", &verifychain, true }, { "blockchain", "getspentinfo", &getspentinfo, false }, - //{ "blockchain", "paxprice", &paxprice, true }, - //{ "blockchain", "paxpending", &paxpending, true }, - //{ "blockchain", "paxprices", &paxprices, true }, { "blockchain", "notaries", ¬aries, true }, //{ "blockchain", "height_MoM", &height_MoM, true }, //{ "blockchain", "txMoMproof", &txMoMproof, true }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 87b46610d..3bfc0654e 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -502,10 +502,5 @@ extern UniValue notaries(const UniValue& params, bool fHelp, const CPubKey& mypk extern UniValue minerids(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue kvsearch(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk); -extern UniValue paxprice(const UniValue& params, bool fHelp, const CPubKey& mypk); -extern UniValue paxpending(const UniValue& params, bool fHelp, const CPubKey& mypk); -extern UniValue paxprices(const UniValue& params, bool fHelp, const CPubKey& mypk); -extern UniValue paxdeposit(const UniValue& params, bool fHelp, const CPubKey& mypk); -extern UniValue paxwithdraw(const UniValue& params, bool fHelp, const CPubKey& mypk); #endif // HUSH_RPCSERVER_H diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 87d8ed64f..db2250a66 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -612,7 +612,6 @@ extern int32_t HUSH_PAX; int32_t hush_is_issuer(); int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); int32_t hush_isrealtime(int32_t *hushheightp); -int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base); int32_t hush_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[DRAGON_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen); int32_t hush_kvcmp(uint8_t *refvalue,uint16_t refvaluesize,uint8_t *value,uint16_t valuesize); uint64_t hush_kvfee(uint32_t flags,int32_t opretlen,int32_t keylen); @@ -763,86 +762,6 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk) return ret; } -UniValue paxdeposit(const UniValue& params, bool fHelp, const CPubKey& mypk) -{ - uint64_t available,deposited,issued,withdrawn,approved,redeemed,seed,puposhis = 0; int32_t height; char destaddr[64]; uint8_t i,pubkey37[33]; - bool fSubtractFeeFromAmount = false; - if ( HUSH_PAX == 0 ) - { - throw runtime_error("paxdeposit disabled without -pax"); - } - if ( hush_is_issuer() != 0 ) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "paxdeposit only from KYC"); - if (!EnsureWalletIsAvailable(fHelp)) - throw runtime_error("paxdeposit needs wallet"); //return Value::null; - if (fHelp || params.size() != 3) - throw runtime_error("paxdeposit address fiatoshis base"); - LOCK2(cs_main, pwalletMain->cs_wallet); - CBitcoinAddress address(params[0].get_str()); - if (!address.IsValid()) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); - int64_t fiatoshis = atof(params[1].get_str().c_str()) * COIN; - std::string base = params[2].get_str(); - std::string dest; - height = chainActive.LastTip()->GetHeight(); - if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis ) - { - fprintf(stderr,"available %llu vs fiatoshis %llu\n",(long long)available,(long long)fiatoshis); - throw runtime_error("paxdeposit not enough available inventory"); - } - puposhis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis); - dest.append(destaddr); - CBitcoinAddress destaddress(CRYPTO555_HUSHADDR); - if (!destaddress.IsValid()) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid dest Bitcoin address"); - for (i=0; i<33; i++) - fprintf(stderr,"%02x",pubkey37[i]); - fprintf(stderr," ht.%d srcaddr.(%s) %s fiatoshis.%lld -> dest.(%s) puposhis.%llu seed.%llx\n",height,(char *)params[0].get_str().c_str(),(char *)base.c_str(),(long long)fiatoshis,destaddr,(long long)puposhis,(long long)seed); - EnsureWalletIsUnlocked(); - CWalletTx wtx; - uint8_t opretbuf[64]; int32_t opretlen; uint64_t fee = puposhis / 1000; - if ( fee < 10000 ) - fee = 10000; - dragon_rwnum(1,&pubkey37[33],sizeof(height),&height); - opretlen = hush_opreturnscript(opretbuf,'D',pubkey37,37); - SendMoney(address.Get(),fee,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,puposhis); - return wtx.GetHash().GetHex(); -} - -UniValue paxwithdraw(const UniValue& params, bool fHelp, const CPubKey& mypk) -{ - CWalletTx wtx; std::string dest; int32_t hushheight; uint64_t seed,puposhis = 0; char destaddr[64]; uint8_t i,pubkey37[37]; bool fSubtractFeeFromAmount = false; - if ( SMART_CHAIN_SYMBOL[0] == 0 ) - return(0); - if (!EnsureWalletIsAvailable(fHelp)) - return 0; - throw runtime_error("paxwithdraw deprecated"); - if (fHelp || params.size() != 2) - throw runtime_error("paxwithdraw address fiatamount"); - if ( hush_isrealtime(&hushheight) == 0 ) - return(0); - LOCK2(cs_main, pwalletMain->cs_wallet); - CBitcoinAddress address(params[0].get_str()); - if (!address.IsValid()) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); - int64_t fiatoshis = atof(params[1].get_str().c_str()) * COIN; - puposhis = PAX_fiatdest(&seed,1,destaddr,pubkey37,(char *)params[0].get_str().c_str(),hushheight,SMART_CHAIN_SYMBOL,fiatoshis); - dest.append(destaddr); - CBitcoinAddress destaddress(CRYPTO555_HUSHADDR); - if (!destaddress.IsValid()) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid dest Bitcoin address"); - for (i=0; i<33; i++) - printf("%02x",pubkey37[i]); - printf(" hushheight.%d srcaddr.(%s) %s fiatoshis.%lld -> dest.(%s) puposhis.%llu seed.%llx\n",hushheight,(char *)params[0].get_str().c_str(),SMART_CHAIN_SYMBOL,(long long)fiatoshis,destaddr,(long long)puposhis,(long long)seed); - EnsureWalletIsUnlocked(); - uint8_t opretbuf[64]; int32_t opretlen; uint64_t fee = fiatoshis / 1000; - if ( fee < 10000 ) - fee = 10000; - dragon_rwnum(1,&pubkey37[33],sizeof(hushheight),&hushheight); - opretlen = hush_opreturnscript(opretbuf,'W',pubkey37,37); - SendMoney(destaddress.Get(),fee,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,fiatoshis); - return wtx.GetHash().GetHex(); -} UniValue listaddressgroupings(const UniValue& params, bool fHelp, const CPubKey& mypk) { From fc69220e78d24e5f275853d5e4e535d50fa45779 Mon Sep 17 00:00:00 2001 From: Duke Date: Sat, 17 Jun 2023 21:38:39 -0400 Subject: [PATCH 37/78] Remove unused code --- src/hush_pax.h | 5 ----- src/wallet/rpcwallet.cpp | 1 - 2 files changed, 6 deletions(-) diff --git a/src/hush_pax.h b/src/hush_pax.h index eba734593..029f6e31f 100644 --- a/src/hush_pax.h +++ b/src/hush_pax.h @@ -32,11 +32,6 @@ void hush_pvals(int32_t height,uint32_t *pvals,uint8_t numpvals) { } -uint64_t hush_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) -{ - return(0); -} - uint64_t hush_paxpriceB(uint64_t seed,int32_t height,char *base,char *rel,uint64_t basevolume) { return 0; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index db2250a66..cdf16c695 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -606,7 +606,6 @@ UniValue sendtoaddress(const UniValue& params, bool fHelp, const CPubKey& mypk) #define HUSH_KVBINARY 2 #define HUSH_KVDURATION 1440 #define DRAGON_MAXSCRIPTSIZE 10001 -uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pubkey37[37],char *coinaddr,int32_t height,char *base,int64_t fiatoshis); int32_t hush_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_t opretlen); extern int32_t HUSH_PAX; int32_t hush_is_issuer(); From 95080951861e7756f7e9fcb58a20cc174deee2e9 Mon Sep 17 00:00:00 2001 From: Duke Date: Thu, 29 Jun 2023 11:48:30 -0400 Subject: [PATCH 38/78] 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 39/78] 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 40/78] 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 41/78] 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 42/78] 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 43/78] 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 44/78] 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 45/78] 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 46/78] 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 47/78] 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 48/78] 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 49/78] 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 50/78] 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 51/78] 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 52/78] 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 53/78] 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 54/78] 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 55/78] 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 56/78] 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 57/78] 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 58/78] 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 59/78] 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 60/78] 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 61/78] 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 62/78] 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 63/78] 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 64/78] 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 65/78] 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 66/78] 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 67/78] 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 68/78] 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 69/78] 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 70/78] 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 71/78] 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 72/78] 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 73/78] 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 74/78] 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 75/78] 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 76/78] 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 77/78] 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 78/78] 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))