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

Using calculate_fee() to set fee may result in incorrect fee amount #435

Closed
theoreticalbts opened this issue Nov 5, 2015 · 2 comments
Closed
Assignees
Milestone

Comments

@theoreticalbts
Copy link
Contributor

Fee size is based on operation size, which may change when the fee is set (depending on how the fee is serialized, in particular, whether either the share_type or asset_id_type is serialized as a variable length integer).

In other words, after set_fee assigns the fee to the fee field, the result is (in some sense) a different operation which might have a different fee (i.e., calling calculate_fee() on the newly produced operation may have a different result from calling calculate_fee() on the original, zero-fee operation).

Currently this is completely ignored, resulting in the possibility that some transactions might have set_fee calculate a slightly incorrect fee -- resulting in breaking its contract of computing the minimal fee that the chain will accept. If the fee is too high it is not bad, but in the main real-world case, the fee will be being set from zero, which is much more likely to result in an expansion of the operation's serialized form than a contraction. Net result: an operation that will not validate due to insufficient fees even after setting the fee to the result of calculate_fee(), calling set_fee() on your operation, or using the get_required_fees() API call.

@theoreticalbts
Copy link
Contributor Author

Merged to develop, awaiting review.

@theoreticalbts
Copy link
Contributor Author

Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants