mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-14 13:52:36 -03:00
9be7fe4849
b2ee8b207d
net: Deserialize hardcoded seeds from BIP155 blob (W. J. van der Laan)9b29d5df7f
contrib: Add explicit port numbers for testnet seeds (W. J. van der Laan)2a257de113
contrib: Add a few TorV3 seed nodes (W. J. van der Laan)06030f7a42
contrib: generate-seeds.py generates output in BIP155 format (W. J. van der Laan) Pull request description: Closes #20239 and mitigates my node's problem in #21351. - Add a few hardcoded seeds for TorV3 - As the [bitcoin-seeder](https://github.com/sipa/bitcoin-seeder) doesn't collect TorV3 addresses yet, I have extracted these from my own node using [a script](https://gist.github.com/laanwj/b3d7b01ef61ce07c2eff0a72a6b90183) and added them manually. This is intended to be a temporary stop gap until 22.0's seeds update. - Change hardcoded seeds to variable length BIP155 binary format. - It is stored as a single serialized blob in a byte array, instead of pseudo-IPv6 address slots. This is more flexible and, assuming most of the list is IPv4, more compact. - Only the (networkID, addr, port) subset (CService). Services and time are construed on the fly as before. - Change input format for `nodes_*.txt`. - Drop legacy `0xAABBCCDD` format for IPv4. It is never generated by `makeseeds.py`. - Stop interpreting lack of port as default port, interpret it as 'no port', to accomodate I2P and other port-less protocols (not handled in this PR). An explicit port is always generated by `makeseeds.py` so in practice this makes no difference right now. A follow-up to this PR could do the same for I2P. ACKs for top commit: jonatack: ACKb2ee8b207d
Tree-SHA512: 11a6b54f9fb0192560f2bd7b218f798f86c1abe01d1bf37f734cb88b91848124beb2de801ca4e6f856e9946aea5dc3ee16b0dbb9863799e42eec1b239d40d59d
154 lines
5.6 KiB
C++
154 lines
5.6 KiB
C++
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
|
// Copyright (c) 2009-2020 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#ifndef BITCOIN_CHAINPARAMS_H
|
|
#define BITCOIN_CHAINPARAMS_H
|
|
|
|
#include <chainparamsbase.h>
|
|
#include <consensus/params.h>
|
|
#include <primitives/block.h>
|
|
#include <protocol.h>
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
typedef std::map<int, uint256> MapCheckpoints;
|
|
|
|
struct CCheckpointData {
|
|
MapCheckpoints mapCheckpoints;
|
|
|
|
int GetHeight() const {
|
|
const auto& final_checkpoint = mapCheckpoints.rbegin();
|
|
return final_checkpoint->first /* height */;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Holds configuration for use during UTXO snapshot load and validation. The contents
|
|
* here are security critical, since they dictate which UTXO snapshots are recognized
|
|
* as valid.
|
|
*/
|
|
struct AssumeutxoData {
|
|
//! The expected hash of the deserialized UTXO set.
|
|
const uint256 hash_serialized;
|
|
|
|
//! Used to populate the nChainTx value, which is used during BlockManager::LoadBlockIndex().
|
|
//!
|
|
//! We need to hardcode the value here because this is computed cumulatively using block data,
|
|
//! which we do not necessarily have at the time of snapshot load.
|
|
const unsigned int nChainTx;
|
|
};
|
|
|
|
std::ostream& operator<<(std::ostream& o, const AssumeutxoData& aud);
|
|
|
|
using MapAssumeutxo = std::map<int, const AssumeutxoData>;
|
|
|
|
/**
|
|
* Holds various statistics on transactions within a chain. Used to estimate
|
|
* verification progress during chain sync.
|
|
*
|
|
* See also: CChainParams::TxData, GuessVerificationProgress.
|
|
*/
|
|
struct ChainTxData {
|
|
int64_t nTime; //!< UNIX timestamp of last known number of transactions
|
|
int64_t nTxCount; //!< total number of transactions between genesis and that timestamp
|
|
double dTxRate; //!< estimated number of transactions per second after that timestamp
|
|
};
|
|
|
|
/**
|
|
* CChainParams defines various tweakable parameters of a given instance of the
|
|
* Bitcoin system.
|
|
*/
|
|
class CChainParams
|
|
{
|
|
public:
|
|
enum Base58Type {
|
|
PUBKEY_ADDRESS,
|
|
SCRIPT_ADDRESS,
|
|
SECRET_KEY,
|
|
EXT_PUBLIC_KEY,
|
|
EXT_SECRET_KEY,
|
|
|
|
MAX_BASE58_TYPES
|
|
};
|
|
|
|
const Consensus::Params& GetConsensus() const { return consensus; }
|
|
const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; }
|
|
uint16_t GetDefaultPort() const { return nDefaultPort; }
|
|
|
|
const CBlock& GenesisBlock() const { return genesis; }
|
|
/** Default value for -checkmempool and -checkblockindex argument */
|
|
bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
|
|
/** Policy: Filter transactions that do not match well-defined patterns */
|
|
bool RequireStandard() const { return fRequireStandard; }
|
|
/** If this chain is exclusively used for testing */
|
|
bool IsTestChain() const { return m_is_test_chain; }
|
|
/** If this chain allows time to be mocked */
|
|
bool IsMockableChain() const { return m_is_mockable_chain; }
|
|
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; }
|
|
/** Whether it is possible to mine blocks on demand (no retargeting) */
|
|
bool MineBlocksOnDemand() const { return consensus.fPowNoRetargeting; }
|
|
/** Return the network string */
|
|
std::string NetworkIDString() const { return strNetworkID; }
|
|
/** Return the list of hostnames to look up for DNS seeds */
|
|
const std::vector<std::string>& DNSSeeds() const { return vSeeds; }
|
|
const std::vector<unsigned char>& Base58Prefix(Base58Type type) const { return base58Prefixes[type]; }
|
|
const std::string& Bech32HRP() const { return bech32_hrp; }
|
|
const std::vector<uint8_t>& FixedSeeds() const { return vFixedSeeds; }
|
|
const CCheckpointData& Checkpoints() const { return checkpointData; }
|
|
|
|
//! Get allowed assumeutxo configuration.
|
|
//! @see ChainstateManager
|
|
const MapAssumeutxo& Assumeutxo() const { return m_assumeutxo_data; }
|
|
|
|
const ChainTxData& TxData() const { return chainTxData; }
|
|
protected:
|
|
CChainParams() {}
|
|
|
|
Consensus::Params consensus;
|
|
CMessageHeader::MessageStartChars pchMessageStart;
|
|
uint16_t nDefaultPort;
|
|
uint64_t nPruneAfterHeight;
|
|
uint64_t m_assumed_blockchain_size;
|
|
uint64_t m_assumed_chain_state_size;
|
|
std::vector<std::string> vSeeds;
|
|
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
|
|
std::string bech32_hrp;
|
|
std::string strNetworkID;
|
|
CBlock genesis;
|
|
std::vector<uint8_t> vFixedSeeds;
|
|
bool fDefaultConsistencyChecks;
|
|
bool fRequireStandard;
|
|
bool m_is_test_chain;
|
|
bool m_is_mockable_chain;
|
|
CCheckpointData checkpointData;
|
|
MapAssumeutxo m_assumeutxo_data;
|
|
ChainTxData chainTxData;
|
|
};
|
|
|
|
/**
|
|
* Creates and returns a std::unique_ptr<CChainParams> of the chosen chain.
|
|
* @returns a CChainParams* of the chosen chain.
|
|
* @throws a std::runtime_error if the chain is not supported.
|
|
*/
|
|
std::unique_ptr<const CChainParams> CreateChainParams(const ArgsManager& args, const std::string& chain);
|
|
|
|
/**
|
|
* Return the currently selected parameters. This won't change after app
|
|
* startup, except for unit tests.
|
|
*/
|
|
const CChainParams &Params();
|
|
|
|
/**
|
|
* Sets the params returned by Params() to those for the given chain name.
|
|
* @throws std::runtime_error when the chain is not supported.
|
|
*/
|
|
void SelectParams(const std::string& chain);
|
|
|
|
#endif // BITCOIN_CHAINPARAMS_H
|