From 2be7001a60ac62cd6b79909afdf97e7513dd6abf Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Apr 2018 14:41:51 +0300 Subject: [PATCH 01/12] MoMoM code complete --- iguana/dPoW.h | 10 +++++++ iguana/dpow/dpow_fsm.c | 62 ++++++++++++++++++++++++++++++++------- iguana/dpow/dpow_rpc.c | 18 ++++++++++++ iguana/dpow/dpow_tx.c | 24 +++++++++------ iguana/iguana_notary.c | 12 +++++--- includes/iguana_structs.h | 2 +- 6 files changed, 103 insertions(+), 25 deletions(-) diff --git a/iguana/dPoW.h b/iguana/dPoW.h index 49461af75..9518d158e 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -141,6 +141,16 @@ struct dpow_info uint32_t ipbits[128],numipbits; struct dpow_block **blocks; }; + +struct komodo_ccdatapair { int32_t notarization_height; uint32_t MoMoMoffset; }; + +struct komodo_ccdataMoMoM +{ + bits256 MoMoM; + int32_t kmdstarti,kmdendi,MoMoMdepth,numpairs,len; + struct komodo_ccdatapair *pairs; +}; + uint64_t dpow_notarybestk(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp); int32_t dpow_paxpending(uint8_t *hex,uint32_t *paxwdcrcp,bits256 MoM,uint32_t MoMdepth); void dex_updateclient(struct supernet_info *myinfo); diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 54bfe4644..6d2f83095 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -162,7 +162,8 @@ int32_t dpow_checkutxo(struct supernet_info *myinfo,struct dpow_info *dp,struct uint32_t Numallocated; -int32_t dpow_opreturn_parsesrc(bits256 *blockhashp,int32_t *heightp,bits256 *txidp,char *symbol,bits256 *MoMp,uint32_t *MoMdepthp,uint8_t *opret,int32_t opretlen) +int32_t dpow_opreturn_parsesrc(bits256 *blockhashp,int32_t *heightp,bits256 *txidp,char *symbol,bits256 *MoMp,uint32_t *MoMdepthp,uint8_t *opret,int32_t opretlen,struct komodo_ccdataMoMoM + *mdata) { int32_t i,c,len,offset = 0; uint8_t op; symbol[0] = 0; @@ -171,6 +172,7 @@ int32_t dpow_opreturn_parsesrc(bits256 *blockhashp,int32_t *heightp,bits256 *txi memset(txidp->bytes,0,sizeof(*txidp)); memset(MoMp->bytes,0,sizeof(*MoMp)); memset(MoMdepthp,0,sizeof(*MoMdepthp)); + memset(mdata,0,sizeof(*mdata)); if ( opret[offset++] == 0x6a ) { if ( (op= opret[offset++]) < 0x4c ) @@ -198,16 +200,37 @@ int32_t dpow_opreturn_parsesrc(bits256 *blockhashp,int32_t *heightp,bits256 *txi } if ( offset+sizeof(bits256)+sizeof(uint32_t) <= opretlen ) { + uint32_t CCid,k; offset += iguana_rwbignum(0,&opret[offset],sizeof(*MoMp),MoMp->bytes); offset += iguana_rwnum(0,&opret[offset],sizeof(*MoMdepthp),(uint32_t *)MoMdepthp); + // MoMoM, depth, numpairs, (notarization ht, MoMoM offset) + if ( offset+52 <= opretlen ) + { + offset += iguana_rwnum(0,&opret[offset],sizeof(CCid),(uint8_t *)&CCid); + offset += iguana_rwnum(0,&opret[offset],sizeof(uint32_t),(uint8_t *)&mdata->kmdstarti); + offset += iguana_rwnum(0,&opret[offset],sizeof(uint32_t),(uint8_t *)&mdata->kmdendi); + offset += iguana_rwbignum(0,&opret[offset],sizeof(mdata->MoMoM),(uint8_t *)&mdata->MoMoM); + offset += iguana_rwnum(0,&opret[offset],sizeof(uint32_t),(uint8_t *)&mdata->MoMoMdepth); + offset += iguana_rwnum(0,&opret[offset],sizeof(uint32_t),(uint8_t *)&mdata->numpairs); + mdata->len += sizeof(mdata->MoMoM) + sizeof(uint32_t)*4; + if ( offset+mdata->numpairs*8 == opretlen ) + { + mdata->pairs = (struct komodo_ccdatapair *)calloc(mdata->numpairs,sizeof(*mdata->pairs)); + for (k=0; knumpairs; k++) + { + offset += iguana_rwnum(0,&opret[offset],sizeof(int32_t),(uint8_t *)&mdata->pairs[k].notarization_height); + offset += iguana_rwnum(0,&opret[offset],sizeof(uint32_t),(uint8_t *)&mdata->pairs[k].MoMoMoffset); + mdata->len += sizeof(uint32_t) * 2; + } + } else if ( mdata->numpairs > 0 ) + printf("offset.%d + %d*8 != opretlen.%d\n",offset,mdata->numpairs,opretlen); + } } - ///printf("offset.%d vs len.%d\n",offset,len); - return(len); } return(-1); } -int32_t dpow_txhasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t height) +int32_t dpow_txhasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t height,struct komodo_ccdataMoMoM *mdata) { cJSON *txobj,*vins,*vin,*vouts,*vout,*spentobj,*sobj; char *hexstr; uint8_t script[256]; bits256 spenttxid; uint64_t notarymask=0; int32_t i,j,numnotaries,len,spentvout,numvins,numvouts,hasnotarization = 0; if ( (txobj= dpow_gettransaction(myinfo,coin,txid)) != 0 ) @@ -269,12 +292,25 @@ int32_t dpow_txhasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supe { len >>= 1; decode_hex(script,len,hexstr); - if ( dpow_opreturn_parsesrc(&blockhash,nothtp,&txid,symbol,&MoM,&MoMdepth,script,len) > 0 ) + if ( dpow_opreturn_parsesrc(&blockhash,nothtp,&txid,symbol,&MoM,&MoMdepth,script,len,mdata) > 0 && strcmp(symbol,coin->symbol) == 0 ) { - if ( Notaries_port != DPOW_SOCKPORT ) + // if ( Notaries_port != DPOW_SOCKPORT ) // keep going till valid MoM found, useful for new chains without any MoM { if ( bits256_nonz(MoM) == 0 || MoMdepth == 0 || *nothtp >= height || *nothtp < 0 ) + { *nothtp = 0; + } + } + if ( mdata->pairs != 0 && mdata->numpairs > 0 ) + { + for (j=0; jnumpairs; j++) + { + if ( mdata->pairs[j].notarization_height > coin->MoMoMheight ) + { + coin->MoMoMheight = mdata->pairs[j].notarization_height; + printf("set %s MoMoMheight <- %d\n",coin->symbol,coin->MoMoMheight); + } + } } //printf("%s.%d notarizationht.%d %s -> %s MoM.%s [%d]\n",symbol,height,*nothtp,bits256_str(str,blockhash),bits256_str(str2,txid),bits256_str(str3,MoM),MoMdepth); } @@ -291,17 +327,18 @@ int32_t dpow_txhasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supe return(hasnotarization); } -int32_t dpow_hasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supernet_info *myinfo,struct iguana_info *coin,cJSON *blockjson,int32_t ht) +int32_t dpow_hasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supernet_info *myinfo,struct iguana_info *coin,cJSON *blockjson,int32_t ht,struct komodo_ccdataMoMoM *mdata) { int32_t i,n,hasnotarization = 0; bits256 txid; cJSON *txarray; *nothtp = 0; *signedmaskp = 0; + memset(mdata,0,sizeof(*mdata)); if ( (txarray= jarray(&n,blockjson,"tx")) != 0 ) { for (i=0; isymbol,height); @@ -328,10 +365,9 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu blockhash = dpow_getblockhash(myinfo,coin,ht); if ( (blockjson= dpow_getblock(myinfo,coin,blockhash)) != 0 ) { - if ( breakht == 0 && dpow_hasnotarization(&signedmask,¬ht,myinfo,coin,blockjson,ht) > 0 ) + if ( breakht == 0 && dpow_hasnotarization(&signedmask,¬ht,myinfo,coin,blockjson,ht,&mdata) > 0 ) { breakht = notht; - //free_json(blockjson); printf("%s has notarization at %d for breakht.%d\n",coin->symbol,ht,notht); } merkle = jbits256(blockjson,"merkleroot"); @@ -342,6 +378,8 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu { printf("%s MoMdepth.%d ht.%d from height.%d, null merkleroot\n",coin->symbol,MoMdepth,ht,height); MoMdepth = 0; + if ( mdata.pairs != 0 ) + free(mdata.pairs); break; } } @@ -349,6 +387,8 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu { printf("%s MoMdepth.%d ht.%d from height.%d, no blockhash\n",coin->symbol,MoMdepth,ht,height); MoMdepth = 0; + if ( mdata.pairs != 0 ) + free(mdata.pairs); break; } ht = height - MoMdepth; diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index a44e02fbc..920596d1a 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -226,6 +226,24 @@ bits256 dpow_getbestblockhash(struct supernet_info *myinfo,struct iguana_info *c return(blockhash); } + +cJSON *dpow_MoMoMdata(struct iguana_info *coin,char *symbol,int32_t kmdheight) +{ + char buf[128],*retstr=0; cJSON *retjson = 0; struct iguana_info *src; + if ( coin->FULLNODE < 0 && strcmp(coin->symbol,"KMD") == 0 && (src= iguana_coinfind(symbol)) != 0 ) + { + sprintf(buf,"[\"%s\", %d, %d]",symbol,kmdheight,src->MoMoMheight); + if ( (retstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"MoMoMdata",buf)) != 0 ) + { + retjson = cJSON_Parse(retstr); + printf("MoMoM.(%s %d %d) -> %s\n",symbol,kmdheight,src->MoMoMheight,retstr); + free(retstr); + } + usleep(10000); + } + return(retjson); +} + int32_t dpow_paxpending(uint8_t *hex,uint32_t *paxwdcrcp,bits256 MoM,uint32_t MoMdepth) { struct iguana_info *coin; char *retstr,*hexstr; cJSON *retjson; int32_t n=0; uint32_t paxwdcrc; diff --git a/iguana/dpow/dpow_tx.c b/iguana/dpow/dpow_tx.c index ffb1feadb..7d578c2d2 100755 --- a/iguana/dpow/dpow_tx.c +++ b/iguana/dpow/dpow_tx.c @@ -226,17 +226,23 @@ int32_t dpow_voutstandard(struct dpow_block *bp,uint8_t *serialized,int32_t m,in } printf("numvouts.%d len.%d RATIFY vouts\n",numvouts,len); } - /*if ( 0 && (src_or_dest == 0 || strcmp(bp->destcoin->symbol,"BTC") != 0) && (n= dpow_paxpending(extras,&paxwdcrc,bp->MoM,bp->MoMdepth)) > 0 ) - { - for (i=0; iMoMdepth > 0 && (strcmp(bp->destcoin->symbol,"KMD") == 0 || strcmp(bp->srccoin->symbol,"KMD") == 0) ) + if ( bp->MoMdepth > 0 && (strcmp(bp->destcoin->symbol,"KMD") == 0 || strcmp(bp->srccoin->symbol,"KMD") == 0) ) { + cJSON *retjson; char *hexstr; int32_t hexlen; struct iguana_info *kmdcoin = 0; n = dpow_paxpending(extras,&paxwdcrc,bp->MoM,bp->MoMdepth); - //n += iguana_rwbignum(1,&extras[n],sizeof(bp->MoM),bp->MoM.bytes); - //n += iguana_rwnum(1,&extras[n],sizeof(bp->MoMdepth),(uint32_t *)&bp->MoMdepth); + if ( src_or_dest == 0 && strcmp(bp->destcoin->symbol,"KMD") == 0 ) + { + kmdcoin = bp->destcoin; + if ( kmdcoin->lastbestheight > 10 && (retjson= dpow_MoMoMdata(kmdcoin,bp->srccoin->symbol,kmdcoin->lastbestheight-10)) != 0 ) + { + if ( (hexstr= jstr(retjson,"data")) != 0 && (hexlen= (int32_t)strlen(hexstr)) > 0 && n+hexlen/2 <= sizeof(extras) ) + { + hexlen >>= 1; + decode_hex(&extras[n],hexlen,hexstr), n += hexlen; + } + free_json(retjson); + } + } } satoshis = 0; len += iguana_rwnum(1,&serialized[len],sizeof(satoshis),&satoshis); diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 5238fe2a3..575039e26 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -60,7 +60,7 @@ void dpow_checkpointset(struct supernet_info *myinfo,struct dpow_checkpoint *che void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t height,bits256 hash,uint32_t timestamp,uint32_t blocktime) { - void **ptrs; char str[65]; cJSON *blockjson; struct iguana_info *coin; struct dpow_checkpoint checkpoint; int32_t freq,minsigs,i,ht,notht; uint64_t signedmask; struct dpow_block *bp; + struct komodo_ccdataMoMoM mdata; void **ptrs; char str[65]; cJSON *blockjson; struct iguana_info *coin; struct dpow_checkpoint checkpoint; int32_t freq,minsigs,i,ht,notht; uint64_t signedmask; struct dpow_block *bp; dpow_checkpointset(myinfo,&dp->last,height,hash,timestamp,blocktime); checkpoint = dp->srcfifo[dp->srcconfirms]; if ( strcmp("BTC",dp->dest) == 0 ) @@ -88,8 +88,10 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he if ( (blockjson= dpow_getblock(myinfo,coin,hash)) != 0 ) { height = jint(blockjson,"height"); - if ( dpow_hasnotarization(&signedmask,¬ht,myinfo,coin,blockjson,height) <= 0 ) + if ( dpow_hasnotarization(&signedmask,¬ht,myinfo,coin,blockjson,height,&mdata) <= 0 ) { + if ( mdata.pairs != 0 ) + free(mdata.pairs); blocktime = juint(blockjson,"time"); free_json(blockjson); if ( height > 0 && blocktime > 0 ) @@ -579,7 +581,7 @@ void iguana_notarystats(int32_t totals[64],int32_t dispflag) STRING_AND_TWOINTS(dpow,notarizations,symbol,height,numblocks) { - int32_t i,j,ht,maxheight,notht,masksums[64]; uint64_t signedmask; cJSON *retjson,*blockjson,*item,*array; bits256 blockhash; + struct komodo_ccdataMoMoM mdata; int32_t i,j,ht,maxheight,notht,masksums[64]; uint64_t signedmask; cJSON *retjson,*blockjson,*item,*array; bits256 blockhash; memset(masksums,0,sizeof(masksums)); ht = height; if ( (coin= iguana_coinfind(symbol)) != 0 ) @@ -597,8 +599,10 @@ STRING_AND_TWOINTS(dpow,notarizations,symbol,height,numblocks) blockhash = dpow_getblockhash(myinfo,coin,ht); if ( (blockjson= dpow_getblock(myinfo,coin,blockhash)) != 0 ) { - if ( dpow_hasnotarization(&signedmask,¬ht,myinfo,coin,blockjson,ht) > 0 ) + if ( dpow_hasnotarization(&signedmask,¬ht,myinfo,coin,blockjson,ht,&mdata) > 0 ) { + if ( mdata.pairs != 0 ) + free(mdata.pairs); for (j=0; j<64; j++) if ( ((1LL << j) & signedmask) != 0 ) masksums[j]++; diff --git a/includes/iguana_structs.h b/includes/iguana_structs.h index feaf910e7..29d6fa501 100755 --- a/includes/iguana_structs.h +++ b/includes/iguana_structs.h @@ -499,7 +499,7 @@ struct iguana_info uint32_t fastfind; FILE *fastfps[0x100]; uint8_t *fast[0x100]; int32_t *fasttables[0x100]; long fastsizes[0x100]; uint64_t instance_nonce,myservices,totalsize,totalrecv,totalpackets,sleeptime; int64_t mining,totalfees,TMPallocated,MAXRECVCACHE,MAXMEM,PREFETCHLAG,estsize,activebundles; - int32_t MAXPEERS,MAXPENDINGREQUESTS,MAXBUNDLES,MAXSTUCKTIME,active,closestbundle,numemitted,lastsweep,numemit,startutc,newramchain,numcached,cachefreed,helperdepth,startPEND,endPEND,enableCACHE,FULLNODE,VALIDATENODE,origbalanceswritten,balanceswritten,lastRTheight,RTdatabad; + int32_t MoMoMheight,MAXPEERS,MAXPENDINGREQUESTS,MAXBUNDLES,MAXSTUCKTIME,active,closestbundle,numemitted,lastsweep,numemit,startutc,newramchain,numcached,cachefreed,helperdepth,startPEND,endPEND,enableCACHE,FULLNODE,VALIDATENODE,origbalanceswritten,balanceswritten,lastRTheight,RTdatabad; bits256 balancehash,allbundles; uint32_t lastsync,parsetime,numiAddrs,lastpossible,bundlescount,savedblocks,backlog,spendvectorsaved,laststats,lastinv2,symbolcrc,spendvalidated; char VALIDATEDIR[512]; int32_t longestchain,badlongestchain,longestchain_strange,RTramchain_busy,emitbusy,stuckiters,virtualchain,RTheight,RTreset_needed; From 4e4be81b942aac7edd658f4de6aa28109d1a2738 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Apr 2018 21:41:50 +0300 Subject: [PATCH 02/12] Fix MoMoM opret --- iguana/dPoW.h | 2 +- iguana/dpow/dpow_fsm.c | 13 +++++++++---- iguana/dpow/dpow_rpc.c | 20 +++++++++++++++++--- iguana/dpow/dpow_tx.c | 16 +--------------- 4 files changed, 28 insertions(+), 23 deletions(-) diff --git a/iguana/dPoW.h b/iguana/dPoW.h index 9518d158e..addd5e883 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -152,7 +152,7 @@ struct komodo_ccdataMoMoM }; uint64_t dpow_notarybestk(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp); -int32_t dpow_paxpending(uint8_t *hex,uint32_t *paxwdcrcp,bits256 MoM,uint32_t MoMdepth); +int32_t dpow_paxpending(uint8_t *hex,int32_t hexsize,uint32_t *paxwdcrcp,bits256 MoM,uint32_t MoMdepth,int32_t src_or_dest,struct dpow_block *bp); void dex_updateclient(struct supernet_info *myinfo); char *dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *data,int32_t datalen,int32_t M,char *field); char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int32_t keylen,uint8_t *data,int32_t datalen,int32_t sendping,uint32_t duration); diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 6d2f83095..f972f7977 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -416,7 +416,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,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; + 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; memset(&zero,0,sizeof(zero)); MoM = zero; srcprevtxid0 = destprevtxid0 = zero; @@ -656,9 +656,11 @@ void dpow_statemachinestart(void *ptr) starttime = (uint32_t)time(NULL); if ( bp->isratify == 0 ) { - //if ( (starttime= checkpoint.timestamp) == 0 ) bp->starttime = starttime; - extralen = dpow_paxpending(extras,&bp->paxwdcrc,bp->MoM,bp->MoMdepth); + if ( strcmp(bp->destcoin->symbol,"KMD") == 0 ) + src_or_dest = 0; + else src_or_dest = 1; + extralen = dpow_paxpending(extras,sizeof(extras),&bp->paxwdcrc,bp->MoM,bp->MoMdepth,src_or_dest,bp); bp->notaries[bp->myind].paxwdcrc = bp->paxwdcrc; } printf("PAXWDCRC.%x myind.%d isratify.%d DPOW.%s statemachine checkpoint.%d %s start.%u+dur.%d vs %ld\n",bp->paxwdcrc,bp->myind,bp->isratify,src->symbol,checkpoint.blockhash.height,bits256_str(str,checkpoint.blockhash.hash),starttime,bp->duration,time(NULL)); @@ -676,7 +678,10 @@ void dpow_statemachinestart(void *ptr) printf("break due to already ratifying\n"); break; } - extralen = dpow_paxpending(extras,&bp->paxwdcrc,bp->MoM,bp->MoMdepth); + if ( strcmp(bp->destcoin->symbol,"KMD") == 0 ) + src_or_dest = 0; + else src_or_dest = 1; + extralen = dpow_paxpending(extras,sizeof(extras),&bp->paxwdcrc,bp->MoM,bp->MoMdepth,src_or_dest,bp); bp->notaries[bp->myind].paxwdcrc = bp->paxwdcrc; } if ( (checkpoint.blockhash.height % 100) != 0 && dp->checkpoint.blockhash.height > checkpoint.blockhash.height ) diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 920596d1a..6e7ffe9b9 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -244,18 +244,32 @@ cJSON *dpow_MoMoMdata(struct iguana_info *coin,char *symbol,int32_t kmdheight) return(retjson); } -int32_t dpow_paxpending(uint8_t *hex,uint32_t *paxwdcrcp,bits256 MoM,uint32_t MoMdepth) +int32_t dpow_paxpending(uint8_t *hex,int32_t hexsize,uint32_t *paxwdcrcp,bits256 MoM,uint32_t MoMdepth,int32_t src_or_dest,struct dpow_block *bp) { - struct iguana_info *coin; char *retstr,*hexstr; cJSON *retjson; int32_t n=0; uint32_t paxwdcrc; + struct iguana_info *coin,*kmdcoin; char *retstr,*hexstr; cJSON *retjson; int32_t hexlen,n=0; uint32_t paxwdcrc; paxwdcrc = 0; //if ( Notaries_port != DPOW_SOCKPORT ) { n += iguana_rwbignum(1,&hex[n],sizeof(MoM),MoM.bytes); n += iguana_rwnum(1,&hex[n],sizeof(MoMdepth),(uint32_t *)&MoMdepth); + if ( src_or_dest == 0 && strcmp(bp->destcoin->symbol,"KMD") == 0 ) + { + kmdcoin = bp->destcoin; + if ( kmdcoin->lastbestheight > 10 && (retjson= dpow_MoMoMdata(kmdcoin,bp->srccoin->symbol,kmdcoin->lastbestheight-10)) != 0 ) + { + if ( (hexstr= jstr(retjson,"data")) != 0 && (hexlen= (int32_t)strlen(hexstr)) > 0 && n+hexlen/2 <= hexsize ) + { + hexlen >>= 1; + decode_hex(&hex[n],hexlen,hexstr), n += hexlen; + } + free_json(retjson); + } + } paxwdcrc = calc_crc32(0,hex,n) & 0xffffff00; paxwdcrc |= (n & 0xff); } - *paxwdcrcp = paxwdcrc; + *paxwdcrcp = paxwdcrc; + printf("opretlen.%d\n",n); return(n); if ( (coin= iguana_coinfind("KMD")) != 0 ) { diff --git a/iguana/dpow/dpow_tx.c b/iguana/dpow/dpow_tx.c index 7d578c2d2..11b814f4a 100755 --- a/iguana/dpow/dpow_tx.c +++ b/iguana/dpow/dpow_tx.c @@ -228,21 +228,7 @@ int32_t dpow_voutstandard(struct dpow_block *bp,uint8_t *serialized,int32_t m,in } if ( bp->MoMdepth > 0 && (strcmp(bp->destcoin->symbol,"KMD") == 0 || strcmp(bp->srccoin->symbol,"KMD") == 0) ) { - cJSON *retjson; char *hexstr; int32_t hexlen; struct iguana_info *kmdcoin = 0; - n = dpow_paxpending(extras,&paxwdcrc,bp->MoM,bp->MoMdepth); - if ( src_or_dest == 0 && strcmp(bp->destcoin->symbol,"KMD") == 0 ) - { - kmdcoin = bp->destcoin; - if ( kmdcoin->lastbestheight > 10 && (retjson= dpow_MoMoMdata(kmdcoin,bp->srccoin->symbol,kmdcoin->lastbestheight-10)) != 0 ) - { - if ( (hexstr= jstr(retjson,"data")) != 0 && (hexlen= (int32_t)strlen(hexstr)) > 0 && n+hexlen/2 <= sizeof(extras) ) - { - hexlen >>= 1; - decode_hex(&extras[n],hexlen,hexstr), n += hexlen; - } - free_json(retjson); - } - } + n = dpow_paxpending(extras,sizeof(extras),&paxwdcrc,bp->MoM,bp->MoMdepth,src_or_dest,bp); } satoshis = 0; len += iguana_rwnum(1,&serialized[len],sizeof(satoshis),&satoshis); From 201cf50689368526afc5663625104fa9126ee780 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Apr 2018 21:45:13 +0300 Subject: [PATCH 03/12] Test --- iguana/dpow/dpow_network.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index bbbfcad68..d4a146bba 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -1923,7 +1923,7 @@ void dpow_nanoutxoget(struct supernet_info *myinfo,struct dpow_info *dp,struct d void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen) { - struct dpow_nanomsghdr *np; int32_t i,size,extralen=0,sentbytes = 0; uint32_t crc32,paxwdcrc; uint8_t extras[10000]; + struct dpow_nanomsghdr *np; int32_t i,src_or_dest,size,extralen=0,sentbytes = 0; uint32_t crc32,paxwdcrc; uint8_t extras[10000]; if ( bp->myind < 0 ) return; if ( time(NULL) < myinfo->nanoinit+5 ) @@ -1944,7 +1944,10 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo //printf(" dpow_send.(%d) size.%d numipbits.%d myind.%d\n",datalen,size,np->numipbits,bp->myind); if ( bp->isratify == 0 ) { - extralen = dpow_paxpending(extras,&paxwdcrc,bp->MoM,bp->MoMdepth); + if ( strcmp(bp->destcoin->symbol,"KMD") == 0 ) + src_or_dest = 0; + else src_or_dest = 1; + extralen = dpow_paxpending(extras,&paxwdcrc,bp->MoM,bp->MoMdepth,src_or_dest,bp); bp->paxwdcrc = bp->notaries[bp->myind].paxwdcrc = np->notarize.paxwdcrc = paxwdcrc; //dpow_bestconsensus(bp); dpow_nanoutxoset(myinfo,dp,&np->notarize,bp,0); From 87e56450eacd5e94afe83aa3ec06904b1e068b03 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Apr 2018 21:46:48 +0300 Subject: [PATCH 04/12] Test --- iguana/dpow/dpow_network.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index d4a146bba..581e7379b 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -1947,7 +1947,7 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo if ( strcmp(bp->destcoin->symbol,"KMD") == 0 ) src_or_dest = 0; else src_or_dest = 1; - extralen = dpow_paxpending(extras,&paxwdcrc,bp->MoM,bp->MoMdepth,src_or_dest,bp); + extralen = dpow_paxpending(extras,sizeof(extras),&paxwdcrc,bp->MoM,bp->MoMdepth,src_or_dest,bp); bp->paxwdcrc = bp->notaries[bp->myind].paxwdcrc = np->notarize.paxwdcrc = paxwdcrc; //dpow_bestconsensus(bp); dpow_nanoutxoset(myinfo,dp,&np->notarize,bp,0); From 6b62b6cce796e357cc5bf0bf16bc278f31f05f21 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Apr 2018 22:03:46 +0300 Subject: [PATCH 05/12] Test --- iguana/dpow/dpow_rpc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 6e7ffe9b9..ae64b75ce 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -236,7 +236,7 @@ cJSON *dpow_MoMoMdata(struct iguana_info *coin,char *symbol,int32_t kmdheight) if ( (retstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"MoMoMdata",buf)) != 0 ) { retjson = cJSON_Parse(retstr); - printf("MoMoM.(%s %d %d) -> %s\n",symbol,kmdheight,src->MoMoMheight,retstr); + printf("MoMoM.%s -> %s\n",buf,retstr); free(retstr); } usleep(10000); @@ -246,7 +246,7 @@ cJSON *dpow_MoMoMdata(struct iguana_info *coin,char *symbol,int32_t kmdheight) int32_t dpow_paxpending(uint8_t *hex,int32_t hexsize,uint32_t *paxwdcrcp,bits256 MoM,uint32_t MoMdepth,int32_t src_or_dest,struct dpow_block *bp) { - struct iguana_info *coin,*kmdcoin; char *retstr,*hexstr; cJSON *retjson; int32_t hexlen,n=0; uint32_t paxwdcrc; + struct iguana_info *coin,*kmdcoin=0; char *retstr,*hexstr; cJSON *retjson; int32_t hexlen,n=0; uint32_t paxwdcrc; paxwdcrc = 0; //if ( Notaries_port != DPOW_SOCKPORT ) { @@ -269,7 +269,7 @@ int32_t dpow_paxpending(uint8_t *hex,int32_t hexsize,uint32_t *paxwdcrcp,bits256 paxwdcrc |= (n & 0xff); } *paxwdcrcp = paxwdcrc; - printf("opretlen.%d\n",n); + printf("opretlen.%d src_or_dest.%d dest.(%s) lastbest.%d\n",n,src_or_dest,bp->destcoin->symbol,kmdcoin!=0?kmdcoin->lastbestheight:-1); return(n); if ( (coin= iguana_coinfind("KMD")) != 0 ) { From 8961d12c46effcb08673c624dc8751734bde7cf5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Apr 2018 22:18:37 +0300 Subject: [PATCH 06/12] Test --- iguana/dpow/dpow_rpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index ae64b75ce..7dec55258 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -232,7 +232,7 @@ cJSON *dpow_MoMoMdata(struct iguana_info *coin,char *symbol,int32_t kmdheight) char buf[128],*retstr=0; cJSON *retjson = 0; struct iguana_info *src; if ( coin->FULLNODE < 0 && strcmp(coin->symbol,"KMD") == 0 && (src= iguana_coinfind(symbol)) != 0 ) { - sprintf(buf,"[\"%s\", %d, %d]",symbol,kmdheight,src->MoMoMheight); + sprintf(buf,"[\"%s\", \"%d\", \"%d\"]",symbol,kmdheight,src->MoMoMheight); if ( (retstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"MoMoMdata",buf)) != 0 ) { retjson = cJSON_Parse(retstr); From a6975feac1ceec2ab99c35e65c50036ec09531a8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Apr 2018 22:30:06 +0300 Subject: [PATCH 07/12] Test --- iguana/dpow/dpow_rpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 7dec55258..f99227fbe 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -269,7 +269,7 @@ int32_t dpow_paxpending(uint8_t *hex,int32_t hexsize,uint32_t *paxwdcrcp,bits256 paxwdcrc |= (n & 0xff); } *paxwdcrcp = paxwdcrc; - printf("opretlen.%d src_or_dest.%d dest.(%s) lastbest.%d\n",n,src_or_dest,bp->destcoin->symbol,kmdcoin!=0?kmdcoin->lastbestheight:-1); + printf("opretlen.%d src_or_dest.%d dest.(%s) lastbest.%d paxwdcrc.%x\n",n,src_or_dest,bp->destcoin->symbol,kmdcoin!=0?kmdcoin->lastbestheight:-1,paxwdcrc); return(n); if ( (coin= iguana_coinfind("KMD")) != 0 ) { From 21dd9658386614f9b2343472bd048bac7aa14b24 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 12 Apr 2018 23:15:50 +0300 Subject: [PATCH 08/12] Sync to dev m_notary_testnet --- iguana/m_notary_testnet | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/iguana/m_notary_testnet b/iguana/m_notary_testnet index 483d523f3..0e377a239 100755 --- a/iguana/m_notary_testnet +++ b/iguana/m_notary_testnet @@ -15,17 +15,18 @@ sleep 4 curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"SuperNET\",\"method\":\"myipaddr\",\"ipaddr\":\"$myip\"}" sleep 3 curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"145.239.204.33\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"167.114.116.173\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"167.99.16.61\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"172.104.107.94\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"208.79.81.98\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"31.192.110.70\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"139.99.124.117\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"167.114.208.203\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"103.6.12.111\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"195.154.78.44\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"139.99.148.62\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"addnotary\",\"ipaddr\":\"172.104.244.83\"}" coins/btc_7776 coins/kmd_7776 ./wp_7776 -curl --url "http://127.0.0.1:7776" --data "{\"conf\":\"BEER.conf\",\"path\":\"${HOME#"/"}/.komodo/BEER\",\"unitval\":\"20\",\"zcash\":1,\"RELAY\":-1,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":8,\"newcoin\":\"BEER\",\"name\":\"BEER\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"9fecbb6e\",\"p2p\":8922,\"rpc\":8923,\"pubval\":60,\"p2shval\":85,\"wifval\":188,\"txfee_satoshis\":\"10000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\",\"protover\":170002,\"genesisblock\":\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\",\"debug\":0,\"seedipaddr\":\"78.47.196.146\"}" +#curl --url "http://127.0.0.1:7776" --data "{\"conf\":\"BEER.conf\",\"path\":\"${HOME#"/"}/.komodo/BEER\",\"unitval\":\"20\",\"zcash\":1,\"RELAY\":-1,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":8,\"newcoin\":\"BEER\",\"name\":\"BEER\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"9fecbb6e\",\"p2p\":8922,\"rpc\":8923,\"pubval\":60,\"p2shval\":85,\"wifval\":188,\"txfee_satoshis\":\"10000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\",\"protover\":170002,\"genesisblock\":\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\",\"debug\":0,\"seedipaddr\":\"78.47.196.146\"}" curl --url "http://127.0.0.1:7776" --data "{\"conf\":\"PIZZA.conf\",\"path\":\"${HOME#"/"}/.komodo/PIZZA\",\"unitval\":\"20\",\"zcash\":1,\"RELAY\":-1,\"VALIDATE\":0,\"prefetchlag\":-1,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":4,\"endpend\":4,\"services\":129,\"maxpeers\":8,\"newcoin\":\"PIZZA\",\"name\":\"PIZZA\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"adbe523c\",\"p2p\":11607,\"rpc\":11608,\"pubval\":60,\"p2shval\":85,\"wifval\":188,\"txfee_satoshis\":\"10000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\",\"protover\":170002,\"genesisblock\":\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\",\"debug\":0,\"seedipaddr\":\"78.47.196.146\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"KMD\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"timeout\":60000,\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BEER\",\"pubkey\":\"$pubkey\"}" +#curl --url "http://127.0.0.1:7776" --data "{\"timeout\":60000,\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BEER\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"timeout\":60000,\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PIZZA\",\"pubkey\":\"$pubkey\"}" + From b37c71555b51c9bd21a218e3af61ad212c4cc996 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 13 Apr 2018 10:34:47 +0300 Subject: [PATCH 09/12] Reduce MoMoM frequency --- iguana/dpow/dpow_rpc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index f99227fbe..75e338b49 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -255,7 +255,7 @@ int32_t dpow_paxpending(uint8_t *hex,int32_t hexsize,uint32_t *paxwdcrcp,bits256 if ( src_or_dest == 0 && strcmp(bp->destcoin->symbol,"KMD") == 0 ) { kmdcoin = bp->destcoin; - if ( kmdcoin->lastbestheight > 10 && (retjson= dpow_MoMoMdata(kmdcoin,bp->srccoin->symbol,kmdcoin->lastbestheight-10)) != 0 ) + if ( (bp->height % 10) == 0 && kmdcoin->lastbestheight > 100 && (retjson= dpow_MoMoMdata(kmdcoin,bp->srccoin->symbol,(kmdcoin->lastbestheight/10)*10 - 5)) != 0 ) { if ( (hexstr= jstr(retjson,"data")) != 0 && (hexlen= (int32_t)strlen(hexstr)) > 0 && n+hexlen/2 <= hexsize ) { @@ -269,7 +269,7 @@ int32_t dpow_paxpending(uint8_t *hex,int32_t hexsize,uint32_t *paxwdcrcp,bits256 paxwdcrc |= (n & 0xff); } *paxwdcrcp = paxwdcrc; - printf("opretlen.%d src_or_dest.%d dest.(%s) lastbest.%d paxwdcrc.%x\n",n,src_or_dest,bp->destcoin->symbol,kmdcoin!=0?kmdcoin->lastbestheight:-1,paxwdcrc); + printf("ht.%d opretlen.%d src_or_dest.%d dest.(%s) lastbest.%d paxwdcrc.%x\n",bp->height,n,src_or_dest,bp->destcoin->symbol,kmdcoin!=0?((kmdcoin->lastbestheight/10)*10 - 5):-1,paxwdcrc); return(n); if ( (coin= iguana_coinfind("KMD")) != 0 ) { From 2f81f6ce7306dde54685282758b9cfa8a8370ec1 Mon Sep 17 00:00:00 2001 From: SHossain Date: Fri, 13 Apr 2018 15:46:45 +0100 Subject: [PATCH 10/12] added broadcast:1 parameter to make it easier to send tx --- iguana/exchanges/withdraw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/withdraw b/iguana/exchanges/withdraw index 8a78fa5a1..021434103 100755 --- a/iguana/exchanges/withdraw +++ b/iguana/exchanges/withdraw @@ -1,3 +1,3 @@ #!/bin/bash source userpass -curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"withdraw\",\"coin\":\"KMD\",\"outputs\":[{\"RUgW6fLfVsLJ87Ng4zJTqNedJSKYQ9ToAf\":0.001}, {\"RUgW6fLfVsLJ87Ng4zJTqNedJSKYQ9ToAf\":0.002}]}" +curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"withdraw\",\"coin\":\"KMD\",\"outputs\":[{\"RUgW6fLfVsLJ87Ng4zJTqNedJSKYQ9ToAf\":0.001}, {\"RUgW6fLfVsLJ87Ng4zJTqNedJSKYQ9ToAf\":0.002}],\"broadcast\":1}" From f51ac7aefa0f1f52e9d6c26fa0a85a3166f19738 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 14 Apr 2018 04:49:18 +0300 Subject: [PATCH 11/12] One week loopback + prints --- iguana/dPoW.h | 2 ++ iguana/dpow/dpow_fsm.c | 2 +- iguana/dpow/dpow_rpc.c | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/iguana/dPoW.h b/iguana/dPoW.h index addd5e883..4e448ba97 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -16,6 +16,8 @@ #ifndef INCLUDE_DPOW_H #define INCLUDE_DPOW_H +#define DPOW_MAXMOMDEPTH (1440 * 7) + #define DPOW_FIRSTRATIFY 1000 #define DPOW_CHECKPOINTFREQ 10 diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index f972f7977..b7febc725 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -346,7 +346,7 @@ int32_t dpow_hasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supern bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct iguana_info *coin,int32_t height) { - struct komodo_ccdataMoMoM mdata; bits256 MoM,blockhash,merkle,*merkles; cJSON *blockjson; uint64_t signedmask; int32_t breakht=0,notht=0,ht,maxdepth = 1440,MoMdepth = 0; + struct komodo_ccdataMoMoM mdata; bits256 MoM,blockhash,merkle,*merkles; cJSON *blockjson; uint64_t signedmask; int32_t breakht=0,notht=0,ht,maxdepth = DPOW_MAXMOMDEPTH,MoMdepth = 0; memset(MoM.bytes,0,sizeof(MoM)); blockhash = dpow_getblockhash(myinfo,coin,height); //printf("start MoM calc %s height.%d\n",coin->symbol,height); diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 75e338b49..284a2f18c 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -246,7 +246,7 @@ cJSON *dpow_MoMoMdata(struct iguana_info *coin,char *symbol,int32_t kmdheight) int32_t dpow_paxpending(uint8_t *hex,int32_t hexsize,uint32_t *paxwdcrcp,bits256 MoM,uint32_t MoMdepth,int32_t src_or_dest,struct dpow_block *bp) { - struct iguana_info *coin,*kmdcoin=0; char *retstr,*hexstr; cJSON *retjson; int32_t hexlen,n=0; uint32_t paxwdcrc; + struct iguana_info *coin,*kmdcoin=0; char *retstr,*hexstr; cJSON *retjson; int32_t hexlen=0,n=0; uint32_t paxwdcrc; paxwdcrc = 0; //if ( Notaries_port != DPOW_SOCKPORT ) { @@ -267,9 +267,10 @@ int32_t dpow_paxpending(uint8_t *hex,int32_t hexsize,uint32_t *paxwdcrcp,bits256 } paxwdcrc = calc_crc32(0,hex,n) & 0xffffff00; paxwdcrc |= (n & 0xff); + if ( hexlen > 0 ) + printf("%s.ht.%d opretlen.%d src_or_dest.%d dest.(%s) lastbest.%d paxwdcrc.%x\n",bp->srccoin->symbol,bp->height,n,src_or_dest,bp->destcoin->symbol,kmdcoin!=0?((kmdcoin->lastbestheight/10)*10 - 5):-1,paxwdcrc); } *paxwdcrcp = paxwdcrc; - printf("ht.%d opretlen.%d src_or_dest.%d dest.(%s) lastbest.%d paxwdcrc.%x\n",bp->height,n,src_or_dest,bp->destcoin->symbol,kmdcoin!=0?((kmdcoin->lastbestheight/10)*10 - 5):-1,paxwdcrc); return(n); if ( (coin= iguana_coinfind("KMD")) != 0 ) { From 579ac0ded240e86e18c5e9688db3b1b59bedb7b7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 14 Apr 2018 04:52:57 +0300 Subject: [PATCH 12/12] MoMoM for PIZZA only --- iguana/dpow/dpow_rpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 284a2f18c..f7950e6d4 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -252,7 +252,7 @@ int32_t dpow_paxpending(uint8_t *hex,int32_t hexsize,uint32_t *paxwdcrcp,bits256 { n += iguana_rwbignum(1,&hex[n],sizeof(MoM),MoM.bytes); n += iguana_rwnum(1,&hex[n],sizeof(MoMdepth),(uint32_t *)&MoMdepth); - if ( src_or_dest == 0 && strcmp(bp->destcoin->symbol,"KMD") == 0 ) + if ( strcmp(bp->srccoin->symbol,"PIZZA") == 0 && src_or_dest == 0 && strcmp(bp->destcoin->symbol,"KMD") == 0 ) { kmdcoin = bp->destcoin; if ( (bp->height % 10) == 0 && kmdcoin->lastbestheight > 100 && (retjson= dpow_MoMoMdata(kmdcoin,bp->srccoin->symbol,(kmdcoin->lastbestheight/10)*10 - 5)) != 0 )