From ec8a120b4d16d6408c67993b7215eb341483c9c0 Mon Sep 17 00:00:00 2001 From: miketout Date: Sat, 13 Oct 2018 22:49:45 -0700 Subject: [PATCH] Cleanup, comment out test code, prepare for release PR --- src/cc/CCcustom.cpp | 13 ++++++------ src/cc/StakeGuard.cpp | 6 ++++++ src/cc/StakeGuard.h | 2 ++ src/cheatcatcher.cpp | 2 +- src/komodo_gateway.h | 4 ++-- src/miner.cpp | 5 +++-- src/primitives/nonce.cpp | 4 ---- src/wallet/wallet.cpp | 45 ++++++++++++++++++++-------------------- 8 files changed, 43 insertions(+), 38 deletions(-) diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index e60f66acf..ae9188eea 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -13,6 +13,7 @@ * * ******************************************************************************/ +#include "key_io.h" #include "CCinclude.h" #include "CCassets.h" #include "CCfaucet.h" @@ -56,7 +57,7 @@ // to create a new CCaddr, add to rpcwallet the CCaddress and start with -pubkey= with the pubkey of the new address, with its wif already imported. set normaladdr and CChexstr. run CCaddress and it will print the privkey along with autocorrect the CCaddress. which should then update the CCaddr here // StakeGuard - nothing at stake -std::string StakeGuardaddr = "RCG8KwJNDVwpUBcdoa6AoHqHVJsA1uMYMR"; +std::string StakeGuardAddr = "RCG8KwJNDVwpUBcdoa6AoHqHVJsA1uMYMR"; std::string StakeGuardPubKey = "03166b7813a4855a88e9ef7340a692ef3c2decedfdc2c7563ec79537e89667d935"; std::string StakeGuardWIF = "Uw7vRYHGKjyi1FaJ8Lv1USSuj7ntUti8fAhSDiCdbzuV6yDagaTn"; @@ -233,12 +234,12 @@ struct CCcontract_info *CCinit(struct CCcontract_info *cp, uint8_t evalcode) switch ( evalcode ) { case EVAL_STAKEGUARD: - strcpy(cp->unspendableCCaddr,AssetsCCaddr); - strcpy(cp->normaladdr,AssetsNormaladdr); - strcpy(cp->CChexstr,AssetsCChexstr); - memcpy(cp->CCpriv,AssetsCCpriv,32); + strcpy(cp->unspendableCCaddr,StakeGuardAddr.c_str()); + strcpy(cp->normaladdr,StakeGuardAddr.c_str()); + strcpy(cp->CChexstr,StakeGuardPubKey.c_str()); + memcpy(cp->CCpriv,DecodeSecret(StakeGuardWIF).begin(),32); cp->validate = StakeGuardValidate; - cp->ismyvin = IsAssetsInput; + cp->ismyvin = IsStakeGuardInput; break; case EVAL_ASSETS: diff --git a/src/cc/StakeGuard.cpp b/src/cc/StakeGuard.cpp index 6d4ec999c..04669aa4d 100644 --- a/src/cc/StakeGuard.cpp +++ b/src/cc/StakeGuard.cpp @@ -431,6 +431,12 @@ bool StakeGuardValidate(struct CCcontract_info *cp, Eval* eval, const CTransacti else return true; } +bool IsStakeGuardInput(const CScript &scriptSig) +{ + printf("IsStakeGuardInput: not implemented"); + return false; +} + UniValue StakeGuardInfo() { UniValue result(UniValue::VOBJ); char numstr[64]; diff --git a/src/cc/StakeGuard.h b/src/cc/StakeGuard.h index 0149c618b..824d09efb 100644 --- a/src/cc/StakeGuard.h +++ b/src/cc/StakeGuard.h @@ -34,6 +34,8 @@ bool MakeCheatEvidence(CMutableTransaction &mtx, const CTransaction &ccTx, uint3 bool StakeGuardValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx, uint32_t nIn); +bool IsStakeGuardInput(const CScript &scriptSig); + UniValue StakeGuardInfo(); #endif diff --git a/src/cheatcatcher.cpp b/src/cheatcatcher.cpp index c48f80f1e..8cdfa9718 100644 --- a/src/cheatcatcher.cpp +++ b/src/cheatcatcher.cpp @@ -99,7 +99,7 @@ bool CCheatList::Add(const CTxHolder &txh) LOCK(cs_cheat); auto it = orderedCheatCandidates.insert(pair(txh.height, txh)); indexedCheatCandidates.insert(pair(txh.utxo, &it->second)); - printf("CCheatList::Add orderedCheatCandidates.size: %d, indexedCheatCandidates.size: %d\n", orderedCheatCandidates.size(), indexedCheatCandidates.size()); + //printf("CCheatList::Add orderedCheatCandidates.size: %d, indexedCheatCandidates.size: %d\n", (int)orderedCheatCandidates.size(), (int)indexedCheatCandidates.size()); } } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 16e165534..7e85d80fa 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -687,10 +687,10 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim } } } - // we don't want any of these checks in VRSC, leave it for other chains until/unless KMD removes + // we don't want these checks in VRSC, leave it at the Sapling upgrade if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_COMMISSION != 0 && height > 1) || - (strcmp(ASSETCHAINS_SYMBOL,"VRSC") == 0 && height < VRSC_SAPLING_UPGRADE) ) + NetworkUpgradeActive(height, Params().GetConsensus(), Consensus::UPGRADE_SAPLING) ) { n = block.vtx[0].vout.size(); int64_t val,prevtotal = 0; int32_t strangeout=0,overflow = 0; diff --git a/src/miner.cpp b/src/miner.cpp index 674d6540f..5fdaf9c0a 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -239,6 +239,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, // check if we should add cheat transaction CBlockIndex *ppast; + CTransaction cb; int cheatHeight = nHeight - COINBASE_MATURITY < 1 ? 1 : nHeight - COINBASE_MATURITY; if (cheatCatcher && sapling && chainActive.Height() > 100 && @@ -263,7 +264,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, extern CWallet *pwalletMain; LOCK(pwalletMain->cs_wallet); TransactionBuilder tb = TransactionBuilder(consensusParams, nHeight); - CTransaction cb = b.vtx[0]; + cb = b.vtx[0]; cbHash = cb.GetHash(); bool hasInput = false; @@ -314,7 +315,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount, std::list removed; mempool.removeConflicts(cheatSpend.value(), removed); printf("Found cheating stake! Adding cheat spend for %.8f at block #%d, coinbase tx\n%s\n", - (double)cheatSpend.value().vout[0].nValue / (double)COIN, nHeight, cheatSpend.value().vin[0].prevout.hash.GetHex().c_str()); + (double)cb.GetValueOut() / (double)COIN, nHeight, cheatSpend.value().vin[0].prevout.hash.GetHex().c_str()); } // now add transactions from the mem pool diff --git a/src/primitives/nonce.cpp b/src/primitives/nonce.cpp index 6ff258174..85cb7155a 100644 --- a/src/primitives/nonce.cpp +++ b/src/primitives/nonce.cpp @@ -15,8 +15,6 @@ bool CPOSNonce::NewPOSActive(int32_t height) { if ((strcmp(ASSETCHAINS_SYMBOL, "VRSC") == 0) && (height < (96480 + 100))) return false; - else if ((strcmp(ASSETCHAINS_SYMBOL, "VRSCTEST") == 0) && (height < (1000 + 100))) - return false; else return true; } @@ -25,8 +23,6 @@ bool CPOSNonce::NewNonceActive(int32_t height) { if ((strcmp(ASSETCHAINS_SYMBOL, "VRSC") == 0) && (height < 96480)) return false; - else if ((strcmp(ASSETCHAINS_SYMBOL, "VRSCTEST") == 0) && (height < 1000)) - return false; else return true; } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index e343648f6..6f38ba4d4 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1420,12 +1420,11 @@ 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 + // !! DISABLE THIS FOR RELEASE: THIS MAKES A CHEAT TRANSACTION FOR EVERY STAKE FOR TESTING + //CMutableTransaction cheat; + // !! DOWN TO HERE // if we are staking with the extended format, add the opreturn data required - // if (extendedStake) { uint256 srcBlock = uint256(); @@ -1440,30 +1439,30 @@ 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 + // !! DISABLE THIS FOR RELEASE: 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(); + // !! DOWN TO HERE txOut1.scriptPubKey << OP_RETURN << CStakeParams(pSrcIndex->GetHeight(), tipindex->GetHeight() + 1, tipindex->GetBlockHash(), pk).AsVector(); } - // TODO REMOVE THIS TOO - nValue = 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 + // !! DISABLE THIS FOR RELEASE: REMOVE THIS TOO + //nValue = 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)); + //} + // !! DOWN TO HERE nValue = txNew.vout[0].nValue = stakeSource.vout[voutNum].nValue - txfee; -- 2.42.0