implements different disk sizes for different networks on intro

- Creates m_assumed_blockchain_size and m_assumed_chain_state_size on CChainParams.
- Implements access to CChainParams' m_assumed_blockchain_size and m_assumed_chain_state_size on node interface.
- Implements m_assumed_blockchain_size and m_assumed_chain_state_size on qt/intro via node interface.
- Updates release process document with the new CChainParam's values.
This commit is contained in:
marcoagner 2018-10-07 13:11:36 +01:00
parent f504a1402a
commit 9d0e52834b
No known key found for this signature in database
GPG key ID: 0DC77FC61ED3ECC4
7 changed files with 40 additions and 12 deletions

View file

@ -22,7 +22,7 @@ Before every minor and major release:
Before every major release: Before every major release:
* Update hardcoded [seeds](/contrib/seeds/README.md), see [this pull request](https://github.com/bitcoin/bitcoin/pull/7415) for an example. * Update hardcoded [seeds](/contrib/seeds/README.md), see [this pull request](https://github.com/bitcoin/bitcoin/pull/7415) for an example.
* Update [`BLOCK_CHAIN_SIZE`](/src/qt/intro.cpp) to the current size plus some overhead. * Update [`src/chainparams.cpp`](/src/chainparams.cpp) m_assumed_blockchain_size and m_assumed_chain_state_size with the current size plus some overhead.
* Update `src/chainparams.cpp` chainTxData with statistics about the transaction count and rate. Use the output of the RPC `getchaintxstats`, see * Update `src/chainparams.cpp` chainTxData with statistics about the transaction count and rate. Use the output of the RPC `getchaintxstats`, see
[this pull request](https://github.com/bitcoin/bitcoin/pull/12270) for an example. Reviewers can verify the results by running `getchaintxstats <window_block_count> <window_last_block_hash>` with the `window_block_count` and `window_last_block_hash` from your output. [this pull request](https://github.com/bitcoin/bitcoin/pull/12270) for an example. Reviewers can verify the results by running `getchaintxstats <window_block_count> <window_last_block_hash>` with the `window_block_count` and `window_last_block_hash` from your output.
* Update version of `contrib/gitian-descriptors/*.yml`: usually one'd want to do this on master after branching off the release - but be sure to at least do it before a new major release * Update version of `contrib/gitian-descriptors/*.yml`: usually one'd want to do this on master after branching off the release - but be sure to at least do it before a new major release

View file

@ -107,6 +107,8 @@ public:
pchMessageStart[3] = 0xd9; pchMessageStart[3] = 0xd9;
nDefaultPort = 8333; nDefaultPort = 8333;
nPruneAfterHeight = 100000; nPruneAfterHeight = 100000;
m_assumed_blockchain_size = 200;
m_assumed_chain_state_size = 3;
genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN); genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN);
consensus.hashGenesisBlock = genesis.GetHash(); consensus.hashGenesisBlock = genesis.GetHash();
@ -216,6 +218,8 @@ public:
pchMessageStart[3] = 0x07; pchMessageStart[3] = 0x07;
nDefaultPort = 18333; nDefaultPort = 18333;
nPruneAfterHeight = 1000; nPruneAfterHeight = 1000;
m_assumed_blockchain_size = 20;
m_assumed_chain_state_size = 2;
genesis = CreateGenesisBlock(1296688602, 414098458, 0x1d00ffff, 1, 50 * COIN); genesis = CreateGenesisBlock(1296688602, 414098458, 0x1d00ffff, 1, 50 * COIN);
consensus.hashGenesisBlock = genesis.GetHash(); consensus.hashGenesisBlock = genesis.GetHash();
@ -305,6 +309,8 @@ public:
pchMessageStart[3] = 0xda; pchMessageStart[3] = 0xda;
nDefaultPort = 18444; nDefaultPort = 18444;
nPruneAfterHeight = 1000; nPruneAfterHeight = 1000;
m_assumed_blockchain_size = 0;
m_assumed_chain_state_size = 0;
UpdateVersionBitsParametersFromArgs(args); UpdateVersionBitsParametersFromArgs(args);

View file

@ -67,6 +67,10 @@ public:
/** Policy: Filter transactions that do not match well-defined patterns */ /** Policy: Filter transactions that do not match well-defined patterns */
bool RequireStandard() const { return fRequireStandard; } bool RequireStandard() const { return fRequireStandard; }
uint64_t PruneAfterHeight() const { return nPruneAfterHeight; } uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
/** Minimum free space (in GB) needed for data directory */
uint64_t AssumedBlockchainSize() const { return m_assumed_blockchain_size; }
/** Minimum free space (in GB) needed for data directory when pruned; Does not include prune target*/
uint64_t AssumedChainStateSize() const { return m_assumed_chain_state_size; }
/** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */ /** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; } bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
/** Return the BIP70 network string (main, test or regtest) */ /** Return the BIP70 network string (main, test or regtest) */
@ -87,6 +91,8 @@ protected:
CMessageHeader::MessageStartChars pchMessageStart; CMessageHeader::MessageStartChars pchMessageStart;
int nDefaultPort; int nDefaultPort;
uint64_t nPruneAfterHeight; uint64_t nPruneAfterHeight;
uint64_t m_assumed_blockchain_size;
uint64_t m_assumed_chain_state_size;
std::vector<std::string> vSeeds; std::vector<std::string> vSeeds;
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES]; std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
std::string bech32_hrp; std::string bech32_hrp;

View file

@ -56,6 +56,8 @@ class NodeImpl : public Node
bool softSetArg(const std::string& arg, const std::string& value) override { return gArgs.SoftSetArg(arg, value); } bool softSetArg(const std::string& arg, const std::string& value) override { return gArgs.SoftSetArg(arg, value); }
bool softSetBoolArg(const std::string& arg, bool value) override { return gArgs.SoftSetBoolArg(arg, value); } bool softSetBoolArg(const std::string& arg, bool value) override { return gArgs.SoftSetBoolArg(arg, value); }
void selectParams(const std::string& network) override { SelectParams(network); } void selectParams(const std::string& network) override { SelectParams(network); }
uint64_t getAssumedBlockchainSize() override { return Params().AssumedBlockchainSize(); }
uint64_t getAssumedChainStateSize() override { return Params().AssumedChainStateSize(); }
std::string getNetwork() override { return Params().NetworkIDString(); } std::string getNetwork() override { return Params().NetworkIDString(); }
void initLogging() override { InitLogging(); } void initLogging() override { InitLogging(); }
void initParameterInteraction() override { InitParameterInteraction(); } void initParameterInteraction() override { InitParameterInteraction(); }

View file

@ -52,6 +52,12 @@ public:
//! Choose network parameters. //! Choose network parameters.
virtual void selectParams(const std::string& network) = 0; virtual void selectParams(const std::string& network) = 0;
//! Get the (assumed) blockchain size.
virtual uint64_t getAssumedBlockchainSize() = 0;
//! Get the (assumed) chain state size.
virtual uint64_t getAssumedChainStateSize() = 0;
//! Get network name. //! Get network name.
virtual std::string getNetwork() = 0; virtual std::string getNetwork() = 0;

View file

@ -22,10 +22,6 @@
#include <cmath> #include <cmath>
static const uint64_t GB_BYTES = 1000000000LL; static const uint64_t GB_BYTES = 1000000000LL;
/* Minimum free space (in GB) needed for data directory */
constexpr uint64_t BLOCK_CHAIN_SIZE = 220;
/* Minimum free space (in GB) needed for data directory when pruned; Does not include prune target */
static const uint64_t CHAIN_STATE_SIZE = 3;
/* Total required space (in GB) depending on user choice (prune, not prune) */ /* Total required space (in GB) depending on user choice (prune, not prune) */
static uint64_t requiredSpace; static uint64_t requiredSpace;
@ -114,11 +110,13 @@ void FreespaceChecker::check()
} }
Intro::Intro(QWidget *parent) : Intro::Intro(QWidget *parent, uint64_t blockchain_size, uint64_t chain_state_size) :
QDialog(parent), QDialog(parent),
ui(new Ui::Intro), ui(new Ui::Intro),
thread(0), thread(0),
signalled(false) signalled(false),
m_blockchain_size(blockchain_size),
m_chain_state_size(chain_state_size)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->welcomeLabel->setText(ui->welcomeLabel->text().arg(tr(PACKAGE_NAME))); ui->welcomeLabel->setText(ui->welcomeLabel->text().arg(tr(PACKAGE_NAME)));
@ -126,14 +124,14 @@ Intro::Intro(QWidget *parent) :
ui->lblExplanation1->setText(ui->lblExplanation1->text() ui->lblExplanation1->setText(ui->lblExplanation1->text()
.arg(tr(PACKAGE_NAME)) .arg(tr(PACKAGE_NAME))
.arg(BLOCK_CHAIN_SIZE) .arg(m_blockchain_size)
.arg(2009) .arg(2009)
.arg(tr("Bitcoin")) .arg(tr("Bitcoin"))
); );
ui->lblExplanation2->setText(ui->lblExplanation2->text().arg(tr(PACKAGE_NAME))); ui->lblExplanation2->setText(ui->lblExplanation2->text().arg(tr(PACKAGE_NAME)));
uint64_t pruneTarget = std::max<int64_t>(0, gArgs.GetArg("-prune", 0)); uint64_t pruneTarget = std::max<int64_t>(0, gArgs.GetArg("-prune", 0));
requiredSpace = BLOCK_CHAIN_SIZE; requiredSpace = m_blockchain_size;
QString storageRequiresMsg = tr("At least %1 GB of data will be stored in this directory, and it will grow over time."); QString storageRequiresMsg = tr("At least %1 GB of data will be stored in this directory, and it will grow over time.");
if (pruneTarget) { if (pruneTarget) {
uint64_t prunedGBs = std::ceil(pruneTarget * 1024 * 1024.0 / GB_BYTES); uint64_t prunedGBs = std::ceil(pruneTarget * 1024 * 1024.0 / GB_BYTES);
@ -145,7 +143,7 @@ Intro::Intro(QWidget *parent) :
} else { } else {
ui->lblExplanation3->setVisible(false); ui->lblExplanation3->setVisible(false);
} }
requiredSpace += CHAIN_STATE_SIZE; requiredSpace += m_chain_state_size;
ui->sizeWarningLabel->setText( ui->sizeWarningLabel->setText(
tr("%1 will download and store a copy of the Bitcoin block chain.").arg(tr(PACKAGE_NAME)) + " " + tr("%1 will download and store a copy of the Bitcoin block chain.").arg(tr(PACKAGE_NAME)) + " " +
storageRequiresMsg.arg(requiredSpace) + " " + storageRequiresMsg.arg(requiredSpace) + " " +
@ -201,8 +199,15 @@ bool Intro::pickDataDirectory(interfaces::Node& node)
if(!fs::exists(GUIUtil::qstringToBoostPath(dataDir)) || gArgs.GetBoolArg("-choosedatadir", DEFAULT_CHOOSE_DATADIR) || settings.value("fReset", false).toBool() || gArgs.GetBoolArg("-resetguisettings", false)) if(!fs::exists(GUIUtil::qstringToBoostPath(dataDir)) || gArgs.GetBoolArg("-choosedatadir", DEFAULT_CHOOSE_DATADIR) || settings.value("fReset", false).toBool() || gArgs.GetBoolArg("-resetguisettings", false))
{ {
/* Use selectParams here to guarantee Params() can be used by node interface */
try {
node.selectParams(gArgs.GetChainName());
} catch (const std::exception&) {
return false;
}
/* If current default data directory does not exist, let the user choose one */ /* If current default data directory does not exist, let the user choose one */
Intro intro; Intro intro(0, node.getAssumedBlockchainSize(), node.getAssumedChainStateSize());
intro.setDataDirectory(dataDir); intro.setDataDirectory(dataDir);
intro.setWindowIcon(QIcon(":icons/bitcoin")); intro.setWindowIcon(QIcon(":icons/bitcoin"));

View file

@ -30,7 +30,8 @@ class Intro : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit Intro(QWidget *parent = 0); explicit Intro(QWidget *parent = 0,
uint64_t blockchain_size = 0, uint64_t chain_state_size = 0);
~Intro(); ~Intro();
QString getDataDirectory(); QString getDataDirectory();
@ -71,6 +72,8 @@ private:
QMutex mutex; QMutex mutex;
bool signalled; bool signalled;
QString pathToCheck; QString pathToCheck;
uint64_t m_blockchain_size;
uint64_t m_chain_state_size;
void startThread(); void startThread();
void checkPath(const QString &dataDir); void checkPath(const QString &dataDir);