17 #include "validation.h"
22 static const std::string CLSIG_REQUESTID_PREFIX =
"clsig";
124 LogPrintf(
"CChainLocksHandler::%s -- invalid CLSIG (%s), peer=%d\n", __func__, clsig.
ToString(), from);
138 LogPrintf(
"CChainLocksHandler::%s -- new CLSIG (%s) tries to reorg previous CLSIG (%s), peer=%d\n",
147 g_connman->RelayInv(inv, LLMQS_PROTO_VERSION);
156 if (blockIt->second->nHeight != clsig.
nHeight) {
158 LogPrintf(
"CChainLocksHandler::%s -- height of CLSIG (%s) does not match the specified block's height (%d)\n",
159 __func__, clsig.
ToString(), blockIt->second->nHeight);
182 LogPrintf(
"CChainLocksHandler::%s -- block header %s came in late, updating and enforcing\n", __func__, pindexNew->
GetBlockHash().
ToString());
186 LogPrintf(
"CChainLocksHandler::%s -- height of CLSIG (%s) does not match the specified block's height (%d)\n",
236 if (!pindex->
pprev) {
302 if (!currentBestChainLockBlockIndex) {
318 for (
auto jt = itp.first; jt != itp.second; ++jt) {
319 if (jt->second == pindex) {
322 LogPrintf(
"CChainLocksHandler::%s -- CLSIG (%s) invalidates block %s\n",
323 __func__, clsig.
ToString(), jt->second->GetBlockHash().ToString());
327 pindex = pindex->
pprev;
333 if (!currentBestChainLockBlockIndex->
IsValid()) {
343 LogPrintf(
"CChainLocksHandler::%s -- ActivateBestChain failed: %s\n", __func__, state.
GetRejectReason());
386 LogPrintf(
"CChainLocksHandler::%s -- InvalidateBlock failed: %s\n", __func__, state.
GetRejectReason());
394 LogPrintf(
"CChainLocksHandler::%s -- ActivateBestChain failed: %s\n", __func__, state.
GetRejectReason());
427 return pAncestor && pAncestor->
GetBlockHash() == blockHash;
458 return pAncestor->GetBlockHash() != blockHash;
const CChainParams & Params()
Return the currently selected parameters.
const BLSObject & Get() const
The block chain is a tree shaped structure starting with the genesis block at the root,...
CBlockIndex * pprev
pointer to the index of the predecessor of this block
uint256 GetBlockHash() const
bool IsValid(enum BlockStatus nUpTo=BLOCK_VALID_TRANSACTIONS) const
Check whether this block index entry is valid up to the passed validity level.
CBlockIndex * GetAncestor(int height)
Efficiently find an ancestor of this block.
int nHeight
height of the entry in the chain. The genesis block has height 0
CBlockIndex * Tip(bool fProofOfStake=false) const
Returns the index entry for the tip of this chain, or nullptr if none.
bool Contains(const CBlockIndex *pindex) const
Efficiently check whether a block is present in this chain.
Information about a peer.
void scheduleFromNow(Function f, int64_t deltaMilliSeconds)
void scheduleEvery(Function f, int64_t deltaMilliSeconds)
bool IsSporkActive(SporkId nSporkID)
Capture information about block/transaction validation.
std::string GetRejectReason() const
bool IsBlockchainSynced() const
std::string ToString() const
std::string ToString() const
virtual void HandleNewRecoveredSig(const CRecoveredSig &recoveredSig)
bool InternalHasConflictingChainLock(int nHeight, const uint256 &blockHash)
bool InternalHasChainLock(int nHeight, const uint256 &blockHash)
bool tryLockChainTipScheduled
uint256 lastSignedRequestId
bool AlreadyHave(const CInv &inv)
bool GetChainLockByHash(const uint256 &hash, CChainLockSig &ret)
CChainLocksHandler(CScheduler *_scheduler)
uint256 lastSignedMsgHash
CChainLockSig bestChainLockWithKnownBlock
bool HasChainLock(int nHeight, const uint256 &blockHash)
void DoInvalidateBlock(const CBlockIndex *pindex, bool activateBestChain)
void EnforceBestChainLock()
std::map< uint256, int64_t > seenChainLocks
const CBlockIndex * bestChainLockBlockIndex
uint256 bestChainLockHash
void ProcessMessage(CNode *pfrom, const std::string &strCommand, CDataStream &vRecv, CConnman &connman)
CChainLockSig GetBestChainLock()
static const int64_t CLEANUP_SEEN_TIMEOUT
void AcceptedBlockHeader(const CBlockIndex *pindexNew)
void UpdatedBlockTip(const CBlockIndex *pindexNew)
static const int64_t CLEANUP_INTERVAL
CChainLockSig bestChainLock
void ProcessNewChainLock(NodeId from, const CChainLockSig &clsig, const uint256 &hash)
bool HasConflictingChainLock(int nHeight, const uint256 &blockHash)
uint256 SerializeHash(const T &obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
Compute the 256-bit hash of an object's serialization.
std::unique_ptr< CConnman > g_connman
#define LogPrint(category,...)
std::unique_ptr< CSigningManager > quorumSigningManager
std::unique_ptr< CChainLocksHandler > chainLocksHandler
void Misbehaving(NodeId pnode, int howmuch, const std::string &message) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Increase a node's misbehavior score.
RecursiveMutex cs_main
Global state.
CSporkManager sporkManager
@ SPORK_23_CHAINLOCKS_ENFORCEMENT
#define AssertLockNotHeld(cs)
#define AssertLockHeld(cs)
std::atomic< bool > fMasterNode
TierTwoSyncState g_tiertwo_sync_state
int64_t GetTimeMillis()
Returns the system time (not mockable)
bool ActivateBestChain(CValidationState &state, std::shared_ptr< const CBlock > pblock)
Make the best chain active, in multiple steps.
bool ReconsiderBlock(CValidationState &state, CBlockIndex *pindex)
Remove invalidity status from a block and its descendants.
PrevBlockMap mapPrevBlockIndex
CChain chainActive
The currently-connected chain of blocks (protected by cs_main).
bool InvalidateBlock(CValidationState &state, const CChainParams &chainparams, CBlockIndex *pindex)
Mark a block as invalid.