-
Notifications
You must be signed in to change notification settings - Fork 46
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
Deduct min fee on error #354
Conversation
This comment has been minimized.
This comment has been minimized.
x/cash/dynamicfee.go
Outdated
} | ||
|
||
// prepare is all shared setup between Check and Deliver, one more level above extractFee | ||
func (d DynamicFeeDecorator) prepare(ctx weave.Context, store weave.KVStore, tx weave.Tx) (fee x.Coin, payer weave.Address, cache weave.KVCacheWrap, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pp: named return params should be avoided as a best practice. See https://github.com/golang/go/wiki/CodeReviewComments#named-result-parameters
I will rebase this with |
Caching configuration in a decorator makes it immutable and prevents from being updated during the runtime. If the performance is a concern, instead of caching in the decorator a store wrapper could be used that would keep an in memory representation of the whole gconf set and flush on any update.
3ed05ad
to
e73998f
Compare
Rebased everything on master to prepare to merge it. |
Closes #348
Prepares #349
This embeds a checkpoint in a DynamicFeeDecorator, such that on success it will deduct the entire tx fee passed in the transaction, and on failure, only deducts the minimum fee.
Note this is designed for support of RequiredFee, but doesn't do that yet, just the variable deduction on tx failure. It would be good to test this is solid first in the face of possible attacks. (If the user pays less than minfee, it is rejected in CheckTx and nothing deducted, this is not really an attack).