PIVX Core  5.6.99
P2P Digital Currency
deterministicmns.h
Go to the documentation of this file.
1 // Copyright (c) 2018-2021 The Dash Core developers
2 // Copyright (c) 2021 The PIVX Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef PIVX_EVO_DETERMINISTICMNS_H
7 #define PIVX_EVO_DETERMINISTICMNS_H
8 
9 #include "arith_uint256.h"
10 #include "bls/bls_wrapper.h"
11 #include "dbwrapper.h"
12 #include "evo/evodb.h"
13 #include "evo/providertx.h"
15 #include "netaddress.h"
16 #include "saltedhasher.h"
17 #include "serialize.h"
18 #include "sync.h"
19 #include "version.h"
20 
21 #include <immer/map.hpp>
22 #include <immer/map_transient.hpp>
23 
24 #include <unordered_map>
25 
26 class CBlock;
27 class CBlockIndex;
28 class CValidationState;
29 
31 {
32 public:
35  int nPoSePenalty{0};
37  int nPoSeBanHeight{-1};
39 
40  // the block hash X blocks after registration, used in quorum calculations
42  // sha256(proTxHash, confirmedHash) to speed up quorum calculations
43  // please note that this is NOT a double-sha256 hash
45 
52 
53 public:
55  explicit CDeterministicMNState(const ProRegPL& pl)
56  {
60  addr = pl.addr;
63  }
64  template <typename Stream>
65  CDeterministicMNState(deserialize_type, Stream& s) { s >> *this; }
66 
68  {
69  READWRITE(obj.nRegisteredHeight);
70  READWRITE(obj.nLastPaidHeight);
71  READWRITE(obj.nPoSePenalty);
72  READWRITE(obj.nPoSeRevivedHeight);
73  READWRITE(obj.nPoSeBanHeight);
74  READWRITE(obj.nRevocationReason);
75  READWRITE(obj.confirmedHash);
76  READWRITE(obj.confirmedHashWithProRegTxHash);
77  READWRITE(obj.keyIDOwner);
78  READWRITE(obj.pubKeyOperator);
79  READWRITE(obj.keyIDVoting);
80  READWRITE(obj.addr);
81  READWRITE(obj.scriptPayout);
82  READWRITE(obj.scriptOperatorPayout);
83  }
84 
86  {
88  addr = CService();
91  }
92  void BanIfNotBanned(int height)
93  {
94  if (nPoSeBanHeight == -1) {
95  nPoSeBanHeight = height;
96  }
97  }
98  void UpdateConfirmedHash(const uint256& _proTxHash, const uint256& _confirmedHash)
99  {
100  confirmedHash = _confirmedHash;
101  CSHA256 h;
102  h.Write(_proTxHash.begin(), _proTxHash.size());
103  h.Write(_confirmedHash.begin(), _confirmedHash.size());
105  }
106 
107 public:
108  std::string ToString() const;
109  void ToJson(UniValue& obj) const;
110 };
111 typedef std::shared_ptr<CDeterministicMNState> CDeterministicMNStatePtr;
112 typedef std::shared_ptr<const CDeterministicMNState> CDeterministicMNStateCPtr;
113 
115 {
116 public:
117  enum Field : uint32_t {
129  Field_addr = 0x0800,
132  };
133 
134 #define DMN_STATE_DIFF_ALL_FIELDS \
135  DMN_STATE_DIFF_LINE(nRegisteredHeight) \
136  DMN_STATE_DIFF_LINE(nLastPaidHeight) \
137  DMN_STATE_DIFF_LINE(nPoSePenalty) \
138  DMN_STATE_DIFF_LINE(nPoSeRevivedHeight) \
139  DMN_STATE_DIFF_LINE(nPoSeBanHeight) \
140  DMN_STATE_DIFF_LINE(nRevocationReason) \
141  DMN_STATE_DIFF_LINE(confirmedHash) \
142  DMN_STATE_DIFF_LINE(confirmedHashWithProRegTxHash) \
143  DMN_STATE_DIFF_LINE(keyIDOwner) \
144  DMN_STATE_DIFF_LINE(pubKeyOperator) \
145  DMN_STATE_DIFF_LINE(keyIDVoting) \
146  DMN_STATE_DIFF_LINE(addr) \
147  DMN_STATE_DIFF_LINE(scriptPayout) \
148  DMN_STATE_DIFF_LINE(scriptOperatorPayout)
149 
150 public:
151  uint32_t fields{0};
152  // we reuse the state class, but only the members as noted by fields are valid
154 
155 public:
158  {
159 #define DMN_STATE_DIFF_LINE(f) if (a.f != b.f) { state.f = b.f; fields |= Field_##f; }
161 #undef DMN_STATE_DIFF_LINE
162  }
163 
165  {
166  READWRITE(VARINT(obj.fields));
167 #define DMN_STATE_DIFF_LINE(f) if (obj.fields & Field_##f) READWRITE(obj.state.f);
169 #undef DMN_STATE_DIFF_LINE
170  }
171 
173  {
174 #define DMN_STATE_DIFF_LINE(f) if (fields & Field_##f) target.f = state.f;
176 #undef DMN_STATE_DIFF_LINE
177  }
178 };
179 
181 {
182 private:
183  uint64_t internalId{std::numeric_limits<uint64_t>::max()};
184 
185 public:
186  CDeterministicMN() = delete; // no default constructor, must specify internalId
187  explicit CDeterministicMN(uint64_t _internalId) : internalId(_internalId)
188  {
189  // only non-initial values
190  assert(_internalId != std::numeric_limits<uint64_t>::max());
191  }
192  // TODO: can be removed in a future version
193  CDeterministicMN(const CDeterministicMN& mn, uint64_t _internalId) : CDeterministicMN(mn) {
194  // only non-initial values
195  assert(_internalId != std::numeric_limits<uint64_t>::max());
196  internalId = _internalId;
197  }
198 
199  template <typename Stream>
201  {
202  s >> *this;
203  }
204 
207  uint16_t nOperatorReward;
209 
210 public:
212  {
213  READWRITE(obj.proTxHash);
214  READWRITE(VARINT(obj.internalId));
215  READWRITE(obj.collateralOutpoint);
216  READWRITE(obj.nOperatorReward);
217  READWRITE(obj.pdmnState);
218  }
219 
220  uint64_t GetInternalId() const;
221  bool IsPoSeBanned() const { return pdmnState->nPoSeBanHeight != -1; }
222 
223  std::string ToString() const;
224  void ToJson(UniValue& obj) const;
225 };
226 
227 typedef std::shared_ptr<const CDeterministicMN> CDeterministicMNCPtr;
228 
230 
231 template <typename Stream, typename K, typename T, typename Hash, typename Equal>
232 void SerializeImmerMap(Stream& os, const immer::map<K, T, Hash, Equal>& m)
233 {
234  WriteCompactSize(os, m.size());
235  for (typename immer::map<K, T, Hash, Equal>::const_iterator mi = m.begin(); mi != m.end(); ++mi)
236  Serialize(os, (*mi));
237 }
238 
239 template <typename Stream, typename K, typename T, typename Hash, typename Equal>
240 void UnserializeImmerMap(Stream& is, immer::map<K, T, Hash, Equal>& m)
241 {
242  m = immer::map<K, T, Hash, Equal>();
243  unsigned int nSize = ReadCompactSize(is);
244  for (unsigned int i = 0; i < nSize; i++) {
245  std::pair<K, T> item;
246  Unserialize(is, item);
247  m = m.set(item.first, item.second);
248  }
249 }
250 
251 // For some reason the compiler is not able to choose the correct Serialize/Deserialize methods without a specialized
252 // version of SerReadWrite. It otherwise always chooses the version that calls a.Serialize()
253 template<typename Stream, typename K, typename T, typename Hash, typename Equal>
254 inline void SerReadWrite(Stream& s, const immer::map<K, T, Hash, Equal>& m, CSerActionSerialize ser_action)
255 {
256  ::SerializeImmerMap(s, m);
257 }
258 
259 template<typename Stream, typename K, typename T, typename Hash, typename Equal>
260 inline void SerReadWrite(Stream& s, immer::map<K, T, Hash, Equal>& obj, CSerActionUnserialize ser_action)
261 {
262  ::UnserializeImmerMap(s, obj);
263 }
264 
266 {
267 public:
268  typedef immer::map<uint256, CDeterministicMNCPtr> MnMap;
269  typedef immer::map<uint64_t, uint256> MnInternalIdMap;
270  typedef immer::map<uint256, std::pair<uint256, uint32_t> > MnUniquePropertyMap;
271 
272 private:
274  int nHeight{-1};
278 
279  // map of unique properties like address and keys
280  // we keep track of this as checking for duplicates would otherwise be painfully slow
282 
283 public:
285  explicit CDeterministicMNList(const uint256& _blockHash, int _height, uint32_t _totalRegisteredCount) :
286  blockHash(_blockHash),
287  nHeight(_height),
288  nTotalRegisteredCount(_totalRegisteredCount)
289  {
290  }
291 
292  template<typename Stream>
293  void Serialize(Stream& s) const
294  {
295  s << blockHash;
296  s << nHeight;
298  // Serialize the map as a vector
299  WriteCompactSize(s, mnMap.size());
300  for (const auto& p : mnMap) {
301  s << *p.second;
302  }
303  }
304 
305  template<typename Stream>
306  void Unserialize(Stream& s) {
307  mnMap = MnMap();
310 
311  s >> blockHash;
312  s >> nHeight;
314  size_t cnt = ReadCompactSize(s);
315  for (size_t i = 0; i < cnt; i++) {
316  AddMN(std::make_shared<CDeterministicMN>(deserialize, s), false);
317  }
318  }
319 
320 public:
321  size_t GetAllMNsCount() const
322  {
323  return mnMap.size();
324  }
325 
326  size_t GetValidMNsCount() const
327  {
328  size_t count = 0;
329  for (const auto& p : mnMap) {
330  if (!p.second->IsPoSeBanned()) {
331  count++;
332  }
333  }
334  return count;
335  }
336 
337  template <typename Callback>
338  void ForEachMN(bool onlyValid, Callback&& cb) const
339  {
340  for (const auto& p : mnMap) {
341  if (!onlyValid || !p.second->IsPoSeBanned()) {
342  cb(p.second);
343  }
344  }
345  }
346 
347 public:
348  const uint256& GetBlockHash() const { return blockHash; }
349  int GetHeight() const { return nHeight; }
350  uint32_t GetTotalRegisteredCount() const { return nTotalRegisteredCount; }
351  void SetHeight(int _height) { nHeight = _height; }
352  void SetBlockHash(const uint256& _blockHash) { blockHash = _blockHash; }
353 
354  bool HasMN(const uint256& proTxHash) const
355  {
356  return GetMN(proTxHash) != nullptr;
357  }
358  bool HasMNByCollateral(const COutPoint& collateralOutpoint) const
359  {
360  return GetMNByCollateral(collateralOutpoint) != nullptr;
361  }
362  bool HasValidMNByCollateral(const COutPoint& collateralOutpoint) const
363  {
364  return GetValidMNByCollateral(collateralOutpoint) != nullptr;
365  }
369  CDeterministicMNCPtr GetMNByCollateral(const COutPoint& collateralOutpoint) const;
370  CDeterministicMNCPtr GetValidMNByCollateral(const COutPoint& collateralOutpoint) const;
371  CDeterministicMNCPtr GetMNByService(const CService& service) const;
372  CDeterministicMNCPtr GetMNByInternalId(uint64_t internalId) const;
374 
381  std::vector<CDeterministicMNCPtr> GetProjectedMNPayees(unsigned int nCount) const;
382 
389  std::vector<CDeterministicMNCPtr> CalculateQuorum(size_t maxSize, const uint256& modifier) const;
390  std::vector<std::pair<arith_uint256, CDeterministicMNCPtr>> CalculateScores(const uint256& modifier) const;
391 
397  int CalcMaxPoSePenalty() const;
398 
407  int CalcPenalty(int percent) const;
408 
416  void PoSePunish(const uint256& proTxHash, int penalty, bool debugLogs);
417 
423  void PoSeDecrease(const uint256& proTxHash);
424 
426  CDeterministicMNList ApplyDiff(const CBlockIndex* pindex, const CDeterministicMNListDiff& diff) const;
427 
428  void AddMN(const CDeterministicMNCPtr& dmn, bool fBumpTotalCount = true);
429  void UpdateMN(const CDeterministicMNCPtr& oldDmn, const CDeterministicMNStateCPtr& pdmnState);
430  void UpdateMN(const uint256& proTxHash, const CDeterministicMNStateCPtr& pdmnState);
431  void UpdateMN(const CDeterministicMNCPtr& oldDmn, const CDeterministicMNStateDiff& stateDiff);
432  void RemoveMN(const uint256& proTxHash);
433 
434  template <typename T>
435  bool HasUniqueProperty(const T& v) const
436  {
437  return mnUniquePropertyMap.count(::SerializeHash(v, SER_GETHASH, PROTOCOL_VERSION | ADDRV2_FORMAT)) != 0;
438  }
439  template <typename T>
441  {
442  auto p = mnUniquePropertyMap.find(::SerializeHash(v, SER_GETHASH, PROTOCOL_VERSION | ADDRV2_FORMAT));
443  if (!p) {
444  return nullptr;
445  }
446  return GetMN(p->first);
447  }
448 
449 private:
450  template <typename T>
451  void AddUniqueProperty(const CDeterministicMNCPtr& dmn, const T& v)
452  {
453  static const T nullValue;
454  assert(v != nullValue);
455 
456  auto hash = ::SerializeHash(v, SER_GETHASH, PROTOCOL_VERSION | ADDRV2_FORMAT);
457  auto oldEntry = mnUniquePropertyMap.find(hash);
458  assert(!oldEntry || oldEntry->first == dmn->proTxHash);
459  std::pair<uint256, uint32_t> newEntry(dmn->proTxHash, 1);
460  if (oldEntry) {
461  newEntry.second = oldEntry->second + 1;
462  }
463  mnUniquePropertyMap = mnUniquePropertyMap.set(hash, newEntry);
464  }
465  template <typename T>
466  void DeleteUniqueProperty(const CDeterministicMNCPtr& dmn, const T& oldValue)
467  {
468  static const T nullValue;
469  assert(oldValue != nullValue);
470 
471  auto oldHash = ::SerializeHash(oldValue, SER_GETHASH, PROTOCOL_VERSION | ADDRV2_FORMAT);
472  auto p = mnUniquePropertyMap.find(oldHash);
473  assert(p && p->first == dmn->proTxHash);
474  if (p->second == 1) {
475  mnUniquePropertyMap = mnUniquePropertyMap.erase(oldHash);
476  } else {
477  mnUniquePropertyMap = mnUniquePropertyMap.set(oldHash, std::make_pair(dmn->proTxHash, p->second - 1));
478  }
479  }
480  template <typename T>
481  void UpdateUniqueProperty(const CDeterministicMNCPtr& dmn, const T& oldValue, const T& newValue)
482  {
483  if (oldValue == newValue) {
484  return;
485  }
486  static const T nullValue;
487 
488  if (oldValue != nullValue) {
489  DeleteUniqueProperty(dmn, oldValue);
490  }
491 
492  if (newValue != nullValue) {
493  AddUniqueProperty(dmn, newValue);
494  }
495  }
496 };
497 
499 {
500 public:
501  int nHeight{-1}; //memory only
502 
503  std::vector<CDeterministicMNCPtr> addedMNs;
504  // keys are all relating to the internalId of MNs
505  std::map<uint64_t, CDeterministicMNStateDiff> updatedMNs;
506  std::set<uint64_t> removedMns;
507 
508 public:
509  template<typename Stream>
510  void Serialize(Stream& s) const
511  {
512  s << addedMNs;
513  WriteCompactSize(s, updatedMNs.size());
514  for (const auto& p : updatedMNs) {
515  s << VARINT(p.first);
516  s << p.second;
517  }
518  WriteCompactSize(s, removedMns.size());
519  for (const auto& p : removedMns) {
520  s << VARINT(p);
521  }
522  }
523 
524  template<typename Stream>
525  void Unserialize(Stream& s)
526  {
527  updatedMNs.clear();
528  removedMns.clear();
529 
530  size_t tmp;
531  uint64_t tmp2;
532  s >> addedMNs;
533  tmp = ReadCompactSize(s);
534  for (size_t i = 0; i < tmp; i++) {
536  s >> VARINT(tmp2);
537  s >> diff;
538  updatedMNs.emplace(tmp2, std::move(diff));
539  }
540  tmp = ReadCompactSize(s);
541  for (size_t i = 0; i < tmp; i++) {
542  s >> VARINT(tmp2);
543  removedMns.emplace(tmp2);
544  }
545  }
546 
547 public:
548  bool HasChanges() const
549  {
550  return !addedMNs.empty() || !updatedMNs.empty() || !removedMns.empty();
551  }
552 };
553 
555 {
556  static const int DISK_SNAPSHOT_PERIOD = 1440; // once per day
557  static const int DISK_SNAPSHOTS = 3; // keep cache for 3 disk snapshots to have 2 full days covered
559 
560 public:
562 
563 private:
565 
566  std::unordered_map<uint256, CDeterministicMNList, StaticSaltedHasher> mnListsCache;
567  std::unordered_map<uint256, CDeterministicMNListDiff, StaticSaltedHasher> mnListDiffsCache;
568  const CBlockIndex* tipIndex{nullptr};
569 
570 public:
571  explicit CDeterministicMNManager(CEvoDB& _evoDb);
572 
573  bool ProcessBlock(const CBlock& block, const CBlockIndex* pindex, CValidationState& state, bool fJustCheck);
574  bool UndoBlock(const CBlock& block, const CBlockIndex* pindex);
575 
576  void SetTipIndex(const CBlockIndex* pindex);
577 
578  // the returned list will not contain the correct block hash (we can't know it yet as the coinbase TX is not updated yet)
579  bool BuildNewListFromBlock(const CBlock& block, const CBlockIndex* pindexPrev, CValidationState& state, CDeterministicMNList& mnListRet, bool debugLogs);
580  void HandleQuorumCommitment(llmq::CFinalCommitment& qc, const CBlockIndex* pindexQuorum, CDeterministicMNList& mnList, bool debugLogs);
582 
583  // to return a valid list, it must have been built first, so never call it with a block not-yet connected (e.g. from CheckBlock).
586 
587  // Whether DMNs are enforced at provided height, or at the chain-tip
588  bool IsDIP3Enforced(int nHeight) const;
589  bool IsDIP3Enforced() const;
590 
591  // Whether Legacy MNs are disabled at provided height, or at the chain-tip
592  bool LegacyMNObsolete(int nHeight) const;
593  bool LegacyMNObsolete() const;
594 
595  // Get the list of members for a given quorum type and index
596  std::vector<CDeterministicMNCPtr> GetAllQuorumMembers(Consensus::LLMQType llmqType, const CBlockIndex* pindexQuorum);
597 
598 private:
599  void CleanupCache(int nHeight);
600 };
601 
602 extern std::unique_ptr<CDeterministicMNManager> deterministicMNManager;
603 
604 #endif // PIVX_EVO_DETERMINISTICMNS_H
void Set(const BLSObject &_obj)
Definition: bls_wrapper.h:341
Definition: block.h:80
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:139
CDeterministicMNStateCPtr pdmnState
uint64_t GetInternalId() const
void ToJson(UniValue &obj) const
CDeterministicMN(const CDeterministicMN &mn, uint64_t _internalId)
bool IsPoSeBanned() const
std::string ToString() const
CDeterministicMN(deserialize_type, Stream &s)
CDeterministicMN()=delete
COutPoint collateralOutpoint
CDeterministicMN(uint64_t _internalId)
SERIALIZE_METHODS(CDeterministicMN, obj)
std::set< uint64_t > removedMns
void Serialize(Stream &s) const
std::map< uint64_t, CDeterministicMNStateDiff > updatedMNs
std::vector< CDeterministicMNCPtr > addedMNs
void DeleteUniqueProperty(const CDeterministicMNCPtr &dmn, const T &oldValue)
immer::map< uint256, std::pair< uint256, uint32_t > > MnUniquePropertyMap
CDeterministicMNCPtr GetMNByOperatorKey(const CBLSPublicKey &pubKey)
CDeterministicMNCPtr GetValidMN(const uint256 &proTxHash) const
CDeterministicMNList ApplyDiff(const CBlockIndex *pindex, const CDeterministicMNListDiff &diff) const
CDeterministicMNCPtr GetMNByService(const CService &service) const
void UpdateMN(const CDeterministicMNCPtr &oldDmn, const CDeterministicMNStateCPtr &pdmnState)
bool HasMN(const uint256 &proTxHash) const
uint32_t GetTotalRegisteredCount() const
void UpdateUniqueProperty(const CDeterministicMNCPtr &dmn, const T &oldValue, const T &newValue)
immer::map< uint256, CDeterministicMNCPtr > MnMap
immer::map< uint64_t, uint256 > MnInternalIdMap
bool HasMNByCollateral(const COutPoint &collateralOutpoint) const
void SetBlockHash(const uint256 &_blockHash)
void AddMN(const CDeterministicMNCPtr &dmn, bool fBumpTotalCount=true)
void AddUniqueProperty(const CDeterministicMNCPtr &dmn, const T &v)
std::vector< CDeterministicMNCPtr > CalculateQuorum(size_t maxSize, const uint256 &modifier) const
Calculate a quorum based on the modifier.
int CalcMaxPoSePenalty() const
Calculates the maximum penalty which is allowed at the height of this MN list.
void PoSeDecrease(const uint256 &proTxHash)
Decrease penalty score of MN by 1.
size_t GetValidMNsCount() const
int CalcPenalty(int percent) const
Returns a the given percentage from the max penalty for this MN list.
CDeterministicMNCPtr GetMNByInternalId(uint64_t internalId) const
CDeterministicMNCPtr GetMNPayee() const
bool HasUniqueProperty(const T &v) const
std::vector< std::pair< arith_uint256, CDeterministicMNCPtr > > CalculateScores(const uint256 &modifier) const
CDeterministicMNCPtr GetValidMNByCollateral(const COutPoint &collateralOutpoint) const
MnInternalIdMap mnInternalIdMap
const uint256 & GetBlockHash() const
void Serialize(Stream &s) const
CDeterministicMNListDiff BuildDiff(const CDeterministicMNList &to) const
void SetHeight(int _height)
void ForEachMN(bool onlyValid, Callback &&cb) const
void RemoveMN(const uint256 &proTxHash)
void Unserialize(Stream &s)
void PoSePunish(const uint256 &proTxHash, int penalty, bool debugLogs)
Punishes a MN for misbehavior.
CDeterministicMNCPtr GetMN(const uint256 &proTxHash) const
size_t GetAllMNsCount() const
CDeterministicMNCPtr GetMNByCollateral(const COutPoint &collateralOutpoint) const
CDeterministicMNList(const uint256 &_blockHash, int _height, uint32_t _totalRegisteredCount)
CDeterministicMNCPtr GetUniquePropertyMN(const T &v) const
bool HasValidMNByCollateral(const COutPoint &collateralOutpoint) const
std::vector< CDeterministicMNCPtr > GetProjectedMNPayees(unsigned int nCount) const
Calculates the projected MN payees for the next count blocks.
MnUniquePropertyMap mnUniquePropertyMap
CDeterministicMNList GetListForBlock(const CBlockIndex *pindex)
bool UndoBlock(const CBlock &block, const CBlockIndex *pindex)
static const int DISK_SNAPSHOTS
CDeterministicMNManager(CEvoDB &_evoDb)
static const int LIST_DIFFS_CACHE_SIZE
void SetTipIndex(const CBlockIndex *pindex)
void CleanupCache(int nHeight)
static const int DISK_SNAPSHOT_PERIOD
bool ProcessBlock(const CBlock &block, const CBlockIndex *pindex, CValidationState &state, bool fJustCheck)
const CBlockIndex * tipIndex
CDeterministicMNList GetListAtChainTip()
std::vector< CDeterministicMNCPtr > GetAllQuorumMembers(Consensus::LLMQType llmqType, const CBlockIndex *pindexQuorum)
void DecreasePoSePenalties(CDeterministicMNList &mnList)
std::unordered_map< uint256, CDeterministicMNListDiff, StaticSaltedHasher > mnListDiffsCache
bool BuildNewListFromBlock(const CBlock &block, const CBlockIndex *pindexPrev, CValidationState &state, CDeterministicMNList &mnListRet, bool debugLogs)
std::unordered_map< uint256, CDeterministicMNList, StaticSaltedHasher > mnListsCache
void HandleQuorumCommitment(llmq::CFinalCommitment &qc, const CBlockIndex *pindexQuorum, CDeterministicMNList &mnList, bool debugLogs)
CDeterministicMNStateDiff(const CDeterministicMNState &a, const CDeterministicMNState &b)
void ApplyToState(CDeterministicMNState &target) const
SERIALIZE_METHODS(CDeterministicMNStateDiff, obj)
CDeterministicMNState state
void BanIfNotBanned(int height)
void UpdateConfirmedHash(const uint256 &_proTxHash, const uint256 &_confirmedHash)
CBLSLazyPublicKey pubKeyOperator
uint256 confirmedHashWithProRegTxHash
std::string ToString() const
CDeterministicMNState(const ProRegPL &pl)
void ToJson(UniValue &obj) const
SERIALIZE_METHODS(CDeterministicMNState, obj)
CDeterministicMNState(deserialize_type, Stream &s)
Definition: evodb.h:32
A reference to a CKey: the Hash160 of its serialized public key.
Definition: pubkey.h:21
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:72
A hasher class for SHA-256.
Definition: sha256.h:13
void Finalize(unsigned char hash[OUTPUT_SIZE])
Definition: sha256.cpp:168
CSHA256 & Write(const unsigned char *data, size_t len)
Definition: sha256.cpp:142
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:381
A combination of a network address (CNetAddr) and a (TCP) port.
Definition: netaddress.h:484
Capture information about block/transaction validation.
Definition: validation.h:24
CScript scriptOperatorPayout
Definition: providertx.h:36
CKeyID keyIDVoting
Definition: providertx.h:33
CScript scriptPayout
Definition: providertx.h:34
CBLSPublicKey pubKeyOperator
Definition: providertx.h:32
CKeyID keyIDOwner
Definition: providertx.h:31
CService addr
Definition: providertx.h:30
@ REASON_NOT_SPECIFIED
Definition: providertx.h:142
unsigned int size() const
Definition: uint256.h:83
unsigned char * begin()
Definition: uint256.h:63
256-bit opaque blob.
Definition: uint256.h:138
std::shared_ptr< const CDeterministicMNState > CDeterministicMNStateCPtr
void SerReadWrite(Stream &s, const immer::map< K, T, Hash, Equal > &m, CSerActionSerialize ser_action)
std::shared_ptr< CDeterministicMNState > CDeterministicMNStatePtr
#define DMN_STATE_DIFF_ALL_FIELDS
void SerializeImmerMap(Stream &os, const immer::map< K, T, Hash, Equal > &m)
std::unique_ptr< CDeterministicMNManager > deterministicMNManager
void UnserializeImmerMap(Stream &is, immer::map< K, T, Hash, Equal > &m)
std::shared_ptr< const CDeterministicMN > CDeterministicMNCPtr
uint256 SerializeHash(const T &obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
Compute the 256-bit hash of an object's serialization.
Definition: hash.h:289
#define T(expected, seed, data)
LLMQType
Definition: params.h:90
@ proTxHash
Definition: rpcevo.cpp:50
@ SER_GETHASH
Definition: serialize.h:176
#define VARINT(obj)
Definition: serialize.h:513
constexpr deserialize_type deserialize
Definition: serialize.h:57
void Serialize(Stream &s, char a)
Definition: serialize.h:237
void Unserialize(Stream &s, char &a)
Definition: serialize.h:253
uint64_t ReadCompactSize(Stream &is, bool range_check=true)
Decode a CompactSize-encoded variable-length integer.
Definition: serialize.h:359
#define READWRITE(...)
Definition: serialize.h:183
void WriteCompactSize(CSizeComputer &os, uint64_t nSize)
Definition: serialize.h:1435
Support for SERIALIZE_METHODS and READWRITE macro.
Definition: serialize.h:1316
Dummy data type to identify deserializing constructors.
Definition: serialize.h:56