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

[mint] Update mint distribution to be daily #718

Merged
merged 16 commits into from
Apr 27, 2023
Merged

[mint] Update mint distribution to be daily #718

merged 16 commits into from
Apr 27, 2023

Conversation

BrandonWeng
Copy link
Contributor

@BrandonWeng BrandonWeng commented Apr 22, 2023

Describe your changes and provide context

Will follow up with another PR to add a gov prop with updating the current release minter.

Previously the mint rewards are distributed to the block immediately following the mint event, this PR makes it such that the mints are distributed daily over a period of time (as defined in the mint parms). This incentivizes users to stake for longer periods of time rather just for the mint event.

This pretty much rewrites the entire mint module

Testing performed to validate your change

Unit test for individual methods and overall hook test

Simple e2e test:
image

Going to spin up a loadtest cluster and let it run for a couple of days and use metrics to observe mint events (final verification)

Tested upgrade path locally:

image

Before
image

After
image

@BrandonWeng BrandonWeng marked this pull request as ready for review April 22, 2023 21:42
@BrandonWeng BrandonWeng changed the title update proto Update Minting to be daily Apr 22, 2023
@BrandonWeng BrandonWeng force-pushed the sei-3710 branch 7 times, most recently from 922ceae to 76c2d92 Compare April 25, 2023 14:48
@BrandonWeng BrandonWeng changed the title Update Minting to be daily [mint] Update mint distribution to be daily Apr 25, 2023
Comment on lines -34 to -35
case bytes.HasPrefix(key, minttypes.LastTokenReleaseDate):
keyItems = append(keyItems, "LastTokenReleaseDate")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not needed anymore

Comment on lines 45 to 46
cat ~/.sei/config/genesis.json | jq --arg start_date "$(date +"%Y-%m-%d")" --arg end_date "$(date -v+3d +"%Y-%m-%d")" '.app_state["mint"]["params"]["token_release_schedule"]=[{"start_date": $start_date, "end_date": $end_date, "token_release_amount": "999999999999"}]' > ~/.sei/config/tmp_genesis.json && mv ~/.sei/config/tmp_genesis.json ~/.sei/config/genesis.json
cat ~/.sei/config/genesis.json | jq --arg start_date "$(date -v+3d +"%Y-%m-%d")" --arg end_date "$(date -v+5d +"%Y-%m-%d")" '.app_state["mint"]["params"]["token_release_schedule"] += [{"start_date": $start_date, "end_date": $end_date, "token_release_amount": "999999999999"}]' > ~/.sei/config/tmp_genesis.json && mv ~/.sei/config/tmp_genesis.json ~/.sei/config/genesis.json
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Two schedule for testing, first mint will occur in 1 min (epoch handler)

Comment on lines +89 to +108
func SortTokenReleaseCalendar(tokenReleaseSchedule []ScheduledTokenRelease) []ScheduledTokenRelease {
sort.Slice(tokenReleaseSchedule, func(i, j int) bool {
startDate1, _ := time.Parse(TokenReleaseDateFormat, tokenReleaseSchedule[i].GetStartDate())
startDate2, _ := time.Parse(TokenReleaseDateFormat, tokenReleaseSchedule[j].GetStartDate())
return startDate1.Before(startDate2)
})
return tokenReleaseSchedule
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorted so it's easier to detect overlaps and search for next release window

string denom = 4 [
(gogoproto.moretags) = "yaml:\"denom\""
];
string start_date = 1; // yyyy-mm-dd
Copy link
Contributor

Choose a reason for hiding this comment

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

i think we'll need to consider migration? maybe you can sync with @udpatil who did the same with x/slashing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yeah, good point, thanks!

expectedAmount := int64(100000)
newMinter := seiApp.MintKeeper.GetMinter(ctx)

if i == 25 {
Copy link
Contributor

Choose a reason for hiding this comment

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

will we ever hit this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

},
},
{
name: "Unsorted schedule",
Copy link
Contributor

Choose a reason for hiding this comment

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

do we want to allow an unsorted schedule? seems like it could be potentially messy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we can raise a panic if it's unsorted but at that point, I think just sorting it and storing it by default would be a better user interface.

require.Equal(t, postOutageTime.Format(minttypes.TokenReleaseDateFormat), newMinter.GetLastMintDate(), "Last mint date should be correct")
require.InDelta(t, 127315, newMinter.GetLastMintAmountCoin().Amount.Int64(), 1, "Minted amount should be correct")
require.InDelta(t, int64(1018522), int64(newMinter.GetRemainingMintAmount()), 24, "Remaining amount should be correct")
})
Copy link
Contributor

Choose a reason for hiding this comment

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

can we finish the mitn release cycle and ensure all tokens are released?

@BrandonWeng BrandonWeng requested a review from philipsu522 April 26, 2023 23:06
app/upgrades.go Outdated
@@ -62,6 +62,7 @@ var upgradesList = []string{
"2.0.44beta",
"2.0.45beta",
"2.0.46beta",
"2.0.46beta-bweng-test",
Copy link
Contributor

Choose a reason for hiding this comment

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

mighht want to revert this before merge

@github-actions
Copy link

Code Coverage

Package Line Rate Complexity Health
github.com/sei-protocol/sei-chain/aclmapping/bank 83% 0
github.com/sei-protocol/sei-chain/aclmapping/dex 100% 0
github.com/sei-protocol/sei-chain/aclmapping/oracle 100% 0
github.com/sei-protocol/sei-chain/aclmapping/staking 96% 0
github.com/sei-protocol/sei-chain/aclmapping/tokenfactory 96% 0
github.com/sei-protocol/sei-chain/aclmapping/utils 0% 0
github.com/sei-protocol/sei-chain/aclmapping/wasm 83% 0
github.com/sei-protocol/sei-chain/app 61% 0
github.com/sei-protocol/sei-chain/app/antedecorators 76% 0
github.com/sei-protocol/sei-chain/oracle/price-feeder/config 85% 0
github.com/sei-protocol/sei-chain/oracle/price-feeder/oracle 67% 0
github.com/sei-protocol/sei-chain/oracle/price-feeder/oracle/provider 50% 0
github.com/sei-protocol/sei-chain/oracle/price-feeder/router/v1 45% 0
github.com/sei-protocol/sei-chain/store/whitelist/cachemulti 100% 0
github.com/sei-protocol/sei-chain/store/whitelist/kv 100% 0
github.com/sei-protocol/sei-chain/store/whitelist/multi 100% 0
github.com/sei-protocol/sei-chain/utils 59% 0
github.com/sei-protocol/sei-chain/utils/datastructures 90% 0
github.com/sei-protocol/sei-chain/utils/logging 100% 0
github.com/sei-protocol/sei-chain/x/dex 58% 0
github.com/sei-protocol/sei-chain/x/dex/cache 87% 0
github.com/sei-protocol/sei-chain/x/dex/client/cli/query 22% 0
github.com/sei-protocol/sei-chain/x/dex/contract 53% 0
github.com/sei-protocol/sei-chain/x/dex/exchange 94% 0
github.com/sei-protocol/sei-chain/x/dex/keeper 63% 0
github.com/sei-protocol/sei-chain/x/dex/keeper/abci 24% 0
github.com/sei-protocol/sei-chain/x/dex/keeper/msgserver 80% 0
github.com/sei-protocol/sei-chain/x/dex/keeper/query 82% 0
github.com/sei-protocol/sei-chain/x/dex/migrations 88% 0
github.com/sei-protocol/sei-chain/x/dex/types 1% 0
github.com/sei-protocol/sei-chain/x/dex/types/utils 100% 0
github.com/sei-protocol/sei-chain/x/dex/types/wasm 50% 0
github.com/sei-protocol/sei-chain/x/epoch 11% 0
github.com/sei-protocol/sei-chain/x/epoch/keeper 66% 0
github.com/sei-protocol/sei-chain/x/epoch/types 2% 0
github.com/sei-protocol/sei-chain/x/mint 0% 0
github.com/sei-protocol/sei-chain/x/mint/keeper 77% 0
github.com/sei-protocol/sei-chain/x/mint/simulation 95% 0
github.com/sei-protocol/sei-chain/x/mint/types 4% 0
github.com/sei-protocol/sei-chain/x/nitro/client/cli 45% 0
github.com/sei-protocol/sei-chain/x/nitro/keeper 83% 0
github.com/sei-protocol/sei-chain/x/nitro/replay 63% 0
github.com/sei-protocol/sei-chain/x/oracle 67% 0
github.com/sei-protocol/sei-chain/x/oracle/keeper 82% 0
github.com/sei-protocol/sei-chain/x/oracle/simulation 18% 0
github.com/sei-protocol/sei-chain/x/oracle/types 3% 0
github.com/sei-protocol/sei-chain/x/tokenfactory/keeper 85% 0
github.com/sei-protocol/sei-chain/x/tokenfactory/types 2% 0
Summary 15% (5323 / 35126) 0

@BrandonWeng BrandonWeng merged commit 399f2eb into master Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants