Merge pull request #1243 from dimxy/non-existing-eval-fix-sq
check for non-existing eval
This commit is contained in:
@@ -270,7 +270,7 @@ UniValue ValueFromAmount(const CAmount& amount);
|
|||||||
#define CCLOG_DEBUG3 3
|
#define CCLOG_DEBUG3 3
|
||||||
#define CCLOG_MAXLEVEL 3
|
#define CCLOG_MAXLEVEL 3
|
||||||
template <class T>
|
template <class T>
|
||||||
inline void CCLogPrintStream(const char *category, int level, T print_to_stream)
|
void CCLogPrintStream(const char *category, int level, T print_to_stream)
|
||||||
{
|
{
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
print_to_stream(stream);
|
print_to_stream(stream);
|
||||||
@@ -279,12 +279,13 @@ inline void CCLogPrintStream(const char *category, int level, T print_to_stream)
|
|||||||
if (level > CCLOG_MAXLEVEL)
|
if (level > CCLOG_MAXLEVEL)
|
||||||
level = CCLOG_MAXLEVEL;
|
level = CCLOG_MAXLEVEL;
|
||||||
for (int i = level; i <= CCLOG_MAXLEVEL; i++)
|
for (int i = level; i <= CCLOG_MAXLEVEL; i++)
|
||||||
if (LogAcceptCategory((std::string(category) + (i > 0 ? std::string("-") + std::to_string(i) : std::string(""))).c_str())) {
|
if( LogAcceptCategory((std::string(category) + std::string("-") + std::to_string(i)).c_str()) || // '-debug=cctokens-0', '-debug=cctokens-1',...
|
||||||
|
i == 0 && LogAcceptCategory(std::string(category).c_str()) ) { // also supporting '-debug=cctokens' for CCLOG_INFO
|
||||||
LogPrintStr(stream.str());
|
LogPrintStr(stream.str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// use: LOGSTREAM("yourcategory", your-debug-level, stream << "some log data" << data2 << data3 << ... << std::endl);
|
||||||
#define LOGSTREAM(category, level, logoperator) CCLogPrintStream( category, level, [=](std::ostringstream &stream) {logoperator;} )
|
#define LOGSTREAM(category, level, logoperator) CCLogPrintStream( category, level, [=](std::ostringstream &stream) {logoperator;} )
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ bool TokensValidate(struct CCcontract_info *cp, Eval* eval, const CTransaction &
|
|||||||
if ((funcid = DecodeTokenOpRet(tx.vout[numvouts - 1].scriptPubKey, evalCodeInOpret, tokenid, voutTokenPubkeys, vopretExtra)) == 0)
|
if ((funcid = DecodeTokenOpRet(tx.vout[numvouts - 1].scriptPubKey, evalCodeInOpret, tokenid, voutTokenPubkeys, vopretExtra)) == 0)
|
||||||
return eval->Invalid("TokenValidate: invalid opreturn payload");
|
return eval->Invalid("TokenValidate: invalid opreturn payload");
|
||||||
|
|
||||||
LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "TokensValidate funcId=" << (char)(funcid?funcid:' ') << " evalcode=" << cp->evalcode << std::endl);
|
LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "TokensValidate funcId=" << (char)(funcid?funcid:' ') << " evalcode=" << std::hex << (int)cp->evalcode << std::endl);
|
||||||
|
|
||||||
if (eval->GetTxUnconfirmed(tokenid, createTx, hashBlock) == 0)
|
if (eval->GetTxUnconfirmed(tokenid, createTx, hashBlock) == 0)
|
||||||
return eval->Invalid("cant find token create txid");
|
return eval->Invalid("cant find token create txid");
|
||||||
|
|||||||
@@ -687,6 +687,9 @@ bool ProcessCC(struct CCcontract_info *cp,Eval* eval, std::vector<uint8_t> param
|
|||||||
from_mempool = 1;
|
from_mempool = 1;
|
||||||
height &= ((1<<30) - 1);
|
height &= ((1<<30) - 1);
|
||||||
}
|
}
|
||||||
|
if (cp->validate == NULL)
|
||||||
|
return eval->Invalid("validation not supported for eval code");
|
||||||
|
|
||||||
//fprintf(stderr,"KOMODO_CONNECTING.%d mempool.%d vs CCactive.%d\n",height,from_mempool,KOMODO_CCACTIVATE);
|
//fprintf(stderr,"KOMODO_CONNECTING.%d mempool.%d vs CCactive.%d\n",height,from_mempool,KOMODO_CCACTIVATE);
|
||||||
// there is a chance CC tx is valid in mempool, but invalid when in block, so we cant filter duplicate requests. if any of the vins are spent, for example
|
// there is a chance CC tx is valid in mempool, but invalid when in block, so we cant filter duplicate requests. if any of the vins are spent, for example
|
||||||
//txid = ctx.GetHash();
|
//txid = ctx.GetHash();
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ bool Eval::Dispatch(const CC *cond, const CTransaction &txTo, unsigned int nIn)
|
|||||||
CCinit(cp,ecode);
|
CCinit(cp,ecode);
|
||||||
cp->didinit = 1;
|
cp->didinit = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( ecode )
|
switch ( ecode )
|
||||||
{
|
{
|
||||||
case EVAL_IMPORTPAYOUT:
|
case EVAL_IMPORTPAYOUT:
|
||||||
|
|||||||
Reference in New Issue
Block a user