24#include <test/util/setup_common.h>
26#include <boost/mpl/list.hpp>
27#include <boost/test/unit_test.hpp>
38 struct AvalancheTest {
41 static std::vector<CInv> getInvsForNextPoll(
Processor &
p) {
42 return p.getInvsForNextPoll(
false);
47 return p.peerManager->selectNode());
53 return p.minQuorumScore;
57 return p.minQuorumConnectedScoreRatio;
61 p.avaproofsNodeCounter = 0;
66 p.voteRecords.getWriteView()->insert(
72 LOCK(
p.cs_finalizationTip);
73 p.finalizationTip = pindex;
80 static void updatedBlockTip(
Processor &
p) {
p.updatedBlockTip(); }
85 return p.finalizedItems.insert(proofid));
98struct CConnmanTest :
public CConnman {
119struct AvalancheTestingSetup :
public TestChain100Setup {
120 const ::Config &config;
121 CConnmanTest *m_connman;
123 std::unique_ptr<Processor> m_processor;
128 std::unordered_set<std::string> m_overridden_args;
130 AvalancheTestingSetup()
131 : TestChain100Setup(), config(
GetConfig()),
132 masterpriv(
CKey::MakeCompressedKey()) {
134 auto connman = std::make_unique<CConnmanTest>(config, 0x1337, 0x1337,
136 m_connman = connman.get();
137 m_node.connman = std::move(connman);
140 setArg(
"-avaminquorumstake",
"0");
141 setArg(
"-avaminquorumconnectedstakeratio",
"0");
142 setArg(
"-avaminavaproofsnodecount",
"0");
143 setArg(
"-avaproofstakeutxoconfirmations",
"1");
153 *
m_node.mempool, m_processor.get(), {});
158 m_connman->ClearNodes();
162 for (
const std::string &key : m_overridden_args) {
165 m_overridden_args.clear();
180 node->m_has_all_wanted_services =
184 node->fSuccessfullyConnected =
true;
186 m_connman->AddNode(*
node);
204 BOOST_CHECK(
pb.addUTXO(outpoint, amount, height,
false, key));
210 return pm.addNode(nodeid, proofid);
214 bool addNode(
NodeId nodeid) {
217 return pm.registerProof(proof) &&
218 pm.addNode(nodeid, proof->getId());
226 return pm.registerProof(proof);
228 const ProofId &proofid = proof->getId();
230 std::array<CNode *, 8> nodes;
231 for (
CNode *&n : nodes) {
239 void runEventLoop() { AvalancheTest::runEventLoop(*m_processor); }
242 return AvalancheTest::getSuitableNodeToQuery(*m_processor);
245 std::vector<CInv> getInvsForNextPoll() {
246 return AvalancheTest::getInvsForNextPoll(*m_processor);
249 uint64_t getRound()
const {
return AvalancheTest::getRound(*m_processor); }
252 std::vector<avalanche::VoteItemUpdate> &updates,
253 std::string &
error) {
260 std::vector<avalanche::VoteItemUpdate> &updates) {
267 void setArg(std::string key,
const std::string &value) {
269 argsman.ForceSetArg(key, value);
270 m_overridden_args.emplace(std::move(key));
274 return m_processor->addToReconcile(item);
278struct BlockProvider {
279 AvalancheTestingSetup *fixture;
282 BlockProvider(AvalancheTestingSetup *
_fixture)
286 CBlock block = fixture->CreateAndProcessBlock({},
CScript());
290 return Assert(fixture->m_node.chainman)
291 ->m_blockman.LookupBlockIndex(blockHash);
299 std::vector<CBlockIndex *> &&
items) {
302 std::vector<Vote> votes;
308 votes.emplace_back(
error, item->GetBlockHash());
316 pindex->nStatus = pindex->nStatus.withFailed();
320 return std::get<const CBlockIndex *>(item);
324struct ProofProvider {
325 AvalancheTestingSetup *fixture;
328 ProofProvider(AvalancheTestingSetup *
_fixture)
332 const ProofRef proof = fixture->GetProof();
340 return proof->
getId();
344 std::vector<ProofRef> &&
items) {
347 std::vector<Vote> votes;
352 for (
auto &item :
items) {
353 votes.emplace_back(
error, item->getId());
367 return std::get<const ProofRef>(item);
372 AvalancheTestingSetup *fixture;
374 std::vector<avalanche::VoteItemUpdate> updates;
377 TxProvider(AvalancheTestingSetup *
_fixture)
406 std::vector<CTransactionRef> &&
items) {
409 std::vector<Vote> votes;
415 return lhs->GetId() < rhs->GetId();
417 for (
auto &item :
items) {
418 votes.emplace_back(
error, item->GetId());
434 return std::get<const CTransactionRef>(item);
444 boost::
mpl::list<BlockProvider, ProofProvider, TxProvider>;
449 std::set<VoteStatus> status{
450 VoteStatus::Invalid, VoteStatus::Rejected, VoteStatus::Accepted,
451 VoteStatus::Finalized, VoteStatus::Stale,
454 auto item = provider.buildVoteItem();
456 for (
auto s : status) {
479 auto item = provider.buildVoteItem();
480 auto itemid = provider.getVoteItemId(item);
491 std::vector<avalanche::VoteItemUpdate> updates;
503 if (updates.size() > 0) {
508 BOOST_CHECK(updates[0].getStatus() == VoteStatus::Finalized);
543 AvalancheTest::setFinalizationTip(*m_processor,
chaintip);
555 auto item =
decltype(provider.buildVoteItem())();
562 item = provider.buildVoteItem();
571 const uint32_t invType = provider.invType;
573 auto item = provider.buildVoteItem();
574 auto itemid = provider.getVoteItemId(item);
584 auto invs = getInvsForNextPoll();
592 std::vector<avalanche::VoteItemUpdate> updates;
601 for (
int i = 0; i < 6; i++) {
616 for (
int i = 1; i < 7; i++) {
635 for (
int i = 2; i < 8; i++) {
651 invs = getInvsForNextPoll();
659 BOOST_CHECK(provider.fromAnyVoteItem(updates[0].getVoteItem()) == item);
660 BOOST_CHECK(updates[0].getStatus() == VoteStatus::Finalized);
664 invs = getInvsForNextPoll();
668 item = provider.buildVoteItem();
669 itemid = provider.getVoteItemId(item);
673 invs = getInvsForNextPoll();
679 for (
int i = 0; i < 6; i++) {
689 BOOST_CHECK(provider.fromAnyVoteItem(updates[0].getVoteItem()) == item);
690 BOOST_CHECK(updates[0].getStatus() == VoteStatus::Rejected);
701 invs = getInvsForNextPoll();
710 BOOST_CHECK(provider.fromAnyVoteItem(updates[0].getVoteItem()) == item);
711 BOOST_CHECK(updates[0].getStatus() == VoteStatus::Invalid);
715 invs = getInvsForNextPoll();
721 const uint32_t invType = provider.invType;
723 auto itemA = provider.buildVoteItem();
726 auto itemB = provider.buildVoteItem();
738 auto invs = getInvsForNextPoll();
745 std::vector<avalanche::VoteItemUpdate> updates;
751 std::vector<Vote> votes = provider.buildVotesForItems(0, {
itemA,
itemB});
754 invs = getInvsForNextPoll();
758 for (
size_t i = 0; i < invs.size(); i++) {
764 for (
int i = 0; i < 4; i++) {
792 BOOST_CHECK(updates[0].getStatus() == VoteStatus::Finalized);
796 invs = getInvsForNextPoll();
805 BOOST_CHECK(updates[0].getStatus() == VoteStatus::Finalized);
809 invs = getInvsForNextPoll();
815 const uint32_t invType = provider.invType;
817 auto item = provider.buildVoteItem();
818 auto itemid = provider.getVoteItemId(item);
843 auto invs = getInvsForNextPoll();
870 std::vector<avalanche::VoteItemUpdate> updates;
903 resp = {getRound(), 0, {}};
918 invs = getInvsForNextPoll();
921 item = provider.buildVoteItem();
922 itemid = provider.getVoteItemId(item);
925 invs = getInvsForNextPoll();
950 const auto item2 = provider.buildVoteItem();
953 std::vector<Vote> votes = provider.buildVotesForItems(0, {item,
item2});
954 resp = {getRound(), 0, {votes[1], votes[0]}};
960 resp = {getRound(), 0, votes};
969 const uint32_t invType = provider.invType;
971 auto itemA = provider.buildVoteItem();
972 auto itemB = provider.buildVoteItem();
977 std::vector<Vote> votes = provider.buildVotesForItems(0, {
itemA,
itemB});
983 auto invs = getInvsForNextPoll();
985 for (
size_t i = 0; i < invs.size(); i++) {
991 provider.invalidateItem(
itemB);
994 std::vector<avalanche::VoteItemUpdate> updates;
1020 const auto item = provider.buildVoteItem();
1021 const auto itemid = provider.getVoteItemId(item);
1031 for (
int i = 0; i < 10; i++) {
1039 std::this_thread::sleep_for(std::chrono::milliseconds(1));
1042 std::vector<avalanche::VoteItemUpdate> updates;
1067 const uint32_t invType = provider.invType;
1074 std::array<CNode *, AVALANCHE_MAX_INFLIGHT_POLL + 1> nodes;
1075 for (
auto &n : nodes) {
1081 const auto item = provider.buildVoteItem();
1082 const auto itemid = provider.getVoteItemId(item);
1090 node_round_map.insert(std::pair<NodeId, uint64_t>(nodeid, getRound()));
1091 auto invs = getInvsForNextPoll();
1101 auto invs = getInvsForNextPoll();
1109 std::vector<avalanche::VoteItemUpdate> updates;
1113 invs = getInvsForNextPoll();
1120 std::vector<VoteItemUpdate> updates;
1128 Assert(
m_node.chainman)->m_blockman.LookupBlockIndex(blockHash);
1145 for (
size_t i = 0; i <
avanodes.size(); i++) {
1154 for (
size_t i = 0; i <
avanodes.size(); i++) {
1163 auto confidence = m_processor->getConfidence(pindex);
1174 registerVotes(nodeid, {r, 0, {
Vote(0, blockHash)}}, updates));
1179 registerVotes(
firstNodeId, {round, 0, {
Vote(0, blockHash)}}, updates));
1192 Assert(
m_node.chainman)->m_blockman.LookupBlockIndex(blockHash);
1199 std::chrono::steady_clock::time_point start,
stop;
1220 for (
int i = 0; i < 60 * 1000; i++) {
1236 std::vector<VoteItemUpdate> updates;
1241 for (
int i = 0; i < 10000; i++) {
1269 std::chrono::steady_clock::time_point start,
stop;
1281 m_processor.reset();
1307 auto invs = AvalancheTest::getInvsForNextPoll(*m_processor);
1316 for (
size_t i = 0; i < 10; i++) {
1319 auto invs = AvalancheTest::getInvsForNextPoll(*m_processor);
1327 for (
size_t i = 0; i < 10; i++) {
1330 auto invs = AvalancheTest::getInvsForNextPoll(*m_processor);
1339 auto invs = AvalancheTest::getInvsForNextPoll(*m_processor);
1340 for (
auto &
inv : invs) {
1347 setArg(
"-avaproofstakeutxoconfirmations",
"2");
1348 setArg(
"-avalancheconflictingproofcooldown",
"0");
1362 Assert(
m_node.chainman)->ActiveChainstate().CoinsTip();
1434 setArg(
"-avaminquorumconnectedstakeratio",
"0.5");
1446 setArg(
"-avaproof", localProof->ToHex());
1455 BOOST_CHECK(m_processor->getLocalProof() !=
nullptr);
1457 localProof->getId());
1460 AvalancheTest::getMinQuorumConnectedScoreRatio(*m_processor), 0.5);
1473 BOOST_CHECK(
pm.registerProof(m_processor->getLocalProof()));
1474 BOOST_CHECK(
pm.isBoundToPeer(m_processor->getLocalProof()->getId()));
1481 for (
NodeId id = 0;
id < 8;
id++) {
1483 pm.addNode(
id, m_processor->getLocalProof()->getId());
1504 const int height = 100;
1505 const bool isCoinbase =
false;
1512 height, isCoinbase),
1516 BOOST_CHECK(
pb.addUTXO(utxo, amount, height, isCoinbase, key));
1547 m_processor->withPeerManager(
1553 pm.addNode(7, m_processor->getLocalProof()->getId());
1565 pm.updatedBlockTip();
1571 for (
int64_t i = 0; i < 6; i++) {
1577 ->GetMedianTimePast(),
1578 proof2->getExpirationTime());
1580 pm.updatedBlockTip();
1608 const std::vector<std::tuple<std::string, std::string, std::string, bool>>
1611 {
"",
"",
"",
false},
1612 {
"-1",
"-1",
"-1",
false},
1615 {
"-1",
"0",
"0",
false},
1616 {
"-0.01",
"0",
"0",
false},
1617 {
"21000000000000.01",
"0",
"0",
false},
1620 {
"0",
"-1",
"0",
false},
1621 {
"0",
"1.1",
"0",
false},
1624 {
"0",
"0",
"-1",
false},
1627 {
"0",
"0",
"0",
true},
1628 {
"0.00",
"0",
"0",
true},
1629 {
"0.01",
"0",
"0",
true},
1630 {
"1",
"0.1",
"0",
true},
1631 {
"10",
"0.5",
"0",
true},
1632 {
"10",
"1",
"0",
true},
1633 {
"21000000000000.00",
"0",
"0",
true},
1634 {
"0",
"0",
"1",
true},
1635 {
"0",
"0",
"100",
true},
1642 setArg(
"-avaminquorumstake", stake);
1675 auto addNode = [&](
NodeId nodeid) {
1688 for (
NodeId id = 100;
id < 108;
id++) {
1698 processor->avaproofsSent(i);
1702 processor->avaproofsSent(i);
1713 AvalancheTest::clearavaproofsNodeCounter(*processor);
1725 setArg(
"-avastalevotethreshold",
1727 setArg(
"-avastalevotefactor",
"2");
1729 const std::vector<std::tuple<int, int>>
testCases = {
1745 const uint32_t invType = provider.invType;
1747 const auto item = provider.buildVoteItem();
1748 const auto itemid = provider.getVoteItemId(item);
1754 std::vector<avalanche::VoteItemUpdate> updates;
1758 auto invs = getInvsForNextPoll();
1777 i >= 6 ? i - 5 : 0);
1789 invs = getInvsForNextPoll();
1798 BOOST_CHECK(provider.fromAnyVoteItem(updates[0].getVoteItem()) == item);
1799 BOOST_CHECK(updates[0].getStatus() == VoteStatus::Stale);
1803 invs = getInvsForNextPoll();
1809 BlockProvider provider(
this);
1820 auto invs = getInvsForNextPoll();
1832 std::vector<Vote> votes;
1842 std::vector<avalanche::VoteItemUpdate> updates;
1857 for (
auto &
update : updates) {
1858 if (
update.getStatus() == VoteStatus::Finalized &&
1859 provider.fromAnyVoteItem(
update.getVoteItem())
1872 invs = getInvsForNextPoll();
1874 for (
size_t i = 0; i < 10; i++) {
1896 ->m_blockman.LookupBlockIndex(
altblock.GetHash()));
1910 invs = getInvsForNextPoll();
1917 for (
auto &
inv : invs) {
1925 for (
auto &
update : updates) {
1926 if (
update.getStatus() == VoteStatus::Finalized &&
1927 provider.fromAnyVoteItem(
update.getVoteItem())
1928 ->GetBlockHash() ==
tiphash) {
1938 invs = getInvsForNextPoll();
1953 for (
auto &
update : updates) {
1954 if (
update.getStatus() == VoteStatus::Invalid &&
1955 provider.fromAnyVoteItem(
update.getVoteItem())
1962 invs = getInvsForNextPoll();
1976 std::vector<ProofRef>
proofs;
1981 proofs.emplace_back(std::move(proof));
1985 std::vector<CBlockIndex>
indexes;
1989 indexes.emplace_back(std::move(index));
2031 BOOST_CHECK(std::holds_alternative<const ProofRef>(it->first));
2034 std::get<const ProofRef>(it->first)->getScore();
2045 BOOST_CHECK(std::holds_alternative<const CBlockIndex *>(it->first));
2048 std::get<const CBlockIndex *>(it->first)->nChainWork;
2063 const auto block = std::make_shared<const CBlock>(
2076 blockindex = chainman->m_blockman.LookupBlockIndex(blockhash);
2081 BOOST_CHECK(AvalancheTest::getInvsForNextPoll(*m_processor).empty());
2082 BOOST_CHECK(!m_processor->isAccepted(blockindex));
2090 auto invs = AvalancheTest::getInvsForNextPoll(*m_processor);
2109 std::vector<CScript> winners;
2114 BOOST_CHECK(!m_processor->computeStakingReward(
nullptr));
2126 setArg(
"-avaminquorumstake",
"0");
2127 setArg(
"-avaminquorumconnectedstakeratio",
"0");
2128 setArg(
"-avaminavaproofsnodecount",
"0");
2132 std::vector<ProofRef>
proofs;
2134 for (
size_t i = 0; i <
numProofs; i++) {
2144 return pm.setFinalized(peer.peerid);
2148 proofs.emplace_back(std::move(proof));
2199 m_processor->cleanupStakingRewards(101);
2215 m_processor->cleanupStakingRewards(200);
2232 Assert(
m_node.chainman)->ActiveChainstate().CoinsTip();
2246 auto localProof =
buildProof(outpoint, 1, 100);
2249 setArg(
"-avaproof", localProof->ToHex());
2250 setArg(
"-avalancheconflictingproofcooldown",
"0");
2251 setArg(
"-avalanchepeerreplacementcooldown",
"0");
2252 setArg(
"-avaproofstakeutxoconfirmations",
"3");
2261 localProof->getId());
2268 return pm.isBoundToPeer(localProof->getId());
2272 m_processor->getLocalProofRegistrationState().GetResult() ==
2274 m_processor->getLocalProofRegistrationState().ToString());
2281 AvalancheTest::updatedBlockTip(*m_processor);
2285 AvalancheTest::setLocalProofShareable(*m_processor,
true);
2287 AvalancheTest::updatedBlockTip(*m_processor);
2292 AvalancheTest::updatedBlockTip(*m_processor);
2297 AvalancheTest::updatedBlockTip(*m_processor);
2307 AvalancheTest::updatedBlockTip(*m_processor);
2312 setArg(
"-avalancheconflictingproofcooldown",
"0");
2313 setArg(
"-avalanchepeerreplacementcooldown",
"0");
2344 BOOST_CHECK(!m_processor->reconcileOrFinalize(proof));
2354 BOOST_CHECK(m_processor->reconcileOrFinalize(proof));
2356 BOOST_CHECK(!m_processor->reconcileOrFinalize(proof));
2359 AvalancheTest::addProofToRecentfinalized(*m_processor, proof->
getId());
2361 BOOST_CHECK(m_processor->reconcileOrFinalize(proof));
2366 return peer.hasFinalized;
2389 BOOST_CHECK(!m_processor->reconcileOrFinalize(proof));
2395 setArg(
"-avalanchestakingpreconsensus",
"1");
2421 m_processor->addStakeContender(
proof1);
2422 m_processor->addStakeContender(
proof2);
2438 AvalancheTest::setFinalizationTip(*m_processor,
chaintip);
2444 ->m_blockman.LookupBlockIndex(block.
GetHash()));
2445 AvalancheTest::updatedBlockTip(*m_processor);
2466 AvalancheTest::setFinalizationTip(*m_processor,
chaintip);
2471 m_processor->cleanupStakingRewards(
chaintip->nHeight);
static constexpr Amount COIN
uint256 ArithToUint256(const arith_uint256 &a)
const CChainParams & Params()
Return the currently selected parameters.
#define Assert(val)
Identity function.
A CService with information about it as peer.
The block chain is a tree shaped structure starting with the genesis block at the root,...
arith_uint256 nChainWork
(memory only) Total amount of work (expected number of hashes) in the chain up to and including this ...
const BlockHash * phashBlock
pointer to the hash of the block, if any.
BlockHash GetBlockHash() const
CCoinsView that adds a memory cache for transactions to another CCoinsView.
void AddCoin(const COutPoint &outpoint, Coin coin, bool possible_overwrite)
Add a coin.
bool SpendCoin(const COutPoint &outpoint, Coin *moveto=nullptr)
Spend a coin.
CConnman(const Config &configIn, uint64_t seed0, uint64_t seed1, AddrMan &addrmanIn, bool network_active=true)
bool AddNode(const std::string &node) EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex)
An encapsulated secp256k1 private key.
static CKey MakeCompressedKey()
Produce a valid compressed key.
CPubKey GetPubKey() const
Compute the public key from a private key.
A mutable version of CTransaction.
Information about a peer.
An outpoint - a combination of a transaction hash and an index n into its vout.
Simple class for background tasks that should be run periodically or once "after a while".
void serviceQueue() EXCLUSIVE_LOCKS_REQUIRED(!newTaskMutex)
Services the queue 'forever'.
size_t getQueueInfo(std::chrono::steady_clock::time_point &first, std::chrono::steady_clock::time_point &last) const EXCLUSIVE_LOCKS_REQUIRED(!newTaskMutex)
Returns number of tasks waiting to be serviced, and first and last task times.
void StopWhenDrained() EXCLUSIVE_LOCKS_REQUIRED(!newTaskMutex)
Tell any threads running serviceQueue to stop when there is no work left to be done.
Serialized script, used inside transaction inputs and outputs.
A combination of a network address (CNetAddr) and a (TCP) port.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason) EXCLUSIVE_LOCKS_REQUIRED(cs)
bool exists(const TxId &txid) const
void check(const CCoinsViewCache &active_coins_tip, int64_t spendheight) const EXCLUSIVE_LOCKS_REQUIRED(void addUnchecked(CTxMemPoolEntryRef entry) EXCLUSIVE_LOCKS_REQUIRED(cs
If sanity-checking is turned on, check makes sure the pool is consistent (does not contain two transa...
An output of a transaction.
Chainstate stores and provides an API to update our local knowledge of the current best chain.
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
RecursiveMutex & GetMutex() const LOCK_RETURNED(
Alias for cs_main.
CBlockIndex * ActiveTip() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
SnapshotCompletionResult MaybeCompleteSnapshotValidation(std::function< void(bilingual_str)> shutdown_fnc=[](bilingual_str msg) { AbortNode(msg.original, msg);}) EXCLUSIVE_LOCKS_REQUIRED(Chainstate & ActiveChainstate() const
Once the background validation chainstate has reached the height which is the base of the UTXO snapsh...
uint64_t randrange(uint64_t range) noexcept
Generate a random integer in the range [0..range).
static std::unique_ptr< PeerManager > make(CConnman &connman, AddrMan &addrman, BanMan *banman, ChainstateManager &chainman, CTxMemPool &pool, avalanche::Processor *const avalanche, Options opts)
256-bit unsigned big integer.
static std::unique_ptr< Processor > MakeProcessor(const ArgsManager &argsman, interfaces::Chain &chain, CConnman *connman, ChainstateManager &chainman, CTxMemPool *mempoolIn, CScheduler &scheduler, bilingual_str &error)
const CScript & getPayoutScript() const
const ProofId & getId() const
const std::vector< SignedStake > & getStakes() const
static uint32_t amountToScore(Amount amount)
uint32_t getCooldown() const
const std::vector< Vote > & GetVotes() const
uint64_t getRound() const
unsigned int size() const
static const uint256 ZERO
const Config & GetConfig()
std::string FormatScript(const CScript &script)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
std::string EncodeSecret(const CKey &key)
bool error(const char *fmt, const Args &...args)
static constexpr Amount PROOF_DUST_THRESHOLD
Minimum amount per utxo.
const CScript UNSPENDABLE_ECREG_PAYOUT_SCRIPT
ProofRef buildRandomProof(Chainstate &active_chainstate, uint32_t score, int height, const CKey &masterKey)
constexpr uint32_t MIN_VALID_PROOF_SCORE
std::variant< const ProofRef, const CBlockIndex *, const CTransactionRef > AnyVoteItem
std::unique_ptr< Chain > MakeChain(node::NodeContext &node, const CChainParams ¶ms)
Return implementation of Chain interface.
@ OUTBOUND_FULL_RELAY
These are the default connections that we use to connect with the network.
static constexpr NodeId NO_NODE
Special NodeId that represent no node.
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
static CTransactionRef MakeTransactionRef()
std::shared_ptr< const CTransaction > CTransactionRef
static constexpr size_t AVALANCHE_MAX_ELEMENT_POLL
Maximum item that can be polled at once.
static constexpr uint32_t AVALANCHE_FINALIZED_ITEMS_FILTER_NUM_ELEMENTS
The size of the finalized items filter.
BOOST_AUTO_TEST_CASE_TEMPLATE(voteitemupdate, P, VoteItemProviders)
BOOST_AUTO_TEST_CASE(quorum_diversity)
boost::mpl::list< BlockProvider, ProofProvider, TxProvider > VoteItemProviders
static bool HasAllDesirableServiceFlags(ServiceFlags services)
A shortcut for (services & GetDesirableServiceFlags(services)) == GetDesirableServiceFlags(services),...
ServiceFlags
nServices flags.
uint256 GetRandHash() noexcept
void Shuffle(I first, I last, R &&rng)
More efficient than using std::shuffle on a FastRandomContext.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
reverse_range< T > reverse_iterate(T &x)
static uint16_t GetDefaultPort()
static std::string ToString(const CService &ip)
CScript GetScriptForRawPubKey(const CPubKey &pubKey)
Generate a P2PK script for the given pubkey.
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
A BlockHash is a unqiue identifier for a block.
static const Currency & get()
A TxId is the identifier of a transaction.
Compare proofs by score, then by id in case of equality.
StakeContenderIds are unique for each block to ensure that the peer polling for their acceptance has ...
TestVoteRecord(uint16_t conf)
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
void UninterruptibleSleep(const std::chrono::microseconds &n)
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
@ CONFLICT
Removed for conflict with in-block transaction.
void SyncWithValidationInterfaceQueue()
This is a synonym for the following, which asserts certain locks are not held: std::promise<void> pro...
static const int PROTOCOL_VERSION
network protocol versioning
static constexpr int AVALANCHE_MAX_INFLIGHT_POLL
How many inflight requests can exist for one item.
static constexpr uint32_t AVALANCHE_VOTE_STALE_MIN_THRESHOLD
Lowest configurable staleness threshold (finalization score + necessary votes to increase confidence ...
static constexpr int AVALANCHE_FINALIZATION_SCORE
Finalization score.