Cheatcatcher tests to remove and change to max sequential POS
This commit is contained in:
@@ -85,7 +85,7 @@ bool CCheatList::IsCheatInList(const CTransaction &tx, CTransaction *cheatTx)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCheatList::Add(CTxHolder &txh)
|
bool CCheatList::Add(const CTxHolder &txh)
|
||||||
{
|
{
|
||||||
if (NetworkUpgradeActive(txh.height, Params().GetConsensus(), Consensus::UPGRADE_SAPLING))
|
if (NetworkUpgradeActive(txh.height, Params().GetConsensus(), Consensus::UPGRADE_SAPLING))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class CCheatList
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add a potential cheat transaction to the list. we do this for all stake transactions from orphaned stakes
|
// 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
|
// remove a transaction from the the list
|
||||||
void Remove(const CTxHolder &txh);
|
void Remove(const CTxHolder &txh);
|
||||||
|
|||||||
10
src/pow.cpp
10
src/pow.cpp
@@ -275,7 +275,15 @@ uint32_t lwmaGetNextPOSRequired(const CBlockIndex* pindexLast, const Consensus::
|
|||||||
if ((j - i) >= VERUS_CONSECUTIVE_POS_THRESHOLD)
|
if ((j - i) >= VERUS_CONSECUTIVE_POS_THRESHOLD)
|
||||||
{
|
{
|
||||||
// if this is real time, return zero
|
// 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
|
// target of 0 (virtually impossible), if we hit max consecutive POS blocks
|
||||||
nextTarget.SetCompact(0);
|
nextTarget.SetCompact(0);
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ uint32_t komodo_segid32(char *coinaddr);
|
|||||||
int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height);
|
int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height);
|
||||||
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp);
|
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp);
|
||||||
#define KOMODO_VERSION "0.2.1"
|
#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 uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
|
||||||
extern uint32_t ASSETCHAINS_CC;
|
extern uint32_t ASSETCHAINS_CC;
|
||||||
extern uint32_t ASSETCHAINS_MAGIC;
|
extern uint32_t ASSETCHAINS_MAGIC;
|
||||||
|
|||||||
@@ -1420,6 +1420,10 @@ int32_t CWallet::VerusStakeTransaction(CBlock *pBlock, CMutableTransaction &txNe
|
|||||||
else
|
else
|
||||||
return 0;
|
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 we are staking with the extended format, add the opreturn data required
|
||||||
//
|
//
|
||||||
if (extendedStake)
|
if (extendedStake)
|
||||||
@@ -1436,10 +1440,31 @@ int32_t CWallet::VerusStakeTransaction(CBlock *pBlock, CMutableTransaction &txNe
|
|||||||
if ((pSrcIndex = mapBlockIndex[srcBlock]) == 0)
|
if ((pSrcIndex = mapBlockIndex[srcBlock]) == 0)
|
||||||
return 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
|
txOut1.scriptPubKey << OP_RETURN
|
||||||
<< CStakeParams(pSrcIndex->GetHeight(), tipindex->GetHeight() + 1, tipindex->GetBlockHash(), pk).AsVector();
|
<< 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;
|
nValue = txNew.vout[0].nValue = stakeSource.vout[voutNum].nValue - txfee;
|
||||||
|
|
||||||
txNew.nLockTime = 0;
|
txNew.nLockTime = 0;
|
||||||
@@ -2767,6 +2792,8 @@ void CWallet::ReacceptWalletTransactions()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<uint256> vwtxh;
|
||||||
|
|
||||||
// Try to add wallet transactions to memory pool
|
// Try to add wallet transactions to memory pool
|
||||||
BOOST_FOREACH(PAIRTYPE(const int64_t, CWalletTx*)& item, mapSorted)
|
BOOST_FOREACH(PAIRTYPE(const int64_t, CWalletTx*)& item, mapSorted)
|
||||||
{
|
{
|
||||||
@@ -2786,11 +2813,14 @@ void CWallet::ReacceptWalletTransactions()
|
|||||||
if (!wtx.IsCoinBase() && invalid && nDoS > 0)
|
if (!wtx.IsCoinBase() && invalid && nDoS > 0)
|
||||||
{
|
{
|
||||||
LogPrintf("erasing transaction\n");
|
LogPrintf("erasing transaction\n");
|
||||||
//printf("erasing transaction\n");
|
vwtxh.push_back(wtx.GetHash());
|
||||||
EraseFromWallets(wtx.GetHash());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (auto hash : vwtxh)
|
||||||
|
{
|
||||||
|
EraseFromWallet(hash);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CWalletTx::RelayWalletTransaction()
|
bool CWalletTx::RelayWalletTransaction()
|
||||||
|
|||||||
Reference in New Issue
Block a user