Skip to content

Commit

Permalink
feat: create min dust fee setting (#5947)
Browse files Browse the repository at this point in the history
Description
---
Create a setting to ignore dust below a certain value/ 

Motivation and Context
---

See #5807



Fixes: #5807
Fixes: #4501

---------

Co-authored-by: Brian Pearce <[email protected]>
  • Loading branch information
SWvheerden and brianp authored Nov 14, 2023
1 parent 623f127 commit 8f5466c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions base_layer/wallet/src/output_manager_service/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub struct OutputManagerServiceConfig {
/// If a large amount of tiny valued uT UTXOs are used as inputs to a transaction, the fee may be larger than the
/// transaction amount. Set this value to `false` to allow spending of "dust" UTXOs for small valued transactions.
pub prevent_fee_gt_amount: bool,
/// Ignores dust below this value, value in micro MinoTari
pub dust_ignore_value: u64,
/// This is the size of the event channel used to communicate output manager events to the wallet.
pub event_channel_size: usize,
/// The number of confirmations (difference between tip height and mined height) required for the output to be
Expand All @@ -49,6 +51,7 @@ impl Default for OutputManagerServiceConfig {
fn default() -> Self {
Self {
prevent_fee_gt_amount: true,
dust_ignore_value: 100,
event_channel_size: 250,
num_confirmations_required: 3,
tx_validator_batch_size: 100,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,25 @@ pub struct UtxoSelectionCriteria {
pub filter: UtxoSelectionFilter,
pub ordering: UtxoSelectionOrdering,
pub excluding: Vec<Commitment>,
pub min_dust: u64,
pub excluding_onesided: bool,
}

impl UtxoSelectionCriteria {
pub fn smallest_first() -> Self {
pub fn smallest_first(min_dust: u64) -> Self {
Self {
filter: UtxoSelectionFilter::Standard,
ordering: UtxoSelectionOrdering::SmallestFirst,
min_dust,
..Default::default()
}
}

pub fn largest_first() -> Self {
pub fn largest_first(min_dust: u64) -> Self {
Self {
filter: UtxoSelectionFilter::Standard,
ordering: UtxoSelectionOrdering::LargestFirst,
min_dust,
..Default::default()
}
}
Expand All @@ -64,6 +67,7 @@ impl UtxoSelectionCriteria {
Self {
filter: UtxoSelectionFilter::SpecificOutputs { commitments },
ordering: UtxoSelectionOrdering::Default,
min_dust: 0,
..Default::default()
}
}
Expand Down
2 changes: 1 addition & 1 deletion base_layer/wallet/src/output_manager_service/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ where
let selection = self
.select_utxos(
amount_per_split * MicroMinotari(number_of_splits as u64),
UtxoSelectionCriteria::largest_first(),
UtxoSelectionCriteria::largest_first(self.resources.config.dust_ignore_value),
fee_per_gram,
number_of_splits,
self.default_features_and_scripts_size()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,12 @@ impl OutputSql {
conn: &mut SqliteConnection,
) -> Result<Vec<OutputSql>, OutputManagerStorageError> {
let i64_tip_height = tip_height.and_then(|h| i64::try_from(h).ok()).unwrap_or(i64::MAX);
let i64_value = i64::try_from(selection_criteria.min_dust).unwrap_or(i64::MAX);

let mut query = outputs::table
.into_boxed()
.filter(outputs::status.eq(OutputStatus::Unspent as i32))
.filter(outputs::value.gt(i64_value))
.order_by(outputs::spending_priority.desc());

// NOTE: Safe mode presets `script_lock_height` and `maturity` filters for all queries
Expand Down
2 changes: 2 additions & 0 deletions common/config/presets/d_console_wallet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ transaction_event_channel_size = 25000
# transaction amount. Set this value to `false` to allow spending of "dust" UTXOs for small valued transactions
# (default = true).
prevent_fee_gt_amount = false
# Ignores dust below this value, value in micro MinoTari, defaults to 100
# dust_ignore_value: 100,
# This is the size of the event channel used to communicate output manager events to the wallet. A busy console
# wallet doing thousands of bulk payments or used for stress testing needs a fairly big size (>3000) (default = 250).
event_channel_size = 3500
Expand Down

0 comments on commit 8f5466c

Please sign in to comment.