From 461c10db0eeac01b9abb691e588533aef77c0b63 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 14 Nov 2020 16:32:56 -0500 Subject: [PATCH] DPoW updates --- src/komodo_defs.h | 2 +- src/komodo_notary.h | 47 +++++++++++++++++++----------------------- src/komodo_utils.h | 6 +++--- src/rpc/blockchain.cpp | 2 +- 4 files changed, 26 insertions(+), 31 deletions(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index c372ed3e4..0c9113885 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -461,7 +461,7 @@ extern std::vector vWhiteListAddress; extern std::map mapHeightEvalActivate; void komodo_netevent(std::vector payload); int32_t getacseason(uint32_t timestamp); -int32_t getkmdseason(int32_t height); +int32_t gethushseason(int32_t height); #define IGUANA_MAXSCRIPTSIZE 10001 #define KOMODO_KVDURATION 1440 diff --git a/src/komodo_notary.h b/src/komodo_notary.h index d5591aa29..6e7032848 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -61,7 +61,7 @@ const char *Notaries_genesis[][2] = #define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9" -int32_t getkmdseason(int32_t height) +int32_t gethushseason(int32_t height) { if ( height <= KMD_SEASON_HEIGHTS[0] ) return(1); @@ -90,42 +90,36 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; static uint8_t kmd_pubkeys[NUM_KMD_SEASONS][64][33],didinit[NUM_KMD_SEASONS]; - if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) { timestamp = komodo_heightstamp(height); - else if ( ASSETCHAINS_SYMBOL[0] == 0 ) + } else if ( ASSETCHAINS_SYMBOL[0] == 0 ) { timestamp = 0; + } // If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW. - if ( is_STAKED(ASSETCHAINS_SYMBOL) == 0 ) + int32_t hush_season = 0; + bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; + hush_season = ishush3 ? gethushseason(height) : getacseason(timestamp); + if ( hush_season != 0 ) { - int32_t kmd_season = 0; - bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; - if ( ishush3 ) { - // This is HUSH, use block heights to determine the notary season.. - kmd_season = getkmdseason(height); - } else { - // Use timestamp to detemine notary pubkeys. - kmd_season = getacseason(timestamp); - } - if ( kmd_season != 0 ) + if ( didinit[hush_season-1] == 0 ) { - if ( didinit[kmd_season-1] == 0 ) + for (i=0; i= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP ) htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1; @@ -151,6 +145,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam return(n); printf("error retrieving notaries ht.%d got mask.%llx for n.%d\n",height,(long long)mask,n); return(-1); + */ } int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index ff55c2833..a57df01de 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1790,16 +1790,16 @@ void komodo_args(char *argv0) { // We dont have any chain data yet, so use system clock to guess. // I think on season change should reccomend notaries to use -notary to avoid needing this. - int32_t kmd_season = getacseason(time(NULL)); + int32_t hush_season = getacseason(time(NULL)); for (i=0; i<64; i++) { - if ( strcmp(NOTARY_PUBKEY.c_str(),notaries_elected[kmd_season-1][i][1]) == 0 ) + if ( strcmp(NOTARY_PUBKEY.c_str(),notaries_elected[hush_season-1][i][1]) == 0 ) { IS_KOMODO_NOTARY = 1; KOMODO_MININGTHREADS = 1; mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS); IS_STAKED_NOTARY = -1; - fprintf(stderr,"running as notary.%d %s\n",i,notaries_elected[kmd_season-1][i][0]); + fprintf(stderr,"running as notary.%d %s\n",i,notaries_elected[hush_season-1][i][0]); break; } } diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index e805b3141..aff9373b8 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1439,7 +1439,7 @@ UniValue gettxout(const UniValue& params, bool fHelp, const CPubKey& mypk) " \"hex\" : \"hex\", (string) \n" " \"reqSigs\" : n, (numeric) Number of required signatures\n" " \"type\" : \"pubkeyhash\", (string) The type, eg pubkeyhash\n" - " \"addresses\" : [ (array of string) array of Komodo addresses\n" + " \"addresses\" : [ (array of string) array of Hush addresses\n" " \"hushaddress\" (string) Hush address\n" " ,...\n" " ]\n"