diff --git a/iguana/dPoW.h b/iguana/dPoW.h index bc343f144..e121d24e6 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -29,7 +29,7 @@ #define DPOW_VERSION 0x1782 #define DPOW_UTXOSIZE dpow_utxosize(coin->symbol) //10000 #define DPOW_MINOUTPUT 6000 -#define DPOW_DURATION 1200 +#define DPOW_DURATION 300 #define DPOW_RATIFYDURATION (3600 * 24) //#define DPOW_ENTRIESCHANNEL ('e' | ('n' << 8) | ('t' << 16) | ('r' << 24)) @@ -135,6 +135,8 @@ struct pax_transaction char symbol[16],coinaddr[64]; uint8_t rmd160[20],shortflag; }; +#define DPOW_MAXIPBITS 512 + struct dpow_info { char symbol[16],dest[16]; uint8_t minerkey33[33],minerid; uint64_t lastrecvmask; @@ -146,7 +148,7 @@ struct dpow_info struct pax_transaction *PAX; uint32_t fullCCid; portable_mutex_t paxmutex,dexmutex; - uint32_t ipbits[128],numipbits; + uint32_t ipbits[DPOW_MAXIPBITS],numipbits; struct dpow_block **blocks,*currentbp; }; diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index bdfc579d6..8aa8050b7 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -265,7 +265,7 @@ void dpow_statemachinestart(void *ptr) void **ptrs = ptr; struct supernet_info *myinfo; struct dpow_info *dp; struct dpow_checkpoint checkpoint; int32_t i,j,ht,extralen,destprevvout0,srcprevvout0,src_or_dest,numratified=0,kmdheight,myind = -1; uint8_t extras[10000],pubkeys[64][33]; cJSON *ratified=0,*item; struct iguana_info *src,*dest; char *jsonstr,*handle,*hexstr,str[65],str2[65],srcaddr[64],destaddr[64]; bits256 zero,MoM,merkleroot,srchash,destprevtxid0,srcprevtxid0; struct dpow_block *bp; struct dpow_entry *ep = 0; uint32_t MoMdepth,duration,minsigs,starttime,srctime; - char *destlockunspent,*srclockunspent,*destunlockunspent,*srcunlockunspent; + char *destlockunspent=0,*srclockunspent=0,*destunlockunspent=0,*srcunlockunspent=0; memset(&zero,0,sizeof(zero)); MoM = zero; srcprevtxid0 = destprevtxid0 = zero; @@ -519,7 +519,7 @@ void dpow_statemachinestart(void *ptr) free(destlockunspent); } - if ( strcmp("BTC",dest->symbol) == 0 ) + if ( strcmp("KMD",src->symbol) == 0 ) { // lock the src coin selected utxo if the source coin is KMD. srclockunspent = dpow_lockunspent(myinfo,bp->srccoin,srcaddr,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout); @@ -634,7 +634,7 @@ void dpow_statemachinestart(void *ptr) } // unlock the src selected utxo on KMD, as those are the only ones we LOCK, and CHIPS does not like the lockunspent call. - if ( strcmp("BTC",dest->symbol) == 0 ) + if ( strcmp("BTC",src->symbol) == 0 ) { srcunlockunspent = dpow_unlockunspent(myinfo,bp->srccoin,srcaddr,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout); if (strncmp(srcunlockunspent,"true", 4) == 0 ) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index c6d3db7d5..2abf37350 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -481,7 +481,7 @@ char *_dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *key,int32 for (i=0; idexipbits[i] ) break; - if ( i == n && n < 64 ) + if ( i == n && n < DPOW_MAXIPBITS ) { myinfo->dexipbits[n++] = ipbits; qsort(myinfo->dexipbits,n,sizeof(uint32_t),_increasing_ipbits); @@ -1292,7 +1292,7 @@ struct dpow_nanomsghdr { bits256 srchash,desthash; struct dpow_nanoutxo ratify,notarize; - uint32_t channel,height,size,datalen,crc32,myipbits,numipbits,ipbits[128]; + uint32_t channel,height,size,datalen,crc32,myipbits,numipbits,ipbits[DPOW_MAXIPBITS]; char symbol[16]; uint8_t senderind,version0,version1,packet[]; } PACKED; @@ -1363,15 +1363,15 @@ int32_t dpow_addnotary(struct supernet_info *myinfo,struct dpow_info *dp,char *i { char str[512]; uint32_t ipbits,*ptr; int32_t i,iter,n,retval = -1; - #ifdef CHECKNODEIP +#ifdef CHECKNODEIP // -B- [+] Decker --- - static uint32_t list_ipbits[128]; - static int dead_or_alive[128]; // 0 - not set, -1 - dead, 1 - alive + static uint32_t list_ipbits[DPOW_MAXIPBITS]; + static int dead_or_alive[DPOW_MAXIPBITS]; // 0 - not set, -1 - dead, 1 - alive static int list_ipsize; int in_list_flag; uint32_t ip_pattern; // -E- [+] Decker --- - #endif +#endif if ( myinfo->IAMNOTARY == 0 ) return(-1); @@ -1382,8 +1382,8 @@ int32_t dpow_addnotary(struct supernet_info *myinfo,struct dpow_info *dp,char *i // -B- [+] Decker --- // every new ip in BUS topology network goes to dead or white list forever, until iguana restart ip_pattern = (uint32_t)calc_ipbits(ipaddr); - if ((list_ipsize == 0) || (list_ipsize > 127)) { - for (int i_list = 0; i_list < 128; i_list++) { list_ipbits[i_list] = 0; dead_or_alive[i_list] = 0; } + if ((list_ipsize == 0) || (list_ipsize > DPOW_MAXIPBITS-1)) { + for (int i_list = 0; i_list < DPOW_MAXIPBITS; i_list++) { list_ipbits[i_list] = 0; dead_or_alive[i_list] = 0; } list_ipsize = 0; in_list_flag = -1; } else { @@ -1426,7 +1426,7 @@ int32_t dpow_addnotary(struct supernet_info *myinfo,struct dpow_info *dp,char *i for (i=0; iipaddr) != 0 ) @@ -1665,7 +1665,7 @@ void dpow_bestconsensus(struct dpow_info *dp,struct dpow_block *bp) bp->notaries[bp->myind].bestk = bp->bestk = bestks[besti]; if ( bp->myind == 0 ) printf("matches.%d bestmatches.%d recv.%llx (%d %llx)\n",matches,bestmatches,(long long)bp->recvmask,bp->bestk,(long long)bp->bestmask); - if ( 0 && bp->myind == 0 && strcmp("CHIPS",dp->symbol) == 0 ) + if ( 1 && bp->myind == 0 && strcmp("KMD",dp->symbol) == 0 ) { for (i=0; inumnotaries; i++) printf("%d:%d%s ",wts[i],owts[i],wts[i]*owts[i]>median?"*":""); @@ -1993,24 +1993,6 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru { //fprintf(stderr,"{%d %x} ",senderind,paxwdcrc); } - if ( bestk >= 0 || bp->notaries[senderind].bestk < 0 ) - { - bp->notaries[senderind].bestk = bestk; - if ( (bp->notaries[senderind].src.siglens[bestk]= siglens[0]) != 0 ) - { - memcpy(bp->notaries[senderind].src.sigs[bestk],sigs[0],siglens[0]); - if ( bestk == bp->bestk && bestmask == bp->bestmask ) - bp->srcsigsmasks[bestk] |= (1LL << senderind); - else bp->srcsigsmasks[bestk] &= ~(1LL << senderind); - } - if ( (bp->notaries[senderind].dest.siglens[bestk]= siglens[1]) != 0 ) - { - memcpy(bp->notaries[senderind].dest.sigs[bestk],sigs[1],siglens[1]); - if ( bestk == bp->bestk && bestmask == bp->bestmask ) - bp->destsigsmasks[bestk] |= (1LL << senderind); - else bp->destsigsmasks[bestk] &= ~(1LL << senderind); - } - } bp->notaries[bp->myind].paxwdcrc = bp->paxwdcrc; if ( bp->bestmask == 0 ) { @@ -2024,6 +2006,27 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru bp->notaries[bp->myind].bestmask = bp->bestmask; if ( bp->recvmask != 0 ) bp->notaries[bp->myind].recvmask = bp->recvmask; + if ( bestk >= 0 || bp->notaries[senderind].bestk < 0 ) + { + bp->notaries[senderind].bestk = bestk; + if ( bp->pendingbestk == bestk && bp->pendingbestmask == bp->bestmask ) + { + if ( bp->notaries[senderind].src.siglens[bestk] == 0 && (bp->notaries[senderind].src.siglens[bestk]= siglens[0]) != 0 ) + { + memcpy(bp->notaries[senderind].src.sigs[bestk],sigs[0],siglens[0]); + if ( bestk == bp->bestk && bestmask == bp->bestmask ) + bp->srcsigsmasks[bestk] |= (1LL << senderind); + else bp->srcsigsmasks[bestk] &= ~(1LL << senderind); + } + if ( bp->notaries[senderind].dest.siglens[bestk] == 0 && (bp->notaries[senderind].dest.siglens[bestk]= siglens[1]) != 0 ) + { + memcpy(bp->notaries[senderind].dest.sigs[bestk],sigs[1],siglens[1]); + if ( bestk == bp->bestk && bestmask == bp->bestmask ) + bp->destsigsmasks[bestk] |= (1LL << senderind); + else bp->destsigsmasks[bestk] &= ~(1LL << senderind); + } + } + } if ( bp->bestk >= 0 ) { flag = -1; @@ -2135,7 +2138,7 @@ void dpow_nanoutxoget(struct supernet_info *myinfo,struct dpow_info *dp,struct d } } } - if ( 0 && bp->myind == 0 && dispflag != 0 ) + if ( 1 && bp->myind == 0 && dispflag != 0 ) { printf("%s.%d RECV.%-2d %llx (%2d %llx) %llx/%llx matches.%-2d best.%-2d %s\n",dp->symbol,bp->height,senderind,(long long)np->recvmask,(int8_t)np->bestk,(long long)np->bestmask,(long long)np->srcutxo.txid,(long long)np->destutxo.txid,matches,bestmatches,Notaries_elected[senderind][0]); } @@ -2219,7 +2222,7 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo printf("maxiters expired for signed_nn_send dpowsock.%d\n",myinfo->dpowsock); //portable_mutex_unlock(&myinfo->dpowmutex); free(np); - if ( 0 && bp->myind == 0 ) + if ( 1 && bp->myind == 0 ) printf("%d NANOSEND.%d %s.%d channel.%08x (%d) pax.%08x datalen.%d (%d %llx) (%d %llx) recv.%llx\n",i,sentbytes,dp->symbol,np->height,np->channel,size,np->notarize.paxwdcrc,datalen,(int8_t)np->notarize.bestk,(long long)np->notarize.bestmask,bp->notaries[bp->myind].bestk,(long long)bp->notaries[bp->myind].bestmask,(long long)bp->recvmask); } diff --git a/iguana/dpow/dpow_tx.c b/iguana/dpow/dpow_tx.c index 51ba39f8b..148827d68 100755 --- a/iguana/dpow/dpow_tx.c +++ b/iguana/dpow/dpow_tx.c @@ -615,7 +615,7 @@ void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_info *dp,struct dpo else { bp->state = 0xffffffff; - printf("dpow_sigscheck: mismatched txid.%s vs %s\n",bits256_str(str,txid),retstr); + printf("dpow_sigscheck.(%s): mismatched txid.%s vs %s\n",bp->signedtx,bits256_str(str,txid),retstr); } free(retstr); retstr = 0; diff --git a/iguana/dpowassets b/iguana/dpowassets new file mode 100755 index 000000000..7b20beb51 --- /dev/null +++ b/iguana/dpowassets @@ -0,0 +1,47 @@ +#!/bin/bash +set -x +source pubkey.txt +echo $pubkey +sleep 3 + +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"REVS\",\"pubkey\":\"$pubkey\"}" + +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"SUPERNET\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"DEX\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PANGEA\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"JUMBLR\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BET\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CRYPTO\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HODL\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MSHARK\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BOTS\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MGW\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"COQUI\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"WLC\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"KV\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CEAL\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MESH\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MNZ\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"AXO\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"ETOMIC\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BTCH\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CHAIN\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"NINJA\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"OOT\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BNTN\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PRLPAY\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"DSEC\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GLXT\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"EQL\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"ZILLA\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CHIPS\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GAME\",\"freq\":5,\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"RFOX\",\"freq\":10,\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"VRSC\",\"freq\":10,\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"SEC\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CCL\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HUSH\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PIRATE\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MGNX\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"EMC2\",\"freq\":5,\"pubkey\":\"$pubkey\"}" + diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 164bbac51..4eb574b6a 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -127,9 +127,9 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he ptrs[0] = (void *)myinfo; ptrs[1] = (void *)dp; ptrs[2] = (void *)(uint64_t)dp->minsigs; - if ( strcmp(dp->dest,"KMD") != 0 ) + //if ( strcmp(dp->dest,"KMD") != 0 ) ptrs[3] = (void *)DPOW_DURATION; - else ptrs[3] = (void *)(DPOW_DURATION * 60); // essentially try forever for assetchains + //else ptrs[3] = (void *)(DPOW_DURATION * 60); // essentially try forever for assetchains ptrs[4] = 0; memcpy(&ptrs[5],&checkpoint,sizeof(checkpoint)); dp->activehash = checkpoint.blockhash.hash;