-
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
feat: CheckTX Priority #10507
feat: CheckTX Priority #10507
Conversation
unblocked |
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.
I'm concerned that this doesn't differentiate denoms when doing the naive addition. It would give a lot of priority to txs which add some denom which is cheap or has large exponent (say 10e9) but isn't even a fee denom.
A fix to this would be using only one fee denom to determine the priority. Or if we don't want to add configuration, using the min integer value of all the demons in the fee so it's not easily gameable. |
@aaronc I don't really understand the concern. What do you mean by "but isn't even a fee denom."? In any case, I implemented and even documented that this is a naive approach, which will work just fine for the Hub btw. Applications that need a more sophisticated model would just implement their own middleware. In fact, they could do so and release updates and changes to this middleware in point releases (non-breaking). This PR wasn't intended to solve most uses cases, but rather just get the ball rolling on a basic approach to tx priority. |
|
||
// GetTxPriority returns a naive tx priority based on the total sum of all fees | ||
// provided in a transaction. | ||
func GetTxPriority(fee sdk.Coins) int64 { |
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.
how about renaming to ComputeTxPriority
?
Aaron concerns is about rebasing the fees (if there are fees in multiple tokens) to a common denominator. |
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.
lgtm, Let's consider renaming GetTxPriority (made a comment about it).
I'm not sure why this is so complicated. I suggested a very simple approach to make this non-gameable. I'll make a code suggestion with my approach. |
func GetTxPriority(fee sdk.Coins) int64 { | ||
var priority int64 | ||
for _, c := range fee { | ||
priority += c.Amount.Int64() |
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.
priority += c.Amount.Int64() | |
p := c.Amount.Int64() | |
if priority == 0 || p < priority { | |
priority = p | |
} |
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.
I know you're just taking the minimum here. What does this really buy you? If all fees provided are valid denominations, what is the issue exactly?
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.
but the denominations have different prices and settling on the minimum makes it hard to use a cheaper denom alongside the primary denom to boost a tx. the primary denom will take precedence with the minimum
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.
I would say this is out of scope of a naive implementation. Its either we spend time designing a new way to do this, which we have pre open for but no reviews, or we document teams how do this and say they have to do it based on their use case. We don't have the man power to design yet another thing right now
Maybe adding a warning godoc could benefit this.
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.
But why is there a lot of design needed? It seems like just taking the min solves a lot to potential issues and is a very simple code change
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.
I agree with Aaron, what if one denom has exponent = 2, and another one 6? Adding 2 = 0.2
(fee from first denom) to 500 = 0.0005
(fee from the secon denom) doesn't really make sense. So at least we should document / add a comment, that his is a naive implementation.
Set the
Priority
inResponseCheckTx
to prioritize txs in Tendermint's mempool. For now, we compute the tx priority naively as the total sum of all fees in a tx.Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change