Cheatcatcher tests to remove and change to max sequential POS

This commit is contained in:
miketout
2018-10-12 21:09:45 -07:00
parent a5d8fff5e5
commit 4326041663
5 changed files with 44 additions and 6 deletions

View File

@@ -85,7 +85,7 @@ bool CCheatList::IsCheatInList(const CTransaction &tx, CTransaction *cheatTx)
return false;
}
bool CCheatList::Add(CTxHolder &txh)
bool CCheatList::Add(const CTxHolder &txh)
{
if (NetworkUpgradeActive(txh.height, Params().GetConsensus(), Consensus::UPGRADE_SAPLING))
{

View File

@@ -70,7 +70,7 @@ class CCheatList
}
// add a potential cheat transaction to the list. we do this for all stake transactions from orphaned stakes
bool Add(CTxHolder &txh);
bool Add(const CTxHolder &txh);
// remove a transaction from the the list
void Remove(const CTxHolder &txh);

View File

@@ -275,7 +275,15 @@ uint32_t lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::
if ((j - i) >= VERUS_CONSECUTIVE_POS_THRESHOLD)
{
// if this is real time, return zero
if (j == (N - 1))
if ((strcmp(ASSETCHAINS_SYMBOL, "VRSC") == 0 &&
NetworkUpgradeActive(pindexLast->GetHeight(), params, Consensus::UPGRADE_SAPLING)) ||
(strcmp(ASSETCHAINS_SYMBOL, "VERUSTEST") == 0 && pindexLast->GetHeight() > 600))
{
// target of 0 (virtually impossible), if we hit max consecutive POS blocks
nextTarget.SetCompact(0);
return nextTarget.GetCompact();
}
else if (j == (N - 1))
{
// target of 0 (virtually impossible), if we hit max consecutive POS blocks
nextTarget.SetCompact(0);

View File

@@ -56,7 +56,7 @@ uint32_t komodo_segid32(char *coinaddr);
int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height);
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp);
#define KOMODO_VERSION "0.2.1"
#define VERUS_VERSION "0.3.2"
#define VERUS_VERSION "0.4.0"
extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
extern uint32_t ASSETCHAINS_CC;
extern uint32_t ASSETCHAINS_MAGIC;

View File

@@ -1420,6 +1420,10 @@ int32_t CWallet::VerusStakeTransaction(CBlock *pBlock, CMutableTransaction &txNe
else
return 0;
// TODO: REMOVE THIS: THIS MAKES A CHEAT TRANSACTION FOR EVERY STAKE FOR TESTING
CMutableTransaction cheat;
// UP TO HERE
// if we are staking with the extended format, add the opreturn data required
//
if (extendedStake)
@@ -1436,10 +1440,31 @@ int32_t CWallet::VerusStakeTransaction(CBlock *pBlock, CMutableTransaction &txNe
if ((pSrcIndex = mapBlockIndex[srcBlock]) == 0)
return 0;
// TODO: REMOVE THIS: THIS MAKES A CHEAT TRANSACTION FOR EVERY STAKE FOR TESTING
cheat = CMutableTransaction(txNew);
cheat.vout[1].scriptPubKey << OP_RETURN
<< CStakeParams(pSrcIndex->GetHeight(), tipindex->GetHeight() + 1, pSrcIndex->GetBlockHash(), pk).AsVector();
// REMOVE UP TO HERE
txOut1.scriptPubKey << OP_RETURN
<< CStakeParams(pSrcIndex->GetHeight(), tipindex->GetHeight() + 1, tipindex->GetBlockHash(), pk).AsVector();
}
// TODO REMOVE THIS TOO
cheat.vout[0].nValue = stakeSource.vout[voutNum].nValue - txfee;
cheat.nLockTime = 0;
CTransaction cheatConst(cheat);
SignatureData cheatSig;
if (!ProduceSignature(TransactionSignatureCreator(&keystore, &cheatConst, 0, nValue, SIGHASH_ALL), stakeSource.vout[voutNum].scriptPubKey, cheatSig, consensusBranchId))
fprintf(stderr,"failed to create cheat test signature\n");
else
{
uint8_t *ptr;
UpdateTransaction(cheat,0,cheatSig);
cheatList.Add(CTxHolder(CTransaction(cheat), tipindex->GetHeight() + 1));
}
// UP TO HERE
nValue = txNew.vout[0].nValue = stakeSource.vout[voutNum].nValue - txfee;
txNew.nLockTime = 0;
@@ -2767,6 +2792,8 @@ void CWallet::ReacceptWalletTransactions()
}
}
std::vector<uint256> vwtxh;
// Try to add wallet transactions to memory pool
BOOST_FOREACH(PAIRTYPE(const int64_t, CWalletTx*)& item, mapSorted)
{
@@ -2786,11 +2813,14 @@ void CWallet::ReacceptWalletTransactions()
if (!wtx.IsCoinBase() && invalid && nDoS > 0)
{
LogPrintf("erasing transaction\n");
//printf("erasing transaction\n");
EraseFromWallets(wtx.GetHash());
vwtxh.push_back(wtx.GetHash());
}
}
}
for (auto hash : vwtxh)
{
EraseFromWallet(hash);
}
}
bool CWalletTx::RelayWalletTransaction()