Merge pull request #1308 from jl777/jl777
skip revalidating already validated playerdata, ie. 't'
This commit is contained in:
@@ -51,7 +51,7 @@ Komodo is based on Zcash and has been extended by our innovative consensus algor
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
#The following packages are needed:
|
#The following packages are needed:
|
||||||
sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python python-zmq zlib1g-dev wget libcurl4-gnutls-dev bsdmainutils automake curl libboost-dev
|
sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python python-zmq zlib1g-dev wget libcurl4-gnutls-dev bsdmainutils automake curl
|
||||||
```
|
```
|
||||||
|
|
||||||
### Build Komodo
|
### Build Komodo
|
||||||
|
|||||||
@@ -235,6 +235,7 @@ int32_t safecopy(char *dest,char *src,long len)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t rogue_replay(uint64_t seed,int32_t sleeptime);
|
int32_t rogue_replay(uint64_t seed,int32_t sleeptime);
|
||||||
|
char *rogue_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter);
|
||||||
int rogue(int argc, char **argv, char **envp);
|
int rogue(int argc, char **argv, char **envp);
|
||||||
|
|
||||||
void *OS_loadfile(char *fname,uint8_t **bufp,long *lenp,long *allocsizep)
|
void *OS_loadfile(char *fname,uint8_t **bufp,long *lenp,long *allocsizep)
|
||||||
@@ -741,7 +742,7 @@ int32_t rogue_sendrawtransaction(char *rawtx)
|
|||||||
|
|
||||||
void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num)
|
void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *keystrokes,int32_t num)
|
||||||
{
|
{
|
||||||
char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx; int32_t i; cJSON *retjson;
|
char cmd[16384],hexstr[16384],params[32768],*retstr,*rawtx,*pastkeys; int32_t i,numpastkeys; cJSON *retjson;
|
||||||
//fprintf(stderr,"rogue_progress num.%d\n",num);
|
//fprintf(stderr,"rogue_progress num.%d\n",num);
|
||||||
if ( rs->guiflag != 0 && Gametxidstr[0] != 0 )
|
if ( rs->guiflag != 0 && Gametxidstr[0] != 0 )
|
||||||
{
|
{
|
||||||
@@ -762,6 +763,11 @@ void rogue_progress(struct rogue_state *rs,int32_t waitflag,uint64_t seed,char *
|
|||||||
}
|
}
|
||||||
free(rs->keystrokeshex), rs->keystrokeshex = 0;
|
free(rs->keystrokeshex), rs->keystrokeshex = 0;
|
||||||
}
|
}
|
||||||
|
if ( (pastkeys= rogue_keystrokesload(&numpastkeys,seed,1)) != 0 )
|
||||||
|
{
|
||||||
|
free(pastkeys);
|
||||||
|
}
|
||||||
|
|
||||||
for (i=0; i<num; i++)
|
for (i=0; i<num; i++)
|
||||||
sprintf(&hexstr[i<<1],"%02x",keystrokes[i]&0xff);
|
sprintf(&hexstr[i<<1],"%02x",keystrokes[i]&0xff);
|
||||||
hexstr[i<<1] = 0;
|
hexstr[i<<1] = 0;
|
||||||
|
|||||||
@@ -254,11 +254,10 @@ long get_filesize(FILE *fp)
|
|||||||
return(fsize);
|
return(fsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t rogue_replay(uint64_t seed,int32_t sleeptime)
|
char *rogue_keystrokesload(int32_t *numkeysp,uint64_t seed,int32_t counter)
|
||||||
{
|
{
|
||||||
FILE *fp; char fname[1024]; char *keystrokes = 0; long num=0,fsize; int32_t i,counter = 0; struct rogue_state *rs; struct rogue_player P,*player = 0;
|
char fname[1024],*keystrokes = 0; FILE *fp; long fsize; int32_t num = 0;
|
||||||
if ( seed == 0 )
|
*numkeysp = 0;
|
||||||
seed = 777;
|
|
||||||
while ( 1 )
|
while ( 1 )
|
||||||
{
|
{
|
||||||
roguefname(fname,seed,counter);
|
roguefname(fname,seed,counter);
|
||||||
@@ -275,19 +274,30 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime)
|
|||||||
{
|
{
|
||||||
fprintf(stderr,"error reallocating keystrokes\n");
|
fprintf(stderr,"error reallocating keystrokes\n");
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return(-1);
|
return(0);
|
||||||
}
|
}
|
||||||
if ( fread(&keystrokes[num],1,fsize,fp) != fsize )
|
if ( fread(&keystrokes[num],1,fsize,fp) != fsize )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"error reading keystrokes from (%s)\n",fname);
|
fprintf(stderr,"error reading keystrokes from (%s)\n",fname);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return(-1);
|
free(keystrokes);
|
||||||
|
return(0);
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
num += fsize;
|
num += fsize;
|
||||||
counter++;
|
counter++;
|
||||||
fprintf(stderr,"loaded %ld from (%s) total %ld\n",fsize,fname,num);
|
fprintf(stderr,"loaded %ld from (%s) total %d\n",fsize,fname,num);
|
||||||
}
|
}
|
||||||
|
*numkeysp = num;
|
||||||
|
return(keystrokes);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t rogue_replay(uint64_t seed,int32_t sleeptime)
|
||||||
|
{
|
||||||
|
FILE *fp; char fname[1024]; char *keystrokes = 0; long fsize; int32_t i,num=0,counter = 0; struct rogue_state *rs; struct rogue_player P,*player = 0;
|
||||||
|
if ( seed == 0 )
|
||||||
|
seed = 777;
|
||||||
|
keystrokes = rogue_keystrokesload(&num,seed,counter);
|
||||||
if ( num > 0 )
|
if ( num > 0 )
|
||||||
{
|
{
|
||||||
sprintf(fname,"rogue.%llu.player",(long long)seed);
|
sprintf(fname,"rogue.%llu.player",(long long)seed);
|
||||||
@@ -301,7 +311,6 @@ int32_t rogue_replay(uint64_t seed,int32_t sleeptime)
|
|||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
rogue_replay2(0,seed,keystrokes,num,player,sleeptime);
|
rogue_replay2(0,seed,keystrokes,num,player,sleeptime);
|
||||||
|
|
||||||
mvaddstr(LINES - 2, 0, (char *)"replay completed");
|
mvaddstr(LINES - 2, 0, (char *)"replay completed");
|
||||||
endwin();
|
endwin();
|
||||||
my_exit(0);
|
my_exit(0);
|
||||||
|
|||||||
@@ -978,16 +978,18 @@ char *rogue_extractgame(int32_t makefiles,char *str,int32_t *numkeysp,std::vecto
|
|||||||
}
|
}
|
||||||
if ( endP.gold <= 0 || endP.hitpoints <= 0 || (endP.strength&0xffff) <= 0 || endP.level <= 0 || endP.experience <= 0 || endP.dungeonlevel <= 0 )
|
if ( endP.gold <= 0 || endP.hitpoints <= 0 || (endP.strength&0xffff) <= 0 || endP.level <= 0 || endP.experience <= 0 || endP.dungeonlevel <= 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"zero value character was killed -> no playerdata\n");
|
sprintf(str,"zero value character was killed -> no playerdata\n");
|
||||||
newdata.resize(0);
|
newdata.resize(0);
|
||||||
//P.gold = (P.gold * 8) / 10;
|
*numkeysp = numkeys;
|
||||||
|
return(keystrokes);
|
||||||
|
/* P.gold = (P.gold * 8) / 10;
|
||||||
if ( keystrokes != 0 )
|
if ( keystrokes != 0 )
|
||||||
{
|
{
|
||||||
free(keystrokes);
|
free(keystrokes);
|
||||||
keystrokes = 0;
|
keystrokes = 0;
|
||||||
*numkeysp = 0;
|
*numkeysp = 0;
|
||||||
return(keystrokes);
|
return(keystrokes);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1466,7 +1468,7 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
|
|||||||
funcid = script[1];
|
funcid = script[1];
|
||||||
if ( (e= script[0]) == EVAL_TOKENS )
|
if ( (e= script[0]) == EVAL_TOKENS )
|
||||||
{
|
{
|
||||||
tokentx = 1;
|
tokentx = funcid;
|
||||||
if ( (funcid= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) == 0 )
|
if ( (funcid= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) == 0 )
|
||||||
{
|
{
|
||||||
if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) == 0 )
|
if ( (funcid= rogue_registeropretdecode(gametxid,tokenid,playertxid,scriptPubKey)) == 0 )
|
||||||
@@ -1515,14 +1517,15 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
|
|||||||
return(true);
|
return(true);
|
||||||
break;
|
break;
|
||||||
case 'H': case 'Q':
|
case 'H': case 'Q':
|
||||||
if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) != funcid )
|
/*if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) != funcid )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"height.%d couldnt decode H/Q opret\n",height);
|
//fprintf(stderr,"height.%d couldnt decode H/Q opret\n",height);
|
||||||
//if ( height > 20000 )
|
//if ( height > 20000 )
|
||||||
return eval->Invalid("couldnt decode H/Q opret");
|
return eval->Invalid("couldnt decode H/Q opret");
|
||||||
}
|
}
|
||||||
|
fprintf(stderr,"height.%d decoded H/Q opret\n",height);
|
||||||
// spending the baton proves it is the user if the pk is the signer
|
// spending the baton proves it is the user if the pk is the signer
|
||||||
// rest of validation is done below
|
// rest of validation is done below*/
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return eval->Invalid("illegal rogue non-decoded funcid");
|
return eval->Invalid("illegal rogue non-decoded funcid");
|
||||||
@@ -1536,19 +1539,30 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
|
|||||||
return(true);
|
return(true);
|
||||||
case 'H': // win
|
case 'H': // win
|
||||||
case 'Q': // bailout
|
case 'Q': // bailout
|
||||||
// verify pk belongs to this tx
|
if ( (f= rogue_highlanderopretdecode(gametxid,tokenid,regslot,pk,playerdata,symbol,pname,scriptPubKey)) != funcid )
|
||||||
if ( playerdata.size() > 0 )
|
|
||||||
{
|
{
|
||||||
|
//fprintf(stderr,"height.%d couldnt decode H/Q opret\n",height);
|
||||||
|
//if ( height > 20000 )
|
||||||
|
return eval->Invalid("couldnt decode H/Q opret");
|
||||||
|
}
|
||||||
|
// verify pk belongs to this tx
|
||||||
|
if ( tokentx == 'c' && playerdata.size() > 0 )
|
||||||
|
{
|
||||||
|
static char laststr[512]; char cashstr[512];
|
||||||
if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 )
|
if ( rogue_playerdata_validate(&cashout,ptxid,cp,playerdata,gametxid,pk) < 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size());
|
sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d gametxid.%s player.%s invalid playerdata[%d]\n",tokentx,decoded,height,gametxid.GetHex().c_str(),ptxid.GetHex().c_str(),(int32_t)playerdata.size());
|
||||||
|
if ( strcmp(laststr,cashstr) != 0 )
|
||||||
|
{
|
||||||
|
strcpy(laststr,cashstr);
|
||||||
|
fprintf(stderr,"%s\n",cashstr);
|
||||||
|
}
|
||||||
|
if ( enabled != 0 )
|
||||||
|
return eval->Invalid("mismatched playerdata");
|
||||||
}
|
}
|
||||||
if ( funcid == 'H' )
|
if ( funcid == 'H' )
|
||||||
cashout *= 2;
|
cashout *= 2;
|
||||||
if ( tx.vout.size() > 3 ) // orig of 't' has 0 cashout
|
sprintf(cashstr,"tokentx.(%c) decoded.%d ht.%d txid.%s %.8f vs vout2 %.8f",tokentx,decoded,height,txid.GetHex().c_str(),(double)cashout/COIN,(double)tx.vout[2].nValue/COIN);
|
||||||
{
|
|
||||||
static char laststr[512]; char cashstr[512];
|
|
||||||
sprintf(cashstr,"ht.%d txid.%s %d,%d %.8f vs vout2 %.8f",height,txid.GetHex().c_str(),tokentx,decoded,(double)cashout/COIN,(double)tx.vout[2].nValue/COIN);
|
|
||||||
if ( strcmp(laststr,cashstr) != 0 )
|
if ( strcmp(laststr,cashstr) != 0 )
|
||||||
{
|
{
|
||||||
strcpy(laststr,cashstr);
|
strcpy(laststr,cashstr);
|
||||||
@@ -1557,7 +1571,6 @@ bool rogue_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C
|
|||||||
if ( enabled != 0 && tx.vout[2].nValue != cashout )
|
if ( enabled != 0 && tx.vout[2].nValue != cashout )
|
||||||
return eval->Invalid("mismatched cashout amount");
|
return eval->Invalid("mismatched cashout amount");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if ( funcid == 'Q' )
|
if ( funcid == 'Q' )
|
||||||
{
|
{
|
||||||
// verify vin/vout
|
// verify vin/vout
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
#define KOMODO_MAXNVALUE (((uint64_t)1 << 63) - 1)
|
#define KOMODO_MAXNVALUE (((uint64_t)1 << 63) - 1)
|
||||||
#define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63))
|
#define KOMODO_BIT63SET(x) ((x) & ((uint64_t)1 << 63))
|
||||||
#define KOMODO_VALUETOOBIG(x) ((x) > (uint64_t)10000000000*COIN)
|
#define KOMODO_VALUETOOBIG(x) ((x) > (uint64_t)10000000001*COIN)
|
||||||
|
|
||||||
extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC;
|
extern uint8_t ASSETCHAINS_TXPOW,ASSETCHAINS_PUBLIC;
|
||||||
int32_t MAX_BLOCK_SIZE(int32_t height);
|
int32_t MAX_BLOCK_SIZE(int32_t height);
|
||||||
|
|||||||
10
src/main.cpp
10
src/main.cpp
@@ -3373,8 +3373,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
int64_t nTimeStart = GetTimeMicros();
|
int64_t nTimeStart = GetTimeMicros();
|
||||||
CAmount nFees = 0;
|
CAmount nFees = 0;
|
||||||
int nInputs = 0;
|
int nInputs = 0;
|
||||||
uint64_t voutsum = 0,prevsum=0,valueout;
|
uint64_t valueout;
|
||||||
int64_t interest,sum = 0;
|
int64_t voutsum = 0,prevsum=0,interest,sum = 0;
|
||||||
unsigned int nSigOps = 0;
|
unsigned int nSigOps = 0;
|
||||||
CDiskTxPos pos(pindex->GetBlockPos(), GetSizeOfCompactSize(block.vtx.size()));
|
CDiskTxPos pos(pindex->GetBlockPos(), GetSizeOfCompactSize(block.vtx.size()));
|
||||||
std::vector<std::pair<uint256, CDiskTxPos> > vPos;
|
std::vector<std::pair<uint256, CDiskTxPos> > vPos;
|
||||||
@@ -3501,12 +3501,13 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
}
|
}
|
||||||
prevsum = voutsum;
|
prevsum = voutsum;
|
||||||
voutsum += valueout;
|
voutsum += valueout;
|
||||||
if ( KOMODO_VALUETOOBIG(voutsum) != 0 )
|
/*if ( KOMODO_VALUETOOBIG(voutsum) != 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"voutsum %.8f too big\n",(double)voutsum/COIN);
|
fprintf(stderr,"voutsum %.8f too big\n",(double)voutsum/COIN);
|
||||||
return state.DoS(100, error("ConnectBlock(): voutsum too big"),REJECT_INVALID,"tx valueout is too big");
|
return state.DoS(100, error("ConnectBlock(): voutsum too big"),REJECT_INVALID,"tx valueout is too big");
|
||||||
}
|
}
|
||||||
else if ( voutsum < prevsum )
|
else*/
|
||||||
|
if ( voutsum < prevsum )
|
||||||
return state.DoS(100, error("ConnectBlock(): voutsum less after adding valueout"),REJECT_INVALID,"tx valueout is too big");
|
return state.DoS(100, error("ConnectBlock(): voutsum less after adding valueout"),REJECT_INVALID,"tx valueout is too big");
|
||||||
if (!tx.IsCoinBase())
|
if (!tx.IsCoinBase())
|
||||||
{
|
{
|
||||||
@@ -4276,6 +4277,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
|
|||||||
ASSETCHAINS_SYMBOL,pindexFork->phashBlock->GetHex(), pindexFork->GetHeight()) + "\n\n" +
|
ASSETCHAINS_SYMBOL,pindexFork->phashBlock->GetHex(), pindexFork->GetHeight()) + "\n\n" +
|
||||||
_("Please help, human!");
|
_("Please help, human!");
|
||||||
LogPrintf("*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg,reorgLength+10);
|
LogPrintf("*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg,reorgLength+10);
|
||||||
|
fprintf(stderr,"*** %s\nif you launch with -maxreorg=%d it might be able to resolve this automatically", msg.c_str(),reorgLength+10);
|
||||||
uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR);
|
uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR);
|
||||||
StartShutdown();
|
StartShutdown();
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user