32static void addCoin(
const CAmount& nValue, std::vector<std::unique_ptr<CWalletTx>>& wtxs)
38 tx.
vout[0].nValue = nValue;
51 const auto test_setup = MakeNoLogFileContext<TestingSetup>();
53 std::vector<std::unique_ptr<CWalletTx>> wtxs;
60 for (
int i = 0; i < 400; ++i) {
64 amount = 10'000 + det_rand.randrange(90'000);
66 amount = 100'000 + det_rand.randrange(900'000);
68 amount = 1'000'000 + det_rand.randrange(9'000'000);
70 amount = 10'000'000 + det_rand.randrange(90'000'000);
77 for (
const auto& wtx : wtxs) {
78 const auto txout = wtx->GetTx()->vout.at(0);
81 int y{det_rand.randrange(100)};
95 CAmount fees = 20 * input_bytes;
96 available_coins.
coins[outtype].emplace_back(
COutPoint(wtx->GetHash(), 0), txout, 6 * 24, input_bytes,
true,
true, wtx->GetTxTime(),
true, fees);
101 constexpr size_t NUM_TARGETS{10};
102 std::vector<CAmount> targets;
103 targets.reserve(NUM_TARGETS);
104 for (
size_t i{0}; i < NUM_TARGETS; ++i) {
105 targets.push_back(10'000'000 + det_rand.randrange(90'000'000));
108 std::optional<FastRandomContext>
rng;
109 std::optional<CoinSelectionParams> params;
110 std::vector<wallet::OutputGroupTypeMap> groups;
114 params.emplace(*
rng);
116 params->change_output_size = 31;
117 params->change_spend_size = 68;
119 params->m_effective_feerate =
CFeeRate{20'000};
120 params->m_long_term_feerate =
CFeeRate{10'000};
121 params->m_discard_feerate =
CFeeRate{3000};
122 params->tx_noinputs_size = 72;
123 params->m_avoid_partial_spends =
false;
125 params->m_change_fee = params->m_effective_feerate.
GetFee(params->change_output_size);
126 params->min_viable_change = params->m_discard_feerate.GetFee(params->change_spend_size);
127 params->m_cost_of_change = params->min_viable_change + params->m_change_fee;
132 for (
size_t i{0}; i < NUM_TARGETS; ++i) {
134 assert(result && result->GetSelectedValue() >= targets[i]);
139static void add_coin(
const CAmount& nValue, uint32_t nInput, std::vector<OutputGroup>& set)
142 tx.
vout.resize(nInput + 1);
143 tx.
vout[nInput].nValue = nValue;
146 set.back().Insert(std::make_shared<COutput>(output), 0, 0);
153 for (
int i = 0; i < utxos; ++i) {
154 target +=
CAmount{1} << (utxos+i);
163 std::vector<OutputGroup> utxo_pool;
int64_t CAmount
Amount in satoshis (Can be negative)
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac.
CAmount GetFee(int32_t virtual_bytes) const
Return the fee in satoshis for the given vsize in vbytes.
An outpoint - a combination of a transaction hash and an index n into its vout.
I randrange(I range) noexcept
Generate a random integer in the range [0..range), with range > 0.
Main entry point to nanobench's benchmarking facility.
Bench & batch(T b) noexcept
Sets the batch size.
Bench & unit(char const *unit)
Sets the operation unit.
detail::SetupRunner< SetupOp > setup(SetupOp setupOp)
Configure an untimed setup step per epoch (forces single-iteration epochs).
Bench & epochIterations(uint64_t numIters) noexcept
Sets exactly the number of iterations for each epoch.
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
void doNotOptimizeAway(Arg &&arg)
Makes sure none of the given arguments are optimized away by the compiler.
std::unique_ptr< WalletDatabase > MakeInMemoryWalletDatabase()
static const CoinEligibilityFilter filter_standard(1, 6, 0)
FilteredOutputGroups GroupOutputs(const CWallet &wallet, const CoinsResult &coins, const CoinSelectionParams &coin_sel_params, const std::vector< SelectionFilter > &filters, std::vector< OutputGroup > &ret_discarded_groups)
constexpr CAmount CHANGE_LOWER
lower bound for randomly-chosen target change amount
util::Result< SelectionResult > SelectCoinsBnB(std::vector< OutputGroup > &utxo_pool, const CAmount &selection_target, const CAmount &cost_of_change, int max_selection_weight)
static void add_coin(const CAmount &nValue, uint32_t nInput, std::vector< OutputGroup > &set)
util::Result< SelectionResult > AttemptSelection(interfaces::Chain &chain, const CAmount &nTargetValue, OutputGroupTypeMap &groups, const CoinSelectionParams &coin_selection_params, bool allow_mixed_output_types)
Attempt to find a valid input set that preserves privacy by not mixing OutputTypes.
static void addCoin(const CAmount &nValue, std::vector< std::unique_ptr< CWalletTx > > &wtxs)
static void CoinSelection(benchmark::Bench &bench)
static void BnBExhaustion(benchmark::Bench &bench)
static CAmount make_hard_case(int utxos, std::vector< OutputGroup > &utxo_pool)
constexpr int32_t MAX_STANDARD_TX_WEIGHT
The maximum weight for transactions we're willing to relay/mine.
static CTransactionRef MakeTransactionRef(Tx &&txIn)
A mutable version of CTransaction.
std::vector< CTxOut > vout
Txid GetHash() const
Compute the hash of this CMutableTransaction.
A UTXO under consideration for use in funding a new transaction.
Parameters for filtering which OutputGroups we may use in coin selection.
COutputs available for spending, stored by OutputType.
std::map< OutputType, std::vector< COutput > > coins
State of transaction not confirmed or conflicting with a known block and not in the mempool.