-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
R4R: Support min fees-based anti spam strategy #2328
Conversation
a333407
to
e5edb2a
Compare
e5edb2a
to
a986ac0
Compare
Codecov Report
@@ Coverage Diff @@
## develop #2328 +/- ##
===========================================
- Coverage 64.97% 64.73% -0.25%
===========================================
Files 135 137 +2
Lines 8418 8467 +49
===========================================
+ Hits 5470 5481 +11
- Misses 2587 2622 +35
- Partials 361 364 +3 |
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.
Thanks @alessio -- left some minor initial feedback 👍
server/config/config.go
Outdated
func (c *Config) MinimumFees() sdk.Coins { | ||
fees, err := sdk.ParseCoins(c.MinFees) | ||
if err != nil { | ||
panic(err) |
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.
panic(fmt.Sprintf("invalid minimum fees: %v", err))
x/auth/ante.go
Outdated
if ctx.MinimumFees().Minus(fee.Amount).IsNotNegative() { | ||
fee = NewStdFee(fee.Gas, ctx.MinimumFees()...) | ||
} | ||
// Validators reject any tx from the mempool with less than the required fee per gas |
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.
validators
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.
Where does the rejection actually occur? If the fee amount is zero?
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.
validators
ACKd.
Where does the rejection actually occur? If the fee amount is zero?
Currently the rejection occurs at deductFees()
.
227830b
to
b2ce856
Compare
I think the way min-fees should related to gas prices is some absolute minimium value + a factor * gas consumed |
d470c25
to
a2c7116
Compare
2141405
to
c6034f3
Compare
@alexanderbez your comments were addressed, please review |
dd6a0a5
to
6e89aaa
Compare
Hmmm I don't recall |
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.
Left a few more minor questions and suggestions, but otherwise, it looks good.
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.
Structure looks good, see comments.
x/auth/ante.go
Outdated
if ctx.IsCheckTx() && !simulate { | ||
// required fees must be greater than the minimum set by the validator | ||
if ctx.MinimumFees().Minus(fee.Amount).IsNotNegative() { | ||
fee = NewStdFee(fee.Gas, ctx.MinimumFees()...) |
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.
Why are we setting fee
here? Do we only want users to pay the minimum fee even if they set a higher one?
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.
When MinimumFees > Fee
(MinimumFees - Fee > 0
), we pick MinimumFees
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.
What if the user supplies Fee > MinimumFees
?
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.
We shouldn't auto set the fee to min fee if the provided fee isn't enough. There are several issues with that. It will cause a consensus fault, since every validator would subtract it differently. Even if this didn't happen, it provides a validator a way to drain your entire account.
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.
What if the user supplies Fee > MinimumFees?
That just works.
We shouldn't auto set the fee to min fee if the provided fee isn't enough.
I thourougly agree, I've just stumbled upon such a case while performing some testing.
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.
We should do neither - if the user didn't sign a transaction with high-enough fees, we should reject the transaction, not subtract fees from their account which they didn't sign. The only check we should perform is that the fees provided in the transaction are greater than the minimum fee - the user should always pay exactly the fee they specified.
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.
Fixed. Please review @cwgoes @ValarDragon @alexanderbez
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.
Mhmmm, what about refunds in the case where they specify a greater amount? Are we relying on the user to know a safe estimate ahead of time?
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.
Are we relying on the user to know a safe estimate ahead of time?
Short answer: yes. A solution may be returning an estimate of the fees along with the gas in --dry-run
mode
b166630
to
0d354a6
Compare
@alexanderbez I noticed that too - @cwgoes any help/clues are appreciated |
Create cosmos.toml configuration file and handle minimum_fees setting/flag to provide validators with a simple and flexible anti-spam mechanism. Closes: #1921
67e4a28
to
62387d9
Compare
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.
Tested ACK
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.
One small minor remark, otherwise utACK 👍
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.
utACK -- thanks @alessio
Create cosmos.toml configuration file and handle minimum_fees
setting/flag to provide validators with a simple and flexible
anti-spam mechanism.
Closes: #1921
docs/
)PENDING.md
with issue #Files changed
in the github PR explorerFor Admin Use: