From 3784791752501c9f874afc71f62e4dfcb7cf6bed Mon Sep 17 00:00:00 2001 From: drklee3 Date: Wed, 25 Oct 2023 13:53:32 -0700 Subject: [PATCH] Add mainnet and testnet community params (#1753) --- app/upgrades.go | 41 +++++++++++++++++++++++++++++++++++------ app/upgrades_test.go | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 app/upgrades_test.go diff --git a/app/upgrades.go b/app/upgrades.go index 0401c4fe69..bd2f6cc142 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -19,21 +19,50 @@ const ( UpgradeName_E2ETest = "v0.25.0-testing" ) -var CommunityParams_E2E = communitytypes.NewParams( - time.Now().Add(10*time.Second).UTC(), // relative time for testing - sdkmath.LegacyNewDec(0), // stakingRewardsPerSecond - sdkmath.LegacyNewDec(1000), // upgradeTimeSetstakingRewardsPerSecond +var ( + // KAVA to ukava - 6 decimals + kavaConversionFactor = sdk.NewInt(1000_000) + secondsPerYear = sdk.NewInt(365 * 24 * 60 * 60) + + // 10 Million KAVA per year in staking rewards, inflation disable time 2024-01-01T00:00:00 UTC + CommunityParams_Mainnet = communitytypes.NewParams( + time.Date(2024, 1, 1, 0, 0, 0, 0, time.UTC), + // before switchover + sdkmath.LegacyZeroDec(), + // after switchover - 10M KAVA to ukava per year / seconds per year + sdkmath.LegacyNewDec(10_000_000). + MulInt(kavaConversionFactor). + QuoInt(secondsPerYear), + ) + + // Testnet -- 15 Trillion KAVA per year in staking rewards, inflation disable time 2023-11-16T00:00:00 UTC + CommunityParams_Testnet = communitytypes.NewParams( + time.Date(2023, 11, 16, 0, 0, 0, 0, time.UTC), + // before switchover + sdkmath.LegacyZeroDec(), + // after switchover + sdkmath.LegacyNewDec(15_000_000). + MulInt64(1_000_000). // 15M * 1M = 15T + MulInt(kavaConversionFactor). + QuoInt(secondsPerYear), + ) + + CommunityParams_E2E = communitytypes.NewParams( + time.Now().Add(10*time.Second).UTC(), // relative time for testing + sdkmath.LegacyNewDec(0), // stakingRewardsPerSecond + sdkmath.LegacyNewDec(1000), // upgradeTimeSetstakingRewardsPerSecond + ) ) // RegisterUpgradeHandlers registers the upgrade handlers for the app. func (app App) RegisterUpgradeHandlers() { app.upgradeKeeper.SetUpgradeHandler( UpgradeName_Mainnet, - upgradeHandler(app, UpgradeName_Mainnet, communitytypes.DefaultParams()), + upgradeHandler(app, UpgradeName_Mainnet, CommunityParams_Mainnet), ) app.upgradeKeeper.SetUpgradeHandler( UpgradeName_Testnet, - upgradeHandler(app, UpgradeName_Testnet, communitytypes.DefaultParams()), + upgradeHandler(app, UpgradeName_Testnet, CommunityParams_Testnet), ) app.upgradeKeeper.SetUpgradeHandler( UpgradeName_E2ETest, diff --git a/app/upgrades_test.go b/app/upgrades_test.go new file mode 100644 index 0000000000..804fe6e47a --- /dev/null +++ b/app/upgrades_test.go @@ -0,0 +1,41 @@ +package app_test + +import ( + "testing" + + sdkmath "cosmossdk.io/math" + "github.com/kava-labs/kava/app" + "github.com/stretchr/testify/require" +) + +func TestUpgradeCommunityParams_Mainnet(t *testing.T) { + require.Equal( + t, + sdkmath.LegacyZeroDec().String(), + app.CommunityParams_Mainnet.StakingRewardsPerSecond.String(), + ) + + require.Equal( + t, + // Manually confirmed + "317097.919837645865043125", + app.CommunityParams_Mainnet.UpgradeTimeSetStakingRewardsPerSecond.String(), + "mainnet kava per second should be correct", + ) +} + +func TestUpgradeCommunityParams_Testnet(t *testing.T) { + require.Equal( + t, + sdkmath.LegacyZeroDec().String(), + app.CommunityParams_Testnet.StakingRewardsPerSecond.String(), + ) + + require.Equal( + t, + // Manually confirmed + "475646879756.468797564687975646", + app.CommunityParams_Testnet.UpgradeTimeSetStakingRewardsPerSecond.String(), + "testnet kava per second should be correct", + ) +}