-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Global min Self Delegation (#134)
* fix testing and protobuf related issues * remove unnecessary changes in legacy migration tests * remove extraneous comments * add test for minselfdelegation * fix: Ensure that MsgCreateValidator's accompanying delegation is at least the provided MinSelfDelegation (#132) * add check to make sure validator object is only created if min delegation threshold is met * fix check location and use standard error type * fix logic for check * add test for new check * update test comments for better context * add checks for global min self delegation and fix corresponding tests * add migration code * fix migration code tests * fix staking client unit tests * tidy up * Apply suggestions from code review Co-authored-by: Dev Ojha <[email protected]> Co-authored-by: Aleksandr Bezobchuk <[email protected]> * apply changes suggested in review * fixed edge case error * lint++ * lint++ * Update x/staking/keeper/msg_server.go * Update x/staking/keeper/msg_server.go * Update x/staking/keeper/msg_server.go Co-authored-by: Aleksandr Bezobchuk <[email protected]> Co-authored-by: Aleksandr Bezobchuk <[email protected]> Co-authored-by: Dev Ojha <[email protected]> Co-authored-by: Aleksandr Bezobchuk <[email protected]>
- Loading branch information
1 parent
71bb5bd
commit 7a06fb2
Showing
14 changed files
with
967 additions
and
712 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package v046 | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" | ||
"github.com/cosmos/cosmos-sdk/x/staking/types" | ||
) | ||
|
||
// MigrateStore performs in-place store migrations from v0.43/v0.44 to v0.45. | ||
// The migration includes: | ||
// | ||
// - Setting the MinCommissionRate param in the paramstore | ||
func MigrateStore(ctx sdk.Context, paramstore paramtypes.Subspace) error { | ||
migrateParamsStore(ctx, paramstore) | ||
|
||
return nil | ||
} | ||
|
||
func migrateParamsStore(ctx sdk.Context, paramstore paramtypes.Subspace) { | ||
DefaultMinSelfDelegation := sdk.ZeroInt() | ||
paramstore.WithKeyTable(types.ParamKeyTable()) | ||
paramstore.Set(ctx, types.KeyMinSelfDelegation, DefaultMinSelfDelegation) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package v046_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/cosmos/cosmos-sdk/simapp" | ||
"github.com/cosmos/cosmos-sdk/testutil" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" | ||
v046staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v046" | ||
"github.com/cosmos/cosmos-sdk/x/staking/types" | ||
) | ||
|
||
func TestStoreMigration(t *testing.T) { | ||
encCfg := simapp.MakeTestEncodingConfig() | ||
stakingKey := sdk.NewKVStoreKey("staking") | ||
tStakingKey := sdk.NewTransientStoreKey("transient_test") | ||
ctx := testutil.DefaultContext(stakingKey, tStakingKey) | ||
paramstore := paramtypes.NewSubspace(encCfg.Marshaler, encCfg.Amino, stakingKey, tStakingKey, "staking") | ||
|
||
// Check no params | ||
require.False(t, paramstore.Has(ctx, types.KeyMinSelfDelegation)) | ||
|
||
// Run migrations. | ||
err := v046staking.MigrateStore(ctx, paramstore) | ||
require.NoError(t, err) | ||
|
||
// Make sure the new params are set. | ||
require.True(t, paramstore.Has(ctx, types.KeyMinSelfDelegation)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.