From 52240c64b15ccc7995d40184a685ab7ee48c027b Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 14 Nov 2020 20:00:23 -0500 Subject: [PATCH] Tweak test suite and rename to HUSH_INSYNC --- src/Makefile.am | 10 ++++++---- src/Makefile.test-hush.include | 20 ++++++++++---------- src/cc/dice.cpp | 10 +++++----- src/komodo_gateway.h | 4 ++-- src/komodo_globals.h | 2 +- src/main.cpp | 16 ++++++++-------- src/miner.cpp | 2 +- src/rpc/blockchain.cpp | 6 +++--- src/rpc/misc.cpp | 4 ++-- src/test-hush/main.cpp | 8 ++++++-- src/test-hush/testutils.cpp | 2 -- src/wallet/rpcwallet.cpp | 8 ++++---- 12 files changed, 48 insertions(+), 44 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 87bed1375..0bc49fc94 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,6 @@ # Copyright 2019-2020 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 DIST_SUBDIRS = secp256k1 univalue cryptoconditions @@ -251,7 +253,7 @@ obj/build.h: FORCE $(abs_top_srcdir) libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h -# server: zcashd +# server: hushd libbitcoin_server_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS) libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libbitcoin_server_a_SOURCES = \ @@ -398,7 +400,7 @@ crypto_libbitcoin_crypto_a_SOURCES += \ ${EQUIHASH_TROMP_SOURCES} endif -# common: shared between zcashd and non-server tools +# common: shared between hushd and non-server tools libbitcoin_common_a_CPPFLAGS = -fPIC $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) libbitcoin_common_a_CXXFLAGS = -fPIC $(AM_CXXFLAGS) $(PIE_FLAGS) libbitcoin_common_a_SOURCES = \ @@ -607,7 +609,7 @@ komodo_tx_LDADD = \ komodo_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS) -# zcash protocol primitives # +# Zcash Protocol Primitives libzcash_a_SOURCES = \ zcash/IncrementalMerkleTree.cpp \ zcash/NoteEncryption.cpp \ @@ -712,7 +714,7 @@ endif $(AM_V_GEN) $(PROTOC) --cpp_out=$(@D) --proto_path=$(abspath $(= 0) * (height > 1000000)) < 0 ) - // fprintf(stderr, ">>>>>>> FAILED BLOCK.%d notary.%d insync.%d\n",height,notary,KOMODO_INSYNC); + // 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,KOMODO_INSYNC); + // fprintf(stderr, "<<<<<<< VALID BLOCK.%d notary.%d insync.%d\n",height,notary,HUSH_INSYNC); return(-1 * (komodo_electednotary(&num,script+1,height,0) >= 0) * (height > 1000000)); } } diff --git a/src/komodo_globals.h b/src/komodo_globals.h index df24b828d..f07e47498 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -50,7 +50,7 @@ unsigned int WITNESS_CACHE_SIZE = _COINBASE_MATURITY+10; uint256 KOMODO_EARLYTXID; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS,ASSETCHAINS_CBMATURITY,KOMODO_NSPV; -int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; +int32_t HUSH_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB,NOTARY_ADDRESS,ASSETCHAINS_SELFIMPORT,ASSETCHAINS_CCLIB; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_MARMARA; int8_t ASSETCHAINS_ADAPTIVEPOW; diff --git a/src/main.cpp b/src/main.cpp index 6ad8bfe97..67b959cb9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -79,7 +79,7 @@ using namespace std; #define TMPFILE_START 100000000 CCriticalSection cs_main; extern uint8_t NOTARY_PUBKEY33[33]; -extern int32_t KOMODO_LOADINGBLOCKS,KOMODO_LONGESTCHAIN,KOMODO_INSYNC,KOMODO_CONNECTING,KOMODO_EXTRASATOSHI; +extern int32_t KOMODO_LOADINGBLOCKS,KOMODO_LONGESTCHAIN,HUSH_INSYNC,KOMODO_CONNECTING,KOMODO_EXTRASATOSHI; int32_t KOMODO_NEWBLOCKS; int32_t komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block); //void komodo_broadcast(CBlock *pblock,int32_t limit); @@ -2442,7 +2442,7 @@ bool IsInitialBlockDownload() } state = ((chainActive.Height() < ptr->GetHeight() - 24*60) || ptr->GetBlockTime() < (GetTime() - nMaxTipAge)); - if ( KOMODO_INSYNC != 0 ) + if ( HUSH_INSYNC != 0 ) state = false; if (!state) { @@ -4203,10 +4203,10 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * LogPrint("bench", " - Connect postprocess: %.2fms [%.2fs]\n", (nTime6 - nTime5) * 0.001, nTimePostConnect * 0.000001); LogPrint("bench", "- Connect block: %.2fms [%.2fs]\n", (nTime6 - nTime1) * 0.001, nTimeTotal * 0.000001); if ( KOMODO_LONGESTCHAIN != 0 && (pindexNew->GetHeight() == KOMODO_LONGESTCHAIN || pindexNew->GetHeight() == KOMODO_LONGESTCHAIN+1) ) - KOMODO_INSYNC = (int32_t)pindexNew->GetHeight(); - else KOMODO_INSYNC = 0; - //fprintf(stderr,"connect.%d insync.%d ASSETCHAINS_SAPLING.%d\n",(int32_t)pindexNew->GetHeight(),KOMODO_INSYNC,ASSETCHAINS_SAPLING); - /*if ( KOMODO_INSYNC != 0 ) //ASSETCHAINS_SYMBOL[0] == 0 && + HUSH_INSYNC = (int32_t)pindexNew->GetHeight(); + else HUSH_INSYNC = 0; + //fprintf(stderr,"connect.%d insync.%d ASSETCHAINS_SAPLING.%d\n",(int32_t)pindexNew->GetHeight(),HUSH_INSYNC,ASSETCHAINS_SAPLING); + /*if ( HUSH_INSYNC != 0 ) //ASSETCHAINS_SYMBOL[0] == 0 && komodo_broadcast(pblock,8); else if ( ASSETCHAINS_SYMBOL[0] != 0 ) komodo_broadcast(pblock,4);*/ @@ -5471,7 +5471,7 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat *ppindex = pindex; if ( pindex != 0 && (pindex->nStatus & BLOCK_FAILED_MASK) != 0 ) { - if ( ASSETCHAINS_CC == 0 )//&& (ASSETCHAINS_PRIVATE == 0 || KOMODO_INSYNC >= Params().GetConsensus().vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight) ) + if ( ASSETCHAINS_CC == 0 )//&& (ASSETCHAINS_PRIVATE == 0 || HUSH_INSYNC >= Params().GetConsensus().vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight) ) return state.Invalid(error("%s: block is marked invalid", __func__), 0, "duplicate"); else { @@ -7606,7 +7606,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } else if (strCommand == "getnSPV") { - if ( KOMODO_NSPV == 0 )//&& KOMODO_INSYNC != 0 ) + if ( KOMODO_NSPV == 0 )//&& HUSH_INSYNC != 0 ) { std::vector payload; vRecv >> payload; diff --git a/src/miner.cpp b/src/miner.cpp index 5299c01f9..178f658f0 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1019,7 +1019,7 @@ int32_t komodo_baseid(char *origbase); int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t *blocktimes,int32_t *nonzpkeysp,int32_t height); arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc); int32_t FOUND_BLOCK,KOMODO_MAYBEMINED; -extern int32_t KOMODO_LASTMINED,KOMODO_INSYNC; +extern int32_t KOMODO_LASTMINED,HUSH_INSYNC; int32_t roundrobin_delay; arith_uint256 HASHTarget,HASHTarget_POW; diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index aff9373b8..e82fde943 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -50,7 +50,7 @@ using namespace std; -extern int32_t KOMODO_INSYNC; +extern int32_t HUSH_INSYNC; extern bool fZindex; extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry); void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex); @@ -1658,7 +1658,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp, const CPubKey& my UniValue obj(UniValue::VOBJ); obj.push_back(Pair("chain", Params().NetworkIDString())); obj.push_back(Pair("blocks", (int)chainActive.Height())); - obj.push_back(Pair("synced", KOMODO_INSYNC!=0)); + obj.push_back(Pair("synced", HUSH_INSYNC!=0)); obj.push_back(Pair("longestchain", KOMODO_LONGESTCHAIN)); obj.push_back(Pair("notarized", notarized_height)); obj.push_back(Pair("headers", pindexBestHeader ? pindexBestHeader->GetHeight() : -1)); @@ -1887,7 +1887,7 @@ inline CBlockIndex* LookupBlockIndex(const uint256& hash) UniValue getchaintxstats(const UniValue& params, bool fHelp, const CPubKey& mypk) { - THROW_IF_SYNCING(KOMODO_INSYNC); + THROW_IF_SYNCING(HUSH_INSYNC); if (fHelp || params.size() > 2) throw runtime_error( diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 654c0262e..e4442d29b 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -70,7 +70,7 @@ bool komodo_txnotarizedconfirmed(uint256 txid); uint32_t komodo_chainactive_timestamp(); int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; -extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN,IS_STAKED_NOTARY,IS_KOMODO_NOTARY,STAKED_ERA,KOMODO_INSYNC; +extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN,IS_STAKED_NOTARY,IS_KOMODO_NOTARY,STAKED_ERA,HUSH_INSYNC; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t komodo_segid32(char *coinaddr); int64_t komodo_coinsupply(int64_t *zfundsp,int64_t *sproutfundsp,int32_t height); @@ -240,7 +240,7 @@ UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) // this KMD version represents the last time we did a full merge, we only cherry-pick or take nothing // in the post-KYC "era" of KMD obj.push_back(Pair("KMDversion", KOMODO_VERSION)); // never change this again, it's set in stone. -- Duke - obj.push_back(Pair("synced", KOMODO_INSYNC!=0)); + obj.push_back(Pair("synced", HUSH_INSYNC!=0)); // any height larger than this can be attacked! obj.push_back(Pair("notarized", notarized_height)); obj.push_back(Pair("prevMoMheight", prevMoMheight)); diff --git a/src/test-hush/main.cpp b/src/test-hush/main.cpp index bdfdeab3a..d4924a4e6 100644 --- a/src/test-hush/main.cpp +++ b/src/test-hush/main.cpp @@ -6,10 +6,13 @@ #include "chainparams.h" #include "gtest/gtest.h" #include "crypto/common.h" -#include "testutils.h" +//#include "testutils.h" +std::string notaryPubkey = "0205a8ad0c1dbc515f149af377981aab58b836af008d4d7ab21bd76faf80550b47"; +std::string notarySecret = "UxFWWxsf1d7w7K5TvAWSkeX4H95XQKwdwGv49DXwWUTzPTTjHBbU"; int main(int argc, char **argv) { + /* assert(init_and_check_sodium() != -1); ECC_Start(); ECCVerifyHandle handle; // Inits secp256k1 verify context @@ -18,7 +21,8 @@ int main(int argc, char **argv) { CBitcoinSecret vchSecret; // this returns false due to network prefix mismatch but works anyway vchSecret.SetString(notarySecret); - notaryKey = vchSecret.GetKey(); + CKey notaryKey = vchSecret.GetKey(); + */ testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/src/test-hush/testutils.cpp b/src/test-hush/testutils.cpp index 3d4244567..8da6680cf 100644 --- a/src/test-hush/testutils.cpp +++ b/src/test-hush/testutils.cpp @@ -4,7 +4,6 @@ #include #include #include - #include "core_io.h" #include "key.h" #include "main.h" @@ -21,7 +20,6 @@ #include "primitives/transaction.h" #include "script/cc.h" #include "script/interpreter.h" - #include "testutils.h" diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 29f1a15ee..fdd5400cb 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -73,7 +73,7 @@ extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern std::string ASSETCHAINS_OVERRIDE_PUBKEY; const std::string ADDR_TYPE_SAPLING = "sapling"; const std::string ADDR_TYPE_AMNESIA = "amnesia"; -extern int32_t KOMODO_INSYNC; +extern int32_t HUSH_INSYNC; uint32_t komodo_segid32(char *coinaddr); int32_t komodo_dpowconfs(int32_t height,int32_t numconfs); int32_t komodo_isnotaryvout(char *coinaddr,uint32_t tiptime); // from ac_private chains only @@ -4640,7 +4640,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) LOCK2(cs_main, pwalletMain->cs_wallet); - THROW_IF_SYNCING(KOMODO_INSYNC); + THROW_IF_SYNCING(HUSH_INSYNC); // Check that the from address is valid. auto fromaddress = params[0].get_str(); @@ -4962,7 +4962,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& myp LOCK2(cs_main, pwalletMain->cs_wallet); - THROW_IF_SYNCING(KOMODO_INSYNC); + THROW_IF_SYNCING(HUSH_INSYNC); // Validate the from address auto fromaddress = params[0].get_str(); @@ -5218,7 +5218,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp LOCK2(cs_main, pwalletMain->cs_wallet); - THROW_IF_SYNCING(KOMODO_INSYNC); + THROW_IF_SYNCING(HUSH_INSYNC); bool useAnyUTXO = false; bool useAnySapling = false;