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

test: x/mint thirdening - identify rounding errors #1874

Merged
merged 9 commits into from
Jun 30, 2022
Merged

Conversation

p0mvn
Copy link
Member

@p0mvn p0mvn commented Jun 26, 2022

Part of: #1839

What is the purpose of the change

There have been concerns about minting rounding errors that were causing total osmo supply to be slightly off.

This change root causes some of the rounding issues related to total supply. The newly introduced test identifies the 2 sources:

  1. Epoch provisions truncation
  2. Developer rewards truncation

The test works by running AfterEpochEnd hook 366 times (until and including thirdening). Before the 366th AfterEpochEnd, we make an assertion on the total supply.

If the aforementioned assertion was to be made directly against the actual osmo supply value, it would be off by 2619.999999999999999705. Instead, we accumulate the delta from the two rounding error sources and add them to the actual supply value to make the assertion pass:

// 299_999_999_999_999.999999999999999705 == 299_999_999_997_380 + 2555 + 64.999999999999999705
require.Equal(t, expectedTotalProvisionedSupply, actualTotalProvisionedSupply.Add(devRewardsDelta).Add(epochProvisionsDelta))
  • Note that the setup excludes the 100M initial mainnet supply and only includes the minted per-epoch provisions.

Essentially, this test helps to root cause the rounding errors. We should refactor and fix the rounding errors. Then, the test should potentially be removed.

Testing and Verifying

go test -timeout 30s -run ^TestAfterEpochEnd_FirstYearThirdening_RealParameters$ github.com/osmosis-labs/osmosis/v7/x/mint/keeper

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? no
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? no
  • How is the feature or change documented? not applicable

@p0mvn p0mvn marked this pull request as ready for review June 28, 2022 01:20
@p0mvn p0mvn requested a review from a team June 28, 2022 01:20
@p0mvn p0mvn changed the title test: x/mint thirdening test: x/mint thirdening - identify rounding errors Jun 28, 2022
x/mint/keeper/hooks_test.go Show resolved Hide resolved
Co-authored-by: Aleksandr Bezobchuk <[email protected]>
@p0mvn p0mvn merged commit d9a4f94 into main Jun 30, 2022
@p0mvn p0mvn deleted the roman/mint-test branch June 30, 2022 18:37
@p0mvn p0mvn added the A:backport/v10.x backport patches to v10.x branch label Jul 19, 2022
mergify bot pushed a commit that referenced this pull request Jul 19, 2022
* test: x/mint thirdening

* add logic for estimating supply

* estimate expected supply w/o offset

* identify the sources of rounding issues

* transcribe calculations

* clean up for readability

* Update x/mint/keeper/hooks_test.go

Co-authored-by: Aleksandr Bezobchuk <[email protected]>

* fix merge conflicts and link a correct issue

Co-authored-by: Aleksandr Bezobchuk <[email protected]>
(cherry picked from commit d9a4f94)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v10.x backport patches to v10.x branch C:x/mint
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants