diff --git a/CHANGELOG.md b/CHANGELOG.md index ba1178ea48..629f890dff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,12 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog +## [v18.0.0] - 2024-04-22 + +### State Machine Breaking + +- (vesting) Refactor vesting module. + ## [v17.0.0] - 2024-04-08 ### State Machine Breaking diff --git a/app/app.go b/app/app.go index 2561a228a8..73f3c390ba 100644 --- a/app/app.go +++ b/app/app.go @@ -160,11 +160,11 @@ import ( inflation "github.com/evmos/evmos/v18/x/inflation/v1" inflationkeeper "github.com/evmos/evmos/v18/x/inflation/v1/keeper" inflationtypes "github.com/evmos/evmos/v18/x/inflation/v1/types" - "github.com/evmos/evmos/v18/x/staking" - stakingkeeper "github.com/evmos/evmos/v18/x/staking/keeper" revenue "github.com/evmos/evmos/v18/x/revenue/v1" revenuekeeper "github.com/evmos/evmos/v18/x/revenue/v1/keeper" revenuetypes "github.com/evmos/evmos/v18/x/revenue/v1/types" + "github.com/evmos/evmos/v18/x/staking" + stakingkeeper "github.com/evmos/evmos/v18/x/staking/keeper" "github.com/evmos/evmos/v18/x/vesting" vestingclient "github.com/evmos/evmos/v18/x/vesting/client" vestingkeeper "github.com/evmos/evmos/v18/x/vesting/keeper" diff --git a/testutil/integration/ibc/coordinator/coordinator.go b/testutil/integration/ibc/coordinator/coordinator.go index c7b4389d15..5cf9276d8e 100644 --- a/testutil/integration/ibc/coordinator/coordinator.go +++ b/testutil/integration/ibc/coordinator/coordinator.go @@ -40,7 +40,6 @@ type Coordinator interface { CommitAll() error } -// TODO: Replace for a config var AmountOfDummyChains = 2 var _ Coordinator = (*IntegrationCoordinator)(nil) diff --git a/x/staking/keeper/msg_server_test.go b/x/staking/keeper/msg_server_test.go index e40a2037aa..990155df05 100644 --- a/x/staking/keeper/msg_server_test.go +++ b/x/staking/keeper/msg_server_test.go @@ -30,7 +30,7 @@ func TestMsgDelegate(t *testing.T) { funderAddr, _ = utiltx.NewAccAddressAndKey() ) - testCases := []struct { + testCases := []struct { //nolint:dupl name string setup func() sdk.Coin expErr bool @@ -74,7 +74,7 @@ func TestMsgDelegate(t *testing.T) { // after first vesting period and before lockup // some vested tokens, but still all locked cliffDuration := time.Duration(testutil.TestVestingSchedule.CliffPeriodLength) - nw.NextBlockAfter(cliffDuration * time.Second) + require.NoError(t, nw.NextBlockAfter(cliffDuration*time.Second)) ctx = nw.GetContext() acc := nw.App.AccountKeeper.GetAccount(ctx, delegatorAddr) @@ -99,7 +99,7 @@ func TestMsgDelegate(t *testing.T) { // Between first and second lockup periods // vested coins are unlocked lockDuration := time.Duration(testutil.TestVestingSchedule.LockupPeriodLength) - nw.NextBlockAfter(lockDuration * time.Second) + require.NoError(t, nw.NextBlockAfter(lockDuration*time.Second)) ctx = nw.GetContext() acc := nw.App.AccountKeeper.GetAccount(ctx, delegatorAddr) @@ -149,7 +149,7 @@ func TestMsgCreateValidator(t *testing.T) { funderAddr, _ = utiltx.NewAccAddressAndKey() ) - testCases := []struct { + testCases := []struct { //nolint:dupl name string setup func() sdk.Coin expErr bool @@ -193,7 +193,7 @@ func TestMsgCreateValidator(t *testing.T) { // after first vesting period and before lockup // some vested tokens, but still all locked cliffDuration := time.Duration(testutil.TestVestingSchedule.CliffPeriodLength) - nw.NextBlockAfter(cliffDuration * time.Second) + require.NoError(t, nw.NextBlockAfter(cliffDuration*time.Second)) ctx = nw.GetContext() acc := nw.App.AccountKeeper.GetAccount(ctx, validatorAddr) @@ -218,7 +218,7 @@ func TestMsgCreateValidator(t *testing.T) { // Between first and second lockup periods // vested coins are unlocked lockDuration := time.Duration(testutil.TestVestingSchedule.LockupPeriodLength) - nw.NextBlockAfter(lockDuration * time.Second) + require.NoError(t, nw.NextBlockAfter(lockDuration*time.Second)) ctx = nw.GetContext() acc := nw.App.AccountKeeper.GetAccount(ctx, validatorAddr) diff --git a/x/vesting/keeper/msg_server.go b/x/vesting/keeper/msg_server.go index fe2644e41e..99c654ed63 100644 --- a/x/vesting/keeper/msg_server.go +++ b/x/vesting/keeper/msg_server.go @@ -375,7 +375,7 @@ func (k Keeper) ConvertVestingAccount( if vestingAcc.HasLockedCoins(ctx.BlockTime()) { return nil, errorsmod.Wrapf(errortypes.ErrInvalidRequest, "locked up coins still left in account: %s", msg.VestingAddress) } - + // if gov clawback is disabled, remove the entry from the store. // if no entry is found for the address, this will no-op k.DeleteGovClawbackDisabled(ctx, address) diff --git a/x/vesting/keeper/msg_server_test.go b/x/vesting/keeper/msg_server_test.go index 3b6fdde087..ff5340d9ad 100644 --- a/x/vesting/keeper/msg_server_test.go +++ b/x/vesting/keeper/msg_server_test.go @@ -97,7 +97,7 @@ func (suite *KeeperTestSuite) TestMsgFundVestingAccount() { } for _, tc := range testCases { suite.Run(fmt.Sprintf("Case %s", tc.name), func() { - suite.SetupTest() // Reset + suite.Require().NoError(suite.SetupTest()) // Reset ctx := sdk.WrapSDKContext(suite.ctx) // fund the recipient account to set the account and then @@ -165,7 +165,7 @@ func (suite *KeeperTestSuite) TestMsgFundVestingAccountSpecialCases() { // --------------------------- // Test blocked address suite.Run("fail - blocked address", func() { - suite.SetupTest() + suite.Require().NoError(suite.SetupTest()) msg := &types.MsgFundVestingAccount{ FunderAddress: funder.String(), VestingAddress: authtypes.NewModuleAddress("transfer").String(), @@ -183,7 +183,7 @@ func (suite *KeeperTestSuite) TestMsgFundVestingAccountSpecialCases() { // Test wrong funder by first creating a clawback vesting account // and then trying to fund it with a different funder suite.Run("fail - wrong funder", func() { - suite.SetupTest() + suite.Require().NoError(suite.SetupTest()) // fund the recipient account to set the account err = testutil.FundAccount(suite.ctx, suite.app.BankKeeper, vestingAddr, balances) @@ -284,7 +284,7 @@ func (suite *KeeperTestSuite) TestMsgCreateClawbackVestingAccount() { for _, tc := range testcases { tc := tc suite.Run(tc.name, func() { - suite.SetupTest() // Reset + suite.Require().NoError(suite.SetupTest()) // Reset ctx := sdk.WrapSDKContext(suite.ctx) tc.malleate(tc.funder, tc.vestingAddr) @@ -425,7 +425,7 @@ func (suite *KeeperTestSuite) TestMsgClawback() { } for _, tc := range testCases { suite.Run(fmt.Sprintf("Case %s", tc.name), func() { - suite.SetupTest() // reset + suite.Require().NoError(suite.SetupTest()) // reset ctx := sdk.WrapSDKContext(suite.ctx) // fund the vesting target address to initialize it as an account and @@ -553,7 +553,7 @@ func (suite *KeeperTestSuite) TestMsgUpdateVestingFunder() { } for _, tc := range testCases { suite.Run(fmt.Sprintf("Case %s", tc.name), func() { - suite.SetupTest() // reset + suite.Require().NoError(suite.SetupTest()) // reset ctx := sdk.WrapSDKContext(suite.ctx) // fund the account at the vesting address to initialize it and then sund all funds to the funder account @@ -596,7 +596,7 @@ func (suite *KeeperTestSuite) TestMsgUpdateVestingFunder() { } func (suite *KeeperTestSuite) TestClawbackVestingAccountStore() { - suite.SetupTest() + suite.Require().NoError(suite.SetupTest()) // Create and set clawback vesting account vestingStart := s.ctx.BlockTime() @@ -612,7 +612,7 @@ func (suite *KeeperTestSuite) TestClawbackVestingAccountStore() { } func (suite *KeeperTestSuite) TestClawbackVestingAccountMarshal() { - suite.SetupTest() + suite.Require().NoError(suite.SetupTest()) // Create and set clawback vesting account vestingStart := s.ctx.BlockTime() @@ -718,7 +718,7 @@ func (suite *KeeperTestSuite) TestConvertVestingAccount() { for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupTest() // reset + suite.Require().NoError(suite.SetupTest()) // reset acc := tc.malleate() msg := types.NewMsgConvertVestingAccount(acc.GetAddress()) diff --git a/x/vesting/types/clawback_vesting_account.go b/x/vesting/types/clawback_vesting_account.go index 9b6829627d..f9ff474bd7 100644 --- a/x/vesting/types/clawback_vesting_account.go +++ b/x/vesting/types/clawback_vesting_account.go @@ -174,7 +174,6 @@ func (va ClawbackVestingAccount) GetVestedCoins(blockTime time.Time) sdk.Coins { return ReadSchedule(va.GetStartTime(), va.EndTime, va.VestingPeriods, va.OriginalVesting, blockTime.Unix()) } - // GetPassedPeriodCount returns the amount of passed periods at blockTime. func (va ClawbackVestingAccount) GetPassedPeriodCount(blockTime time.Time) int { return ReadPastPeriodCount(va.GetStartTime(), va.EndTime, va.VestingPeriods, blockTime.Unix()) diff --git a/x/vesting/types/clawback_vesting_account_test.go b/x/vesting/types/clawback_vesting_account_test.go index a85e154c26..dd201d453e 100644 --- a/x/vesting/types/clawback_vesting_account_test.go +++ b/x/vesting/types/clawback_vesting_account_test.go @@ -293,6 +293,7 @@ func (suite *VestingAccountTestSuite) TestGetCoinsFunctions() { }) } } + func (suite *VestingAccountTestSuite) TestTrackDelegationUndelegation() { now := tmtime.Now() endTime := now.Add(24 * time.Hour)