From 332e0361c77cdaaddbe08d0d23d5517aba0b887a Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 15 Jan 2019 15:46:02 +0300 Subject: [PATCH 1/8] Add checkbox to show only masternodes the wallet has keys for (#2627) --- src/qt/forms/masternodelist.ui | 10 +++++++++ src/qt/masternodelist.cpp | 37 ++++++++++++++++++++++++++++++++++ src/qt/masternodelist.h | 1 + 3 files changed, 48 insertions(+) diff --git a/src/qt/forms/masternodelist.ui b/src/qt/forms/masternodelist.ui index f479a608d..9f5ca2c41 100644 --- a/src/qt/forms/masternodelist.ui +++ b/src/qt/forms/masternodelist.ui @@ -356,6 +356,16 @@ + + + + Show only masternodes this wallet has keys for. + + + My masternodes only + + + diff --git a/src/qt/masternodelist.cpp b/src/qt/masternodelist.cpp index 1331025aa..9e0896b92 100644 --- a/src/qt/masternodelist.cpp +++ b/src/qt/masternodelist.cpp @@ -148,6 +148,17 @@ void MasternodeList::showContextMenuDIP3(const QPoint& point) if (item) contextMenuDIP3->exec(QCursor::pos()); } +static bool CheckWalletOwnsScript(const CScript& script) +{ + CTxDestination dest; + if (ExtractDestination(script, dest)) { + if ((boost::get(&dest) && pwalletMain->HaveKey(*boost::get(&dest))) || (boost::get(&dest) && pwalletMain->HaveCScript(*boost::get(&dest)))) { + return true; + } + } + return false; +} + void MasternodeList::StartAlias(std::string strAlias) { std::string strStatusHtml; @@ -442,7 +453,26 @@ void MasternodeList::updateDIP3List() nextPayments.emplace(dmn->proTxHash, mnList.GetHeight() + (int)i + 1); } + std::set setOutpts; + if (pwalletMain && ui->checkBoxMyMasternodesOnly->isChecked()) { + LOCK(pwalletMain->cs_wallet); + std::vector vOutpts; + pwalletMain->ListProTxCoins(vOutpts); + for (const auto& outpt : vOutpts) { + setOutpts.emplace(outpt); + } + } + mnList.ForEachMN(false, [&](const CDeterministicMNCPtr& dmn) { + if (pwalletMain && ui->checkBoxMyMasternodesOnly->isChecked()) { + LOCK(pwalletMain->cs_wallet); + bool fMyMasternode = setOutpts.count(dmn->collateralOutpoint) || + pwalletMain->HaveKey(dmn->pdmnState->keyIDOwner) || + pwalletMain->HaveKey(dmn->pdmnState->keyIDVoting) || + CheckWalletOwnsScript(dmn->pdmnState->scriptPayout) || + CheckWalletOwnsScript(dmn->pdmnState->scriptOperatorPayout); + if (!fMyMasternode) return; + } // populate list // Address, Protocol, Status, Active Seconds, Last Seen, Pub Key QTableWidgetItem* addressItem = new QTableWidgetItem(QString::fromStdString(dmn->pdmnState->addr.ToString())); @@ -701,6 +731,13 @@ void MasternodeList::ShowQRCode(std::string strAlias) dialog->show(); } +void MasternodeList::on_checkBoxMyMasternodesOnly_stateChanged(int state) +{ + // no cooldown + nTimeFilterUpdatedDIP3 = GetTime() - MASTERNODELIST_FILTER_COOLDOWN_SECONDS; + fFilterUpdatedDIP3 = true; +} + CDeterministicMNCPtr MasternodeList::GetSelectedDIP3MN() { std::string strProTxHash; diff --git a/src/qt/masternodelist.h b/src/qt/masternodelist.h index 5532c94e6..88ef6fe6d 100644 --- a/src/qt/masternodelist.h +++ b/src/qt/masternodelist.h @@ -90,6 +90,7 @@ private Q_SLOTS: void on_startMissingButton_clicked(); void on_tableWidgetMyMasternodes_itemSelectionChanged(); void on_UpdateButton_clicked(); + void on_checkBoxMyMasternodesOnly_stateChanged(int state); void extraInfoDIP3_clicked(); void copyProTxHash_clicked(); From 3a3586d5a316be9778b566d9a8abd152363d61f9 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 29 Jan 2019 17:54:01 +0300 Subject: [PATCH 2/8] Use helper function to produce help text for params of `protx` rpcs (#2649) * Adjust help text of `register*` rpc commands Copy/paste help for various fields of `register`/`register_prepare` instead of referring to `register_fund` Adjust description of provided functionality and expected results * Adjust whitespaces to match in different protx commands * Add missing results descriptions * Introduce new helper function GetHelpString to concentrate most of param descriptions in rpcevo in one place * [MOVEONLY] Move GetHelpString out of #ifdef ENABLE_WALLET/#endif * static const --- src/rpc/rpcevo.cpp | 192 +++++++++++++++++++++++++++++++-------------- 1 file changed, 131 insertions(+), 61 deletions(-) diff --git a/src/rpc/rpcevo.cpp b/src/rpc/rpcevo.cpp index 5e7e1f44c..6bbc7a03c 100644 --- a/src/rpc/rpcevo.cpp +++ b/src/rpc/rpcevo.cpp @@ -30,6 +30,73 @@ extern UniValue signrawtransaction(const JSONRPCRequest& request); extern UniValue sendrawtransaction(const JSONRPCRequest& request); #endif//ENABLE_WALLET +std::string GetHelpString(int nParamNum, std::string strParamName) +{ + static const std::map mapParamHelp = { + {"collateralAddress", + "%d. \"collateralAddress\" (string, required) The dash address to send the collateral to.\n" + " Must be a P2PKH address.\n" + }, + {"collateralHash", + "%d. \"collateralHash\" (string, required) The collateral transaction hash.\n" + }, + {"collateralIndex", + "%d. collateralIndex (numeric, required) The collateral transaction output index.\n" + }, + {"feeSourceAddress", + "%d. \"feeSourceAddress\" (string, optional) If specified wallet will only use coins from this address to fund ProTx.\n" + " If not specified, payoutAddress is the one that is going to be used.\n" + " The private key belonging to this address must be known in your wallet.\n" + }, + {"fundAddress", + "%d. \"fundAddress\" (string, optional) If specified wallet will only use coins from this address to fund ProTx.\n" + " If not specified, payoutAddress is the one that is going to be used.\n" + " The private key belonging to this address must be known in your wallet.\n" + }, + {"ipAndPort", + "%d. \"ipAndPort\" (string, required) IP and port in the form \"IP:PORT\".\n" + " Must be unique on the network. Can be set to 0, which will require a ProUpServTx afterwards.\n" + }, + {"operatorKey", + "%d. \"operatorKey\" (string, required) The operator private key belonging to the\n" + " registered operator public key.\n" + }, + {"operatorPubKey", + "%d. \"operatorPubKey\" (string, required) The operator BLS public key. The private key does not have to be known.\n" + " It has to match the private key which is later used when operating the masternode.\n" + }, + {"operatorReward", + "%d. \"operatorReward\" (numeric, required) The fraction in %% to share with the operator. The value must be\n" + " between 0.00 and 100.00.\n" + }, + {"ownerAddress", + "%d. \"ownerAddress\" (string, required) The dash address to use for payee updates and proposal voting.\n" + " The private key belonging to this address must be known in your wallet. The address must\n" + " be unused and must differ from the collateralAddress\n" + }, + {"payoutAddress", + "%d. \"payoutAddress\" (string, required) The dash address to use for masternode reward payments.\n" + }, + {"proTxHash", + "%d. \"proTxHash\" (string, required) The hash of the initial ProRegTx.\n" + }, + {"reason", + "%d. reason (numeric, optional) The reason for masternode service revocation.\n" + }, + {"votingAddress", + "%d. \"votingAddress\" (string, required) The voting key address. The private key does not have to be known by your wallet.\n" + " It has to match the private key which is later used when voting on proposals.\n" + " If set to an empty string, ownerAddress will be used.\n" + }, + }; + + auto it = mapParamHelp.find(strParamName); + if (it == mapParamHelp.end()) + throw std::runtime_error(strprintf("FIXME: WRONG PARAM NAME %s!", strParamName)); + + return strprintf(it->second, nParamNum); +} + // Allows to specify Dash address or priv key. In case of Dash address, the priv key is taken from the wallet static CKey ParsePrivKey(const std::string &strKeyOrAddress, bool allowAddresses = true) { CBitcoinAddress address; @@ -231,24 +298,16 @@ void protx_register_fund_help() "A few of the limitations you see in the arguments are temporary and might be lifted after DIP3\n" "is fully deployed.\n" "\nArguments:\n" - "1. \"collateralAddress\" (string, required) The dash address to send the collateral to.\n" - " Must be a P2PKH address.\n" - "2. \"ipAndPort\" (string, required) IP and port in the form \"IP:PORT\".\n" - " Must be unique on the network. Can be set to 0, which will require a ProUpServTx afterwards.\n" - "3. \"ownerAddress\" (string, required) The owner key used for payee updates and proposal voting.\n" - " The private key belonging to this address must be known in your wallet. The address must\n" - " be unused and must differ from the collateralAddress\n" - "4. \"operatorPubKey\" (string, required) The operator BLS public key. The private key does not have to be known.\n" - " It has to match the private key which is later used when operating the masternode.\n" - "5. \"votingAddress\" (string, required) The voting key address. The private key does not have to be known by your wallet.\n" - " It has to match the private key which is later used when voting on proposals.\n" - " If set to an empty string, ownerAddress will be used.\n" - "6. \"operatorReward\" (numeric, required) The fraction in % to share with the operator. The value must be\n" - " between 0.00 and 100.00.\n" - "7. \"payoutAddress\" (string, required) The dash address to use for masternode reward payments.\n" - "8. \"fundAddress\" (string, optional) If specified wallet will only use coins from this address to fund ProTx.\n" - " If not specified, payoutAddress is the one that is going to be used.\n" - " The private key belonging to this address must be known in your wallet.\n" + + GetHelpString(1, "collateralAddress") + + GetHelpString(2, "ipAndPort") + + GetHelpString(3, "ownerAddress") + + GetHelpString(4, "operatorPubKey") + + GetHelpString(5, "votingAddress") + + GetHelpString(6, "operatorReward") + + GetHelpString(7, "payoutAddress") + + GetHelpString(8, "fundAddress") + + "\nResult:\n" + "\"txid\" (string) The transaction id.\n" "\nExamples:\n" + HelpExampleCli("protx", "register_fund \"XrVhS9LogauRJGJu2sHuryjhpuex4RNPSb\" \"1.2.3.4:1234\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" \"93746e8731c57f87f79b3620a7982924e2931717d49540a85864bd543de11c43fb868fd63e501a1db37e19ed59ae6db4\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" 0 \"XrVhS9LogauRJGJu2sHuryjhpuex4RNPSb\"") ); @@ -260,12 +319,19 @@ void protx_register_help() "protx register \"collateralHash\" collateralIndex \"ipAndPort\" \"ownerAddress\" \"operatorPubKey\" \"votingAddress\" operatorReward \"payoutAddress\" ( \"feeSourceAddress\" )\n" "\nSame as \"protx register_fund\", but with an externally referenced collateral.\n" "The collateral is specified through \"collateralHash\" and \"collateralIndex\" and must be an unspent\n" - "transaction output. It must also not be used by any other masternode.\n" + "transaction output spendable by this wallet. It must also not be used by any other masternode.\n" "\nArguments:\n" - "1. \"collateralHash\" (string, required) The collateral transaction hash.\n" - "2. collateralIndex (numeric, required) The collateral transaction output index.\n" - "3., 4., 5. ... See help text of \"protx register_fund\"\n" - "feeSourceAddress See help text for \"fundAddress\" of \"protx register_fund\"\n" + + GetHelpString(1, "collateralHash") + + GetHelpString(2, "collateralIndex") + + GetHelpString(3, "ipAndPort") + + GetHelpString(4, "ownerAddress") + + GetHelpString(5, "operatorPubKey") + + GetHelpString(6, "votingAddress") + + GetHelpString(7, "operatorReward") + + GetHelpString(8, "payoutAddress") + + GetHelpString(9, "feeSourceAddress") + + "\nResult:\n" + "\"txid\" (string) The transaction id.\n" "\nExamples:\n" + HelpExampleCli("protx", "register \"0123456701234567012345670123456701234567012345670123456701234567\" 0 \"1.2.3.4:1234\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" \"93746e8731c57f87f79b3620a7982924e2931717d49540a85864bd543de11c43fb868fd63e501a1db37e19ed59ae6db4\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" 0 \"XrVhS9LogauRJGJu2sHuryjhpuex4RNPSb\"") ); @@ -279,14 +345,21 @@ void protx_register_prepare_help() "key and then passed to \"protx register_submit\". The prepared transaction will also contain inputs\n" "and outputs to cover fees.\n" "\nArguments:\n" - "1., 2., 3., ... See help text of \"protx register\".\n" - "feeSourceAddress See help text for \"fundAddress\" of \"protx register_fund\"\n" + + GetHelpString(1, "collateralHash") + + GetHelpString(2, "collateralIndex") + + GetHelpString(3, "ipAndPort") + + GetHelpString(4, "ownerAddress") + + GetHelpString(5, "operatorPubKey") + + GetHelpString(6, "votingAddress") + + GetHelpString(7, "operatorReward") + + GetHelpString(8, "payoutAddress") + + GetHelpString(9, "feeSourceAddress") + "\nResult:\n" - "{ (json object)\n" - " \"tx\" : (string) The serialized ProTx in hex format.\n" - " \"collateralAddress\" : (string) The collateral address.\n" - " \"signMessage\" : (string) The string message that needs to be signed with\n" - " the collateral key.\n" + "{ (json object)\n" + " \"tx\" : (string) The serialized ProTx in hex format.\n" + " \"collateralAddress\" : (string) The collateral address.\n" + " \"signMessage\" : (string) The string message that needs to be signed with\n" + " the collateral key.\n" "}\n" "\nExamples:\n" + HelpExampleCli("protx", "register_prepare \"0123456701234567012345670123456701234567012345670123456701234567\" 0 \"1.2.3.4:1234\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" \"93746e8731c57f87f79b3620a7982924e2931717d49540a85864bd543de11c43fb868fd63e501a1db37e19ed59ae6db4\" \"Xt9AMWaYSz7tR7Uo7gzXA3m4QmeWgrR3rr\" 0 \"XrVhS9LogauRJGJu2sHuryjhpuex4RNPSb\"") @@ -302,6 +375,8 @@ void protx_register_submit_help() "\nArguments:\n" "1. \"tx\" (string, required) The serialized transaction previously returned by \"protx register_prepare\"\n" "2. \"sig\" (string, required) The signature signed with the collateral key. Must be in base64 format.\n" + "\nResult:\n" + "\"txid\" (string) The transaction id.\n" "\nExamples:\n" + HelpExampleCli("protx", "register_submit \"tx\" \"sig\"") ); @@ -490,17 +565,13 @@ void protx_update_service_help() "of a masternode.\n" "If this is done for a masternode that got PoSe-banned, the ProUpServTx will also revive this masternode.\n" "\nArguments:\n" - "1. \"proTxHash\" (string, required) The hash of the initial ProRegTx.\n" - "2. \"ipAndPort\" (string, required) IP and port in the form \"IP:PORT\".\n" - " Must be unique on the network.\n" - "3. \"operatorKey\" (string, required) The operator private key belonging to the\n" - " registered operator public key.\n" - "4. \"operatorPayoutAddress\" (string, optional) The address used for operator reward payments.\n" - " Only allowed when the ProRegTx had a non-zero operatorReward value.\n" - " If set to an empty string, the currently active payout address is reused.\n" - "5. \"feeSourceAddress\" (string, optional) If specified wallet will only use coins from this address to fund ProTx.\n" - " If not specified, operatorPayoutAddress is the one that is going to be used.\n" - " The private key belonging to this address must be known in your wallet.\n" + + GetHelpString(1, "proTxHash") + + GetHelpString(2, "ipAndPort") + + GetHelpString(3, "operatorKey") + + GetHelpString(4, "operatorPayoutAddress") + + GetHelpString(5, "feeSourceAddress") + + "\nResult:\n" + "\"txid\" (string) The transaction id.\n" "\nExamples:\n" + HelpExampleCli("protx", "update_service \"0123456701234567012345670123456701234567012345670123456701234567\" \"1.2.3.4:1234\" 5a2e15982e62f1e0b7cf9783c64cf7e3af3f90a52d6c40f6f95d624c0b1621cd") ); @@ -583,18 +654,13 @@ void protx_update_registrar_help() "address of the masternode specified by \"proTxHash\".\n" "The owner key of the masternode must be known to your wallet.\n" "\nArguments:\n" - "1. \"proTxHash\" (string, required) The hash of the initial ProRegTx.\n" - "2. \"operatorPubKey\" (string, required) The operator public key. The private key does not have to be known by you.\n" - " It has to match the private key which is later used when operating the masternode.\n" - " If set to an empty string, the last on-chain operator key of the masternode will be used.\n" - "3. \"votingAddress\" (string, required) The voting key address. The private key does not have to be known by your wallet.\n" - " It has to match the private key which is later used when voting on proposals.\n" - " If set to an empty string, the last on-chain voting key of the masternode will be used.\n" - "4. \"payoutAddress\" (string, required) The dash address to use for masternode reward payments\n" - " If set to an empty string, the last on-chain payout address of the masternode will be used.\n" - "5. \"feeSourceAddress\" (string, optional) If specified wallet will only use coins from this address to fund ProTx.\n" - " If not specified, payoutAddress is the one that is going to be used.\n" - " The private key belonging to this address must be known in your wallet.\n" + + GetHelpString(1, "proTxHash") + + GetHelpString(2, "operatorPubKey") + + GetHelpString(3, "votingAddress") + + GetHelpString(4, "payoutAddress") + + GetHelpString(5, "feeSourceAddress") + + "\nResult:\n" + "\"txid\" (string) The transaction id.\n" "\nExamples:\n" + HelpExampleCli("protx", "update_registrar \"0123456701234567012345670123456701234567012345670123456701234567\" \"982eb34b7c7f614f29e5c665bc3605f1beeef85e3395ca12d3be49d2868ecfea5566f11cedfad30c51b2403f2ad95b67\" \"XwnLY9Tf7Zsef8gMGL2fhWA9ZmMjt4KPwG\"") ); @@ -666,13 +732,12 @@ void protx_revoke_help() "to zero. Use this in case your operator key got compromised or you want to stop providing your service\n" "to the masternode owner.\n" "\nArguments:\n" - "1. \"proTxHash\" (string, required) The hash of the initial ProRegTx.\n" - "2. \"operatorKey\" (string, required) The operator private key belonging to the\n" - " registered operator public key.\n" - "3. reason (numeric, optional) The reason for revocation.\n" - "4. \"feeSourceAddress\" (string, optional) If specified wallet will only use coins from this address to fund ProTx.\n" - " If not specified, operatorPayoutAddress specified earlier is the one that is going to be used.\n" - " The private key belonging to this address must be known in your wallet.\n" + + GetHelpString(1, "proTxHash") + + GetHelpString(2, "operatorKey") + + GetHelpString(3, "reason") + + GetHelpString(4, "feeSourceAddress") + + "\nResult:\n" + "\"txid\" (string) The transaction id.\n" "\nExamples:\n" + HelpExampleCli("protx", "revoke \"0123456701234567012345670123456701234567012345670123456701234567\" \"072f36a77261cdd5d64c32d97bac417540eddca1d5612f416feb07ff75a8e240\"") ); @@ -910,7 +975,12 @@ void protx_info_help() "protx info \"proTxHash\"\n" "\nReturns detailed information about a deterministic masternode.\n" "\nArguments:\n" - "1. \"proTxHash\" (string, required) The hash of the initial ProRegTx.\n" + + GetHelpString(1, "proTxHash") + + "\nResult:\n" + "{ (json object) Details about a specific deterministic masternode\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("protx", "info \"0123456701234567012345670123456701234567012345670123456701234567\"") ); } From 070ad103ff39ce146b2fc882f981a1eac880f08e Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Mon, 28 Jan 2019 14:23:59 +0300 Subject: [PATCH 3/8] Wait for script checks to finish before messing with txes in Dash-specific way (#2652) Benchmark Dash part while at it --- src/validation.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index 51bd5a992..8e9f0a239 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2208,6 +2208,11 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd int64_t nTime3 = GetTimeMicros(); nTimeConnect += nTime3 - nTime2; LogPrint("bench", " - Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin) [%.2fs]\n", (unsigned)block.vtx.size(), 0.001 * (nTime3 - nTime2), 0.001 * (nTime3 - nTime2) / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * (nTime3 - nTime2) / (nInputs-1), nTimeConnect * 0.000001); + if (!control.Wait()) + return state.DoS(100, false); + int64_t nTime4 = GetTimeMicros(); nTimeVerify += nTime4 - nTime2; + LogPrint("bench", " - Verify %u txins: %.2fms (%.3fms/txin) [%.2fs]\n", nInputs - 1, 0.001 * (nTime4 - nTime2), nInputs <= 1 ? 0 : 0.001 * (nTime4 - nTime2) / (nInputs-1), nTimeVerify * 0.000001); + if (!ProcessSpecialTxsInBlock(block, pindex, state)) { return error("ConnectBlock(): ProcessSpecialTxsInBlock for block %s failed with %s", pindex->GetBlockHash().ToString(), FormatStateMessage(state)); @@ -2232,12 +2237,10 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd return state.DoS(0, error("ConnectBlock(DASH): couldn't find masternode or superblock payments"), REJECT_INVALID, "bad-cb-payee"); } - // END DASH + int64_t nTime5 = GetTimeMicros(); nTimeVerify += nTime5 - nTime4; + LogPrint("bench", " - Payee and special txes: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime2), nTimeVerify * 0.000001); - if (!control.Wait()) - return state.DoS(100, false); - int64_t nTime4 = GetTimeMicros(); nTimeVerify += nTime4 - nTime2; - LogPrint("bench", " - Verify %u txins: %.2fms (%.3fms/txin) [%.2fs]\n", nInputs - 1, 0.001 * (nTime4 - nTime2), nInputs <= 1 ? 0 : 0.001 * (nTime4 - nTime2) / (nInputs-1), nTimeVerify * 0.000001); + // END DASH if (fJustCheck) return true; @@ -2294,8 +2297,8 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd } } - int64_t nTime5 = GetTimeMicros(); nTimeIndex += nTime5 - nTime4; - LogPrint("bench", " - Index writing: %.2fms [%.2fs]\n", 0.001 * (nTime5 - nTime4), nTimeIndex * 0.000001); + int64_t nTime6 = GetTimeMicros(); nTimeIndex += nTime6 - nTime5; + LogPrint("bench", " - Index writing: %.2fms [%.2fs]\n", 0.001 * (nTime6 - nTime5), nTimeIndex * 0.000001); // Watch for changes to the previous coinbase transaction. static uint256 hashPrevBestCoinBase; @@ -2304,8 +2307,8 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd evoDb->WriteBestBlock(pindex->GetBlockHash()); - int64_t nTime6 = GetTimeMicros(); nTimeCallbacks += nTime6 - nTime5; - LogPrint("bench", " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime6 - nTime5), nTimeCallbacks * 0.000001); + int64_t nTime7 = GetTimeMicros(); nTimeCallbacks += nTime7 - nTime6; + LogPrint("bench", " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime7 - nTime6), nTimeCallbacks * 0.000001); return true; } From 592210dafc67c2e27ef606bc11e6d1477f6c7ef8 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 29 Jan 2019 17:54:57 +0300 Subject: [PATCH 4/8] Bump block stats when adding commitment tx into block (#2654) --- src/miner.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/miner.cpp b/src/miner.cpp index 217804ac5..ca78887ea 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -159,6 +159,8 @@ std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& sc pblock->vtx.emplace_back(qcTx); pblocktemplate->vTxFees.emplace_back(0); pblocktemplate->vTxSigOps.emplace_back(0); + nBlockSize += qcTx->GetTotalSize(); + ++nBlockTx; } } } From 0d8cc0761c075d67e73612fd482dbc27c3689a99 Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Fri, 1 Feb 2019 08:49:18 +0100 Subject: [PATCH 5/8] Invoke CheckSpecialTx after all normal TX checks have passed (#2673) Otherwise duplicate-keys checks for deterministic masternodes triggers for duplicate/identical transactions. --- src/validation.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index 8e9f0a239..73b1fe2d1 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -656,9 +656,6 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C return state.DoS(100, false, REJECT_INVALID, "qc-not-allowed"); } - if (!CheckSpecialTx(tx, chainActive.Tip(), state)) - return false; - // Coinbase is only valid in a block, not as a loose transaction if (tx.IsCoinBase()) return state.DoS(100, false, REJECT_INVALID, "coinbase"); @@ -866,6 +863,12 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C return state.DoS(0, false, REJECT_NONSTANDARD, "too-long-mempool-chain", false, errString); } + // check special TXs after all the other checks. If we'd do this before the other checks, we might end up + // DoS scoring a node for non-critical errors, e.g. duplicate keys because a TX is received that was already + // mined + if (!CheckSpecialTx(tx, chainActive.Tip(), state)) + return false; + // If we aren't going to actually accept it but just were verifying it, we are fine already if(fDryRun) return true; From e18916386557e5a72a9aef7fe87275f14e74519d Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Mon, 4 Feb 2019 12:52:24 +0300 Subject: [PATCH 6/8] Add missing help text for `operatorPayoutAddress` (#2679) --- src/rpc/rpcevo.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/rpc/rpcevo.cpp b/src/rpc/rpcevo.cpp index 6bbc7a03c..37a36a51a 100644 --- a/src/rpc/rpcevo.cpp +++ b/src/rpc/rpcevo.cpp @@ -61,6 +61,11 @@ std::string GetHelpString(int nParamNum, std::string strParamName) "%d. \"operatorKey\" (string, required) The operator private key belonging to the\n" " registered operator public key.\n" }, + {"operatorPayoutAddress", + "%d. \"operatorPayoutAddress\" (string, optional) The address used for operator reward payments.\n" + " Only allowed when the ProRegTx had a non-zero operatorReward value.\n" + " If set to an empty string, the currently active payout address is reused.\n" + }, {"operatorPubKey", "%d. \"operatorPubKey\" (string, required) The operator BLS public key. The private key does not have to be known.\n" " It has to match the private key which is later used when operating the masternode.\n" From 8961a6acc01fce32c8dca606b07d4b3e9370bb2c Mon Sep 17 00:00:00 2001 From: Alexander Block Date: Tue, 5 Feb 2019 15:45:54 +0100 Subject: [PATCH 7/8] Stop checking MN protocol version before signalling DIP3 (#2684) --- src/versionbits.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/versionbits.cpp b/src/versionbits.cpp index eaddecad2..e570f031b 100644 --- a/src/versionbits.cpp +++ b/src/versionbits.cpp @@ -30,7 +30,7 @@ const struct BIP9DeploymentInfo VersionBitsDeploymentInfo[Consensus::MAX_VERSION { /*.name =*/ "dip0003", /*.gbt_force =*/ true, - /*.check_mn_protocol =*/ true, + /*.check_mn_protocol =*/ false, } }; From 023f8a01ae9d984072f735fe23c871d3ef694170 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Sat, 2 Feb 2019 03:09:03 +0300 Subject: [PATCH 8/8] Fix bench log for payee and special txes (#2678) --- src/validation.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index 73b1fe2d1..53cd09443 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1909,6 +1909,7 @@ static ThresholdConditionCache warningcache[VERSIONBITS_NUM_BITS]; static int64_t nTimeCheck = 0; static int64_t nTimeForks = 0; static int64_t nTimeVerify = 0; +static int64_t nTimePayeeAndSpecial = 0; static int64_t nTimeConnect = 0; static int64_t nTimeIndex = 0; static int64_t nTimeCallbacks = 0; @@ -2240,8 +2241,8 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd return state.DoS(0, error("ConnectBlock(DASH): couldn't find masternode or superblock payments"), REJECT_INVALID, "bad-cb-payee"); } - int64_t nTime5 = GetTimeMicros(); nTimeVerify += nTime5 - nTime4; - LogPrint("bench", " - Payee and special txes: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime2), nTimeVerify * 0.000001); + int64_t nTime5 = GetTimeMicros(); nTimePayeeAndSpecial += nTime5 - nTime4; + LogPrint("bench", " - Payee and special txes: %.2fms [%.2fs]\n", 0.001 * (nTime5 - nTime4), nTimePayeeAndSpecial * 0.000001); // END DASH