From b67adadb9a8a0d7e0bbd029882e6ef40c0219653 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Thu, 25 Feb 2016 10:51:29 +0000 Subject: [PATCH] Adjust default policy for Knots and add -corepolicy option to undo --- src/init.cpp | 13 +++++++++++++ src/node/miner.cpp | 6 +++--- src/policy/policy.h | 14 +++++++------- src/qt/optionsdialog.cpp | 18 +++++++++++++++--- src/qt/optionsmodel.cpp | 3 +++ src/qt/optionsmodel.h | 1 + src/test/fuzz/mini_miner.cpp | 1 + src/test/miner_tests.cpp | 2 ++ test/functional/test_framework/test_node.py | 1 + 9 files changed, 46 insertions(+), 13 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 7abdedf417..f6f72eb89a 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -140,6 +140,7 @@ using util::Join; using util::ReplaceAll; using util::ToString; +static constexpr bool DEFAULT_COREPOLICY{false}; static constexpr bool DEFAULT_PROXYRANDOMIZE{true}; static constexpr bool DEFAULT_REST_ENABLE{false}; static constexpr bool DEFAULT_I2P_ACCEPT_INCOMING{true}; @@ -494,6 +495,7 @@ void SetupServerArgs(ArgsManager& argsman) argsman.AddArg("-coinstatsindex", strprintf("Maintain coinstats index used by the gettxoutsetinfo RPC (default: %u)", DEFAULT_COINSTATSINDEX), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-conf=", strprintf("Specify path to read-only configuration file. Relative paths will be prefixed by datadir location (only useable from command line, not configuration file) (default: %s)", BITCOIN_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-confrw=", strprintf("Specify read/write configuration file. Relative paths will be prefixed by the network-specific datadir location (default: %s)", BITCOIN_RW_CONF_FILENAME), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); + argsman.AddArg("-corepolicy", strprintf("Use Bitcoin Core policy defaults (default: %u)", DEFAULT_COREPOLICY), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-datadir=", "Specify data directory", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-dbbatchsize", strprintf("Maximum database write batch size in bytes (default: %u)", nDefaultDbBatchSize), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::OPTIONS); argsman.AddArg("-dbcache=", strprintf("Maximum database cache size MiB (%d to %d, default: %d). In addition, unused mempool memory is shared for this cache (see -maxmempool).", nMinDbCache, nMaxDbCache, nDefaultDbCache), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); @@ -801,6 +803,17 @@ static bool AppInitServers(NodeContext& node) // Parameter interaction based on rules void InitParameterInteraction(ArgsManager& args) { + if (args.GetBoolArg("-corepolicy", DEFAULT_COREPOLICY)) { + args.SoftSetArg("-bytespersigopstrict", "0"); + args.SoftSetArg("-permitbaremultisig", "1"); + args.SoftSetArg("-datacarriersize", "83"); + + args.SoftSetArg("-spkreuse", "allow"); + args.SoftSetArg("-blockprioritysize", "0"); + args.SoftSetArg("-blockmaxsize", "4000000"); + args.SoftSetArg("-blockmaxweight", "3996000"); + } + // when specifying an explicit binding address, you want to listen on it // even when -connect or -proxy is specified if (args.IsArgSet("-bind")) { diff --git a/src/node/miner.cpp b/src/node/miner.cpp index 33c3ce0a1a..4b50012362 100644 --- a/src/node/miner.cpp +++ b/src/node/miner.cpp @@ -73,14 +73,14 @@ BlockCreateOptions BlockCreateOptions::Clamped() const constexpr size_t theoretical_min_gentx_sz = 1+4+1+36+1+1+4+1+4; constexpr size_t theoretical_min_gentx_weight = theoretical_min_gentx_sz * WITNESS_SCALE_FACTOR; CHECK_NONFATAL(options.coinbase_max_additional_size <= MAX_BLOCK_SERIALIZED_SIZE - 1000); - CHECK_NONFATAL(options.coinbase_max_additional_weight <= DEFAULT_BLOCK_MAX_WEIGHT); + CHECK_NONFATAL(options.coinbase_max_additional_weight <= MAX_BLOCK_WEIGHT - 4000); CHECK_NONFATAL(options.coinbase_max_additional_weight >= theoretical_min_gentx_weight); CHECK_NONFATAL(options.coinbase_output_max_additional_sigops <= MAX_BLOCK_SIGOPS_COST); // Limit size to between coinbase_max_additional_size and MAX_BLOCK_SERIALIZED_SIZE-1K for sanity: options.nBlockMaxSize = std::clamp(options.nBlockMaxSize, options.coinbase_max_additional_size, MAX_BLOCK_SERIALIZED_SIZE - 1000); - // Limit weight to between coinbase_max_additional_weight and DEFAULT_BLOCK_MAX_WEIGHT for sanity: + // Limit weight to between coinbase_max_additional_weight and MAX_BLOCK_WEIGHT for sanity: // Coinbase (reserved) outputs can safely exceed -blockmaxweight, but the rest of the block template will be empty. - options.nBlockMaxWeight = std::clamp(options.nBlockMaxWeight, options.coinbase_max_additional_weight, DEFAULT_BLOCK_MAX_WEIGHT); + options.nBlockMaxWeight = std::clamp(options.nBlockMaxWeight, options.coinbase_max_additional_weight, MAX_BLOCK_WEIGHT); return options; } diff --git a/src/policy/policy.h b/src/policy/policy.h index 99efc581b1..c369875fef 100644 --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -25,13 +25,13 @@ struct MemPoolOptions; }; /** Default for -blockmaxsize, which controls the maximum size of block the mining code will create **/ -static const unsigned int DEFAULT_BLOCK_MAX_SIZE = MAX_BLOCK_SERIALIZED_SIZE; +static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 300000; /** Default for -blockprioritysize, maximum space for zero/low-fee transactions **/ -static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 0; +static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 100000; /** Minimum priority for transactions to be accepted into the priority area **/ static const double MINIMUM_TX_PRIORITY = COIN * 144 / 250; /** Default for -blockmaxweight, which controls the range of block weights the mining code will create **/ -static constexpr unsigned int DEFAULT_BLOCK_MAX_WEIGHT{MAX_BLOCK_WEIGHT - 4000}; +static constexpr unsigned int DEFAULT_BLOCK_MAX_WEIGHT{DEFAULT_BLOCK_MAX_SIZE * WITNESS_SCALE_FACTOR}; /** Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by mining code **/ static constexpr unsigned int DEFAULT_BLOCK_MIN_TX_FEE{1000}; /** The maximum weight for transactions we're willing to relay/mine */ @@ -57,7 +57,7 @@ static constexpr bool DEFAULT_REJECT_TOKENS{false}; /** Default for -permitbarepubkey */ static constexpr bool DEFAULT_PERMIT_BAREPUBKEY{true}; /** Default for -permitbaremultisig */ -static constexpr bool DEFAULT_PERMIT_BAREMULTISIG{true}; +static constexpr bool DEFAULT_PERMIT_BAREMULTISIG{false}; /** Default for -rejectparasites */ static constexpr bool DEFAULT_REJECT_PARASITES{false}; /** The maximum number of witness stack items in a standard P2WSH script */ @@ -92,10 +92,10 @@ static constexpr unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT_KVB{101}; /** Default for -datacarrier */ static const bool DEFAULT_ACCEPT_DATACARRIER = true; /** - * Default setting for -datacarriersize. 80 bytes of data, +1 for OP_RETURN, - * +2 for the pushdata opcodes. + * Default setting for -datacarriersize. 40 bytes of data, +1 for OP_RETURN, + * +1 for the pushdata opcode. */ -static const unsigned int MAX_OP_RETURN_RELAY = 83; +static constexpr unsigned int MAX_OP_RETURN_RELAY{42}; /** Default for -datacarrierfullcount */ static constexpr bool DEFAULT_DATACARRIER_FULLCOUNT{false}; /** diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index d3ce3e529a..8c0cc52d15 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -704,14 +705,25 @@ void OptionsDialog::on_resetButton_clicked() with a client shutdown. */ reset_dialog_text.append(tr("Client will be shut down. Do you want to proceed?")); //: Window title text of pop-up window shown when the user has chosen to reset options. - QMessageBox::StandardButton btnRetVal = QMessageBox::question(this, tr("Confirm options reset"), - reset_dialog_text, QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel); + QStringList items; + QString strPrefix = tr("Use policy defaults for %1"); + items << strPrefix.arg(tr(PACKAGE_NAME)); + items << strPrefix.arg(tr("Bitcoin Core")+" "); - if (btnRetVal == QMessageBox::Cancel) + QInputDialog dialog(this); + dialog.setWindowTitle(tr("Confirm options reset")); + dialog.setLabelText(reset_dialog_text); + dialog.setComboBoxItems(items); + dialog.setTextValue(items[0]); + dialog.setComboBoxEditable(false); + + if (!dialog.exec()) { return; + } /* reset all options and close GUI */ model->Reset(); + model->setData(model->index(OptionsModel::corepolicy, 0), items.indexOf(dialog.textValue())); close(); Q_EMIT quitOnReset(); } diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 7a04fbf2ad..2c78529792 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -1234,6 +1234,9 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std:: gArgs.ModifyRWConfigFile("blockreconstructionextratxn", strNv); } break; + case corepolicy: + gArgs.ModifyRWConfigFile("corepolicy", value.toString().toStdString()); + break; default: break; } diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index b04e1dd098..0e6986a5c1 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -103,6 +103,7 @@ public: blockprioritysize, blockmaxweight, blockreconstructionextratxn, + corepolicy, OptionIDRowCount, }; diff --git a/src/test/fuzz/mini_miner.cpp b/src/test/fuzz/mini_miner.cpp index 24cee28112..e6115e54a3 100644 --- a/src/test/fuzz/mini_miner.cpp +++ b/src/test/fuzz/mini_miner.cpp @@ -30,6 +30,7 @@ void initialize_miner() for (uint32_t i = 0; i < uint32_t{100}; ++i) { g_available_coins.emplace_back(Txid::FromUint256(uint256::ZERO), i); } + g_setup->m_node.args->ForceSetArg("-blockprioritysize", "0"); } // Test that the MiniMiner can run with various outpoints and feerates. diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index 6ff08aec86..801d49bdba 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -607,6 +607,8 @@ void MinerTestingSetup::TestPrioritisedMining(const CScript& scriptPubKey, const // NOTE: These tests rely on CreateNewBlock doing its own self-validation! BOOST_AUTO_TEST_CASE(CreateNewBlock_validity) { + gArgs.ForceSetArg("-blockprioritysize", "0"); + // Note that by default, these tests run with size accounting enabled. CScript scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG; std::shared_ptr pblocktemplate; diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index 9c2b613778..2fa829b038 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -131,6 +131,7 @@ class TestNode(): if self.version is None: self.args += [ + "-corepolicy", "-softwareexpiry=0", "-walletimplicitsegwit", ]