-
Notifications
You must be signed in to change notification settings - Fork 397
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
fix: compare gas prices properly #3771
base: master
Are you sure you want to change the base?
Conversation
🛠 PR Checks SummaryAll Automated Checks passed. ✅ Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):No automated checks match this pull request. ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
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 👍
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
Description
This PR fixes a bug in the gas price comparison logic, where a larger gas price would return
false
for being larger, when compared to a smaller gas price:In this example, a user sent a transaction with the following gas pricing data:
10000
5ugnot
This returned
false
, when being compared to a gas price ofGas Wanted: 1000, Gas Fee: 1ugnot
🤷♂️The issue was that the function cross-multiplied mismatched fields, comparing fee-per-gas ratios instead of comparing total fees (gas x price), which led to an incorrect result when gas values differ. In this example, it would compare the ratios
0.00005
and0.001
, and returnfalse
:How our entire testing suite did not catch a bug like this is beyond me, but here we are.EDIT:
I've figured it out.
Our
std.Fee
is very misleading.The amount the user puts in the
tx.Fee
is actually the total amount of whatever the user is willing to pay for the entire transaction, not just a single unit of gas. The effective gas price is the ratio of the maximum gas wanted and the maximum fee (for the entire tx).