Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wallet coin selection respects max_block_weight #2546

Merged
merged 3 commits into from
Feb 12, 2019

Conversation

i1skn
Copy link
Contributor

@i1skn i1skn commented Feb 8, 2019

Deprecate "soft" max_outputs limit and introduce "hard" max_outputs
limit based on max_block_weight. Should fix #2510

Deprecate "soft" max_outputs limit and introduce "hard" max_outputs
limit based on max_block_weight.
@i1skn i1skn changed the title fix #2510: wallet coin selection respects max_block_weight fix: wallet coin selection respects max_block_weight Feb 8, 2019
@antiochp antiochp self-requested a review February 8, 2019 22:03
@yeastplume yeastplume self-requested a review February 9, 2019 13:17
@ignopeverell
Copy link
Contributor

Looks like this introduces some bona fide test compilation failures.

@i1skn
Copy link
Contributor Author

i1skn commented Feb 9, 2019

@ignopeverell my fault, fixed!

@@ -253,7 +262,7 @@ where
amount,
current_height,
minimum_confirmations,
max_outputs,
calculate_max_inputs_in_block(change_outputs),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies if this is a misunderstanding, I'm not too familiar with this code. But shouldn't you calculate the max number of inputs for change_outputs + 1 to account for the receiver's output?

Copy link
Contributor Author

@i1skn i1skn Feb 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct, but first, we need to understand do we need a change. First, we calculate assuming that there will be no change (this gives us also the lowest fee). We check do we have fee+amount on our balance or not and only then we figure out do we need a change output or we can transfer without it.
If we need one - we set:

let num_outputs = change_outputs + 1;

and then select coins using num_outputs
coins = select_coins(
wallet,
amount_with_fee,
current_height,
minimum_confirmations,
calculate_max_inputs_in_block(num_outputs),
selection_strategy_is_use_all,
parent_key_id,
)

At least that's how I get it, probably @yeastplume can verify does this make sense or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, correct, that's what happens.

@yeastplume
Copy link
Member

LGTM, but merge conflict introduced, sorry.

I think I'm okay with removing the concept of a manually specifiable max_outputs in the name of reducing the exposed complexity.

@ignopeverell ignopeverell added this to the 1.0.2 milestone Feb 12, 2019
@ignopeverell ignopeverell merged commit aa4f44b into mimblewimble:master Feb 12, 2019
@hashmap hashmap deleted the max-tx-weight branch April 4, 2019 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wallet coin selection can build a tx that exceeds max_block_weight
3 participants