46 std::vector<COutPoint> outpoints;
47 outpoints.reserve(200'000);
50 for (
uint8_t i = 0; i < 4; i++) {
81 outpoints.emplace_back(
new_tx->GetHash(), i);
88 const auto wtxid{tx->GetWitnessHash()};
99 assert(std::any_of(
child->vin.cbegin(),
child->vin.cend(), [&](
const auto& input) {
100 return input.prevout.hash == ptx_potential_parent->GetHash();
201 for (
int i{0}; i <
num_txs; ++i) {
242 for (
unsigned int i = 0; i <
num_peers; i++) {
258 std::vector<COutPoint> outpoints;
259 outpoints.reserve(400);
262 for (
uint8_t i = 0; i < 4; i++) {
297 outpoints.emplace_back(
new_tx->GetHash(), i);
302 const auto wtxid{tx->GetWitnessHash()};
323 orphanage->AddTx(tx, peer_id);
324 if (peer_is_protected && orphanage->HaveTxFromPeer(wtxid, peer_id)) {
325 protected_wtxids.insert(wtxid);
386 static constexpr unsigned NUM_TX = 16;
389 static constexpr unsigned NUM_PEERS = 16;
392 static constexpr unsigned MAX_ANN = 64;
408 std::vector<std::pair<unsigned, unsigned>>
deps;
410 for (
unsigned p = 0;
p <
NUM_TX - 1; ++
p) {
415 std::shuffle(
deps.begin(),
deps.end(), rng);
419 std::vector<CTransactionRef> txn(
NUM_TX);
432 for (
unsigned output = 0; output <
num_outputs; ++output) {
443 tx.
vin.emplace_back(outpoint);
448 if (tx.
vin.empty()) {
450 tx.
vin.emplace_back(outpoint);
459 input.scriptWitness.stack.resize(1);
460 input.scriptWitness.stack[0].resize(rng.
randrange(100));
462 input.scriptWitness.stack.resize(0);
512 if (
ann.tx == tx)
return true;
518 std::bitset<NUM_PEERS> mask;
520 mask.set(
ann.announcer);
527 if (
ann.reconsider &&
ann.tx == tx)
return true;
534 if (
ann.reconsider &&
ann.announcer == peer)
return true;
541 if (txn[it->tx]->GetWitnessHash() ==
wtxid && it->announcer == peer)
return it;
548 if (it->tx == tx && it->announcer == peer)
return it;
557 if (
ann.announcer != peer)
continue;
558 count += 1 + (txn[
ann.tx]->vin.size() / 10);
584 bool added =
real->AddAnnouncer(txn[tx]->GetWitnessHash(), peer);
595 bool erased =
real->EraseTx(txn[tx]->GetWitnessHash());
603 real->EraseForPeer(peer);
610 std::set<COutPoint>
spent;
611 for (
unsigned tx = 0; tx <
NUM_TX; ++tx) {
613 block.
vtx.emplace_back(txn[tx]);
614 for (
auto&
txin : block.
vtx.back()->vin) {
619 std::shuffle(block.
vtx.begin(), block.
vtx.end(), rng);
620 real->EraseForBlock(block);
622 for (
auto&
txin : txn[
ann.tx]->vin) {
623 if (
spent.contains(
txin.prevout))
return true;
640 if (
txin.prevout.hash == txn[tx]->GetHash()) {
671 auto result =
real->GetTxToReconsider(peer);
696 for (
unsigned tx = 0; tx <
NUM_TX; ++tx) {
705 if (!oversized)
break;
709 for (
unsigned peer = 0; peer <
NUM_PEERS; ++peer) {
735 assert(
real->TotalLatencyScore() <=
real->MaxGlobalLatencyScore());
752 for (
unsigned tx = 0; tx <
NUM_TX; ++tx) {
763 bool have_tx =
real->HaveTx(txn[tx]->GetWitnessHash());
766 auto txref =
real->GetTx(txn[tx]->GetWitnessHash());
779 bool have_ann =
real->HaveTxFromPeer(txn[tx]->GetWitnessHash(), peer);
787 if (
ann.announcer != peer)
continue;
788 if (
ann.reconsider != (
phase == 1))
continue;
790 for (
const auto& vin : txn[
ann.tx]->vin) {
796 assert((*it)->GetWitnessHash() == txn[
ann.tx]->GetWitnessHash());
int64_t CAmount
Amount in satoshis (Can be negative)
#define Assert(val)
Identity function.
std::vector< CTransactionRef > vtx
An outpoint - a combination of a transaction hash and an index n into its vout.
Serialized script, used inside transaction inputs and outputs.
The basic transaction that is broadcasted on the network and contained in blocks.
static const uint32_t SEQUENCE_FINAL
Setting nSequence to this value for every input in a transaction disables nLockTime/IsFinalTx().
T ConsumeIntegralInRange(T min, T max)
I randrange(I range) noexcept
Generate a random integer in the range [0..range), with range > 0.
uint256 rand256() noexcept
generate a random uint256.
bool randbool() noexcept
Generate a random boolean.
void resize(size_type new_size)
transaction_identifier represents the two canonical transaction identifier types (txid,...
static transaction_identifier FromUint256(const uint256 &id)
static int32_t GetTransactionWeight(const CTransaction &tx)
static const unsigned int MAX_BLOCK_WEIGHT
The maximum allowed weight for a block, see BIP 141 (network rule)
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
std::unique_ptr< TxOrphanage > MakeTxOrphanage() noexcept
Create a new TxOrphanage instance.
static constexpr int32_t MAX_STANDARD_TX_WEIGHT
The maximum weight for transactions we're willing to relay/mine.
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::shared_ptr< const CTransaction > CTransactionRef
std::unique_ptr< T > MakeNoLogFileContext(const ChainType chain_type=ChainType::REGTEST, TestOpts opts={})
Make a test setup that has disk access to the debug.log file disabled.
A mutable version of CTransaction.
std::vector< CTxOut > vout
Data structure storing a fee and size, ordered by increasing fee/size.
NodeSeconds ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
auto & PickValue(FuzzedDataProvider &fuzzed_data_provider, Collection &col)
uint256 ConsumeUInt256(FuzzedDataProvider &fuzzed_data_provider) noexcept
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)
void SeedRandomStateForTest(SeedRand seedtype)
Seed the global RNG state for testing and log the seed value.
@ ZEROS
Seed with a compile time constant of zeros.
void initialize_orphanage()
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
FuzzedDataProvider & fuzzed_data_provider