Skip to content

Conversation

@amadeuszpawlik
Copy link
Contributor

@amadeuszpawlik amadeuszpawlik commented May 24, 2021

rpc: Sanitize fee option inputs. refs #21893

Checks -blockmintxfee, -incrementalrelayfee, -dustrelayfee and -minrelaytxfee values.
Fees are parsed as int64_t, and as a fee is being multiplied by the package size, too large a value might lead to an overflow.

Max value set to 1 BTC as @MarcoFalke states in #21893:

Assuming a maximum transaction size of at most 4MvB, this would give an upper bound for the fee rate of ~46116 BTC/kvB. Though, any fee rate larger than 1 BTC/kvB is probably nonsense and should be rejected early on startup.

@amadeuszpawlik
Copy link
Contributor Author

Before undrafting: Are there any other fees that should be sanitized? Is this the right approach?

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

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

Concept ACK.

@maflcko
Copy link
Member

maflcko commented May 25, 2021

I'd say all fee rates should be sanitized with this

@amadeuszpawlik amadeuszpawlik force-pushed the sanitize_21893 branch 3 times, most recently from 44ad311 to 0094b3e Compare May 25, 2021 13:29
@amadeuszpawlik amadeuszpawlik changed the title High fee check for -blockmintxfee option High fee checks for fee options May 25, 2021
@amadeuszpawlik
Copy link
Contributor Author

I'd say all fee rates should be sanitized with this

-minrelaytxfee is already checked for high fee in CWallet::Create(), does it make sense to do a rough (<1BTC) check in AppInitParameterInteraction(...) too, as to reject it as early as possible?

@maflcko
Copy link
Member

maflcko commented May 25, 2021

The error should be printed even without the wallet

@amadeuszpawlik amadeuszpawlik marked this pull request as ready for review May 26, 2021 09:44
@amadeuszpawlik amadeuszpawlik changed the title High fee checks for fee options Sanitize fee options May 26, 2021
@DrahtBot
Copy link
Contributor

DrahtBot commented Jun 11, 2021

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #25388 (refactor: move policy constants to policy by fanquake)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@timgurto
Copy link

Approach NACK. A 1 BTC/kvB limit may make sense given the current market price of BTC, but in the context of the codebase it's arbitrary and thus doesn't belong.

Given that the purpose of this change is to avoid overflows, it might be more appropriate to sanitize the potential fee once it's ready to be calculated (e.g., check that fee rate < int max / size). In that way it'd based on the technical constraint itself, rather than on what a reasonable fee looks like in 2021.

@maflcko
Copy link
Member

maflcko commented Jul 12, 2021

Given that the purpose of this change is to avoid overflows, it might be more appropriate to sanitize the potential fee once it's ready to be calculated (e.g., check that fee rate < int max / size). In that way it'd based on the technical constraint itself, rather than on what a reasonable fee looks like in 2021.

When you sanitize it once it's calculated, it will become a run-time error, instead of InitError, as it is now. This forces the user to shutdown the node and adjust the fee when the node is already fully running. Also, the error might be intermittent, because it depends on the tx size.

Also, we already have upper limits for the maximum tx fee for local transaction (maxtxfee), with a default of 0.1 BTC. So I don't see why it is so bad to add another constant.

If 1 BTC/kvB is still too controversial, 46116 BTC/kvB can be picked as I explained in #21893.

Check if -blockmintxfee, -incrementalrelayfee, -dustrelayfee and
-minrelaytxfee values are set higher than 1BTC/KvB, in which case
reject such high values.

This protects against potential overflow when fees are multiplied by the
package size, as fees are parsed as int64_t.
@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft".

@achow101
Copy link
Member

Closing this as it has not had any activity in a while. If you are interested in continuing work on this, please leave a comment so that it can be reopened.

@achow101 achow101 closed this Oct 12, 2022
@bitcoin bitcoin locked and limited conversation to collaborators Oct 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants