From d12707bab314c2e9654715024fc72f6dbf6e87e1 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 23 Feb 2024 21:57:44 +0100 Subject: [PATCH] chore: api cleanups --- crypto/codec/cmt.go | 22 ---------------------- types/module/module.go | 16 ++++------------ types/module/module_int_test.go | 5 +++-- x/staking/module.go | 3 +-- x/staking/types/validator.go | 5 ----- 5 files changed, 8 insertions(+), 43 deletions(-) diff --git a/crypto/codec/cmt.go b/crypto/codec/cmt.go index ee8889fd2fcf..c69d416efeac 100644 --- a/crypto/codec/cmt.go +++ b/crypto/codec/cmt.go @@ -68,25 +68,3 @@ func ToCmtPubKeyInterface(pk cryptotypes.PubKey) (cmtcrypto.PubKey, error) { return encoding.PubKeyFromProto(tmProtoPk) } - -// ---------------------- - -// Deprecated: use FromCmtProtoPublicKey instead. -func FromTmProtoPublicKey(protoPk cmtprotocrypto.PublicKey) (cryptotypes.PubKey, error) { - return FromCmtProtoPublicKey(protoPk) -} - -// Deprecated: use ToCmtProtoPublicKey instead. -func ToTmProtoPublicKey(pk cryptotypes.PubKey) (cmtprotocrypto.PublicKey, error) { - return ToCmtProtoPublicKey(pk) -} - -// Deprecated: use FromCmtPubKeyInterface instead. -func FromTmPubKeyInterface(tmPk cmtcrypto.PubKey) (cryptotypes.PubKey, error) { - return FromCmtPubKeyInterface(tmPk) -} - -// Deprecated: use ToCmtPubKeyInterface instead. -func ToTmPubKeyInterface(pk cryptotypes.PubKey) (cmtcrypto.PubKey, error) { - return ToCmtPubKeyInterface(pk) -} diff --git a/types/module/module.go b/types/module/module.go index 640d733fb6a2..7afba9f1211d 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -127,10 +127,6 @@ type HasConsensusVersion interface { ConsensusVersion() uint64 } -// HasABCIEndblock is a released typo of HasABCIEndBlock. -// Deprecated: use HasABCIEndBlock instead. -type HasABCIEndblock HasABCIEndBlock - // HasABCIEndBlock is the interface for modules that need to run code at the end of the block. type HasABCIEndBlock interface { AppModule @@ -140,7 +136,7 @@ type HasABCIEndBlock interface { // Manager defines a module manager that provides the high level utility for managing and executing // operations for a group of modules type Manager struct { - Modules map[string]interface{} // interface{} is used now to support the legacy AppModule as well as new core appmodule.AppModule. + Modules map[string]appmodule.AppModule OrderInitGenesis []string OrderExportGenesis []string OrderPreBlockers []string @@ -153,7 +149,7 @@ type Manager struct { // NewManager creates a new Manager object. func NewManager(modules ...AppModule) *Manager { - moduleMap := make(map[string]interface{}) + moduleMap := make(map[string]appmodule.AppModule) modulesStr := make([]string, 0, len(modules)) preBlockModulesStr := make([]string, 0) for _, module := range modules { @@ -183,7 +179,7 @@ func NewManager(modules ...AppModule) *Manager { // NewManagerFromMap creates a new Manager object from a map of module names to module implementations. // This method should be used for apps and modules which have migrated to the cosmossdk.io/core.appmodule.AppModule API. func NewManagerFromMap(moduleMap map[string]appmodule.AppModule) *Manager { - simpleModuleMap := make(map[string]interface{}) + simpleModuleMap := make(map[string]appmodule.AppModule) modulesStr := make([]string, 0, len(simpleModuleMap)) preBlockModulesStr := make([]string, 0) for name, module := range moduleMap { @@ -767,12 +763,8 @@ func (m *Manager) EndBlock(ctx sdk.Context) (sdk.EndBlock, error) { return sdk.EndBlock{}, errors.New("validator EndBlock updates already set by a previous module") } - for _, updates := range moduleValUpdates { - validatorUpdates = append(validatorUpdates, abci.ValidatorUpdate{PubKey: updates.PubKey, Power: updates.Power}) - } + validatorUpdates = append(validatorUpdates, moduleValUpdates...) } - } else { - continue } } diff --git a/types/module/module_int_test.go b/types/module/module_int_test.go index 443ee0bbcba2..fd3918d4850c 100644 --- a/types/module/module_int_test.go +++ b/types/module/module_int_test.go @@ -4,6 +4,7 @@ import ( "sort" "testing" + "cosmossdk.io/core/appmodule" "github.com/stretchr/testify/suite" ) @@ -17,7 +18,7 @@ type TestSuite struct { func (s *TestSuite) TestAssertNoForgottenModules() { m := Manager{ - Modules: map[string]interface{}{"a": nil, "b": nil}, + Modules: map[string]appmodule.AppModule{"a": nil, "b": nil}, } tcs := []struct { name string @@ -42,7 +43,7 @@ func (s *TestSuite) TestAssertNoForgottenModules() { func (s *TestSuite) TestModuleNames() { m := Manager{ - Modules: map[string]interface{}{"a": nil, "b": nil}, + Modules: map[string]appmodule.AppModule{"a": nil, "b": nil}, } ms := m.ModuleNames() sort.Strings(ms) diff --git a/x/staking/module.go b/x/staking/module.go index 2e4254133d17..46d3875dd3f8 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -168,8 +168,7 @@ func (am AppModule) BeginBlock(ctx context.Context) error { return am.keeper.BeginBlocker(ctx) } -// EndBlock returns the end blocker for the staking module. It returns no validator -// updates. +// EndBlock returns the end blocker for the staking module. func (am AppModule) EndBlock(ctx context.Context) ([]abci.ValidatorUpdate, error) { return am.keeper.EndBlocker(ctx) } diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index f51d4e3990e7..d6cf30864229 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -473,11 +473,6 @@ func (v Validator) ConsPubKey() (cryptotypes.PubKey, error) { return pk, nil } -// Deprecated: use CmtConsPublicKey instead -func (v Validator) TmConsPublicKey() (cmtprotocrypto.PublicKey, error) { - return v.CmtConsPublicKey() -} - // CmtConsPublicKey casts Validator.ConsensusPubkey to cmtprotocrypto.PubKey. func (v Validator) CmtConsPublicKey() (cmtprotocrypto.PublicKey, error) { pk, err := v.ConsPubKey()