Fix negative height issues for pruning cheat lists

This commit is contained in:
miketout
2018-10-11 14:23:14 -07:00
parent 16ef4f1e3d
commit 1021455845
8 changed files with 28 additions and 22 deletions

View File

@@ -267,21 +267,6 @@ void *chainparams_commandline(void *ptr)
mainParams.consensus.nLwmaPOSAjustedWeight = 46531;
}
if (VERUS_CHEATCATCHER.size() == 77)
{
// if we are supposed to catch stake cheaters, there must be a valid sapling parameter, store the Sapling address here
extern boost::optional<libzcash::SaplingPaymentAddress> cheatCatcher;
libzcash::PaymentAddress addr = DecodePaymentAddress(mapArgs["-cheatcatcher"]);
if (IsValidPaymentAddress(addr))
{
cheatCatcher = boost::get<libzcash::SaplingPaymentAddress>(addr);
}
else
{
fprintf(stderr, "-cheatcatcher parameter is invalid Sapling payment address");
}
}
// only require coinbase protection on Verus from the Komodo family of coins
if (strcmp(ASSETCHAINS_SYMBOL,"VRSC") == 0)
{
@@ -734,6 +719,7 @@ bool SelectParamsFromCommandLine()
return false;
SelectParams(network);
return true;
}

View File

@@ -23,11 +23,11 @@ boost::optional<libzcash::SaplingPaymentAddress> cheatCatcher;
uint32_t CCheatList::Prune(uint32_t height)
{
uint32_t count;
uint32_t count = 0;
pair<multimap<const uint32_t, CTxHolder>::iterator, multimap<const uint32_t, CTxHolder>::iterator> range;
vector<CTxHolder *> toPrune;
if (NetworkUpgradeActive(height, Params().GetConsensus(), Consensus::UPGRADE_SAPLING))
if (height > 0 && NetworkUpgradeActive(height, Params().GetConsensus(), Consensus::UPGRADE_SAPLING))
{
LOCK(cs_cheat);
for (auto it = orderedCheatCandidates.begin(); it != orderedCheatCandidates.end() && it->second.height <= height; it--)

View File

@@ -38,6 +38,10 @@ UpgradeState NetworkUpgradeState(
const Consensus::Params& params,
Consensus::UpgradeIndex idx)
{
if (nHeight < 0)
{
printf("height: %d", nHeight);
}
assert(nHeight >= 0);
assert(idx >= Consensus::BASE_SPROUT && idx < Consensus::MAX_NETWORK_UPGRADES);
auto nActivationHeight = params.vUpgrades[idx].nActivationHeight;

View File

@@ -46,10 +46,9 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
int32_t KOMODO_MININGTHREADS = 0,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1;
int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1;
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY;
std::string VERUS_CHEATCATCHER, NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY;
uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE;
bool VERUS_MINTBLOCKS;
std::string VERUS_CHEATCATCHER;
char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096];
uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;

View File

@@ -1645,6 +1645,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight)
}
extern int64_t MAX_MONEY;
extern std::string VERUS_CHEATCATCHER;
void komodo_args(char *argv0)
{
@@ -1661,7 +1662,8 @@ void komodo_args(char *argv0)
else KOMODO_MININGTHREADS = 0;
VERUS_MINTBLOCKS = GetBoolArg("-mint", false);
VERUS_CHEATCATCHER = mapArgs["-cheatcatcher"].size();
VERUS_CHEATCATCHER = GetArg("-cheatcatcher", "");
if ( (KOMODO_EXCHANGEWALLET= GetBoolArg("-exchange", false)) != 0 )
fprintf(stderr,"KOMODO_EXCHANGEWALLET mode active\n");

View File

@@ -5005,7 +5005,8 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo
// when we succeed here, we prune all cheat candidates in the cheat list to 250 blocks ago, as they should be used or not
// useful by then
cheatList.Prune(height - 250);
if ((height - 250) > 1)
cheatList.Prune(height - 250);
return true;
}

View File

@@ -1876,6 +1876,20 @@ void static BitcoinMiner()
void GenerateBitcoins(bool fGenerate, int nThreads)
#endif
{
// if we are supposed to catch stake cheaters, there must be a valid sapling parameter, we need it at
// initialization, and this is the first time we can get it. store the Sapling address here
extern boost::optional<libzcash::SaplingPaymentAddress> cheatCatcher;
extern std::string VERUS_CHEATCATCHER;
libzcash::PaymentAddress addr = DecodePaymentAddress(VERUS_CHEATCATCHER);
if (VERUS_CHEATCATCHER.size() > 0 && IsValidPaymentAddress(addr))
{
cheatCatcher = boost::get<libzcash::SaplingPaymentAddress>(addr);
}
else
{
fprintf(stderr, "-cheatcatcher parameter is invalid Sapling payment address");
}
static boost::thread_group* minerThreads = NULL;
if (nThreads < 0)

View File

@@ -24,7 +24,7 @@ int32_t VERUS_BLOCK_POSUNITS = 1000;
int32_t ASSETCHAINS_OVERWINTER = 227520 - 120;
int32_t ASSETCHAINS_SAPLING = 227520;
boost::optional<libzcash::SaplingPaymentAddress> cheatCatcher;
std::string VERUS_CHEATCATCHER;
std::string VERUS_CHEATCATCHER = "";
unsigned int MAX_BLOCK_SIGOPS = 20000;