47 std::vector<COutPoint> outpoints;
48 outpoints.reserve(200'000);
51 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();
202 for (
int i{0}; i <
num_txs; ++i) {
243 for (
unsigned int i = 0; i <
num_peers; i++) {
259 std::vector<COutPoint> outpoints;
260 outpoints.reserve(400);
263 for (
uint8_t i = 0; i < 4; i++) {
297 outpoints.emplace_back(
new_tx->GetHash(), i);
302 const auto wtxid{tx->GetWitnessHash()};
322 orphanage->AddTx(tx, peer_id);
323 if (peer_is_protected && orphanage->HaveTxFromPeer(wtxid, peer_id)) {
324 protected_wtxids.insert(wtxid);
385 static constexpr unsigned NUM_TX = 16;
388 static constexpr unsigned NUM_PEERS = 16;
391 static constexpr unsigned MAX_ANN = 64;
407 std::vector<std::pair<unsigned, unsigned>>
deps;
409 for (
unsigned p = 0;
p <
NUM_TX - 1; ++
p) {
418 std::vector<CTransactionRef> txn(
NUM_TX);
431 for (
unsigned output = 0; output < num_outputs; ++output) {
442 tx.
vin.emplace_back(outpoint);
447 if (tx.
vin.empty()) {
449 tx.
vin.emplace_back(outpoint);
458 input.scriptWitness.stack.resize(1);
459 input.scriptWitness.stack[0].resize(
rng.
randrange(100));
461 input.scriptWitness.stack.resize(0);
511 if (
ann.tx == tx)
return true;
517 std::bitset<NUM_PEERS> mask;
519 mask.set(
ann.announcer);
526 if (
ann.reconsider &&
ann.tx == tx)
return true;
533 if (
ann.reconsider &&
ann.announcer == peer)
return true;
540 if (txn[it->tx]->GetWitnessHash() ==
wtxid && it->announcer == peer)
return it;
547 if (it->tx == tx && it->announcer == peer)
return it;
556 if (
ann.announcer != peer)
continue;
557 count += 1 + (txn[
ann.tx]->vin.size() / 10);
583 bool added =
real->AddAnnouncer(txn[tx]->GetWitnessHash(), peer);
594 bool erased =
real->EraseTx(txn[tx]->GetWitnessHash());
602 real->EraseForPeer(peer);
609 std::set<COutPoint>
spent;
610 for (
unsigned tx = 0; tx <
NUM_TX; ++tx) {
612 block.
vtx.emplace_back(txn[tx]);
613 for (
auto&
txin : block.
vtx.back()->vin) {
618 std::shuffle(block.
vtx.begin(), block.
vtx.end(),
rng);
619 real->EraseForBlock(block);
621 for (
auto&
txin : txn[
ann.tx]->vin) {
622 if (
spent.contains(
txin.prevout))
return true;
639 if (
txin.prevout.hash == txn[tx]->GetHash()) {
670 auto result =
real->GetTxToReconsider(peer);
695 for (
unsigned tx = 0; tx <
NUM_TX; ++tx) {
704 if (!oversized)
break;
708 for (
unsigned peer = 0; peer <
NUM_PEERS; ++peer) {
734 assert(
real->TotalLatencyScore() <=
real->MaxGlobalLatencyScore());
751 for (
unsigned tx = 0; tx <
NUM_TX; ++tx) {
762 bool have_tx =
real->HaveTx(txn[tx]->GetWitnessHash());
765 auto txref =
real->GetTx(txn[tx]->GetWitnessHash());
778 bool have_ann =
real->HaveTxFromPeer(txn[tx]->GetWitnessHash(), peer);
786 if (
ann.announcer != peer)
continue;
787 if (
ann.reconsider != (
phase == 1))
continue;
789 for (
const auto& vin : txn[
ann.tx]->vin) {
795 assert((*it)->GetWitnessHash() == txn[
ann.tx]->GetWitnessHash());
int64_t CAmount
Amount in satoshis (Can be negative)
#define Assert(val)
Identity function.
Wrapper around FeeFrac & derived types, which adds a feerate-based ordering which treats equal-feerat...
Wrapper around FeeFrac & derived types, which adds a total ordering which first sorts by feerate and ...
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 constexpr uint32_t SEQUENCE_FINAL
Setting nSequence to this value for every input in a transaction disables nLockTime/IsFinalTx().
Helper to initialize the global NodeClock, let a duration elapse, and reset it after use in a test.
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)
static transaction_identifier FromUint256(const uint256 &id)
static int32_t GetTransactionWeight(const CTransaction &tx)
constexpr 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.
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.
SeedRandomStateForTest(SeedRand::ZEROS)
FuzzedDataProvider provider
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)
@ ZEROS
Seed with a compile time constant of zeros.
void initialize_orphanage()
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
FuzzedDataProvider & fuzzed_data_provider