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

Fix unit fees dynamics #732

Closed
wants to merge 2 commits into from
Closed

Fix unit fees dynamics #732

wants to merge 2 commits into from

Conversation

abi87
Copy link

@abi87 abi87 commented Feb 14, 2024

I believe there is an issue with the way we update unit fees here.
I understand unit fees should change in steps of changeDenom from a given unit fee.
This is not what happen in the code right now.
Probably the easier way to understand that there is an issue is to note that current code sums a dimensioned quantity (unitfee, which is Avax or denominated) with a dimensionless quantity (baseDelta).
I propose a change to fix it up.

}
n, over := math.Add64(nextPrice, baseDelta)
rawDelta := previousUnitFee * (totalUnitsConsumed - target) / target
delta := max(rawDelta/changeDenom, 1) * changeDenom // price must change in increments on changeDenom
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main point: delta here is ensured to be a multiple of changeDenom. Moverover, from a dimensional analysis standpoint, delta is a "token amont" quantity, which can be added to unit fees.
In the previous version baseDelta is a dimensionless quantity (ration of two fees) which cannot be added to a dimensioned quantity like next price

Copy link
Author

@abi87 abi87 Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually wrong: this code comes from coreth (see coreth code) which in turns comes from EIP1559 proposal (see for instance ethereum/EIPs#1559 for the original meaning of changeDenom and https://eips.ethereum.org/EIPS/eip-1559 for how it was evolved from there).

The goal of changeDenom is not to make sure that delta happens in multiples of the changeDenom.

@abi87 abi87 requested a review from wlawt February 14, 2024 10:48
@abi87 abi87 self-assigned this Feb 14, 2024
Copy link
Contributor

@wlawt wlawt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me

@abi87
Copy link
Author

abi87 commented Feb 28, 2024

I misunderstood the meaning of changeDenom, so this PR is wrong.

@abi87 abi87 closed this Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants