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

Deduct min fee on error #354

Merged
merged 21 commits into from
Mar 4, 2019
Merged

Deduct min fee on error #354

merged 21 commits into from
Mar 4, 2019

Conversation

ethanfrey
Copy link
Contributor

@ethanfrey ethanfrey commented Feb 25, 2019

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).

@codecov-io

This comment has been minimized.

x/cash/controller.go Outdated Show resolved Hide resolved
x/cash/dynamicfee.go Outdated Show resolved Hide resolved
x/cash/dynamicfee.go Outdated Show resolved Hide resolved
x/cash/dynamicfee.go Show resolved Hide resolved
}

// 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) {
Copy link
Contributor

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

x/cash/staticfee.go Show resolved Hide resolved
@husio
Copy link
Contributor

husio commented Mar 4, 2019

I will rebase this with master once all discussions are finished.

@ethanfrey ethanfrey removed the WIP label Mar 4, 2019
@ethanfrey ethanfrey force-pushed the deduct-min-fee-on-error branch from 3ed05ad to e73998f Compare March 4, 2019 18:57
@ethanfrey
Copy link
Contributor Author

Rebased everything on master to prepare to merge it.
This was implicitly approved by the other modification PRs and requests on slack to merge it

@ethanfrey ethanfrey merged commit c56d9a9 into master Mar 4, 2019
@ethanfrey ethanfrey deleted the deduct-min-fee-on-error branch March 4, 2019 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants