Browse Source

Merge pull request #707 from jl777/jl777

fix CHIPS
patch-3
jl777 7 years ago
committed by GitHub
parent
commit
0e954894e5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      iguana/dpow/dpow_fsm.c
  2. 2
      iguana/dpow/dpow_network.c
  3. 8
      iguana/dpow/dpow_rpc.c
  4. 2
      iguana/dpow/dpow_tx.c
  5. 2
      iguana/iguana777.h
  6. 14
      iguana/iguana_notary.c
  7. 2
      iguana/keccak.c

9
iguana/dpow/dpow_fsm.c

@ -265,7 +265,7 @@ int32_t dpow_txhasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supe
{
bits256 blockhash,txid,MoM; uint32_t MoMdepth; char symbol[65];//,str[65],str2[65],str3[65];
vout = jitem(vouts,numvouts-1);
if ( (sobj= jobj(vout,"scriptPubKey")) != 0 && (hexstr= jstr(sobj,"hex")) != 0 && (len= is_hexstr(hexstr,0)) > 36 && len < sizeof(script)*2 )
if ( (sobj= jobj(vout,"scriptPubKey")) != 0 && (hexstr= jstr(sobj,"hex")) != 0 && (len= is_hexstr(hexstr,0)) > 35*2 && len < sizeof(script)*2 )
{
len >>= 1;
decode_hex(script,len,hexstr);
@ -401,7 +401,7 @@ void dpow_statemachinestart(void *ptr)
{
kmdheight = dest->longestchain;
//portable_mutex_lock(&myinfo->MoM_mutex);
if ( Notaries_port != DPOW_SOCKPORT )
//if ( Notaries_port != DPOW_SOCKPORT )
MoM = dpow_calcMoM(&MoMdepth,myinfo,src,checkpoint.blockhash.height);
//portable_mutex_unlock(&myinfo->MoM_mutex);
}
@ -638,12 +638,11 @@ void dpow_statemachinestart(void *ptr)
extralen = dpow_paxpending(extras,&bp->paxwdcrc,bp->MoM,bp->MoMdepth);
bp->notaries[bp->myind].paxwdcrc = bp->paxwdcrc;
}
sleep(30);
if ( (checkpoint.blockhash.height % 100) != 0 && dp->checkpoint.blockhash.height > checkpoint.blockhash.height )
{
if ( bp->isratify == 0 )
{
printf("abort %s ht.%d due to new checkpoint.%d\n",dp->symbol,checkpoint.blockhash.height,dp->checkpoint.blockhash.height);
//printf("abort %s ht.%d due to new checkpoint.%d\n",dp->symbol,checkpoint.blockhash.height,dp->checkpoint.blockhash.height);
break;
}
}
@ -660,6 +659,7 @@ void dpow_statemachinestart(void *ptr)
{
printf("%s ht.%d %s got reorged to %s, abort notarization\n",bp->srccoin->symbol,bp->height,bits256_str(str,bp->hashmsg),bits256_str(str2,checkhash));
bp->state = 0xffffffff;
break;
}
}
if ( bp->state != 0xffffffff )
@ -677,6 +677,7 @@ void dpow_statemachinestart(void *ptr)
printf("abort pending ratify\n");
break;
}
sleep(30);
}
printf("[%d] 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",Numallocated,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;

2
iguana/dpow/dpow_network.c

@ -1901,7 +1901,7 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru
printf("mypaxcrc.%x\n",bp->paxwdcrc);
}
char str[65];
if ( (rand() % 130) == 0 )//|| strcmp(dp->symbol,"CHIPS") == 0 )
if ( (rand() % 130) == 0 || strcmp(dp->symbol,"CHIPS") == 0 )
printf("%p ht.%d [%d] ips.%d %s NOTARIZE.%d matches.%d paxmatches.%d bestmatches.%d bestk.%d %llx recv.%llx sigmasks.(%llx %llx) senderind.%d state.%x (%x %x %x) MoM.%s [%d]\n",bp,bp->height,bp->myind,dp->numipbits,dp->symbol,bp->minsigs,matches,paxmatches,bestmatches,bp->bestk,(long long)bp->bestmask,(long long)bp->recvmask,(long long)(bp->bestk>=0?bp->destsigsmasks[bp->bestk]:0),(long long)(bp->bestk>=0?bp->srcsigsmasks[bp->bestk]:0),senderind,bp->state,bp->hashmsg.uints[0],bp->desttxid.uints[0],bp->srctxid.uints[0],bits256_str(str,bp->MoM),bp->MoMdepth);
}
}

8
iguana/dpow/dpow_rpc.c

@ -71,11 +71,11 @@ cJSON *dpow_getinfo(struct supernet_info *myinfo,struct iguana_info *coin)
return(json);
}
char *Notaries_elected[64][2];
char *Notaries_elected[65][2];
char *seeds[] = { "78.47.196.146", "5.9.102.210", "149.56.29.163", "191.235.80.138", "88.198.65.74", "94.102.63.226", "129.232.225.202", "104.255.64.3", "52.72.135.200", "149.56.28.84", "103.18.58.150", "221.121.144.140", "123.249.79.12", "103.18.58.146", "27.50.93.252", "176.9.0.233", "94.102.63.227", "167.114.227.223", "27.50.68.219", "192.99.233.217", "94.102.63.217", "45.64.168.216" };
int32_t Notaries_numseeds = (int32_t)(sizeof(seeds)/sizeof(*seeds)),Notaries_num,Notaries_BTCminsigs = DPOW_MINSIGS,Notaries_minsigs = DPOW_MIN_ASSETCHAIN_SIGS;
uint16_t Notaries_port = DPOW_SOCKPORT;
char *Notaries_seeds[64];
char *Notaries_seeds[65];
int32_t komodo_initjson(char *fname)
{
@ -94,7 +94,7 @@ int32_t komodo_initjson(char *fname)
Notaries_minsigs = num;
if ( (array= jarray(&n,argjson,"seeds")) != 0 && n <= 64 )
{
for (i=0; i<n; i++)
for (i=0; i<n&&i<64; i++)
{
Notaries_seeds[i] = clonestr(jstri(array,i));
printf("%s ",Notaries_seeds[i]);
@ -103,7 +103,7 @@ int32_t komodo_initjson(char *fname)
}
if ( (array= jarray(&n,argjson,"notaries")) != 0 && n <= 64 )
{
for (i=0; i<n; i++)
for (i=0; i<n&&i<64; i++)
{
item = jitem(array,i);
field = jfieldname(item);

2
iguana/dpow/dpow_tx.c

@ -169,6 +169,8 @@ struct dpow_block *dpow_heightfind(struct supernet_info *myinfo,struct dpow_info
int32_t r,h,incr = 100000; struct dpow_block *bp = 0;
if ( height > dp->maxblocks )
{
if ( dp->maxblocks+incr < height+10000 )
incr = (height+10000) - dp->maxblocks;
dp->blocks = realloc(dp->blocks,sizeof(*dp->blocks) * (dp->maxblocks + incr));
memset(&dp->blocks[dp->maxblocks],0,sizeof(*dp->blocks) * incr);
dp->maxblocks += incr;

2
iguana/iguana777.h

@ -167,7 +167,7 @@ struct supernet_info
uint8_t *pingbuf;
struct basilisk_request DEXaccept;
FILE *dexfp;
struct dpow_info DPOWS[128]; int32_t numdpows,dpowsock,dexsock,pubsock,repsock,subsock,reqsock;
struct dpow_info DPOWS[1024]; int32_t numdpows,dpowsock,dexsock,pubsock,repsock,subsock,reqsock;
struct delayedPoW_info dPoW;
struct basilisk_spend *spends; int32_t numspends;
char bindaddr[64];

14
iguana/iguana_notary.c

@ -95,7 +95,7 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
if ( height > 0 && blocktime > 0 )
{
dpow_checkpointset(myinfo,&dp->last,height,hash,timestamp,blocktime);
if ( (0) &&strcmp("BEER",dp->symbol) == 0 )
if ( (0) && strcmp("CHIPS",dp->symbol) == 0 )
printf("dynamic set %s/%s %s <- height.%d\n",dp->symbol,dp->dest,bits256_str(str,hash),height);
checkpoint = dp->last;
} else return;
@ -109,7 +109,7 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
printf("lastnotarized.(%s) is current checkpoint, skip\n",bits256_str(str,dp->lastnotarized));
return;
}
if ( (0) && strcmp("BEER",dp->symbol) == 0 )
if ( (0) && strcmp("CHIPS",dp->symbol) == 0 )
printf("checkpoint.(%s) is not active and not lastnotarized\n",bits256_str(str,checkpoint.blockhash.hash));
} else return;
} else return;
@ -118,14 +118,14 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
}
if ( bits256_nonz(checkpoint.blockhash.hash) != 0 && (checkpoint.blockhash.height % freq) == 0 )
{
if ( (0) && strcmp("BEER",dp->symbol) == 0 )
if ( (0) && strcmp("CHIPS",dp->symbol) == 0 )
printf("%s/%s src ht.%d dest.%u nonz.%d %s minsigs.%d\n",dp->symbol,dp->dest,checkpoint.blockhash.height,dp->destupdated,bits256_nonz(checkpoint.blockhash.hash),bits256_str(str,dp->last.blockhash.hash),minsigs);
dpow_heightfind(myinfo,dp,checkpoint.blockhash.height + 1000);
ptrs = calloc(1,sizeof(void *)*5 + sizeof(struct dpow_checkpoint) + sizeof(pthread_t));
ptrs[0] = (void *)myinfo;
ptrs[1] = (void *)dp;
ptrs[2] = (void *)(uint64_t)minsigs;
if ( strcmp(dp->dest,"KMD") != 0 && strcmp(dp->dest,"CHAIN") != 0 )
if ( strcmp(dp->dest,"KMD") != 0 )
ptrs[3] = (void *)DPOW_DURATION;
else ptrs[3] = (void *)(DPOW_DURATION * 60); // essentially try forever for assetchains
ptrs[4] = 0;
@ -135,9 +135,11 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
if ( OS_thread_create((void *)((uint64_t)&ptrs[5] + sizeof(struct dpow_checkpoint)),NULL,(void *)dpow_statemachinestart,(void *)ptrs) != 0 )
{
}
if ( ht > 100 )
if ( ht > 500 )
{
for (i=ht-100; i>=0; i--)
if ( (0) && strcmp("CHIPS",dp->symbol) == 0 )
printf("ht.%d maxblocks.%d\n",ht,dp->maxblocks);
for (i=ht-500; i>ht-10000; i--)
{
if ( (i % 100) != 0 && (bp= dp->blocks[i]) != 0 && bp->state == 0xffffffff )
{

2
iguana/keccak.c

@ -39,9 +39,7 @@
extern "C"{
#endif
#if defined(WIN32)
#include <stdint.h>
#endif
/*
* Parameters:

Loading…
Cancel
Save