33static void addCoin(
const CAmount& nValue, std::vector<std::unique_ptr<CWalletTx>>& wtxs)
39 tx.
vout[0].nValue = nValue;
52 const auto test_setup = MakeNoLogFileContext<TestingSetup>();
54 std::vector<std::unique_ptr<CWalletTx>> wtxs;
61 for (
int i = 0; i < 400; ++i) {
65 amount = 10'000 + det_rand.randrange(90'000);
67 amount = 100'000 + det_rand.randrange(900'000);
69 amount = 1'000'000 + det_rand.randrange(9'000'000);
71 amount = 10'000'000 + det_rand.randrange(90'000'000);
78 for (
const auto& wtx : wtxs) {
79 const auto txout = wtx->tx->vout.at(0);
82 int y{det_rand.randrange(100)};
96 CAmount fees = 20 * input_bytes;
97 available_coins.
coins[outtype].emplace_back(
COutPoint(wtx->GetHash(), 0), txout, 6 * 24, input_bytes,
true,
true, wtx->GetTxTime(),
true, fees);
102 constexpr size_t NUM_TARGETS{10};
103 std::vector<CAmount> targets;
104 targets.reserve(NUM_TARGETS);
105 for (
size_t i{0}; i < NUM_TARGETS; ++i) {
106 targets.push_back(10'000'000 + det_rand.randrange(90'000'000));
109 std::optional<FastRandomContext> rng;
110 std::optional<CoinSelectionParams> params;
111 std::vector<wallet::OutputGroupTypeMap> groups;
115 params.emplace(*rng);
117 params->change_output_size = 31;
118 params->change_spend_size = 68;
120 params->m_effective_feerate =
CFeeRate{20'000};
121 params->m_long_term_feerate =
CFeeRate{10'000};
122 params->m_discard_feerate =
CFeeRate{3000};
123 params->tx_noinputs_size = 72;
124 params->m_avoid_partial_spends =
false;
126 params->m_change_fee = params->m_effective_feerate.
GetFee(params->change_output_size);
127 params->min_viable_change = params->m_discard_feerate.GetFee(params->change_spend_size);
128 params->m_cost_of_change = params->min_viable_change + params->m_change_fee;
133 for (
size_t i{0}; i < NUM_TARGETS; ++i) {
135 assert(result && result->GetSelectedValue() >= targets[i]);
140static void add_coin(
const CAmount& nValue, uint32_t nInput, std::vector<OutputGroup>& set)
143 tx.
vout.resize(nInput + 1);
144 tx.
vout[nInput].nValue = nValue;
147 set.back().Insert(std::make_shared<COutput>(output), 0, 0);
154 for (
int i = 0; i < utxos; ++i) {
155 target +=
CAmount{1} << (utxos+i);
164 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.
static const CoinEligibilityFilter filter_standard(1, 6, 0)
std::unique_ptr< WalletDatabase > CreateMockableWalletDatabase()
FilteredOutputGroups GroupOutputs(const CWallet &wallet, const CoinsResult &coins, const CoinSelectionParams &coin_sel_params, const std::vector< SelectionFilter > &filters, std::vector< OutputGroup > &ret_discarded_groups)
static 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)
static 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.