Browse Source

Merge branch 'KMDLabs-staked' into blacktest

p
blackjok3r
blackjok3r 6 years ago
parent
commit
bdec950e0e
  1. 25
      iguana/dpow/dpow_fsm.c
  2. 2
      iguana/dpow/dpow_rpc.c
  3. 21
      iguana/dpow/dpow_tx.c
  4. 2
      iguana/iguana_notary.c

25
iguana/dpow/dpow_fsm.c

@ -267,6 +267,8 @@ void dpow_statemachinestart(void *ptr)
int32_t i,j,ht,extralen,destprevvout0,srcprevvout0,src_or_dest,numratified=0,kmdheight,myind = -1,blockindex=0; 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=0,*srclockunspent=0,*destunlockunspent=0,*srcunlockunspent=0;
memset(&zero,0,sizeof(zero));
static portable_mutex_t dpowT_mutex;
portable_mutex_init(&dpowT_mutex);
MoM = zero;
srcprevtxid0 = destprevtxid0 = zero;
srcprevvout0 = destprevvout0 = -1;
@ -299,8 +301,10 @@ void dpow_statemachinestart(void *ptr)
{
if ( (blockindex= dpow_blockfind(myinfo,dp)) < 0 )
return;
portable_mutex_lock(&dpowT_mutex);
bp = calloc(1,sizeof(*bp));
dp->blocks[blockindex] = bp;
portable_mutex_unlock(&dpowT_mutex);
printf("blockindex.%i allocate bp for %s ht.%d -> %s\n",blockindex,src->symbol,checkpoint.blockhash.height,dest->symbol);
bp->MoM = MoM;
bp->MoMdepth = MoMdepth;
@ -321,8 +325,11 @@ void dpow_statemachinestart(void *ptr)
if ( numratified > 64 )
{
fprintf(stderr,"cant ratify more than 64 notaries ratified has %d\n",numratified);
portable_mutex_lock(&dpowT_mutex);
dp->blocks[blockindex] = 0;
bp->state = 0xffffffff;
free(bp);
portable_mutex_unlock(&dpowT_mutex);
free(ptr);
return;
}
@ -383,8 +390,11 @@ void dpow_statemachinestart(void *ptr)
if ( dp->ratifying != 0 && bp->isratify == 0 )
{
printf("skip notarization ht.%d when ratifying\n",bp->height);
portable_mutex_lock(&dpowT_mutex);
dp->blocks[blockindex] = 0;
bp->state = 0xffffffff;
free(bp);
portable_mutex_unlock(&dpowT_mutex);
free(ptr);
return;
}
@ -435,8 +445,11 @@ void dpow_statemachinestart(void *ptr)
printf("%02x",dp->minerkey33[i]);
printf(" statemachinestart this node %s %s is not official notary numnotaries.%d kmdht.%d bpht.%d\n",srcaddr,destaddr,bp->numnotaries,kmdheight,bp->height);
dp->ratifying -= bp->isratify;
portable_mutex_lock(&dpowT_mutex);
dp->blocks[blockindex] = 0;
bp->state = 0xffffffff;
free(bp);
portable_mutex_unlock(&dpowT_mutex);
free(ptr);
return;
}
@ -446,8 +459,11 @@ void dpow_statemachinestart(void *ptr)
{
printf("statemachinestart no kmdheight.%d\n",kmdheight);
dp->ratifying -= bp->isratify;
portable_mutex_lock(&dpowT_mutex);
dp->blocks[blockindex] = 0;
bp->state = 0xffffffff;
free(bp);
portable_mutex_unlock(&dpowT_mutex);
free(ptr);
return;
}
@ -462,8 +478,11 @@ void dpow_statemachinestart(void *ptr)
printf("%02x",bp->ratified_pubkeys[0][i]);
printf(" new, cant change notary0\n");
dp->ratifying -= bp->isratify;
portable_mutex_lock(&dpowT_mutex);
dp->blocks[blockindex] = 0;
bp->state = 0xffffffff;
free(bp);
portable_mutex_unlock(&dpowT_mutex);
free(ptr);
return;
}
@ -499,7 +518,7 @@ void dpow_statemachinestart(void *ptr)
{
// lock the src coin selected utxo if the source coin is KMD.
if (dpow_lockunspent(myinfo,bp->srccoin,srcaddr,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout) != 0)
printf(">>>> LOCKED %s UTXO.(%s) vout.(%d\n",src->symbol,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout);
printf(">>>> LOCKED %s UTXO.(%s) vout.(%d)\n",src->symbol,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout);
else
printf("<<<< FAILED TO LOCK %s UTXO.(%s) vout.(%d)\n",src->symbol,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout);
}
@ -619,7 +638,7 @@ void dpow_statemachinestart(void *ptr)
printf("END isratify.%d:%d bestk.%d %llx sigs.%llx state.%x machine ht.%d completed state.%x %s.%s %s.%s recvmask.%llx paxwdcrc.%x %p %p\n",bp->isratify,dp->ratifying,bp->bestk,(long long)bp->bestmask,(long long)(bp->bestk>=0?bp->destsigsmasks[bp->bestk]:0),bp->state,bp->height,bp->state,dp->dest,bits256_str(str,bp->desttxid),dp->symbol,bits256_str(str2,bp->srctxid),(long long)bp->recvmask,bp->paxwdcrc,src,dest);
dp->lastrecvmask = bp->recvmask;
dp->ratifying -= bp->isratify;
#if STAKED
#if STAKEDTEST
// We need to wait for notarized confirm here. If the notarization is reorged for any reason we need to rebroadcast it,
// because the mempool is stupid after the sapling update, or Alright might be playing silly games.
int8_t dest_confs = 0, src_confs = 0, destnotarized = 0, srcnotarized = 0, firstloop = 0;
@ -724,8 +743,10 @@ end:
if ( dpow_unlockunspent(myinfo,bp->srccoin,srcaddr,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout) != 0)
printf(">>>> UNLOCKED %s UTXO.(%s) vout.(%d)\n",src->symbol,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout);
}
portable_mutex_lock(&dpowT_mutex);
dp->blocks[blockindex] = 0;
bp->state = 0xffffffff;
free(bp);
portable_mutex_unlock(&dpowT_mutex);
free(ptr);
}

2
iguana/dpow/dpow_rpc.c

@ -167,7 +167,7 @@ int32_t komodo_initjson(char *fname)
int32_t komodo_notaries(char *symbol,uint8_t pubkeys[64][33],int32_t height)
{
#if STAKED
#if STAKEDTEST
struct iguana_info *coin; char *retstr,*field,*hexstr; ; cJSON *retjson,*array,*item; int32_t i,n;
static portable_mutex_t notaries_mutex; static int32_t initflag;
if ( initflag == 0 )

21
iguana/dpow/dpow_tx.c

@ -182,6 +182,17 @@ struct dpow_block *dpow_heightfind(struct supernet_info *myinfo,struct dpow_info
return(bp);
}
int32_t dpow_heightfind2(struct supernet_info *myinfo,struct dpow_info *dp,int32_t height)
{
int32_t i; struct dpow_block *bp = 0;
for (i = 0; i < dp->maxblocks; i++)
{
if ( dp->blocks[i] != 0 && height == dp->blocks[i]->height )
fprintf(stderr, "FOUND: blockindex.%i\n", i);
}
return(0);
}
int32_t dpow_blockfind(struct supernet_info *myinfo,struct dpow_info *dp)
{
int32_t i;
@ -652,13 +663,6 @@ void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_info *dp,struct dpo
} else
{
bp->srctxid = txid;
#ifdef LOGTX
FILE * fptr;
fptr = fopen("/home/node/complete_notarizations", "a+");
// SRC SRC_TXID DEST DEST_TXID HEIGHT
fprintf(fptr, "%s %s %s\n", bp->srccoin->symbol,bp->srctxid,bp->destcoin->symbol,bp->desttxid,bp->height);
fclose(fptr);
#endif
}
len = (int32_t)strlen(bp->signedtx) >> 1;
decode_hex(txdata+32,len,bp->signedtx);
@ -676,7 +680,8 @@ void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_info *dp,struct dpo
else
{
bp->state = 0xffffffff;
printf("dpow_sigscheck: [src.%s] mismatched txid.%s vs %s\n",bp->srccoin->symbol,bits256_str(str,txid),retstr);
printf("dpow_sigscheck: [src.%s ht.%i] mismatched txid.%s vs %s\n",bp->srccoin->symbol,bp->height,bits256_str(str,txid),retstr);
dpow_heightfind2(myinfo,dp,bp->height);
#ifdef LOGTX
FILE * fptr;
fptr = fopen("/home/node/failed_notarizations", "a+");

2
iguana/iguana_notary.c

@ -90,7 +90,7 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
dp->minsigs = Notaries_minsigs;
supressfreq = 3;
}
#endif
#endif
if ( dp->DESTHEIGHT < dp->prevDESTHEIGHT+supressfreq )
{
suppress = 1;

Loading…
Cancel
Save