Merge branch 'beta' into dev

This commit is contained in:
jl777
2019-06-10 05:16:17 -11:00
7 changed files with 71 additions and 36 deletions

View File

@@ -59,6 +59,8 @@ one other technical note is that komodod has the insight-explorer extensions bui
#define SMALLVAL 0.000000000000001
#define SATOSHIDEN ((uint64_t)100000000L)
#define dstr(x) ((double)(x) / SATOSHIDEN)
#define CCDISABLEALL memset(ASSETCHAINS_CCDISABLES,1,sizeof(ASSETCHAINS_CCDISABLES))
#define CCENABLE(x) ASSETCHAINS_CCDISABLES[((uint8_t)x)] = 0
#ifndef _BITS256
#define _BITS256

View File

@@ -78,8 +78,13 @@ bool Eval::Dispatch(const CC *cond, const CTransaction &txTo, unsigned int nIn)
uint8_t ecode = cond->code[0];
if ( ASSETCHAINS_CCDISABLES[ecode] != 0 )
{
fprintf(stderr,"%s evalcode.%d %02x\n",txTo.GetHash().GetHex().c_str(),ecode,ecode);
return Invalid("disabled-code, -ac_ccenables didnt include this ecode");
// check if a height activation has been set.
if ( mapHeightEvalActivate[ecode] == 0 || this->GetCurrentHeight() == 0 || mapHeightEvalActivate[ecode] > this->GetCurrentHeight() )
{
fprintf(stderr,"%s evalcode.%d %02x\n",txTo.GetHash().GetHex().c_str(),ecode,ecode);
fprintf(stderr, "ac_ccactivateht: evalcode.%i activates at height.%i vs current height.%i\n", ecode, mapHeightEvalActivate[ecode], this->GetCurrentHeight());
return Invalid("disabled-code, -ac_ccenables didnt include this ecode");
}
}
std::vector<uint8_t> vparams(cond->code+1, cond->code+cond->codeLength);
if ( ecode >= EVAL_FIRSTUSER && ecode <= EVAL_LASTUSER )

View File

@@ -642,11 +642,7 @@ int32_t GetLatestTimestamp(int32_t height)
blockHash = chainActive[height]->GetBlockHash();
pindex = mapBlockIndex[blockHash];
if ( komodo_blockload(block,pindex) == 0 )
{
return(block.nTime);
}
return(0);
return(pindex->nTime);
}
bool OraclesValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn)
@@ -1208,4 +1204,3 @@ UniValue OraclesList()
}
return(result);
}

View File

@@ -303,6 +303,7 @@ extern int32_t KOMODO_TESTNODE, KOMODO_SNAPSHOT_INTERVAL;
extern int32_t ASSETCHAINS_EARLYTXIDCONTRACT;
int tx_height( const uint256 &hash );
extern std::vector<std::string> vWhiteListAddress;
extern std::map <std::int8_t, int32_t> mapHeightEvalActivate;
void komodo_netevent(std::vector<uint8_t> payload);
int32_t getacseason(uint32_t timestamp);
@@ -333,6 +334,7 @@ uint32_t komodo_heightstamp(int32_t height);
int64_t komodo_pricemult(int32_t ind);
int32_t komodo_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblocks);
uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight);
int32_t komodo_currentheight();
#endif

View File

@@ -115,6 +115,8 @@ int32_t KOMODO_TESTNODE, KOMODO_SNAPSHOT_INTERVAL;
CScript KOMODO_EARLYTXID_SCRIPTPUB;
int32_t ASSETCHAINS_EARLYTXIDCONTRACT;
std::map <std::int8_t, int32_t> mapHeightEvalActivate;
struct komodo_kv *KOMODO_KV;
pthread_mutex_t KOMODO_KV_mutex,KOMODO_CC_mutex;

View File

@@ -14,6 +14,7 @@
******************************************************************************/
#include "komodo_defs.h"
#include "key_io.h"
#include "cc/CCinclude.h"
#include <string.h>
#ifdef _WIN32
@@ -1691,7 +1692,7 @@ int8_t equihash_params_possible(uint64_t n, uint64_t k)
void komodo_args(char *argv0)
{
std::string name,addn,hexstr,symbol; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[32756],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz=0,baseid,len,n,extralen = 0; uint64_t ccenables[256];
std::string name,addn,hexstr,symbol; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[32756],disablebits[32],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,nonz=0,baseid,len,n,extralen = 0; uint64_t ccenables[256], ccEnablesHeight[512];
IS_KOMODO_NOTARY = GetBoolArg("-notary", false);
IS_STAKED_NOTARY = GetArg("-stakednotary", -1);
memset(ccenables,0,sizeof(ccenables));
@@ -1756,6 +1757,27 @@ void komodo_args(char *argv0)
ASSETCHAINS_PRIVATE = GetArg("-ac_private",0);
KOMODO_SNAPSHOT_INTERVAL = GetArg("-ac_snapshot",0);
Split(GetArg("-ac_nk",""), ASSETCHAINS_NK, 0);
// -ac_ccactivateht=evalcode,height,evalcode,height,evalcode,height....
Split(GetArg("-ac_ccactivateht",""), ccEnablesHeight, 0);
// fill map with all eval codes and activation height of 0.
for ( int i = 0; i < 256; i++ )
mapHeightEvalActivate[i] = 0;
for ( int i = 0; i < 512; i++ )
{
int32_t ecode = ccEnablesHeight[i];
int32_t ht = ccEnablesHeight[i+1];
if ( ecode > 256 )
fprintf(stderr, "ac_ccactivateht: invalid evalcode.%i must be between 0 and 256.\n", ecode);
else if ( ht > 0 )
{
// update global map.
mapHeightEvalActivate[ecode] = ht;
fprintf(stderr, "ac_ccactivateht: ecode.%i activates at height.%i\n", ecode, mapHeightEvalActivate[ecode]);
}
i++;
}
if ( (KOMODO_REWIND= GetArg("-rewind",0)) != 0 )
{
printf("KOMODO_REWIND %d\n",KOMODO_REWIND);
@@ -2299,60 +2321,62 @@ void komodo_args(char *argv0)
// Set cc enables for all existing ac_cc chains here.
if ( strcmp("AXO",ASSETCHAINS_SYMBOL) == 0 )
{
// No CCs used on this chain yet please ask AXO777 what he needs.
memset(ASSETCHAINS_CCDISABLES,1,sizeof(ASSETCHAINS_CCDISABLES));
// No CCs used on this chain yet.
CCDISABLEALL;
}
if ( strcmp("CCL",ASSETCHAINS_SYMBOL) == 0 )
{
// No CCs used on this chain yet.
memset(ASSETCHAINS_CCDISABLES,1,sizeof(ASSETCHAINS_CCDISABLES));
CCDISABLEALL;
}
if ( strcmp("COQUI",ASSETCHAINS_SYMBOL) == 0 )
{
memset(ASSETCHAINS_CCDISABLES,1,sizeof(ASSETCHAINS_CCDISABLES));
ASSETCHAINS_CCDISABLES[230] = 0; // DICE
ASSETCHAINS_CCDISABLES[235] = 0; // CHANNELS
ASSETCHAINS_CCDISABLES[236] = 0; // ORACLES
ASSETCHAINS_CCDISABLES[227] = 0; // ASSETS
ASSETCHAINS_CCDISABLES[242] = 0; // TOKENS
CCDISABLEALL;
CCENABLE(EVAL_DICE);
CCENABLE(EVAL_CHANNELS);
CCENABLE(EVAL_ORACLES);
CCENABLE(EVAL_ASSETS);
CCENABLE(EVAL_TOKENS);
}
if ( strcmp("DION",ASSETCHAINS_SYMBOL) == 0 )
{
// No CCs used on this chain yet.
memset(ASSETCHAINS_CCDISABLES,1,sizeof(ASSETCHAINS_CCDISABLES));
CCDISABLEALL;
}
if ( strcmp("EQL",ASSETCHAINS_SYMBOL) == 0 )
{
// No CCs used on this chain yet.
memset(ASSETCHAINS_CCDISABLES,1,sizeof(ASSETCHAINS_CCDISABLES));
CCDISABLEALL;
}
if ( strcmp("ILN",ASSETCHAINS_SYMBOL) == 0 )
{
// No CCs used on this chain yet.
memset(ASSETCHAINS_CCDISABLES,1,sizeof(ASSETCHAINS_CCDISABLES));
CCDISABLEALL;
}
if ( strcmp("MORTY",ASSETCHAINS_SYMBOL) == 0 )
if ( strcmp("OUR",ASSETCHAINS_SYMBOL) == 0 )
{
memset(ASSETCHAINS_CCDISABLES,1,sizeof(ASSETCHAINS_CCDISABLES));
ASSETCHAINS_CCDISABLES[228] = 0; // FAUCET
// No CCs used on this chain yet.
CCDISABLEALL;
}
if ( strcmp("RICK",ASSETCHAINS_SYMBOL) == 0 )
if ( strcmp("ZEXO",ASSETCHAINS_SYMBOL) == 0 )
{
memset(ASSETCHAINS_CCDISABLES,1,sizeof(ASSETCHAINS_CCDISABLES));
ASSETCHAINS_CCDISABLES[228] = 1; // FAUCET
// No CCs used on this chain yet.
CCDISABLEALL;
}
if ( strcmp("SEC",ASSETCHAINS_SYMBOL) == 0 )
{
memset(ASSETCHAINS_CCDISABLES,1,sizeof(ASSETCHAINS_CCDISABLES));
ASSETCHAINS_CCDISABLES[227] = 0; // ASSETS
ASSETCHAINS_CCDISABLES[242] = 0; // TOKENS
CCDISABLEALL;
CCENABLE(EVAL_ASSETS);
CCENABLE(EVAL_TOKENS);
CCENABLE(EVAL_ORACLES);
}
if ( strcmp("KMDICE",ASSETCHAINS_SYMBOL) == 0 )
{
memset(ASSETCHAINS_CCDISABLES,1,sizeof(ASSETCHAINS_CCDISABLES));
ASSETCHAINS_CCDISABLES[228] = 0; // FAUCET
ASSETCHAINS_CCDISABLES[230] = 0; // DICE
ASSETCHAINS_CCDISABLES[236] = 0; // ORACLES
CCDISABLEALL;
CCENABLE(EVAL_FAUCET);
CCENABLE(EVAL_DICE);
CCENABLE(EVAL_ORACLES);
}
} else BITCOIND_RPCPORT = GetArg("-rpcport", BaseParams().RPCPort());
KOMODO_DPOWCONFS = GetArg("-dpowconfs",dpowconfs);

View File

@@ -5342,8 +5342,13 @@ int32_t ensure_CCrequirements(uint8_t evalcode)
CCerror = "";
if ( ASSETCHAINS_CCDISABLES[evalcode] != 0 || (evalcode == EVAL_MARMARA && ASSETCHAINS_MARMARA == 0) )
{
fprintf(stderr,"evalcode %d disabled\n",evalcode);
return(-1);
// check if a height activation has been set.
fprintf(stderr, "evalcode.%i activates at height. %i current height.%i\n", evalcode, mapHeightEvalActivate[evalcode], komodo_currentheight());
if ( mapHeightEvalActivate[evalcode] == 0 || komodo_currentheight() == 0 || mapHeightEvalActivate[evalcode] > komodo_currentheight() )
{
fprintf(stderr,"evalcode %d disabled\n",evalcode);
return(-1);
}
}
if ( NOTARY_PUBKEY33[0] == 0 )
{