From 90f6d123adca067618208cb942c1175f73f41223 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Sun, 26 May 2019 23:43:27 +0800 Subject: [PATCH 1/6] fix build --- src/cc/makecclib | 2 +- src/wallet/db.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/makecclib b/src/cc/makecclib index 5241ea675..e9a015e2f 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -7,7 +7,7 @@ make -f Makefile_rogue rm ../libcc.so cp librogue.so ../libcc.so -#exit 0 +exit 0 echo sudoku/musig/dilithium gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o sudokucc.so cclib.cpp diff --git a/src/wallet/db.h b/src/wallet/db.h index e1ae52909..f23122830 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -34,8 +34,8 @@ #include // If CCLIB fails to compile with this, use the one below. -#include -//#include "../depends/x86_64-unknown-linux-gnu/include/db_cxx.h" +//#include +#include "../depends/x86_64-unknown-linux-gnu/include/db_cxx.h" extern unsigned int nWalletDBUpdated; From 784679fff6564757b761d9af6aedfd5fc1169f6b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 27 May 2019 02:51:11 +0800 Subject: [PATCH 2/6] This kind of works, result comes out as negative number though. --- src/rpc/mining.cpp | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index c95d7b891..8e5de0f53 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -59,6 +59,20 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he * Return average network hashes per second based on the last 'lookup' blocks, * or over the difficulty averaging window if 'lookup' is nonpositive. * If 'height' is nonnegative, compute the estimate at the time when a given block was found. +time =0, lastBlockTime=time_of_last_block, PoWblocks=0 +for x = 1 to 100 +get block info +if PoS then + lastBlockTime = ThisBlockTime + next x +else + PoWblocks += 1 + some var/array about diff + newTime = timeNow - lastBlockTime + totalTime = totalTime + newTime + lastBlockTime = newTime +next x +do math of num PoW blocks over PoW active Time with stored diff info */ int64_t GetNetworkHashPS(int lookup, int height) { CBlockIndex *pb = chainActive.LastTip(); @@ -79,21 +93,36 @@ int64_t GetNetworkHashPS(int lookup, int height) { CBlockIndex *pb0 = pb; int64_t minTime = pb0->GetBlockTime(); + int64_t timeoffset = 0, n=0,i=0; int64_t maxTime = minTime; - for (int i = 0; i < lookup; i++) { + for (i = 0; i < lookup; i++) { pb0 = pb0->pprev; + // if PoW block save block time, and skip the hash. + if ( pb0->segid >= 0 && pb0->segid != -2 ) + { + n++; + // only staking chains should ever set this. + + timeoffset += pb0->GetBlockTime() - pb0->pprev->GetBlockTime(); + //fprintf(stderr, "staking tx.%li segid.%i blocktime.%li\n", n, pb0->segid, (pb0->GetBlockTime() - pb0->pprev->GetBlockTime())); + if ( lookup > pb->GetHeight() ) + break; + lookup++; + continue; + } int64_t time = pb0->GetBlockTime(); minTime = std::min(time, minTime); maxTime = std::max(time, maxTime); } + //fprintf(stderr, "number blocks scanned.%li\n",i ); // In case there's a situation where minTime == maxTime, we don't want a divide by zero exception. if (minTime == maxTime) return 0; arith_uint256 workDiff = pb->chainPower.chainWork - pb0->chainPower.chainWork; - int64_t timeDiff = maxTime - minTime; - + int64_t timeDiff = maxTime - minTime;// - timeoffset; + fprintf(stderr, "timediff.%li timeoffset.%li mintime.%li maxtime.%li\n", timeDiff, timeoffset, minTime, maxTime); return (int64_t)(workDiff.getdouble() / timeDiff); } From 1c6723b9f1428f3e79ed614275a1863d556ee77f Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 27 May 2019 16:22:43 +0800 Subject: [PATCH 3/6] for gcharang --- src/rpc/blockchain.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 76d35ff61..ddb5dab12 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -51,6 +51,7 @@ using namespace std; extern int32_t KOMODO_INSYNC; extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry); void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex); +int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp); #include "komodo_defs.h" #include "komodo_structs.h" @@ -133,6 +134,9 @@ UniValue blockheaderToJSON(const CBlockIndex* blockindex) result.push_back(Pair("error", "null blockhash")); return(result); } + uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height; + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid); + result.push_back(Pair("last_notarized_height", notarized_height)); result.push_back(Pair("hash", blockindex->GetBlockHash().GetHex())); int confirmations = -1; // Only report confirmations if the block is on the main chain @@ -284,6 +288,9 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false) { UniValue result(UniValue::VOBJ); + uint256 notarized_hash,notarized_desttxid; int32_t prevMoMheight,notarized_height; + notarized_height = komodo_notarized_height(&prevMoMheight,¬arized_hash,¬arized_desttxid); + result.push_back(Pair("last_notarized_height", notarized_height)); result.push_back(Pair("hash", block.GetHash().GetHex())); int confirmations = -1; // Only report confirmations if the block is on the main chain From f08a7d2d03f47036f25845931faa2a060cd04a32 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Mon, 27 May 2019 17:58:23 +0800 Subject: [PATCH 4/6] add ENABLE LABS global var to build cclib correctly with start.sh. --- src/cc/makecclib | 5 ++++- src/wallet/db.h | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cc/makecclib b/src/cc/makecclib index e9a015e2f..0d82463c4 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -7,7 +7,10 @@ make -f Makefile_rogue rm ../libcc.so cp librogue.so ../libcc.so -exit 0 +if [ "${LABS_FLAGS}" = "ENABLE_LABS" ] +then + exit +fi echo sudoku/musig/dilithium gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o sudokucc.so cclib.cpp diff --git a/src/wallet/db.h b/src/wallet/db.h index f23122830..3aaf3d34b 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -33,9 +33,11 @@ #include -// If CCLIB fails to compile with this, use the one below. -//#include -#include "../depends/x86_64-unknown-linux-gnu/include/db_cxx.h" +#ifdef BUILD_ROGUE + #include "../depends/x86_64-unknown-linux-gnu/include/db_cxx.h" +#else + #include +#endif extern unsigned int nWalletDBUpdated; From 8c9fc38a928cbd21b9034dd9a12fa07a5cc0ce73 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 30 May 2019 21:19:15 +0800 Subject: [PATCH 5/6] fix --- src/cc/makecclib | 5 ----- src/cc/makerogue | 3 +++ zcutil/build.sh | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/cc/makecclib b/src/cc/makecclib index 0d82463c4..e4816c55c 100755 --- a/src/cc/makecclib +++ b/src/cc/makecclib @@ -7,11 +7,6 @@ make -f Makefile_rogue rm ../libcc.so cp librogue.so ../libcc.so -if [ "${LABS_FLAGS}" = "ENABLE_LABS" ] -then - exit -fi - echo sudoku/musig/dilithium gcc -O3 -std=c++11 -I../secp256k1/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared -c -o sudokucc.so cclib.cpp diff --git a/src/cc/makerogue b/src/cc/makerogue index ff16cbb16..a389ba2dd 100755 --- a/src/cc/makerogue +++ b/src/cc/makerogue @@ -35,3 +35,6 @@ else echo ROGUE BUILD FAILED exit 1 fi + +rm ../libcc.so +cp librogue.so ../libcc.so diff --git a/zcutil/build.sh b/zcutil/build.sh index dc4d027b1..df3dfa234 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -106,7 +106,7 @@ CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure "$HARDENING_ARG" WD=$PWD cd src/cc echo $PWD -./makecclib +./makerogue cd $WD "$MAKE" "$@" V=1 From bc69675fc386b0977df26a57b8d73109cd99a198 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 4 Jun 2019 17:55:34 +0800 Subject: [PATCH 6/6] undo attempt at hs/s for staking chains --- src/rpc/mining.cpp | 38 +++++--------------------------------- 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 8e5de0f53..53a744497 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -59,22 +59,9 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he * Return average network hashes per second based on the last 'lookup' blocks, * or over the difficulty averaging window if 'lookup' is nonpositive. * If 'height' is nonnegative, compute the estimate at the time when a given block was found. -time =0, lastBlockTime=time_of_last_block, PoWblocks=0 -for x = 1 to 100 -get block info -if PoS then - lastBlockTime = ThisBlockTime - next x -else - PoWblocks += 1 - some var/array about diff - newTime = timeNow - lastBlockTime - totalTime = totalTime + newTime - lastBlockTime = newTime -next x -do math of num PoW blocks over PoW active Time with stored diff info */ -int64_t GetNetworkHashPS(int lookup, int height) { +int64_t GetNetworkHashPS(int lookup, int height) +{ CBlockIndex *pb = chainActive.LastTip(); if (height >= 0 && height < chainActive.Height()) @@ -93,36 +80,21 @@ int64_t GetNetworkHashPS(int lookup, int height) { CBlockIndex *pb0 = pb; int64_t minTime = pb0->GetBlockTime(); - int64_t timeoffset = 0, n=0,i=0; int64_t maxTime = minTime; - for (i = 0; i < lookup; i++) { + for (int i = 0; i < lookup; i++) { pb0 = pb0->pprev; - // if PoW block save block time, and skip the hash. - if ( pb0->segid >= 0 && pb0->segid != -2 ) - { - n++; - // only staking chains should ever set this. - - timeoffset += pb0->GetBlockTime() - pb0->pprev->GetBlockTime(); - //fprintf(stderr, "staking tx.%li segid.%i blocktime.%li\n", n, pb0->segid, (pb0->GetBlockTime() - pb0->pprev->GetBlockTime())); - if ( lookup > pb->GetHeight() ) - break; - lookup++; - continue; - } int64_t time = pb0->GetBlockTime(); minTime = std::min(time, minTime); maxTime = std::max(time, maxTime); } - //fprintf(stderr, "number blocks scanned.%li\n",i ); // In case there's a situation where minTime == maxTime, we don't want a divide by zero exception. if (minTime == maxTime) return 0; arith_uint256 workDiff = pb->chainPower.chainWork - pb0->chainPower.chainWork; - int64_t timeDiff = maxTime - minTime;// - timeoffset; - fprintf(stderr, "timediff.%li timeoffset.%li mintime.%li maxtime.%li\n", timeDiff, timeoffset, minTime, maxTime); + int64_t timeDiff = maxTime - minTime; + return (int64_t)(workDiff.getdouble() / timeDiff); }