Merge #6376: refactor: a bunch of trivial-ish headers improvements

e9387eef69 refactor: remove unused includes and forward declarations from headers (Konstantin Akimov)
f2a186f3f3 refactor: remove definition IsQuorumDKGEnabled from header (Konstantin Akimov)
8a7941bd0d refactor: merge helper GetCoinbaseTx which is used only once into GetNonNullCoinbaseChainlock (Konstantin Akimov)

Pull request description:

  ## Issue being fixed or feature implemented
  Split from https://github.com/dashpay/dash/pull/6375 and added some extra

  ## What was done?
  Tidy up headers of evo/ and llmq/:
   - removed unused includes and added missing
   - removed unused forward declarations and added missing
   - removed helper GetCoinbaseTx, moved helper IsQuorumDKGEnabled from header to implementation

  ## How Has This Been Tested?
  Run unit and functional tests

  Compilation time _in theory_ should be improved, in really it shaved just 2-5 seconds from 5 minutes by my benchmark.

  ## Breaking Changes
  N/A

  ## Checklist:
  - [x] I have performed a self-review of my own code
  - [x] I have commented my code, particularly in hard-to-understand areas
  - [x] I have added or updated relevant unit/integration/functional/e2e tests
  - [x] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  UdjinM6:
    utACK e9387eef69
  PastaPastaPasta:
    utACK e9387eef69

Tree-SHA512: 7b4795fe0bcea23b9f368a962b888d610cac94b42dd6419cfe06977c1a28bbe27a7a2ae2e4cd730ec0ca4f8b333f656a601ebb90bc271f4117dec7a424a08b45
This commit is contained in:
pasta 2024-11-12 08:41:39 -06:00
commit 3aa51d6515
No known key found for this signature in database
GPG Key ID: E2F3D7916E722D38
27 changed files with 85 additions and 80 deletions

View File

@ -6,9 +6,9 @@
#define BITCOIN_EVO_ASSETLOCKTX_H #define BITCOIN_EVO_ASSETLOCKTX_H
#include <bls/bls_ies.h> #include <bls/bls_ies.h>
#include <primitives/transaction.h> #include <consensus/amount.h>
#include <gsl/pointers.h> #include <gsl/pointers.h>
#include <primitives/transaction.h>
#include <serialize.h> #include <serialize.h>
#include <univalue.h> #include <univalue.h>

View File

@ -20,6 +20,7 @@
#include <deploymentstatus.h> #include <deploymentstatus.h>
#include <validation.h> #include <validation.h>
bool CheckCbTx(const CTransaction& tx, const CBlockIndex* pindexPrev, TxValidationState& state) bool CheckCbTx(const CTransaction& tx, const CBlockIndex* pindexPrev, TxValidationState& state)
{ {
if (tx.nType != TRANSACTION_COINBASE) { if (tx.nType != TRANSACTION_COINBASE) {
@ -448,7 +449,7 @@ std::string CCbTx::ToString() const
creditPoolBalance / COIN, creditPoolBalance % COIN); creditPoolBalance / COIN, creditPoolBalance % COIN);
} }
std::optional<CCbTx> GetCoinbaseTx(const CBlockIndex* pindex) std::optional<std::pair<CBLSSignature, uint32_t>> GetNonNullCoinbaseChainlock(const CBlockIndex* pindex)
{ {
if (pindex == nullptr) { if (pindex == nullptr) {
return std::nullopt; return std::nullopt;
@ -464,20 +465,14 @@ std::optional<CCbTx> GetCoinbaseTx(const CBlockIndex* pindex)
return std::nullopt; return std::nullopt;
} }
CTransactionRef cbTx = block.vtx[0]; const CTransactionRef cbTx = block.vtx[0];
return GetTxPayload<CCbTx>(*cbTx); const auto opt_cbtx = GetTxPayload<CCbTx>(*cbTx);
}
std::optional<std::pair<CBLSSignature, uint32_t>> GetNonNullCoinbaseChainlock(const CBlockIndex* pindex)
{
auto opt_cbtx = GetCoinbaseTx(pindex);
if (!opt_cbtx.has_value()) { if (!opt_cbtx.has_value()) {
return std::nullopt; return std::nullopt;
} }
CCbTx& cbtx = opt_cbtx.value(); const CCbTx& cbtx = opt_cbtx.value();
if (cbtx.nVersion < CCbTx::Version::CLSIG_AND_BALANCE) { if (cbtx.nVersion < CCbTx::Version::CLSIG_AND_BALANCE) {
return std::nullopt; return std::nullopt;
} }

View File

@ -100,7 +100,6 @@ bool CheckCbTxBestChainlock(const CBlock& block, const CBlockIndex* pindexPrev,
bool CalcCbTxBestChainlock(const llmq::CChainLocksHandler& chainlock_handler, const CBlockIndex* pindexPrev, bool CalcCbTxBestChainlock(const llmq::CChainLocksHandler& chainlock_handler, const CBlockIndex* pindexPrev,
uint32_t& bestCLHeightDiff, CBLSSignature& bestCLSignature); uint32_t& bestCLHeightDiff, CBLSSignature& bestCLSignature);
std::optional<CCbTx> GetCoinbaseTx(const CBlockIndex* pindex);
std::optional<std::pair<CBLSSignature, uint32_t>> GetNonNullCoinbaseChainlock(const CBlockIndex* pindex); std::optional<std::pair<CBLSSignature, uint32_t>> GetNonNullCoinbaseChainlock(const CBlockIndex* pindex);
#endif // BITCOIN_EVO_CBTX_H #endif // BITCOIN_EVO_CBTX_H

View File

@ -5,10 +5,7 @@
#ifndef BITCOIN_EVO_CREDITPOOL_H #ifndef BITCOIN_EVO_CREDITPOOL_H
#define BITCOIN_EVO_CREDITPOOL_H #define BITCOIN_EVO_CREDITPOOL_H
#include <coins.h> #include <consensus/amount.h>
#include <evo/assetlocktx.h>
#include <saltedhasher.h> #include <saltedhasher.h>
#include <serialize.h> #include <serialize.h>
#include <sync.h> #include <sync.h>
@ -16,10 +13,13 @@
#include <unordered_lru_cache.h> #include <unordered_lru_cache.h>
#include <util/ranges_set.h> #include <util/ranges_set.h>
#include <evo/assetlocktx.h>
#include <optional> #include <optional>
#include <unordered_set> #include <unordered_set>
class BlockManager; class BlockManager;
class CBlock;
class CBlockIndex; class CBlockIndex;
class BlockValidationState; class BlockValidationState;
class CEvoDB; class CEvoDB;

View File

@ -29,6 +29,7 @@
class CBlock; class CBlock;
class CBlockIndex; class CBlockIndex;
class CChainState; class CChainState;
class CCoinsViewCache;
class CConnman; class CConnman;
class CEvoDB; class CEvoDB;
class TxValidationState; class TxValidationState;

View File

@ -5,12 +5,12 @@
#ifndef BITCOIN_EVO_DMNSTATE_H #ifndef BITCOIN_EVO_DMNSTATE_H
#define BITCOIN_EVO_DMNSTATE_H #define BITCOIN_EVO_DMNSTATE_H
#include <crypto/common.h>
#include <bls/bls.h> #include <bls/bls.h>
#include <pubkey.h> #include <crypto/sha256.h>
#include <netaddress.h>
#include <script/script.h>
#include <evo/providertx.h> #include <evo/providertx.h>
#include <netaddress.h>
#include <pubkey.h>
#include <script/script.h>
#include <memory> #include <memory>
#include <utility> #include <utility>

View File

@ -14,16 +14,12 @@ class CBlockIndex;
class CChain; class CChain;
class CConnman; class CConnman;
class CDataStream; class CDataStream;
class CDeterministicMN;
class CDeterministicMNList; class CDeterministicMNList;
class CDeterministicMNListDiff; class CDeterministicMNListDiff;
class CDeterministicMNManager;
class CMasternodeMetaMan; class CMasternodeMetaMan;
class CMasternodeSync; class CMasternodeSync;
class CNode; class CNode;
class UniValue;
enum ServiceFlags : uint64_t; enum ServiceFlags : uint64_t;
/** /**

View File

@ -7,14 +7,12 @@
#include <bls/bls.h> #include <bls/bls.h>
#include <gsl/pointers.h> #include <gsl/pointers.h>
#include <primitives/transaction.h>
#include <sync.h> #include <sync.h>
#include <threadsafety.h> #include <threadsafety.h>
#include <univalue.h> #include <univalue.h>
#include <optional> #include <optional>
#include <saltedhasher.h> #include <saltedhasher.h>
#include <unordered_map>
#include <unordered_lru_cache.h> #include <unordered_lru_cache.h>
#include <versionbits.h> #include <versionbits.h>
@ -22,6 +20,7 @@ class BlockValidationState;
class CBlock; class CBlock;
class CBlockIndex; class CBlockIndex;
class CEvoDB; class CEvoDB;
class CTransaction;
class ChainstateManager; class ChainstateManager;
class TxValidationState; class TxValidationState;
namespace llmq { namespace llmq {

View File

@ -17,8 +17,6 @@
#include <univalue.h> #include <univalue.h>
#include <util/underlying.h> #include <util/underlying.h>
class CBlockIndex;
class CCoinsViewCache;
class TxValidationState; class TxValidationState;
class CProRegTx class CProRegTx

View File

@ -6,18 +6,22 @@
#define BITCOIN_EVO_SIMPLIFIEDMNS_H #define BITCOIN_EVO_SIMPLIFIEDMNS_H
#include <bls/bls.h> #include <bls/bls.h>
#include <evo/deterministicmns.h>
#include <evo/dmn_types.h> #include <evo/dmn_types.h>
#include <merkleblock.h> #include <merkleblock.h>
#include <netaddress.h> #include <netaddress.h>
#include <pubkey.h> #include <pubkey.h>
#include <sync.h>
#include <threadsafety.h>
class UniValue; class UniValue;
class CBlockIndex; class CBlockIndex;
class CDeterministicMNList;
class CDeterministicMN; class CDeterministicMN;
class CDeterministicMNList;
class CDeterministicMNManager;
class ChainstateManager; class ChainstateManager;
extern RecursiveMutex cs_main;
namespace llmq { namespace llmq {
class CFinalCommitment; class CFinalCommitment;
class CQuorumBlockProcessor; class CQuorumBlockProcessor;

View File

@ -11,7 +11,6 @@
#include <uint256.h> #include <uint256.h>
#include <version.h> #include <version.h>
#include <string_view>
#include <optional> #include <optional>
#include <vector> #include <vector>

View File

@ -5,7 +5,7 @@
#ifndef BITCOIN_EVO_SPECIALTXMAN_H #ifndef BITCOIN_EVO_SPECIALTXMAN_H
#define BITCOIN_EVO_SPECIALTXMAN_H #define BITCOIN_EVO_SPECIALTXMAN_H
#include <primitives/transaction.h> #include <consensus/amount.h>
#include <sync.h> #include <sync.h>
#include <threadsafety.h> #include <threadsafety.h>
@ -17,6 +17,7 @@ class CBlockIndex;
class CCoinsViewCache; class CCoinsViewCache;
class CCreditPoolManager; class CCreditPoolManager;
class CDeterministicMNManager; class CDeterministicMNManager;
class CTransaction;
class ChainstateManager; class ChainstateManager;
class CMNHFManager; class CMNHFManager;
class TxValidationState; class TxValidationState;

View File

@ -7,9 +7,7 @@
#include <unordered_lru_cache.h> #include <unordered_lru_cache.h>
#include <chain.h> #include <llmq/params.h>
#include <consensus/params.h>
#include <primitives/block.h>
#include <protocol.h> #include <protocol.h>
#include <saltedhasher.h> #include <saltedhasher.h>
#include <sync.h> #include <sync.h>
@ -19,9 +17,10 @@
#include <optional> #include <optional>
class BlockValidationState; class BlockValidationState;
class CBlock;
class CBlockIndex;
class CChain; class CChain;
class CChainState; class CChainState;
class CConnman;
class CDataStream; class CDataStream;
class CDeterministicMNManager; class CDeterministicMNManager;
class CEvoDB; class CEvoDB;

View File

@ -7,11 +7,10 @@
#include <llmq/clsig.h> #include <llmq/clsig.h>
#include <crypto/common.h> #include <crypto/common.h> // For ReadLE64
#include <llmq/signing.h> #include <llmq/signing.h>
#include <net.h> #include <net.h> // For NodeId
#include <net_types.h> #include <net_types.h>
#include <primitives/block.h>
#include <primitives/transaction.h> #include <primitives/transaction.h>
#include <saltedhasher.h> #include <saltedhasher.h>
#include <sync.h> #include <sync.h>
@ -21,10 +20,10 @@
#include <atomic> #include <atomic>
#include <map> #include <map>
#include <unordered_map> #include <unordered_map>
#include <unordered_set>
class CChainState; class CBlock;
class CBlockIndex; class CBlockIndex;
class CChainState;
class CMasternodeSync; class CMasternodeSync;
class CScheduler; class CScheduler;
class CSporkManager; class CSporkManager;

View File

@ -6,16 +6,20 @@
#define BITCOIN_LLMQ_COMMITMENT_H #define BITCOIN_LLMQ_COMMITMENT_H
#include <bls/bls.h> #include <bls/bls.h>
#include <consensus/params.h> #include <llmq/params.h>
#include <primitives/transaction.h> #include <primitives/transaction.h>
#include <util/irange.h> #include <util/irange.h>
#include <util/strencodings.h> #include <util/strencodings.h>
#include <util/underlying.h> #include <util/underlying.h>
#include <gsl/pointers.h> #include <gsl/pointers.h>
#include <univalue.h> #include <univalue.h>
#include <limits>
#include <memory>
#include <string>
#include <vector>
class CBlockIndex; class CBlockIndex;
class CDeterministicMNManager; class CDeterministicMNManager;
class ChainstateManager; class ChainstateManager;

View File

@ -12,7 +12,6 @@ class CBLSWorker;
class CConnman; class CConnman;
class ChainstateManager; class ChainstateManager;
class CDeterministicMNManager; class CDeterministicMNManager;
class CDBWrapper;
class CEvoDB; class CEvoDB;
class CMasternodeMetaMan; class CMasternodeMetaMan;
class CMasternodeSync; class CMasternodeSync;

View File

@ -22,7 +22,6 @@ class CConnman;
class CDeterministicMN; class CDeterministicMN;
class CMasternodeMetaMan; class CMasternodeMetaMan;
class CSporkManager; class CSporkManager;
class UniValue;
using CDeterministicMNCPtr = std::shared_ptr<const CDeterministicMN>; using CDeterministicMNCPtr = std::shared_ptr<const CDeterministicMN>;

View File

@ -5,21 +5,28 @@
#ifndef BITCOIN_LLMQ_DKGSESSIONHANDLER_H #ifndef BITCOIN_LLMQ_DKGSESSIONHANDLER_H
#define BITCOIN_LLMQ_DKGSESSIONHANDLER_H #define BITCOIN_LLMQ_DKGSESSIONHANDLER_H
#include <ctpl_stl.h> #include <net.h> // for NodeId
#include <net.h>
#include <gsl/pointers.h> #include <gsl/pointers.h>
#include <atomic> #include <atomic>
#include <list>
#include <map> #include <map>
#include <memory>
#include <optional> #include <optional>
#include <set>
#include <string>
#include <thread>
#include <vector>
class CActiveMasternodeManager; class CActiveMasternodeManager;
class CBlockIndex;
class CBLSWorker; class CBLSWorker;
class CBlockIndex;
class CChainState; class CChainState;
class CConnman;
class CDeterministicMNManager; class CDeterministicMNManager;
class CMasternodeMetaMan; class CMasternodeMetaMan;
class CNode;
class CSporkManager; class CSporkManager;
class PeerManager; class PeerManager;

View File

@ -18,6 +18,11 @@
#include <util/underlying.h> #include <util/underlying.h>
#include <validation.h> #include <validation.h>
static bool IsQuorumDKGEnabled(const CSporkManager& sporkman)
{
return sporkman.IsSporkActive(SPORK_17_QUORUM_DKG_ENABLED);
}
namespace llmq namespace llmq
{ {
static const std::string DB_VVEC = "qdkg_V"; static const std::string DB_VVEC = "qdkg_V";
@ -515,9 +520,4 @@ void CDKGSessionManager::CleanupOldContributions() const
} }
} }
bool IsQuorumDKGEnabled(const CSporkManager& sporkman)
{
return sporkman.IsSporkActive(SPORK_17_QUORUM_DKG_ENABLED);
}
} // namespace llmq } // namespace llmq

View File

@ -104,8 +104,6 @@ private:
void MigrateDKG(); void MigrateDKG();
void CleanupCache() const; void CleanupCache() const;
}; };
bool IsQuorumDKGEnabled(const CSporkManager& sporkman);
} // namespace llmq } // namespace llmq
#endif // BITCOIN_LLMQ_DKGSESSIONMGR_H #endif // BITCOIN_LLMQ_DKGSESSIONMGR_H

View File

@ -6,14 +6,13 @@
#define BITCOIN_LLMQ_INSTANTSEND_H #define BITCOIN_LLMQ_INSTANTSEND_H
#include <llmq/signing.h> #include <llmq/signing.h>
#include <unordered_lru_cache.h>
#include <chain.h> #include <consensus/params.h>
#include <coins.h>
#include <net_types.h> #include <net_types.h>
#include <primitives/transaction.h> #include <primitives/transaction.h>
#include <threadinterrupt.h> #include <threadinterrupt.h>
#include <txmempool.h> #include <txmempool.h>
#include <unordered_lru_cache.h>
#include <gsl/pointers.h> #include <gsl/pointers.h>
@ -21,6 +20,7 @@
#include <unordered_map> #include <unordered_map>
#include <unordered_set> #include <unordered_set>
class CBlockIndex;
class CChainState; class CChainState;
class CDBWrapper; class CDBWrapper;
class CMasternodeSync; class CMasternodeSync;
@ -365,7 +365,7 @@ public:
bool IsInstantSendMempoolSigningEnabled() const; bool IsInstantSendMempoolSigningEnabled() const;
bool RejectConflictingBlocks() const; bool RejectConflictingBlocks() const;
}; };
// TODO: split CInstantSendManager and CInstantSendLock to 2 files
extern std::unique_ptr<CInstantSendManager> quorumInstantSendManager; extern std::unique_ptr<CInstantSendManager> quorumInstantSendManager;
} // namespace llmq } // namespace llmq

View File

@ -5,17 +5,16 @@
#ifndef BITCOIN_LLMQ_QUORUMS_H #ifndef BITCOIN_LLMQ_QUORUMS_H
#define BITCOIN_LLMQ_QUORUMS_H #define BITCOIN_LLMQ_QUORUMS_H
#include <chain.h> #include <llmq/params.h>
#include <consensus/params.h>
#include <saltedhasher.h>
#include <threadinterrupt.h>
#include <unordered_lru_cache.h>
#include <bls/bls.h> #include <bls/bls.h>
#include <bls/bls_worker.h> #include <bls/bls_worker.h>
#include <protocol.h> #include <ctpl_stl.h>
#include <gsl/pointers.h> #include <gsl/pointers.h>
#include <protocol.h>
#include <saltedhasher.h>
#include <threadinterrupt.h>
#include <unordered_lru_cache.h>
#include <atomic> #include <atomic>
#include <map> #include <map>
@ -23,6 +22,7 @@
class CActiveMasternodeManager; class CActiveMasternodeManager;
class CBlockIndex; class CBlockIndex;
class CChain;
class CChainState; class CChainState;
class CConnman; class CConnman;
class CDataStream; class CDataStream;

View File

@ -6,14 +6,13 @@
#define BITCOIN_LLMQ_SIGNING_H #define BITCOIN_LLMQ_SIGNING_H
#include <bls/bls.h> #include <bls/bls.h>
#include <consensus/params.h>
#include <gsl/pointers.h> #include <gsl/pointers.h>
#include <llmq/params.h>
#include <protocol.h> #include <protocol.h>
#include <random.h> #include <random.h>
#include <saltedhasher.h> #include <saltedhasher.h>
#include <sync.h> #include <sync.h>
#include <threadinterrupt.h> #include <threadinterrupt.h>
#include <univalue.h>
#include <unordered_lru_cache.h> #include <unordered_lru_cache.h>
#include <unordered_map> #include <unordered_map>
@ -27,6 +26,7 @@ class CDBWrapper;
class CInv; class CInv;
class CNode; class CNode;
class PeerManager; class PeerManager;
class UniValue;
using NodeId = int64_t; using NodeId = int64_t;

View File

@ -5,25 +5,29 @@
#ifndef BITCOIN_LLMQ_SIGNING_SHARES_H #ifndef BITCOIN_LLMQ_SIGNING_SHARES_H
#define BITCOIN_LLMQ_SIGNING_SHARES_H #define BITCOIN_LLMQ_SIGNING_SHARES_H
#include <bls/bls.h>
#include <llmq/signing.h> #include <llmq/signing.h>
#include <net.h>
#include <bls/bls.h>
#include <random.h> #include <random.h>
#include <saltedhasher.h> #include <saltedhasher.h>
#include <serialize.h> #include <serialize.h>
#include <threadinterrupt.h>
#include <sync.h> #include <sync.h>
#include <threadinterrupt.h>
#include <uint256.h> #include <uint256.h>
#include <atomic> #include <atomic>
#include <limits>
#include <memory>
#include <optional> #include <optional>
#include <string>
#include <thread> #include <thread>
#include <unordered_map> #include <unordered_map>
#include <utility> #include <utility>
#include <vector>
class CNode;
class CConnman;
class CDeterministicMN; class CDeterministicMN;
class CEvoDB;
class CScheduler;
class CSporkManager; class CSporkManager;
class PeerManager; class PeerManager;

View File

@ -10,16 +10,16 @@
#include <llmq/params.h> #include <llmq/params.h>
#include <saltedhasher.h> #include <saltedhasher.h>
#include <serialize.h> #include <serialize.h>
#include <univalue.h> #include <sync.h>
#include <threadsafety.h>
#include <unordered_lru_cache.h> #include <unordered_lru_cache.h>
#include <util/irange.h> #include <util/irange.h>
#include <optional> #include <optional>
class CBlockIndex; class CBlockIndex;
class CDeterministicMN; class CEvoDB;
class CDeterministicMNList; class UniValue;
class CEvoDb;
namespace llmq { namespace llmq {
class CQuorumBlockProcessor; class CQuorumBlockProcessor;

View File

@ -5,6 +5,7 @@
#include <masternode/meta.h> #include <masternode/meta.h>
#include <flat-database.h> #include <flat-database.h>
#include <univalue.h>
#include <util/time.h> #include <util/time.h>
#include <sstream> #include <sstream>

View File

@ -7,14 +7,17 @@
#include <serialize.h> #include <serialize.h>
#include <sync.h> #include <sync.h>
#include <threadsafety.h>
#include <uint256.h> #include <uint256.h>
#include <univalue.h>
#include <atomic> #include <atomic>
#include <map>
#include <memory> #include <memory>
#include <vector>
class CConnman; class CConnman;
class UniValue;
template<typename T> template<typename T>
class CFlatDB; class CFlatDB;