From 63cadcf444b9be1f9c3208469ffdf0283fa240db Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 24 Sep 2018 05:45:38 -1100 Subject: [PATCH 01/49] Help human fix --- src/main.cpp | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f93cab2f5..c6188cf47 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3619,23 +3619,34 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo // our genesis block. In practice this (probably) won't happen because of checks elsewhere. auto reorgLength = pindexOldTip ? pindexOldTip->nHeight - (pindexFork ? pindexFork->nHeight : -1) : 0; static_assert(MAX_REORG_LENGTH > 0, "We must be able to reorg some distance"); - if (reorgLength > MAX_REORG_LENGTH) { - auto msg = strprintf(_( - "A block chain reorganization has been detected that would roll back %d blocks! " - "This is larger than the maximum of %d blocks, and so the node is shutting down for your safety." - ), reorgLength, MAX_REORG_LENGTH) + "\n\n" + - _("Reorganization details") + ":\n" + - "- " + strprintf(_("Current tip: %s, height %d, work %s"), - pindexOldTip->phashBlock->GetHex(), pindexOldTip->nHeight, pindexOldTip->nChainWork.GetHex()) + "\n" + - "- " + strprintf(_("New tip: %s, height %d, work %s"), - pindexMostWork->phashBlock->GetHex(), pindexMostWork->nHeight, pindexMostWork->nChainWork.GetHex()) + "\n" + - "- " + strprintf(_("Fork point: %s %s, height %d"), - ASSETCHAINS_SYMBOL,pindexFork->phashBlock->GetHex(), pindexFork->nHeight) + "\n\n" + - _("Please help, human!"); - LogPrintf("*** %s\n", msg); - uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR); - StartShutdown(); - return false; + if (reorgLength > MAX_REORG_LENGTH) + { + int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); + if ( pindexFork->nHeight < notarizedht ) + { + fprintf(stderr,"pindexFork->nHeight.%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->nHeight,notarizedht); + pindexFork = pindexOldTip; + } + else + { + auto msg = strprintf(_( + "A block chain reorganization has been detected that would roll back %d blocks! " + "This is larger than the maximum of %d blocks, and so the node is shutting down for your safety." + ), reorgLength, MAX_REORG_LENGTH) + "\n\n" + + _("Reorganization details") + ":\n" + + "- " + strprintf(_("Current tip: %s, height %d, work %s"), + pindexOldTip->phashBlock->GetHex(), pindexOldTip->nHeight, pindexOldTip->nChainWork.GetHex()) + "\n" + + "- " + strprintf(_("New tip: %s, height %d, work %s"), + pindexMostWork->phashBlock->GetHex(), pindexMostWork->nHeight, pindexMostWork->nChainWork.GetHex()) + "\n" + + "- " + strprintf(_("Fork point: %s %s, height %d"), + ASSETCHAINS_SYMBOL,pindexFork->phashBlock->GetHex(), pindexFork->nHeight) + "\n\n" + + _("Please help, human!"); + LogPrintf("*** %s\n", msg); + uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR); + StartShutdown(); + return false; + } } // Disconnect active blocks which are no longer in the best chain. From dd74b40db3ec80378a17b71c6e7645dbd01b1fd3 Mon Sep 17 00:00:00 2001 From: SHossain Date: Sun, 30 Sep 2018 20:02:05 +0100 Subject: [PATCH 02/49] Update README.md --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e8ed8c3cb..9585c7f78 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,14 @@ This is the official Komodo sourcecode repository based on https://github.com/jl ## Development Resources - Komodo Website: [https://komodoplatform.com/](https://komodoplatform.com/) -- Komodo Blockexplorer: [https://kmdexplorer.io//](https://https://kmdexplorer.io/) +- Komodo Blockexplorer: [https://kmdexplorer.io//](https://kmdexplorer.io/) +- Komodo Discord: [https://komodoplatform.com/discord](https://komodoplatform.com/discord) - Forum: [https://forum.komodoplatform.com/](https://forum.komodoplatform.com/) - Mail: [info@komodoplatform.com](mailto:info@komodoplatform.com) - Support: [https://support.komodoplatform.com/support/home](https://support.komodoplatform.com/support/home) -- Knowledgebase & How-to: [https://komodoplatform.atlassian.net/wiki/spaces/KPSD/pages](https://komodoplatform.atlassian.net/wiki/spaces/KPSD/pages) -- API references: [http://docs.komodoplatform.com/](http://docs.komodoplatform.com/) -- Blog: [http://blog.komodoplatform.com/](http://blog.komodoplatform.com/) +- Knowledgebase & How-to: [https://support.komodoplatform.com/en/support/solutions](https://support.komodoplatform.com/en/support/solutions) +- API references & Dev Documentation: [https://docs.komodoplatform.com/](https://docs.komodoplatform.com/) +- Blog: [https://blog.komodoplatform.com/](https://blog.komodoplatform.com/) - Whitepaper: [Komodo Whitepaper](https://komodoplatform.com/wp-content/uploads/2018/03/2018-03-12-Komodo-White-Paper-Full.pdf) - Komodo Platform public material: [Komodo Platform public material](https://docs.google.com/document/d/1AbhWrtagu4vYdkl-vsWz-HSNyNvK-W-ZasHCqe7CZy0) From 7d88c013d0487b948c436107d0e34b73a0610596 Mon Sep 17 00:00:00 2001 From: SHossain Date: Mon, 1 Oct 2018 10:51:05 +0100 Subject: [PATCH 03/49] Update README.md --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9585c7f78..92a7014f4 100644 --- a/README.md +++ b/README.md @@ -9,16 +9,16 @@ This is the official Komodo sourcecode repository based on https://github.com/jl ## Development Resources -- Komodo Website: [https://komodoplatform.com/](https://komodoplatform.com/) -- Komodo Blockexplorer: [https://kmdexplorer.io//](https://kmdexplorer.io/) +- Komodo Website: [https://komodoplatform.com](https://komodoplatform.com/) +- Komodo Blockexplorer: [https://kmdexplorer.io](https://kmdexplorer.io/) - Komodo Discord: [https://komodoplatform.com/discord](https://komodoplatform.com/discord) -- Forum: [https://forum.komodoplatform.com/](https://forum.komodoplatform.com/) +- Forum: [https://forum.komodoplatform.com](https://forum.komodoplatform.com/) - Mail: [info@komodoplatform.com](mailto:info@komodoplatform.com) - Support: [https://support.komodoplatform.com/support/home](https://support.komodoplatform.com/support/home) - Knowledgebase & How-to: [https://support.komodoplatform.com/en/support/solutions](https://support.komodoplatform.com/en/support/solutions) -- API references & Dev Documentation: [https://docs.komodoplatform.com/](https://docs.komodoplatform.com/) -- Blog: [https://blog.komodoplatform.com/](https://blog.komodoplatform.com/) -- Whitepaper: [Komodo Whitepaper](https://komodoplatform.com/wp-content/uploads/2018/03/2018-03-12-Komodo-White-Paper-Full.pdf) +- API references & Dev Documentation: [https://docs.komodoplatform.com](https://docs.komodoplatform.com/) +- Blog: [https://blog.komodoplatform.com](https://blog.komodoplatform.com/) +- Whitepaper: [Komodo Whitepaper](https://komodoplatform.com/whitepaper) - Komodo Platform public material: [Komodo Platform public material](https://docs.google.com/document/d/1AbhWrtagu4vYdkl-vsWz-HSNyNvK-W-ZasHCqe7CZy0) ## List of Komodo Platform Technologies From f8ffce7f35e4769a8efc62dce98c97feae76466d Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Thu, 18 Oct 2018 10:11:48 -0700 Subject: [PATCH 04/49] This extracts new concept of dpowconfs (confs vs rawconfs) from fsm branch to master --- src/cryptoconditions/compile | 13 +++++++------ src/komodo.h | 2 +- src/komodo_bitcoind.h | 21 +++++++++------------ src/komodo_globals.h | 2 +- src/komodo_kv.h | 2 +- src/komodo_notary.h | 15 +++++++++++++++ src/komodo_utils.h | 4 ++++ src/rpcblockchain.cpp | 16 ++++++++++++---- src/rpcrawtransaction.cpp | 9 ++++++--- 9 files changed, 56 insertions(+), 28 deletions(-) diff --git a/src/cryptoconditions/compile b/src/cryptoconditions/compile index a85b723c7..99e50524b 100755 --- a/src/cryptoconditions/compile +++ b/src/cryptoconditions/compile @@ -1,9 +1,9 @@ #! /bin/sh # Wrapper for compilers which do not understand '-c -o'. -scriptversion=2012-10-14.11; # UTC +scriptversion=2018-03-07.03; # UTC -# Copyright (C) 1999-2014 Free Software Foundation, Inc. +# Copyright (C) 1999-2018 Free Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify @@ -17,7 +17,7 @@ scriptversion=2012-10-14.11; # UTC # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -255,7 +255,8 @@ EOF echo "compile $scriptversion" exit $? ;; - cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ + icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac @@ -339,9 +340,9 @@ exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: diff --git a/src/komodo.h b/src/komodo.h index b233f2ffa..e303c2bac 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -851,7 +851,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) printf("%02x",scriptPubKey[k]); printf(" scriptPubKey doesnt match any notary vini.%d of %d\n",j,numvins); } - } else printf("cant get scriptPubKey for ht.%d txi.%d vin.%d\n",height,i,j); + } //else printf("cant get scriptPubKey for ht.%d txi.%d vin.%d\n",height,i,j); } numvalid = bitweight(signedmask); if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 13501d2a9..73a49e10c 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -391,7 +391,7 @@ int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heig { if ( (item= jobj(json,(char *)"result")) != 0 ) { - txid_confirmations = jint(item,(char *)"confirmations"); + txid_confirmations = jint(item,(char *)"rawconfirmations"); if ( txid_confirmations > 0 && height > txid_confirmations ) txid_height = height - txid_confirmations; else txid_height = height; @@ -1284,7 +1284,7 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc) { - int32_t oldflag = 0; + int32_t oldflag = 0,dispflag = 0; CBlockIndex *pindex; arith_uint256 easydiff,bnTarget,hashval,sum,ave; bool fNegative,fOverflow; int32_t i,n,m,ht,percPoS,diff,val; *percPoSp = percPoS = 0; if ( height <= 10 || (ASSETCHAINS_STAKED == 100 && height <= 100) ) @@ -1303,23 +1303,23 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he { n++; percPoS++; - if ( ASSETCHAINS_STAKED < 100 ) + if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 ) fprintf(stderr,"0"); } else { - if ( ASSETCHAINS_STAKED < 100 ) + if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 ) fprintf(stderr,"1"); sum += UintToArith256(pindex->GetBlockHash()); m++; } } - if ( ASSETCHAINS_STAKED < 100 && (i % 10) == 9 ) + if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 && (i % 10) == 9 ) fprintf(stderr," %d, ",percPoS); } if ( m+n < 100 ) percPoS = ((percPoS * n) + (goalperc * (100-n))) / 100; - if ( ASSETCHAINS_STAKED < 100 ) + if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 ) fprintf(stderr," -> %d%% percPoS vs goalperc.%d ht.%d\n",percPoS,goalperc,height); *percPoSp = percPoS; if ( m > 0 ) @@ -1332,12 +1332,10 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he percPoS = 1; if ( percPoS < goalperc ) // increase PoW diff -> lower bnTarget { - //if ( oldflag != 0 ) - // bnTarget = (ave * arith_uint256(percPoS * percPoS)) / arith_uint256(goalperc * goalperc * goalperc); if ( oldflag != 0 ) bnTarget = (ave / arith_uint256(goalperc * goalperc * goalperc)) * arith_uint256(percPoS * percPoS); else bnTarget = (ave / arith_uint256(goalperc * goalperc * goalperc * goalperc)) * arith_uint256(percPoS * percPoS); - if ( ASSETCHAINS_STAKED < 100 ) + if ( dispflag != 0 && ASSETCHAINS_STAKED < 100 ) { for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&ave)[i]); @@ -1355,7 +1353,6 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he if ( oldflag != 0 ) { bnTarget = ((ave * arith_uint256(goalperc)) + (easydiff * arith_uint256(percPoS))) / arith_uint256(percPoS + goalperc); - //bnTarget = (bnTarget * arith_uint256(percPoS * percPoS * percPoS)) / arith_uint256(goalperc * goalperc); bnTarget = (bnTarget / arith_uint256(goalperc * goalperc)) * arith_uint256(percPoS * percPoS * percPoS); } else bnTarget = (ave / arith_uint256(goalperc * goalperc)) * arith_uint256(percPoS * percPoS * percPoS); @@ -1367,7 +1364,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he if ( bnTarget < ave ) bnTarget = ave; } - if ( 1 ) + if ( dispflag != 0 ) { for (i=31; i>=24; i--) fprintf(stderr,"%02x",((uint8_t *)&ave)[i]); @@ -1453,7 +1450,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED); if ( bhash < bnTarget ) { - fprintf(stderr,"ht.%d isPoS but meets PoW diff!\n",height); + //fprintf(stderr,"ht.%d isPoS but meets PoW diff!\n",height); isPoS = 0; } } diff --git a/src/komodo_globals.h b/src/komodo_globals.h index f352b5333..a3a4e3cae 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -52,7 +52,7 @@ uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096]; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; -uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT; +uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT,KOMODO_DPOWCONFS = 1; uint32_t ASSETCHAINS_MAGIC = 2387029918; uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; uint64_t ASSETCHAINS_ENDSUBSIDY,ASSETCHAINS_REWARD,ASSETCHAINS_HALVING,ASSETCHAINS_DECAY,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED,ASSETCHAINS_SUPPLY = 10; diff --git a/src/komodo_kv.h b/src/komodo_kv.h index 37e11d06d..834584e44 100644 --- a/src/komodo_kv.h +++ b/src/komodo_kv.h @@ -117,7 +117,7 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) } valueptr = &key[keylen]; fee = komodo_kvfee(flags,opretlen,keylen); - //printf("fee %.8f vs %.8f flags.%d keylen.%d valuesize.%d height.%d (%02x %02x %02x) (%02x %02x %02x)\n",(double)fee/COIN,(double)value/COIN,flags,keylen,valuesize,height,key[0],key[1],key[2],valueptr[0],valueptr[1],valueptr[2]); + //fprintf(stderr,"fee %.8f vs %.8f flags.%d keylen.%d valuesize.%d height.%d (%02x %02x %02x) (%02x %02x %02x)\n",(double)fee/COIN,(double)value/COIN,flags,keylen,valuesize,height,key[0],key[1],key[2],valueptr[0],valueptr[1],valueptr[2]); if ( value >= fee ) { coresize = (int32_t)(sizeof(flags)+sizeof(height)+sizeof(keylen)+sizeof(valuesize)+keylen+valuesize+1); diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 04fd30d5f..8c51c7924 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -452,6 +452,21 @@ int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 * } } +int32_t komodo_dpowconfs(int32_t txheight,int32_t numconfs) +{ + char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; + if ( KOMODO_DPOWCONFS != 0 && txheight > 0 && numconfs > 0 && (sp= komodo_stateptr(symbol,dest)) != 0 ) + { + if ( sp->NOTARIZED_HEIGHT > 0 ) + { + if ( txheight < sp->NOTARIZED_HEIGHT ) + return(numconfs); + else return(1); + } + } + return(numconfs); +} + int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t height,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip) { struct notarized_checkpoint *np = 0; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 75f68d87d..e6f6a044d 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1700,6 +1700,7 @@ void komodo_args(char *argv0) break; } } + int32_t dpowconfs = KOMODO_DPOWCONFS; if ( ASSETCHAINS_SYMBOL[0] != 0 ) { BITCOIND_RPCPORT = GetArg("-rpcport", ASSETCHAINS_RPCPORT); @@ -1709,7 +1710,10 @@ void komodo_args(char *argv0) ASSETCHAINS_HALVING *= 5; fprintf(stderr,"PIRATE halving changed to %d %.1f days\n",(int32_t)ASSETCHAINS_HALVING,(double)ASSETCHAINS_HALVING/1440); } + else if ( strcmp("VRSC",ASSETCHAINS_SYMBOL) == 0 ) + dpowconfs = 0; } else BITCOIND_RPCPORT = GetArg("-rpcport", BaseParams().RPCPort()); + KOMODO_DPOWCONFS = GetArg("-dpowconfs",dpowconfs); } void komodo_nameset(char *symbol,char *dest,char *source) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index e9cf54bb4..815860c7d 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -32,6 +32,7 @@ using namespace std; extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry); void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex); int32_t komodo_longestchain(); +int32_t komodo_dpowconfs(int32_t height,int32_t numconfs); double GetDifficultyINTERNAL(const CBlockIndex* blockindex, bool networkDifficulty) { @@ -117,7 +118,8 @@ UniValue blockheaderToJSON(const CBlockIndex* blockindex) // Only report confirmations if the block is on the main chain if (chainActive.Contains(blockindex)) confirmations = chainActive.Height() - blockindex->nHeight + 1; - result.push_back(Pair("confirmations", confirmations)); + result.push_back(Pair("confirmations", komodo_dpowconfs(blockindex->nHeight,confirmations))); + result.push_back(Pair("rawconfirmations", confirmations)); result.push_back(Pair("height", blockindex->nHeight)); result.push_back(Pair("version", blockindex->nVersion)); result.push_back(Pair("merkleroot", blockindex->hashMerkleRoot.GetHex())); @@ -148,7 +150,8 @@ UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) } else { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block is an orphan"); } - result.push_back(Pair("confirmations", confirmations)); + result.push_back(Pair("confirmations", komodo_dpowconfs(blockindex->nHeight,confirmations))); + result.push_back(Pair("rawconfirmations", confirmations)); result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION))); result.push_back(Pair("height", blockindex->nHeight)); result.push_back(Pair("version", block.nVersion)); @@ -265,7 +268,8 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool tx // Only report confirmations if the block is on the main chain if (chainActive.Contains(blockindex)) confirmations = chainActive.Height() - blockindex->nHeight + 1; - result.push_back(Pair("confirmations", confirmations)); + result.push_back(Pair("confirmations", komodo_dpowconfs(blockindex->nHeight,confirmations))); + result.push_back(Pair("rawconfirmations", confirmations)); result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION))); result.push_back(Pair("height", blockindex->nHeight)); result.push_back(Pair("version", block.nVersion)); @@ -1150,7 +1154,11 @@ UniValue gettxout(const UniValue& params, bool fHelp) ret.push_back(Pair("bestblock", pindex->GetBlockHash().GetHex())); if ((unsigned int)coins.nHeight == MEMPOOL_HEIGHT) ret.push_back(Pair("confirmations", 0)); - else ret.push_back(Pair("confirmations", pindex->nHeight - coins.nHeight + 1)); + else + { + ret.push_back(Pair("confirmations", komodo_dpowconfs(coins.nHeight,pindex->nHeight - coins.nHeight + 1))); + ret.push_back(Pair("rawconfirmations", pindex->nHeight - coins.nHeight + 1)); + } ret.push_back(Pair("value", ValueFromAmount(coins.vout[n].nValue))); uint64_t interest; int32_t txheight; uint32_t locktime; if ( (interest= komodo_accrued_interest(&txheight,&locktime,hash,n,coins.nHeight,coins.vout[n].nValue,(int32_t)pindex->nHeight)) != 0 ) diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index 798b991d7..a870d526c 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -34,6 +34,7 @@ using namespace std; extern char ASSETCHAINS_SYMBOL[]; +int32_t komodo_dpowconfs(int32_t height,int32_t numconfs); void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex) { @@ -230,7 +231,8 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& if (nConfirmations > 0) { entry.push_back(Pair("height", nHeight)); - entry.push_back(Pair("confirmations", nConfirmations)); + entry.push_back(Pair("confirmations", komodo_dpowconfs(nHeight,nConfirmations))); + entry.push_back(Pair("rawconfirmations", nConfirmations)); entry.push_back(Pair("time", nBlockTime)); entry.push_back(Pair("blocktime", nBlockTime)); } else { @@ -290,7 +292,8 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) CBlockIndex* pindex = (*mi).second; if (chainActive.Contains(pindex)) { entry.push_back(Pair("height", pindex->nHeight)); - entry.push_back(Pair("confirmations", 1 + chainActive.Height() - pindex->nHeight)); + entry.push_back(Pair("rawconfirmations", 1 + chainActive.Height() - pindex->nHeight)); + entry.push_back(Pair("confirmations", komodo_dpowconfs(pindex->nHeight,1 + chainActive.Height() - pindex->nHeight))); entry.push_back(Pair("time", pindex->GetBlockTime())); entry.push_back(Pair("blocktime", pindex->GetBlockTime())); } else { @@ -477,7 +480,7 @@ int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid uint256 hashBlock; if ( GetTransaction(txid,tx,hashBlock,false) == 0 ) return(-1); - else if ( n <= tx.vout.size() ) // vout.size() seems off by 1 + else if ( n < tx.vout.size() ) { ptr = (uint8_t *)tx.vout[n].scriptPubKey.data(); m = tx.vout[n].scriptPubKey.size(); From 9bf7b5c1f5f48c054794666201db3411a7341ef2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 19 Oct 2018 06:38:28 -1100 Subject: [PATCH 05/49] Dpowconfs for wallet --- src/wallet/rpcwallet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 386208039..93ec9cf0b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -89,7 +89,8 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry) { //int32_t i,n,txheight; uint32_t locktime; uint64_t interest = 0; int confirms = wtx.GetDepthInMainChain(); - entry.push_back(Pair("confirmations", confirms)); + entry.push_back(Pair("rawconfirmations", confirms)); + entry.push_back(Pair("confirmations", komodo_dpowconfs((int32_t)mapBlockIndex[wtx.hashBlock]->nHeight,confirms))); if (wtx.IsCoinBase()) entry.push_back(Pair("generated", true)); if (confirms > 0) From b4e1a4f87bf9baeb26b9403f1445ec7bd1b30210 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 19 Oct 2018 06:49:32 -1100 Subject: [PATCH 06/49] Fix syntax --- src/wallet/rpcwallet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 93ec9cf0b..20e5eb27e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -47,6 +47,7 @@ extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern UniValue TxJoinSplitToJSON(const CTransaction& tx); extern uint8_t ASSETCHAINS_PRIVATE; uint32_t komodo_segid32(char *coinaddr); +int32_t komodo_dpowconfs(int32_t txheight,int32_t numconfs); int64_t nWalletUnlockTime; static CCriticalSection cs_nWalletUnlockTime; From f776d511492946b075aabcd0417e498b54b72d79 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 24 Oct 2018 04:54:29 -1100 Subject: [PATCH 07/49] Fix gettransaction crash with dpowconfs --- src/cc/dice.cpp | 2 +- src/wallet/rpcwallet.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 4271186da..b0bb8ba49 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -279,7 +279,7 @@ uint64_t DiceCalc(int64_t bet,int64_t odds,int64_t minbet,int64_t maxbet,int64_t break; } } - fprintf(stderr,"modval %d vs %d\n",modval,(int32_t)(10000/(odds+1))); + //fprintf(stderr,"modval %d vs %d\n",modval,(int32_t)(10000/(odds+1))); if ( modval < 10000/(odds+1) ) winnings = bet * (odds+1); } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 20e5eb27e..1a1963852 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -91,16 +91,16 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry) //int32_t i,n,txheight; uint32_t locktime; uint64_t interest = 0; int confirms = wtx.GetDepthInMainChain(); entry.push_back(Pair("rawconfirmations", confirms)); - entry.push_back(Pair("confirmations", komodo_dpowconfs((int32_t)mapBlockIndex[wtx.hashBlock]->nHeight,confirms))); if (wtx.IsCoinBase()) entry.push_back(Pair("generated", true)); if (confirms > 0) { + entry.push_back(Pair("confirmations", komodo_dpowconfs((int32_t)mapBlockIndex[wtx.hashBlock]->nHeight,confirms))); entry.push_back(Pair("blockhash", wtx.hashBlock.GetHex())); entry.push_back(Pair("blockindex", wtx.nIndex)); entry.push_back(Pair("blocktime", mapBlockIndex[wtx.hashBlock]->GetBlockTime())); entry.push_back(Pair("expiryheight", (int64_t)wtx.nExpiryHeight)); - } + } else entry.push_back(Pair("confirmations", confirms)); uint256 hash = wtx.GetHash(); entry.push_back(Pair("txid", hash.GetHex())); UniValue conflicts(UniValue::VARR); From 4b3228fccfa1d4f9777f3ceb486959117f567d91 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 6 Nov 2018 22:55:29 -1100 Subject: [PATCH 08/49] Prevent illegal CC funcid --- src/cc/assets.cpp | 11 ++++++++--- src/cc/dice.cpp | 4 ++++ src/cc/oracles.cpp | 4 ++++ src/cc/rewards.cpp | 4 ++++ src/wallet/rpcwallet.cpp | 3 ++- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 1ddbdc4f8..331959a37 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -249,8 +249,8 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx } fprintf(stderr,"fillbuy validated\n"); break; - case 'e': // selloffer - break; // disable swaps + //case 'e': // selloffer + // break; // disable swaps case 's': // selloffer //vin.0: normal input //vin.1+: valid CC output for sale @@ -322,6 +322,7 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx fprintf(stderr,"fill validated\n"); break; case 'E': // fillexchange + return(false); break; // disable asset swaps //vin.0: normal input //vin.1: unspendable.(vout.0 assetoshis from selloffer) sellTx.vout[0] @@ -371,7 +372,11 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx } fprintf(stderr,"fill validated\n"); break; - } + default: + fprintf(stderr,"illegal assets funcid.(%c)\n",funcid); + return(false); + break; + } return(PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts)); } diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index b0bb8ba49..a86fbea0c 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -605,6 +605,10 @@ bool DiceValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx) else if ( DiceVerifyTimeout(vinTx,timeoutblocks) == 0 ) return eval->Invalid("invalid timeout claim for timeout"); break; + default: + fprintf(stderr,"illegal dice funcid.(%c)\n",funcid); + return(false); + break; } } return(PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts)); diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index c24ad5a8b..5abeada8e 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -649,6 +649,10 @@ bool OraclesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t } return eval->Invalid("unexpected OraclesValidate 'D' tx invalid"); break; + default: + fprintf(stderr,"illegal oracles funcid.(%c)\n",script[1]); + return(false); + break; } } return(PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts)); diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index a70071af9..dd637a342 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -287,6 +287,10 @@ bool RewardsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t return eval->Invalid("unlock tx vout.2 isnt 0"); preventCCvouts = 1; break; + default: + fprintf(stderr,"illegal rewards funcid.(%c)\n",funcid); + return(false); + break; } } return(PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts)); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 1a1963852..fa8d3ec31 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -48,6 +48,7 @@ extern UniValue TxJoinSplitToJSON(const CTransaction& tx); extern uint8_t ASSETCHAINS_PRIVATE; uint32_t komodo_segid32(char *coinaddr); int32_t komodo_dpowconfs(int32_t txheight,int32_t numconfs); +int32_t komodo_isnotaryvout(char *coinaddr); // from ac_private chains only int64_t nWalletUnlockTime; static CCriticalSection cs_nWalletUnlockTime; @@ -3789,7 +3790,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp) throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, unknown address format: ")+address ); } } - else if ( ASSETCHAINS_PRIVATE != 0 ) + else if ( ASSETCHAINS_PRIVATE != 0 && komodo_isnotaryvout((char *)address.c_str()) == 0 ) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "cant use transparent addresses in private chain"); if (setAddress.count(address)) From 1eb57a7d9791101cf584feca0faad741c38a9cbb Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Nov 2018 00:33:16 -1100 Subject: [PATCH 09/49] Eval->error() --- src/cc/assets.cpp | 4 ++-- src/cc/dice.cpp | 2 +- src/cc/oracles.cpp | 2 +- src/cc/rewards.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/assets.cpp b/src/cc/assets.cpp index 331959a37..1892a383f 100644 --- a/src/cc/assets.cpp +++ b/src/cc/assets.cpp @@ -322,7 +322,7 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx fprintf(stderr,"fill validated\n"); break; case 'E': // fillexchange - return(false); + return eval->Invalid("unexpected assets funcid"); break; // disable asset swaps //vin.0: normal input //vin.1: unspendable.(vout.0 assetoshis from selloffer) sellTx.vout[0] @@ -374,7 +374,7 @@ bool AssetsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx break; default: fprintf(stderr,"illegal assets funcid.(%c)\n",funcid); - return(false); + return eval->Invalid("unexpected assets funcid"); break; } return(PreventCC(eval,tx,preventCCvins,numvins,preventCCvouts,numvouts)); diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index a86fbea0c..c83ecf17a 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -607,7 +607,7 @@ bool DiceValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx) break; default: fprintf(stderr,"illegal dice funcid.(%c)\n",funcid); - return(false); + return eval->Invalid("unexpected dice funcid"); break; } } diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index 5abeada8e..168f62313 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -651,7 +651,7 @@ bool OraclesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t break; default: fprintf(stderr,"illegal oracles funcid.(%c)\n",script[1]); - return(false); + return eval->Invalid("unexpected OraclesValidate funcid"); break; } } diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index dd637a342..dc4c3be96 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -289,7 +289,7 @@ bool RewardsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &t break; default: fprintf(stderr,"illegal rewards funcid.(%c)\n",funcid); - return(false); + return eval->Invalid("unexpected rewards funcid"); break; } } From f5e142203e9d62db10a0500752fbfafb7e14ca14 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 13 Nov 2018 09:47:15 -1100 Subject: [PATCH 10/49] KOMODO_EXTRASATOSHI --- src/komodo_globals.h | 2 +- src/komodo_utils.h | 2 ++ src/main.cpp | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index a3a4e3cae..1df5682a2 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -45,7 +45,7 @@ struct komodo_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; -int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1; +int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1,KOMODO_EXTRASATOSHI; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index e6f6a044d..37820e3de 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1714,6 +1714,8 @@ void komodo_args(char *argv0) dpowconfs = 0; } else BITCOIND_RPCPORT = GetArg("-rpcport", BaseParams().RPCPort()); KOMODO_DPOWCONFS = GetArg("-dpowconfs",dpowconfs); + if ( ASSETCHAINS_SYMBOL[0] == 0 || strcmp(ASSETCHAINS_SYMBOL,"SUPERNET") == 0 || strcmp(ASSETCHAINS_SYMBOL,"DEX") == 0 || strcmp(ASSETCHAINS_SYMBOL,"COQUI") == 0 || strcmp(ASSETCHAINS_SYMBOL,"PIRATE") == 0 ) + KOMODO_EXTRASATOSHI = 1; } void komodo_nameset(char *symbol,char *dest,char *source) diff --git a/src/main.cpp b/src/main.cpp index 3df3d39c9..9e5d3fbe9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -56,7 +56,7 @@ using namespace std; CCriticalSection cs_main; extern uint8_t NOTARY_PUBKEY33[33]; -extern int32_t KOMODO_LOADINGBLOCKS,KOMODO_LONGESTCHAIN,KOMODO_INSYNC,KOMODO_CONNECTING; +extern int32_t KOMODO_LOADINGBLOCKS,KOMODO_LONGESTCHAIN,KOMODO_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); @@ -3116,7 +3116,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin else fprintf(stderr,"checktoshis %.8f numvouts %d\n",dstr(checktoshis),(int32_t)block.vtx[0].vout.size()); } } - if ( block.vtx[0].GetValueOut() > blockReward+1 ) + if ( block.vtx[0].GetValueOut() > blockReward+KOMODO_EXTRASATOSHI ) { if ( ASSETCHAINS_SYMBOL[0] != 0 || pindex->nHeight >= KOMODO_NOTARIES_HEIGHT1 || block.vtx[0].vout[0].nValue > blockReward ) { From d1e8c8c8fc68f7338bf7a41df4d5f092d7c02911 Mon Sep 17 00:00:00 2001 From: SHossain Date: Sun, 2 Dec 2018 17:44:05 +0000 Subject: [PATCH 11/49] Update assetchains.old --- src/assetchains.old | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assetchains.old b/src/assetchains.old index 9164ca316..5389e54bd 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -27,7 +27,7 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=BEER -ac_supply=100000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=PIZZA -ac_supply=100000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=NINJA -ac_supply=100000000 -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=OOT -ac_supply=216000000 -addnode=174.138.107.226 & +./komodod -pubkey=$pubkey -ac_name=OOT -ac_supply=216000000 -ac_saplinig=5000000 -addnode=174.138.107.226 & ./komodod -pubkey=$pubkey -ac_name=BNTN -ac_supply=500000000 -addnode=94.130.169.205 & ./komodod -pubkey=$pubkey -ac_name=CHAIN -ac_supply=999999 -addnode=78.47.146.222 & ./komodod -pubkey=$pubkey -ac_name=PRLPAY -ac_supply=500000000 -addnode=13.250.226.125 & From 6bd19b0835c42ebec129f5388aa852d79b49909e Mon Sep 17 00:00:00 2001 From: SHossain Date: Sun, 2 Dec 2018 17:47:13 +0000 Subject: [PATCH 12/49] added `-ac_saplinig=5000000` for OOT added `-ac_saplinig=5000000` for OOT --- src/assetchains.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/assetchains.json b/src/assetchains.json index 287a88c19..7bc6b7147 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -94,7 +94,8 @@ }, { "ac_name": "OOT", - "ac_supply": "216000000" + "ac_supply": "216000000", + "ac_sapling": "5000000" }, { "ac_name": "BNTN", From a9935f76579bdfcd355307bd32b64209ff6f4a00 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 6 Dec 2018 04:53:01 -1100 Subject: [PATCH 13/49] Fix inconsistent CC data --- src/cc/CCtx.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index b683a7f51..35cce315e 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -96,8 +96,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran } if ( opret.size() > 0 ) mtx.vout.push_back(CTxOut(0,opret)); - PrecomputedTransactionData txdata(mtx); - n = mtx.vin.size(); + n = mtx.vin.size(); //Reorder vins so that for multiple normal vins all other except vin0 goes to the end //This is a must to avoid hardfork change of validation in every CC, because there could be maximum one normal vin at the begining with current validation. if (normalvins>1) @@ -108,6 +107,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran mtx.vin.erase(mtx.vin.begin() + 1); } } + PrecomputedTransactionData txdata(mtx); for (i=0; i Date: Thu, 6 Dec 2018 17:30:17 +0100 Subject: [PATCH 14/49] Fix reorder of vins in FinalizeCCTx --- src/cc/CCtx.cpp | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 35cce315e..9315faa9a 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -62,8 +62,26 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran GetCCaddress(cp,myaddr,mypk); mycond = MakeCCcond1(cp->evalcode,mypk); GetCCaddress(cp,unspendable,unspendablepk); - othercond = MakeCCcond1(cp->evalcode,unspendablepk); - //fprintf(stderr,"myCCaddr.(%s) %p vs unspendable.(%s) %p\n",myaddr,mycond,unspendable,othercond); + othercond = MakeCCcond1(cp->evalcode,unspendablepk); + //Reorder vins so that for multiple normal vins all other except vin0 goes to the end + //This is a must to avoid hardfork change of validation in every CC, because there could be maximum one normal vin at the begining with current validation. + for (i=0; i1 && ccvins) + { + for(i=1;i 0 ) mtx.vout.push_back(CTxOut(0,opret)); - n = mtx.vin.size(); - //Reorder vins so that for multiple normal vins all other except vin0 goes to the end - //This is a must to avoid hardfork change of validation in every CC, because there could be maximum one normal vin at the begining with current validation. - if (normalvins>1) - { - for(i=1;i Date: Fri, 7 Dec 2018 13:41:45 +0100 Subject: [PATCH 15/49] Fix hanging of oracles --- src/cc/CCtx.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 9315faa9a..27d796ba0 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -69,8 +69,8 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran { if ( GetTransaction(mtx.vin[i].prevout.hash,vintx,hashBlock,false) != 0 ) { - if ( vintx.vout[utxovout].scriptPubKey.IsPayToCryptoCondition() == 0 ) - if (ccvins==0) normalvins++; + if ( vintx.vout[mtx.vin[i].prevout.n].scriptPubKey.IsPayToCryptoCondition() == 0 && ccvins==0) + normalvins++; else ccvins++; } } From ba6f37bb65dc5473cc4edbf9c5c539fc76a3ef0a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 8 Dec 2018 00:57:32 -1100 Subject: [PATCH 16/49] Synchronize version number with agama 0.3.0 --- src/rpc/misc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index e0bbe86c3..03649b8b1 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -56,7 +56,7 @@ extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t komodo_segid32(char *coinaddr); int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height); int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp); -#define KOMODO_VERSION "0.3.2" +#define KOMODO_VERSION "0.3.0" #define VERUS_VERSION "0.4.0g" extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint32_t ASSETCHAINS_CC; From 54431fd74ae77d94af8f8edf6d6994d66d81eae2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 8 Dec 2018 01:33:23 -1100 Subject: [PATCH 17/49] Prevent height -> nLockTime --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 13cd2efd5..be4c8b5a6 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3615,7 +3615,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt if (!NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { max_tx_size = MAX_TX_SIZE_BEFORE_SAPLING; } - +/* // Discourage fee sniping. // // However because of a off-by-one-error in previous versions we need to @@ -3636,7 +3636,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt txNew.nLockTime = std::max(0, (int)txNew.nLockTime - GetRandInt(100)); assert(txNew.nLockTime <= (unsigned int)chainActive.Height()); - assert(txNew.nLockTime < LOCKTIME_THRESHOLD); + assert(txNew.nLockTime < LOCKTIME_THRESHOLD);*/ { LOCK2(cs_main, cs_wallet); From 5ea3f23ac938061dc1fed9cc87a6e2d772dd85d7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 9 Dec 2018 08:41:08 -1100 Subject: [PATCH 18/49] Update three --- src/main.cpp | 2 +- src/rpc/rawtransaction.cpp | 2 +- src/wallet/wallet.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 6c33feb08..5c4d65f00 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1980,7 +1980,7 @@ bool myAddtomempool(CTransaction &tx, CValidationState *pstate) pstate = &state; CTransaction Ltx; bool fMissingInputs,fOverrideFees = false; if ( mempool.lookup(tx.GetHash(),Ltx) == 0 ) - return(AcceptToMemoryPool(mempool, *pstate, tx, false, &fMissingInputs, !fOverrideFees)); + return(AcceptToMemoryPool(mempool, *pstate, tx, true, &fMissingInputs, !fOverrideFees)); else return(true); } diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index e6d356f90..1cb913ad1 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -1274,7 +1274,7 @@ UniValue sendrawtransaction(const UniValue& params, bool fHelp) // push to local node and sync with wallets CValidationState state; bool fMissingInputs; - if (!AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, !fOverrideFees)) { + if (!AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs, !fOverrideFees)) { if (state.IsInvalid()) { throw JSONRPCError(RPC_TRANSACTION_REJECTED, strprintf("%i: %s", state.GetRejectCode(), state.GetRejectReason())); } else { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index c5cfedda8..4ec4dd377 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -46,7 +46,7 @@ extern bool fSendFreeTransactions; extern bool fPayAtLeastCustomFee; //! -paytxfee default -static const CAmount DEFAULT_TRANSACTION_FEE = 0; +static const CAmount DEFAULT_TRANSACTION_FEE = 10000; //! -paytxfee will warn if called with a higher fee than this amount (in satoshis) per KB static const CAmount nHighTransactionFeeWarning = 0.01 * COIN; //! -maxtxfee default From 01a684cd9592674535bd9a29b162d9d1261a09a5 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Sun, 9 Dec 2018 23:23:42 +0300 Subject: [PATCH 19/49] genproclimit fix by default when we start komodod only with -gen arg genproclimit automatically become -1. this behaviour derived from VRSC after last merge (as i remember, vrsc has -1 by default, 0 - for staking, and >= 1 - for mining and staking), so we need to set genproclimit=1 if we pass gen and want to actually start mining. --- src/assetchains | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assetchains b/src/assetchains index 57e705d5c..ce6c3aac2 100755 --- a/src/assetchains +++ b/src/assetchains @@ -11,7 +11,7 @@ if [ -z "$delay" ]; then delay=20; fi ./listassetchainparams | while read args; do gen="" if [ $[RANDOM % 10] == 1 ]; then - gen=" -gen" + gen=" -gen -genproclimit=1" fi ./komodod $gen $args $overide_args -pubkey=$pubkey -addnode=$seed_ip & From a2ea9de06f90c88c0cc0e9c68f018a03eb0df9fb Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 10 Dec 2018 05:45:59 -1100 Subject: [PATCH 20/49] Revert txfee changes --- src/main.cpp | 2 +- src/rpc/rawtransaction.cpp | 2 +- src/wallet/wallet.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 5c4d65f00..6c33feb08 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1980,7 +1980,7 @@ bool myAddtomempool(CTransaction &tx, CValidationState *pstate) pstate = &state; CTransaction Ltx; bool fMissingInputs,fOverrideFees = false; if ( mempool.lookup(tx.GetHash(),Ltx) == 0 ) - return(AcceptToMemoryPool(mempool, *pstate, tx, true, &fMissingInputs, !fOverrideFees)); + return(AcceptToMemoryPool(mempool, *pstate, tx, false, &fMissingInputs, !fOverrideFees)); else return(true); } diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 1cb913ad1..e6d356f90 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -1274,7 +1274,7 @@ UniValue sendrawtransaction(const UniValue& params, bool fHelp) // push to local node and sync with wallets CValidationState state; bool fMissingInputs; - if (!AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs, !fOverrideFees)) { + if (!AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, !fOverrideFees)) { if (state.IsInvalid()) { throw JSONRPCError(RPC_TRANSACTION_REJECTED, strprintf("%i: %s", state.GetRejectCode(), state.GetRejectReason())); } else { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 4ec4dd377..c5cfedda8 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -46,7 +46,7 @@ extern bool fSendFreeTransactions; extern bool fPayAtLeastCustomFee; //! -paytxfee default -static const CAmount DEFAULT_TRANSACTION_FEE = 10000; +static const CAmount DEFAULT_TRANSACTION_FEE = 0; //! -paytxfee will warn if called with a higher fee than this amount (in satoshis) per KB static const CAmount nHighTransactionFeeWarning = 0.01 * COIN; //! -maxtxfee default From 27606f3e0ba1cfae50321e2701716c4fd331cc40 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 10 Dec 2018 09:44:50 -1100 Subject: [PATCH 21/49] Fix typow == 0 --- src/rpc/rawtransaction.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index e6d356f90..21a6e26cd 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -1167,12 +1167,12 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp) if ( txConst.IsCoinBase() != 0 ) { if ( (txpow & 2) == 0 ) - txpow == 0; + txpow = 0; } else { if ( (txpow & 1) == 0 ) - txpow == 0; + txpow = 0; } } while ( 1 ) From fcb709c5e80e5e42047894abd7be42e752a7feea Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 10 Dec 2018 09:56:26 -1100 Subject: [PATCH 22/49] +print --- src/wallet/rpcwallet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 1f4c2c59b..3eeed58a4 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1665,6 +1665,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe BOOST_FOREACH(const COutputEntry& r, listReceived) { string account; + fprintf(stderr,"recv iter %s\n",wtx.GetHash().GetHex()); if (pwalletMain->mapAddressBook.count(r.destination)) account = pwalletMain->mapAddressBook[r.destination].name; if (fAllAccounts || (account == strAccount)) From 80198244d4701a3be42876f8475e7a36a463cd48 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 10 Dec 2018 10:18:42 -1100 Subject: [PATCH 23/49] New prints --- src/wallet/rpcwallet.cpp | 2 +- src/wallet/wallet.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 3eeed58a4..cbda7ea20 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1665,7 +1665,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe BOOST_FOREACH(const COutputEntry& r, listReceived) { string account; - fprintf(stderr,"recv iter %s\n",wtx.GetHash().GetHex()); + //fprintf(stderr,"recv iter %s\n",wtx.GetHash().GetHex()); if (pwalletMain->mapAddressBook.count(r.destination)) account = pwalletMain->mapAddressBook[r.destination].name; if (fAllAccounts || (account == strAccount)) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index be4c8b5a6..d98c0ff78 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1304,6 +1304,7 @@ CWallet::TxItems CWallet::OrderedTxItems(std::list& acentries, { CWalletTx* wtx = &((*it).second); txOrdered.insert(make_pair(wtx->nOrderPos, TxPair(wtx, (CAccountingEntry*)0))); + fprintf(stderr,"ordered iter %s\n",wtx.GetHash().GetHex()); } acentries.clear(); walletdb.ListAccountCreditDebit(strAccount, acentries); From fe0671145e6d6c7925a698ce7fefd40571cfdbdf Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 10 Dec 2018 10:19:12 -1100 Subject: [PATCH 24/49] Fix --- 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 d98c0ff78..ae072d503 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1304,7 +1304,7 @@ CWallet::TxItems CWallet::OrderedTxItems(std::list& acentries, { CWalletTx* wtx = &((*it).second); txOrdered.insert(make_pair(wtx->nOrderPos, TxPair(wtx, (CAccountingEntry*)0))); - fprintf(stderr,"ordered iter %s\n",wtx.GetHash().GetHex()); + fprintf(stderr,"ordered iter %s\n",wtx.GetHash().GetHex().ToString()); } acentries.clear(); walletdb.ListAccountCreditDebit(strAccount, acentries); From 755e64a9af9980caeeeb63238224395577d36a0a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 10 Dec 2018 10:25:07 -1100 Subject: [PATCH 25/49] -> --- 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 ae072d503..aa0ed6a57 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1304,7 +1304,7 @@ CWallet::TxItems CWallet::OrderedTxItems(std::list& acentries, { CWalletTx* wtx = &((*it).second); txOrdered.insert(make_pair(wtx->nOrderPos, TxPair(wtx, (CAccountingEntry*)0))); - fprintf(stderr,"ordered iter %s\n",wtx.GetHash().GetHex().ToString()); + fprintf(stderr,"ordered iter %s\n",wtx->GetHash().GetHex().ToString()); } acentries.clear(); walletdb.ListAccountCreditDebit(strAccount, acentries); From 7c8828545253368b6cae0dcc0073c902f9e4ba97 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 10 Dec 2018 10:26:19 -1100 Subject: [PATCH 26/49] Fix --- 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 aa0ed6a57..3b57744af 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1304,7 +1304,7 @@ CWallet::TxItems CWallet::OrderedTxItems(std::list& acentries, { CWalletTx* wtx = &((*it).second); txOrdered.insert(make_pair(wtx->nOrderPos, TxPair(wtx, (CAccountingEntry*)0))); - fprintf(stderr,"ordered iter %s\n",wtx->GetHash().GetHex().ToString()); + fprintf(stderr,"ordered iter %s\n",wtx->GetHash().GetHex().c_str()); } acentries.clear(); walletdb.ListAccountCreditDebit(strAccount, acentries); From 2b66bcf2479b971b5eb907b1a5be6f7ce2663407 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 10 Dec 2018 10:37:13 -1100 Subject: [PATCH 27/49] Move prints --- src/wallet/rpcwallet.cpp | 3 ++- src/wallet/wallet.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index cbda7ea20..335682b60 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1665,7 +1665,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe BOOST_FOREACH(const COutputEntry& r, listReceived) { string account; - //fprintf(stderr,"recv iter %s\n",wtx.GetHash().GetHex()); + fprintf(stderr,"recv iter %s\n",wtx.GetHash().GetHex().c_str()); if (pwalletMain->mapAddressBook.count(r.destination)) account = pwalletMain->mapAddressBook[r.destination].name; if (fAllAccounts || (account == strAccount)) @@ -1817,6 +1817,7 @@ UniValue listtransactions(const UniValue& params, bool fHelp) CWalletTx *const pwtx = (*it).second.first; if (pwtx != 0) ListTransactions(*pwtx, strAccount, 0, true, ret, filter); + else fprintf(stderr,"null pwtx\n"); CAccountingEntry *const pacentry = (*it).second.second; if (pacentry != 0) AcentryToJSON(*pacentry, strAccount, ret); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 3b57744af..9097740c9 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1304,7 +1304,7 @@ CWallet::TxItems CWallet::OrderedTxItems(std::list& acentries, { CWalletTx* wtx = &((*it).second); txOrdered.insert(make_pair(wtx->nOrderPos, TxPair(wtx, (CAccountingEntry*)0))); - fprintf(stderr,"ordered iter %s\n",wtx->GetHash().GetHex().c_str()); + //fprintf(stderr,"ordered iter %s\n",wtx->GetHash().GetHex().c_str()); } acentries.clear(); walletdb.ListAccountCreditDebit(strAccount, acentries); From 7883afa7fec29ff964d73d8451fc8723750f4f33 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 10 Dec 2018 10:43:21 -1100 Subject: [PATCH 28/49] Print orderpos --- 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 9097740c9..82b52b901 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1304,7 +1304,7 @@ CWallet::TxItems CWallet::OrderedTxItems(std::list& acentries, { CWalletTx* wtx = &((*it).second); txOrdered.insert(make_pair(wtx->nOrderPos, TxPair(wtx, (CAccountingEntry*)0))); - //fprintf(stderr,"ordered iter %s\n",wtx->GetHash().GetHex().c_str()); + fprintf(stderr,"ordered iter.%d %s\n",(int32_t)wtx->nOrderPos,wtx->GetHash().GetHex().c_str()); } acentries.clear(); walletdb.ListAccountCreditDebit(strAccount, acentries); From 181d6b33f37ce4453d0f32aa870f705d61632499 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 10 Dec 2018 11:35:11 -1100 Subject: [PATCH 29/49] +prints --- src/wallet/rpcwallet.cpp | 2 +- src/wallet/wallet.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 335682b60..e52a2503b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1817,7 +1817,7 @@ UniValue listtransactions(const UniValue& params, bool fHelp) CWalletTx *const pwtx = (*it).second.first; if (pwtx != 0) ListTransactions(*pwtx, strAccount, 0, true, ret, filter); - else fprintf(stderr,"null pwtx\n"); + //else fprintf(stderr,"null pwtx\n"); CAccountingEntry *const pacentry = (*it).second.second; if (pacentry != 0) AcentryToJSON(*pacentry, strAccount, ret); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 82b52b901..b5d5b01af 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2533,11 +2533,16 @@ void CWalletTx::GetAmounts(list& listReceived, { // Don't report 'change' txouts if (!(filter & ISMINE_CHANGE) && pwallet->IsChange(txout)) + { + fprintf(stderr,"skip change vout\n"); continue; + } } else if (!(fIsMine & filter)) + { + fprintf(stderr,"skip filtered vout %d %d\n",(int32_t)fIsMine,(int32_t)filter); continue; - + } // In either case, we need to get the destination address CTxDestination address; if (!ExtractDestination(txout.scriptPubKey, address)) @@ -2551,10 +2556,12 @@ void CWalletTx::GetAmounts(list& listReceived, // If we are debited by the transaction, add the output as a "sent" entry if (nDebit > 0) listSent.push_back(output); + else fprintf(stderr,"not sent vout %d %d\n",(int32_t)fIsMine,(int32_t)filter); // If we are receiving the output, add it as a "received" entry if (fIsMine & filter) listReceived.push_back(output); + else fprintf(stderr,"not received vout %d %d\n",(int32_t)fIsMine,(int32_t)filter); } } From 0615c21df0bbcc4f72ac4eff741965001e37287e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 10 Dec 2018 11:38:07 -1100 Subject: [PATCH 30/49] +print --- src/wallet/rpcwallet.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e52a2503b..f94f07199 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1816,7 +1816,10 @@ UniValue listtransactions(const UniValue& params, bool fHelp) { CWalletTx *const pwtx = (*it).second.first; if (pwtx != 0) + { + fprintf(stderr,"pwtx iter %s\n",pwtx->GetHash().GetHex().c_str()); ListTransactions(*pwtx, strAccount, 0, true, ret, filter); + } //else fprintf(stderr,"null pwtx\n"); CAccountingEntry *const pacentry = (*it).second.second; if (pacentry != 0) From 5f162b1a9de3ada4a000005d04dfc30bd37eefda Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 10 Dec 2018 11:39:51 -1100 Subject: [PATCH 31/49] +print --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f94f07199..52e92ceb9 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1817,7 +1817,7 @@ UniValue listtransactions(const UniValue& params, bool fHelp) CWalletTx *const pwtx = (*it).second.first; if (pwtx != 0) { - fprintf(stderr,"pwtx iter %s\n",pwtx->GetHash().GetHex().c_str()); + fprintf(stderr,"pwtx iter.%d %s\n",(int32_t)pwtx->nOrderPos,pwtx->GetHash().GetHex().c_str()); ListTransactions(*pwtx, strAccount, 0, true, ret, filter); } //else fprintf(stderr,"null pwtx\n"); From 3b4ee13f944392492c22bc1ebc061224b278a83d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 10 Dec 2018 11:46:51 -1100 Subject: [PATCH 32/49] Allow one change out in list transactions --- src/wallet/wallet.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index b5d5b01af..b72ee14f3 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1304,7 +1304,7 @@ CWallet::TxItems CWallet::OrderedTxItems(std::list& acentries, { CWalletTx* wtx = &((*it).second); txOrdered.insert(make_pair(wtx->nOrderPos, TxPair(wtx, (CAccountingEntry*)0))); - fprintf(stderr,"ordered iter.%d %s\n",(int32_t)wtx->nOrderPos,wtx->GetHash().GetHex().c_str()); + //fprintf(stderr,"ordered iter.%d %s\n",(int32_t)wtx->nOrderPos,wtx->GetHash().GetHex().c_str()); } acentries.clear(); walletdb.ListAccountCreditDebit(strAccount, acentries); @@ -2522,6 +2522,7 @@ void CWalletTx::GetAmounts(list& listReceived, } // Sent/received. + int32_t oneshot = 0; for (unsigned int i = 0; i < vout.size(); ++i) { const CTxOut& txout = vout[i]; @@ -2534,8 +2535,11 @@ void CWalletTx::GetAmounts(list& listReceived, // Don't report 'change' txouts if (!(filter & ISMINE_CHANGE) && pwallet->IsChange(txout)) { - fprintf(stderr,"skip change vout\n"); - continue; + if ( oneshot++ > 1 ) + { + fprintf(stderr,"skip change vout\n"); + continue; + } } } else if (!(fIsMine & filter)) From 80be59463871910ff88c1449855a254196a56244 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 10 Dec 2018 11:47:18 -1100 Subject: [PATCH 33/49] -print --- src/wallet/wallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index b72ee14f3..b8587a943 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2560,12 +2560,12 @@ void CWalletTx::GetAmounts(list& listReceived, // If we are debited by the transaction, add the output as a "sent" entry if (nDebit > 0) listSent.push_back(output); - else fprintf(stderr,"not sent vout %d %d\n",(int32_t)fIsMine,(int32_t)filter); + //else fprintf(stderr,"not sent vout %d %d\n",(int32_t)fIsMine,(int32_t)filter); // If we are receiving the output, add it as a "received" entry if (fIsMine & filter) listReceived.push_back(output); - else fprintf(stderr,"not received vout %d %d\n",(int32_t)fIsMine,(int32_t)filter); + //else fprintf(stderr,"not received vout %d %d\n",(int32_t)fIsMine,(int32_t)filter); } } From 9742bb74db0fb99de068fe1f99f5ab4ad0deba7f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 10 Dec 2018 11:48:48 -1100 Subject: [PATCH 34/49] -prints --- src/wallet/rpcwallet.cpp | 4 ++-- src/wallet/wallet.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 52e92ceb9..fc8269008 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1665,7 +1665,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe BOOST_FOREACH(const COutputEntry& r, listReceived) { string account; - fprintf(stderr,"recv iter %s\n",wtx.GetHash().GetHex().c_str()); + //fprintf(stderr,"recv iter %s\n",wtx.GetHash().GetHex().c_str()); if (pwalletMain->mapAddressBook.count(r.destination)) account = pwalletMain->mapAddressBook[r.destination].name; if (fAllAccounts || (account == strAccount)) @@ -1817,7 +1817,7 @@ UniValue listtransactions(const UniValue& params, bool fHelp) CWalletTx *const pwtx = (*it).second.first; if (pwtx != 0) { - fprintf(stderr,"pwtx iter.%d %s\n",(int32_t)pwtx->nOrderPos,pwtx->GetHash().GetHex().c_str()); + //fprintf(stderr,"pwtx iter.%d %s\n",(int32_t)pwtx->nOrderPos,pwtx->GetHash().GetHex().c_str()); ListTransactions(*pwtx, strAccount, 0, true, ret, filter); } //else fprintf(stderr,"null pwtx\n"); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index b8587a943..3857f7090 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2537,14 +2537,14 @@ void CWalletTx::GetAmounts(list& listReceived, { if ( oneshot++ > 1 ) { - fprintf(stderr,"skip change vout\n"); + //fprintf(stderr,"skip change vout\n"); continue; } } } else if (!(fIsMine & filter)) { - fprintf(stderr,"skip filtered vout %d %d\n",(int32_t)fIsMine,(int32_t)filter); + //fprintf(stderr,"skip filtered vout %d %d\n",(int32_t)fIsMine,(int32_t)filter); continue; } // In either case, we need to get the destination address From 3958b39ead8f32d58534494b3290b759f503c371 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 10 Dec 2018 11:53:34 -1100 Subject: [PATCH 35/49] Fix rewards claim txid not appearing in list transactions --- src/wallet/rpcwallet.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index fc8269008..c34466a39 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1819,8 +1819,7 @@ UniValue listtransactions(const UniValue& params, bool fHelp) { //fprintf(stderr,"pwtx iter.%d %s\n",(int32_t)pwtx->nOrderPos,pwtx->GetHash().GetHex().c_str()); ListTransactions(*pwtx, strAccount, 0, true, ret, filter); - } - //else fprintf(stderr,"null pwtx\n"); + } //else fprintf(stderr,"null pwtx\n"); CAccountingEntry *const pacentry = (*it).second.second; if (pacentry != 0) AcentryToJSON(*pacentry, strAccount, ret); From 5215b63f6a5d8e33a812afd6c4ab7e4ea62826a7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 10 Dec 2018 12:19:17 -1100 Subject: [PATCH 36/49] 0.3.1 --- src/rpc/misc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 03649b8b1..26c273236 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -56,7 +56,7 @@ extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t komodo_segid32(char *coinaddr); int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height); int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp); -#define KOMODO_VERSION "0.3.0" +#define KOMODO_VERSION "0.3.1" #define VERUS_VERSION "0.4.0g" extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; extern uint32_t ASSETCHAINS_CC; From ab6374c07942a97c6cb17986216c36c1749168c2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 12 Dec 2018 06:09:59 -1100 Subject: [PATCH 37/49] Restore mempool, instead of adding back --- src/main.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 6c33feb08..bc8455279 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -103,7 +103,6 @@ unsigned int expiryDelta = DEFAULT_TX_EXPIRY_DELTA; CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE); CTxMemPool mempool(::minRelayTxFee); -CTxMemPool tmpmempool(::minRelayTxFee); struct COrphanTx { CTransaction tx; @@ -4675,12 +4674,15 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C // Check transactions CTransaction sTx; CTransaction *ptx = NULL; + CTxMemPool savedmempool(::minRelayTxFee); if ( ASSETCHAINS_CC != 0 ) // CC contracts might refer to transactions in the current block, from a CC spend within the same block and out of order { int32_t i,j,rejects=0,lastrejects=0; //fprintf(stderr,"put block's tx into mempool\n"); // Copy all non Z-txs in mempool to temporary mempool because there can be tx in local mempool that make the block invalid. LOCK(mempool.cs); + CTxMemPool tmpmempool(::minRelayTxFee); + savedmempool = mempool; list transactionsToRemove; BOOST_FOREACH(const CTxMemPoolEntry& e, mempool.mapTx) { const CTransaction &tx = e.GetTx(); @@ -4764,9 +4766,9 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C { // here we add back all txs from the temp mempool to the main mempool. // which removes any tx locally that were invalid after the block arrives. - int invalidtxs = 0; + //int invalidtxs = 0; LOCK(mempool.cs); - BOOST_FOREACH(const CTxMemPoolEntry& e, tmpmempool.mapTx) { + /*BOOST_FOREACH(const CTxMemPoolEntry& e, tmpmempool.mapTx) { CTransaction tx = e.GetTx(); CValidationState state; bool fMissingInputs,fOverrideFees = false; @@ -4777,7 +4779,8 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C if ( 0 && invalidtxs > 0 ) fprintf(stderr, "number of invalid txs: %d\n",invalidtxs ); // empty the temp mempool for next time. - tmpmempool.clear(); + tmpmempool.clear();*/ + mempool = savedmempool; } return true; } From 0d02463df6a92c5d43f6536340a0eb71eb6fd938 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 12 Dec 2018 06:20:52 -1100 Subject: [PATCH 38/49] Iteratively add back to mempool --- src/main.cpp | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index bc8455279..15023734d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -103,6 +103,7 @@ unsigned int expiryDelta = DEFAULT_TX_EXPIRY_DELTA; CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE); CTxMemPool mempool(::minRelayTxFee); +CTxMemPool tmpmempool(::minRelayTxFee); struct COrphanTx { CTransaction tx; @@ -4674,15 +4675,12 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C // Check transactions CTransaction sTx; CTransaction *ptx = NULL; - CTxMemPool savedmempool(::minRelayTxFee); if ( ASSETCHAINS_CC != 0 ) // CC contracts might refer to transactions in the current block, from a CC spend within the same block and out of order { int32_t i,j,rejects=0,lastrejects=0; //fprintf(stderr,"put block's tx into mempool\n"); // Copy all non Z-txs in mempool to temporary mempool because there can be tx in local mempool that make the block invalid. LOCK(mempool.cs); - CTxMemPool tmpmempool(::minRelayTxFee); - savedmempool = mempool; list transactionsToRemove; BOOST_FOREACH(const CTxMemPoolEntry& e, mempool.mapTx) { const CTransaction &tx = e.GetTx(); @@ -4697,6 +4695,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C mempool.remove(tx, removed, false); } // add all the txs in the block to the empty mempool. + // CC validation shouldnt (cant) depend on the state of mempool! while ( 1 ) { for (i=0; i removed; LOCK(mempool.cs); - /*BOOST_FOREACH(const CTxMemPoolEntry& e, tmpmempool.mapTx) { - CTransaction tx = e.GetTx(); - CValidationState state; bool fMissingInputs,fOverrideFees = false; - - if (AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, !fOverrideFees) == false ) - invalidtxs++; - //else fprintf(stderr, "added mempool tx back to mempool\n"); + while ( 1 ) + { + numiters++; + numadded = 0; + BOOST_FOREACH(const CTxMemPoolEntry& e, tmpmempool.mapTx) + { + CTransaction tx = e.GetTx(); + if (AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, !fOverrideFees) == true ) + { + numadded++; + tmpmempool.remove(tx, removed, false); + } + } + if ( numadded == 0 ) + break; } - if ( 0 && invalidtxs > 0 ) - fprintf(stderr, "number of invalid txs: %d\n",invalidtxs ); + if ( numadded > 0 ) + fprintf(stderr, "CC mempool add: numiters.%d numadded.%d remains.%d\n",numiters,numadded,(int32_t)tmpmempool.size()); // empty the temp mempool for next time. - tmpmempool.clear();*/ - mempool = savedmempool; + tmpmempool.clear(); } return true; } From dc63bc8d260c8c2d405005b0c029c99082b00bfb Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 12 Dec 2018 06:21:55 -1100 Subject: [PATCH 39/49] Numbers --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 15023734d..01857e8b8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4765,7 +4765,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C { // here we add back all txs from the temp mempool to the main mempool. // which removes any tx locally that were invalid after the block arrives. - int numadded,numadded = 0; + int numadded,numiters = 0; CValidationState state; bool fMissingInputs,fOverrideFees = false; list removed; LOCK(mempool.cs); From b90b38255634369b1201d4c7d1e924b80bc732ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 12 Dec 2018 06:39:20 -1100 Subject: [PATCH 40/49] -print --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 01857e8b8..788ee95b0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4785,7 +4785,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C if ( numadded == 0 ) break; } - if ( numadded > 0 ) + if ( 0 && numadded > 0 ) fprintf(stderr, "CC mempool add: numiters.%d numadded.%d remains.%d\n",numiters,numadded,(int32_t)tmpmempool.size()); // empty the temp mempool for next time. tmpmempool.clear(); From 659b3af80e8f36a3973ab14811dda82c9b62ee87 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 12 Dec 2018 09:06:30 -1100 Subject: [PATCH 41/49] +prints --- src/cc/dice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 6faaa1f0c..4233e8928 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -431,7 +431,7 @@ void *dicefinish(void *_ptr) utxos = (struct dicefinish_utxo *)calloc(vin0_needed,sizeof(*utxos)); if ( (n= dicefinish_utxosget(num,utxos,vin0_needed,coinaddr)) > 0 ) { - //fprintf(stderr,"iter.%d vin0_needed.%d got %d, num 0.0002 %d\n",iter,vin0_needed,n,num); +fprintf(stderr,"iter.%d vin0_needed.%d got %d, num 0.0002 %d\n",iter,vin0_needed,n,num); m = 0; DL_FOREACH_SAFE(DICEFINISH_LIST,ptr,tmp) { @@ -533,7 +533,7 @@ void DiceQueue(int32_t iswin,uint64_t sbits,uint256 fundingtxid,uint256 bettxid, else { //fprintf(stderr,"DiceQueue status bettxid.%s already in list\n",bettxid.GetHex().c_str()); - _dicehash_clear(bettxid); + //_dicehash_clear(bettxid); } pthread_mutex_unlock(&DICE_MUTEX); } From f18e92f0932615673d6b5f5e0f05b0cacca3011a Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 12 Dec 2018 09:12:26 -1100 Subject: [PATCH 42/49] +print --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 4233e8928..32674a51d 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -427,7 +427,7 @@ void *dicefinish(void *_ptr) if ( vin0_needed > 0 ) { num = 0; - //fprintf(stderr,"iter.%d vin0_needed.%d\n",iter,vin0_needed); +fprintf(stderr,"iter.%d vin0_needed.%d\n",iter,vin0_needed); utxos = (struct dicefinish_utxo *)calloc(vin0_needed,sizeof(*utxos)); if ( (n= dicefinish_utxosget(num,utxos,vin0_needed,coinaddr)) > 0 ) { From 527ccd4e2e4efe4bb79db170489f1129606e00b6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 12 Dec 2018 09:28:35 -1100 Subject: [PATCH 43/49] Autocreate 0.0002 for kmdice dealer --- src/cc/dice.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 32674a51d..45e101e9c 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -427,11 +427,11 @@ void *dicefinish(void *_ptr) if ( vin0_needed > 0 ) { num = 0; -fprintf(stderr,"iter.%d vin0_needed.%d\n",iter,vin0_needed); +//fprintf(stderr,"iter.%d vin0_needed.%d\n",iter,vin0_needed); utxos = (struct dicefinish_utxo *)calloc(vin0_needed,sizeof(*utxos)); if ( (n= dicefinish_utxosget(num,utxos,vin0_needed,coinaddr)) > 0 ) { -fprintf(stderr,"iter.%d vin0_needed.%d got %d, num 0.0002 %d\n",iter,vin0_needed,n,num); +//fprintf(stderr,"iter.%d vin0_needed.%d got %d, num 0.0002 %d\n",iter,vin0_needed,n,num); m = 0; DL_FOREACH_SAFE(DICEFINISH_LIST,ptr,tmp) { @@ -484,7 +484,8 @@ fprintf(stderr,"iter.%d vin0_needed.%d got %d, num 0.0002 %d\n",iter,vin0_needed //fprintf(stderr,"error ready.%d dicefinish %d of %d process %s %s using need %.8f finish.%s size.%d betspent.%d\n",ptr->bettxid_ready,m,n,iter<0?"loss":"win",ptr->bettxid.GetHex().c_str(),(double)(iter<0 ? 0 : ptr->winamount)/COIN,ptr->txid.GetHex().c_str(),(int32_t)ptr->rawtx.size(),dice_betspent((char *)"dicefinish",ptr->bettxid)); } } - } + } else if ( system("cc/dapps/sendmany100") != 0 ) + fprintf(stderr,"error issing cc/dapps/sendmany100\n"); free(utxos); } } From 5e1c3d1e32e0d4efea059cbcf593b94c229c3fc2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 12 Dec 2018 11:33:20 -1100 Subject: [PATCH 44/49] zMigrate cap at 1000 --- src/cc/dapps/zmigrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dapps/zmigrate.c b/src/cc/dapps/zmigrate.c index 81de2c13d..a86b529ad 100644 --- a/src/cc/dapps/zmigrate.c +++ b/src/cc/dapps/zmigrate.c @@ -906,7 +906,7 @@ int32_t main(int32_t argc,char **argv) zsaddr = clonestr(argv[2]); printf("%s: %s %s\n",REFCOIN_CLI,coinstr,zsaddr); uint32_t lastopid; char coinaddr[64],zcaddr[128],opidstr[128]; int32_t finished; int64_t amount,stdamount,txfee; - stdamount = 10000 * SATOSHIDEN; + stdamount = 1000 * SATOSHIDEN; txfee = 10000; again: printf("start processing zmigrate\n"); From 994a0151f781687c349a839d9c58c2545229ccf7 Mon Sep 17 00:00:00 2001 From: webworker01 Date: Wed, 12 Dec 2018 18:01:05 -0500 Subject: [PATCH 45/49] Set sapling for zilla in far future, fix oot sapling param --- src/assetchains.json | 6 +++++- src/assetchains.old | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/assetchains.json b/src/assetchains.json index 7bc6b7147..1a0ae25e2 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -124,7 +124,11 @@ }, { "ac_name": "ZILLA", - "ac_supply": "11000000" + "ac_supply": "11000000", + "ac_sapling": "5000000", + "addnode": [ + "51.68.215.104" + ] }, { "ac_name": "RFOX", diff --git a/src/assetchains.old b/src/assetchains.old index 5389e54bd..c1419e7f5 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -27,14 +27,14 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=BEER -ac_supply=100000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=PIZZA -ac_supply=100000000 -addnode=78.47.196.146 & ./komodod -pubkey=$pubkey -ac_name=NINJA -ac_supply=100000000 -addnode=78.47.196.146 & -./komodod -pubkey=$pubkey -ac_name=OOT -ac_supply=216000000 -ac_saplinig=5000000 -addnode=174.138.107.226 & +./komodod -pubkey=$pubkey -ac_name=OOT -ac_supply=216000000 -ac_sapling=5000000 -addnode=174.138.107.226 & ./komodod -pubkey=$pubkey -ac_name=BNTN -ac_supply=500000000 -addnode=94.130.169.205 & ./komodod -pubkey=$pubkey -ac_name=CHAIN -ac_supply=999999 -addnode=78.47.146.222 & ./komodod -pubkey=$pubkey -ac_name=PRLPAY -ac_supply=500000000 -addnode=13.250.226.125 & ./komodod -pubkey=$pubkey -ac_name=DSEC -ac_supply=7000000 -addnode=185.148.147.30 & ./komodod -pubkey=$pubkey -ac_name=GLXT -ac_supply=10000000000 -addnode=13.230.224.15 & ./komodod -pubkey=$pubkey -ac_name=EQL -ac_supply=500000000 -ac_ccactivate=205000 -addnode=46.101.124.153 & -./komodod -pubkey=$pubkey -ac_name=ZILLA -ac_supply=11000000 -addnode=54.39.23.248 & +./komodod -pubkey=$pubkey -ac_name=ZILLA -ac_supply=11000000 -ac_sapling=5000000 -addnode=51.68.215.104 & ./komodod -pubkey=$pubkey -ac_name=RFOX -ac_supply=1000000000 -ac_reward=100000000 -addnode=78.47.196.146 & ~/VerusCoin/src/komodod -pubkey=$pubkey -ac_name=VRSC -ac_algo=verushash -ac_cc=1 -ac_veruspos=50 -ac_supply=0 -ac_eras=3 -ac_reward=0,38400000000,2400000000 -ac_halving=1,43200,1051920 -ac_decay=100000000,0,0 -ac_end=10080,226080,0 -ac_timelockgte=19200000000 -ac_timeunlockfrom=129600 -ac_timeunlockto=1180800 -addnode=185.25.48.236 -addnode=185.64.105.111 & ./komodod -pubkey=$pubkey -ac_name=SEC -ac_cc=333 -ac_supply=1000000000 -addnode=185.148.145.43 & From 6e15b6fbd67c6a96879cabc3839f58d22d081c5e Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Thu, 13 Dec 2018 19:04:52 +0600 Subject: [PATCH 46/49] initial tests for ChannelsCC --- qa/pull-tester/rpc-tests.sh | 1 + qa/rpc-tests/cryptoconditions_channels.py | 174 ++++++++++++++++++++++ 2 files changed, 175 insertions(+) create mode 100755 qa/rpc-tests/cryptoconditions_channels.py diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh index 0d7d5509c..d95bf612c 100755 --- a/qa/pull-tester/rpc-tests.sh +++ b/qa/pull-tester/rpc-tests.sh @@ -14,6 +14,7 @@ testScripts=( 'ac_private.py' 'verushash.py' 'cryptoconditions.py' + 'cryptoconditions_channels.py' 'cryptoconditions_dice.py' 'cryptoconditions_faucet.py' 'cryptoconditions_oracles.py' diff --git a/qa/rpc-tests/cryptoconditions_channels.py b/qa/rpc-tests/cryptoconditions_channels.py new file mode 100755 index 000000000..0010f825b --- /dev/null +++ b/qa/rpc-tests/cryptoconditions_channels.py @@ -0,0 +1,174 @@ +#!/usr/bin/env python2 +# Copyright (c) 2018 SuperNET developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + + +from test_framework.test_framework import BitcoinTestFramework +from test_framework.authproxy import JSONRPCException +from test_framework.util import assert_equal, assert_greater_than, \ + initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ + stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds, rpc_port, assert_raises +from cryptoconditions import assert_success, assert_error, generate_random_string + + +class CryptoconditionsChannelsTest(BitcoinTestFramework): + + def setup_chain(self): + print("Initializing CC test directory "+self.options.tmpdir) + self.num_nodes = 2 + initialize_chain_clean(self.options.tmpdir, self.num_nodes) + + def setup_network(self, split = False): + print("Setting up network...") + self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" + self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" + self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" + self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" + self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" + self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" + self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, + extra_args=[[ + # always give -ac_name as first extra_arg and port as third + '-ac_name=REGTEST', + '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', + '-port=64367', + '-rpcport=64368', + '-regtest', + '-addressindex=1', + '-spentindex=1', + '-ac_supply=5555555', + '-ac_reward=10000000000000', + '-pubkey=' + self.pubkey, + '-ac_cc=2', + '-whitelist=127.0.0.1', + '-debug', + '--daemon', + '-rpcuser=rt', + '-rpcpassword=rt' + ], + ['-ac_name=REGTEST', + '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', + '-port=64365', + '-rpcport=64366', + '-regtest', + '-addressindex=1', + '-spentindex=1', + '-ac_supply=5555555', + '-ac_reward=10000000000000', + '-pubkey=' + self.pubkey1, + '-ac_cc=2', + '-whitelist=127.0.0.1', + '-debug', + '-addnode=127.0.0.1:64367', + '--daemon', + '-rpcuser=rt', + '-rpcpassword=rt']] + ) + self.is_network_split = split + self.rpc = self.nodes[0] + self.rpc1 = self.nodes[1] + self.sync_all() + print("Done setting up network") + + def send_and_mine(self, xtn, rpc_connection): + txid = rpc_connection.sendrawtransaction(xtn) + assert txid, 'got txid' + # we need the tx above to be confirmed in the next block + rpc_connection.generate(1) + return txid + + def run_channels_tests(self): + + + """!!! for testing needed test daemon which built with custom flag + export CONFIGURE_FLAGS='CPPFLAGS=-DTESTMODE' + since in usual mode 101 confirmations are needed for payment/refund + """ + + rpc = self.nodes[0] + rpc1 = self.nodes[1] + + # getting empty channels list + result = rpc.channelsinfo() + assert_equal(len(result), 2) + assert_equal(result["result"], "success") + assert_equal(result["name"], "Channels Info") + + # 10 payments, 100000 sat denomination channel opening with second node pubkey + new_channel_hex = rpc.channelsopen(self.pubkey1, "10", "100000") + assert_success(new_channel_hex) + channel_txid = self.send_and_mine(new_channel_hex["hex"], rpc) + assert channel_txid, "got channel txid" + + # checking if our new channel in common channels list + result = rpc.channelsinfo() + assert_equal(len(result), 3) + + # checking info about channel directly + result = rpc.channelsinfo(channel_txid) + assert_success(result) + assert_equal(result["Open"], "10 payments of 100000 satoshi") + + # open transaction should be confirmed + rpc.generate(1) + + # trying to make wrong denomination channel payment + result = rpc.channelspayment(channel_txid, "199000") + assert_error(result) + + # trying to make 0 channel payment + result = rpc.channelspayment(channel_txid, "0") + assert_error(result) + + # trying to make negative channel payment + result = rpc.channelspayment(channel_txid, "-1") + assert_error(result) + + # valid channel payment + result = rpc.channelspayment(channel_txid, "100000") + assert_success(result) + payment_tx_id = self.send_and_mine(result["hex"], rpc) + assert payment_tx_id, "got txid" + + # now in channelinfo payment information should appear + result = rpc.channelsinfo(channel_txid) + assert_equal(result["Payment"], "100000 satoshi to {}, 9 payments left".format(self.addr1)) + + # executing channel close + result = rpc.channelsclose(channel_txid) + assert_success(result) + channel_close_txid = self.send_and_mine(result["hex"], rpc) + assert channel_close_txid, "got txid" + + rpc.generate(2) + self.sync_all() + + # now in channelinfo closed flag should appear + result = rpc.channelsinfo(channel_txid) + assert_equal(result["Close"], "channel") + + # executing channel refund + result = rpc.channelsrefund(channel_txid, channel_close_txid) + assert_success(result) + refund_txid = self.send_and_mine(result["hex"], rpc) + assert refund_txid, "got txid" + + def run_test(self): + print("Mining blocks...") + rpc = self.nodes[0] + rpc1 = self.nodes[1] + # utxos from block 1 become mature in block 101 + rpc.generate(101) + self.sync_all() + rpc.getinfo() + rpc1.getinfo() + # this corresponds to -pubkey above + print("Importing privkeys") + rpc.importprivkey(self.privkey) + rpc1.importprivkey(self.privkey1) + self.run_channels_tests() + + +if __name__ == '__main__': + CryptoconditionsChannelsTest().main() From fb168165bf47a0d282d151dff4ed9ba77e92a611 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 13 Dec 2018 02:34:25 -1100 Subject: [PATCH 47/49] Prevent divide by 0 in -ac_options --- src/komodo_globals.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 401a874e3..2590a4a21 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -155,6 +155,8 @@ int64_t komodo_current_supply(uint32_t nHeight) uint64_t lastEnd = j == 0 ? 0 : ASSETCHAINS_ENDSUBSIDY[j - 1]; uint64_t curEnd = ASSETCHAINS_ENDSUBSIDY[j] == 0 ? nHeight : nHeight > ASSETCHAINS_ENDSUBSIDY[j] ? ASSETCHAINS_ENDSUBSIDY[j] : nHeight; uint64_t period = ASSETCHAINS_HALVING[j]; + if ( period == 0 ) + period = 210000; uint32_t nSteps = (curEnd - lastEnd) / period; uint32_t modulo = (curEnd - lastEnd) % period; uint64_t decay = ASSETCHAINS_DECAY[j]; @@ -208,7 +210,8 @@ int64_t komodo_current_supply(uint32_t nHeight) // calculate amount in one step's triangular protrusion over minor triangle's hypotenuse denominator = nSteps * period; - + if ( denominator == 0 ) + denominator = 1; // difference of one step vs. total stepDifference = (period * subsidyDifference) / denominator; From d9bada18fc0262d542b1b24649f33af93347148c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 13 Dec 2018 03:28:41 -1100 Subject: [PATCH 48/49] As per decker: https://github.com/novacoin-project/novacoin/commit/2d77cbfb11b028665f09ad5f1c85ccde61b7e637 --- src/net.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/net.cpp b/src/net.cpp index 47aaf921c..85bb8a13e 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1492,13 +1492,18 @@ void ThreadOpenAddedConnections() LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) for (list >::iterator it = lservAddressesToAdd.begin(); it != lservAddressesToAdd.end(); it++) + { BOOST_FOREACH(const CService& addrNode, *(it)) if (pnode->addr == addrNode) { it = lservAddressesToAdd.erase(it); - it--; + if ( it != lservAddressesToAdd.begin() ) + it--; break; } + if (it == lservAddressesToAdd.end()) + break; + } } BOOST_FOREACH(vector& vserv, lservAddressesToAdd) { From 9283364725cdba5a4ed6e7256f2a26a651ba5148 Mon Sep 17 00:00:00 2001 From: Anton Lysakov Date: Thu, 13 Dec 2018 22:11:47 +0600 Subject: [PATCH 49/49] initil gateways test (gateway creation) --- qa/pull-tester/rpc-tests.sh | 1 + qa/rpc-tests/cryptoconditions_gateways.py | 157 ++++++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100755 qa/rpc-tests/cryptoconditions_gateways.py diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh index d95bf612c..006b1890f 100755 --- a/qa/pull-tester/rpc-tests.sh +++ b/qa/pull-tester/rpc-tests.sh @@ -17,6 +17,7 @@ testScripts=( 'cryptoconditions_channels.py' 'cryptoconditions_dice.py' 'cryptoconditions_faucet.py' + 'cryptoconditions_gateways.py' 'cryptoconditions_oracles.py' 'cryptoconditions_rewards.py' 'cryptoconditions_token.py' diff --git a/qa/rpc-tests/cryptoconditions_gateways.py b/qa/rpc-tests/cryptoconditions_gateways.py new file mode 100755 index 000000000..a48b8b3d8 --- /dev/null +++ b/qa/rpc-tests/cryptoconditions_gateways.py @@ -0,0 +1,157 @@ +#!/usr/bin/env python2 +# Copyright (c) 2018 SuperNET developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + + +from test_framework.test_framework import BitcoinTestFramework +from test_framework.authproxy import JSONRPCException +from test_framework.util import assert_equal, assert_greater_than, \ + initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \ + stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds, rpc_port, assert_raises +from cryptoconditions import assert_success, assert_error, generate_random_string + + +class CryptoconditionsGatewaysTest(BitcoinTestFramework): + + + def setup_chain(self): + print("Initializing CC test directory "+self.options.tmpdir) + self.num_nodes = 2 + initialize_chain_clean(self.options.tmpdir, self.num_nodes) + + def setup_network(self, split = False): + print("Setting up network...") + self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D" + self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf" + self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9" + self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp" + self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0" + self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi" + self.nodes = start_nodes(self.num_nodes, self.options.tmpdir, + extra_args=[[ + # always give -ac_name as first extra_arg and port as third + '-ac_name=REGTEST', + '-conf='+self.options.tmpdir+'/node0/REGTEST.conf', + '-port=64367', + '-rpcport=64368', + '-regtest', + '-addressindex=1', + '-spentindex=1', + '-ac_supply=5555555', + '-ac_reward=10000000000000', + '-pubkey=' + self.pubkey, + '-ac_cc=2', + '-whitelist=127.0.0.1', + '-debug', + '--daemon', + '-rpcuser=rt', + '-rpcpassword=rt' + ], + ['-ac_name=REGTEST', + '-conf='+self.options.tmpdir+'/node1/REGTEST.conf', + '-port=64365', + '-rpcport=64366', + '-regtest', + '-addressindex=1', + '-spentindex=1', + '-ac_supply=5555555', + '-ac_reward=10000000000000', + '-pubkey=' + self.pubkey1, + '-ac_cc=2', + '-whitelist=127.0.0.1', + '-debug', + '-addnode=127.0.0.1:64367', + '--daemon', + '-rpcuser=rt', + '-rpcpassword=rt']] + ) + self.is_network_split = split + self.rpc = self.nodes[0] + self.rpc1 = self.nodes[1] + self.sync_all() + print("Done setting up network") + + def send_and_mine(self, xtn, rpc_connection): + txid = rpc_connection.sendrawtransaction(xtn) + assert txid, 'got txid' + # we need the tx above to be confirmed in the next block + rpc_connection.generate(1) + return txid + + def run_gateways_tests(self): + rpc = self.nodes[0] + rpc1 = self.nodes[1] + + result = rpc.gatewaysaddress() + assert_success(result) + for x in ['GatewaysCCaddress', 'myCCaddress', 'Gatewaysmarker', 'myaddress']: + assert_equal(result[x][0], 'R') + + assert_equal("03ea9c062b9652d8eff34879b504eda0717895d27597aaeb60347d65eed96ccb40", result["GatewaysPubkey"]) + + # getting an empty gateways list + + result = rpc.gatewayslist() + assert_equal(result, []) + + # Gateways binding preparation + + # creating oracle + oracle_hex = rpc.oraclescreate("Test", "Testing", "Ihh") + assert_success(oracle_hex) + oracle_txid = self.send_and_mine(oracle_hex["hex"], rpc) + assert oracle_txid, "got txid" + + # registering as an oracle publisher + reg_hex = rpc.oraclesregister(oracle_txid, "10000") + assert_success(reg_hex) + reg_txid = self.send_and_mine(reg_hex["hex"], rpc) + assert reg_txid, "got txid" + + # subscribing on oracle + sub_hex = rpc.oraclessubscribe(oracle_txid, self.pubkey, "1") + assert_success(sub_hex) + sub_txid = self.send_and_mine(sub_hex["hex"], rpc) + assert sub_txid, "got txid" + + # creating token + token_hex = rpc.tokencreate("Test", "1", "Testing") + assert_success(token_hex) + token_txid = self.send_and_mine(token_hex["hex"], rpc) + assert token_txid, "got txid" + + # converting tokens + convertion_hex = rpc.tokenconvert("241",token_txid,"03ea9c062b9652d8eff34879b504eda0717895d27597aaeb60347d65eed96ccb40","100000000") + assert_success(convertion_hex) + convertion_txid = self.send_and_mine(convertion_hex["hex"], rpc) + assert convertion_txid, "got txid" + + # binding gateway + bind_hex = rpc.gatewaysbind(token_txid, oracle_txid, "KMD", "100000000", "1", "1", self.pubkey) + assert_success(bind_hex) + bind_txid = self.send_and_mine(bind_hex["hex"], rpc) + assert bind_txid, "got txid" + + # checking if created gateway in list + result = rpc.gatewayslist() + assert_equal(result[0], bind_txid) + + def run_test(self): + print("Mining blocks...") + rpc = self.nodes[0] + rpc1 = self.nodes[1] + # utxos from block 1 become mature in block 101 + rpc.generate(101) + self.sync_all() + rpc.getinfo() + rpc1.getinfo() + # this corresponds to -pubkey above + print("Importing privkeys") + rpc.importprivkey(self.privkey) + rpc1.importprivkey(self.privkey1) + self.run_gateways_tests() + + +if __name__ == '__main__': + CryptoconditionsGatewaysTest().main()