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();
200 for (
int i{0}; i <
num_txs; ++i) {
238 for (
unsigned int i = 0; i <
num_peers; i++) {
254 std::vector<COutPoint> outpoints;
255 outpoints.reserve(400);
258 for (
uint8_t i = 0; i < 4; i++) {
293 outpoints.emplace_back(
new_tx->GetHash(), i);
298 const auto wtxid{tx->GetWitnessHash()};
319 orphanage->AddTx(tx, peer_id);
320 if (peer_is_protected && orphanage->HaveTxFromPeer(wtxid, peer_id)) {
321 protected_wtxids.insert(wtxid);
382 static constexpr unsigned NUM_TX = 16;
385 static constexpr unsigned NUM_PEERS = 16;
388 static constexpr unsigned MAX_ANN = 64;
404 std::vector<std::pair<unsigned, unsigned>>
deps;
406 for (
unsigned p = 0;
p <
NUM_TX - 1; ++
p) {
411 std::shuffle(
deps.begin(),
deps.end(), rng);
415 std::vector<CTransactionRef> txn(
NUM_TX);
428 for (
unsigned output = 0; output <
num_outputs; ++output) {
439 tx.
vin.emplace_back(outpoint);
444 if (tx.
vin.empty()) {
446 tx.
vin.emplace_back(outpoint);
455 input.scriptWitness.stack.resize(1);
456 input.scriptWitness.stack[0].resize(rng.
randrange(100));
458 input.scriptWitness.stack.resize(0);
508 if (
ann.tx == tx)
return true;
514 std::bitset<NUM_PEERS> mask;
516 mask.set(
ann.announcer);
523 if (
ann.reconsider &&
ann.tx == tx)
return true;
530 if (
ann.reconsider &&
ann.announcer == peer)
return true;
537 if (txn[it->tx]->GetWitnessHash() ==
wtxid && it->announcer == peer)
return it;
544 if (it->tx == tx && it->announcer == peer)
return it;
553 if (
ann.announcer != peer)
continue;
554 count += 1 + (txn[
ann.tx]->vin.size() / 10);
580 bool added =
real->AddAnnouncer(txn[tx]->GetWitnessHash(), peer);
591 bool erased =
real->EraseTx(txn[tx]->GetWitnessHash());
599 real->EraseForPeer(peer);
606 std::set<COutPoint>
spent;
607 for (
unsigned tx = 0; tx <
NUM_TX; ++tx) {
609 block.
vtx.emplace_back(txn[tx]);
610 for (
auto&
txin : block.
vtx.back()->vin) {
615 std::shuffle(block.
vtx.begin(), block.
vtx.end(), rng);
616 real->EraseForBlock(block);
618 for (
auto&
txin : txn[
ann.tx]->vin) {
619 if (
spent.contains(
txin.prevout))
return true;
636 if (
txin.prevout.hash == txn[tx]->GetHash()) {
667 auto result =
real->GetTxToReconsider(peer);
692 for (
unsigned tx = 0; tx <
NUM_TX; ++tx) {
701 if (!oversized)
break;
705 for (
unsigned peer = 0; peer <
NUM_PEERS; ++peer) {
731 assert(
real->TotalLatencyScore() <=
real->MaxGlobalLatencyScore());
748 for (
unsigned tx = 0; tx <
NUM_TX; ++tx) {
759 bool have_tx =
real->HaveTx(txn[tx]->GetWitnessHash());
762 auto txref =
real->GetTx(txn[tx]->GetWitnessHash());
775 bool have_ann =
real->HaveTxFromPeer(txn[tx]->GetWitnessHash(), peer);
783 if (
ann.announcer != peer)
continue;
784 if (
ann.reconsider != (
phase == 1))
continue;
786 for (
const auto& vin : txn[
ann.tx]->vin) {
792 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)
#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