Adjust default policy for Knots and add -corepolicy option to undo

This commit is contained in:
Luke Dashjr 2016-02-25 10:51:29 +00:00
parent 1b37b2d605
commit b67adadb9a
9 changed files with 46 additions and 13 deletions

View File

@ -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=<file>", 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=<file>", 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=<dir>", "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=<n>", strprintf("Maximum database cache size <n> 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")) {

View File

@ -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<size_t>(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<size_t>(options.nBlockMaxWeight, options.coinbase_max_additional_weight, DEFAULT_BLOCK_MAX_WEIGHT);
options.nBlockMaxWeight = std::clamp<size_t>(options.nBlockMaxWeight, options.coinbase_max_additional_weight, MAX_BLOCK_WEIGHT);
return options;
}

View File

@ -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};
/**

View File

@ -35,6 +35,7 @@
#include <QFontDialog>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QInputDialog>
#include <QIntValidator>
#include <QLabel>
#include <QLocale>
@ -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();
}

View File

@ -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;
}

View File

@ -103,6 +103,7 @@ public:
blockprioritysize,
blockmaxweight,
blockreconstructionextratxn,
corepolicy,
OptionIDRowCount,
};

View File

@ -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.

View File

@ -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<CBlockTemplate> pblocktemplate;

View File

@ -131,6 +131,7 @@ class TestNode():
if self.version is None:
self.args += [
"-corepolicy",
"-softwareexpiry=0",
"-walletimplicitsegwit",
]