From ab6374c07942a97c6cb17986216c36c1749168c2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 12 Dec 2018 06:09:59 -1100 Subject: [PATCH 1/8] 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 2/8] 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 3/8] 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 4/8] -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 5/8] +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 6/8] +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 7/8] 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 8/8] 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");