From 696f852a5a8a675c22453811b615c3bc6ea27c52 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Thu, 14 Mar 2024 19:23:38 +0100 Subject: [PATCH] chore: godocs, rm ClientStore from expected keeper, rename events arg to initialHeight --- modules/core/02-client/keeper/events.go | 4 ++-- modules/core/02-client/types/router.go | 8 ++++---- modules/core/02-client/types/store.go | 7 +++---- modules/core/04-channel/types/expected_keepers.go | 3 --- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/modules/core/02-client/keeper/events.go b/modules/core/02-client/keeper/events.go index 828aa4820ba..f030b6cf52c 100644 --- a/modules/core/02-client/keeper/events.go +++ b/modules/core/02-client/keeper/events.go @@ -15,13 +15,13 @@ import ( ) // emitCreateClientEvent emits a create client event -func emitCreateClientEvent(ctx sdk.Context, clientID, clientType string, latestHeight exported.Height) { +func emitCreateClientEvent(ctx sdk.Context, clientID, clientType string, initialHeight exported.Height) { ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeCreateClient, sdk.NewAttribute(types.AttributeKeyClientID, clientID), sdk.NewAttribute(types.AttributeKeyClientType, clientType), - sdk.NewAttribute(types.AttributeKeyConsensusHeight, latestHeight.String()), + sdk.NewAttribute(types.AttributeKeyConsensusHeight, initialHeight.String()), ), sdk.NewEvent( sdk.EventTypeMessage, diff --git a/modules/core/02-client/types/router.go b/modules/core/02-client/types/router.go index 4d345a62205..c13449274c1 100644 --- a/modules/core/02-client/types/router.go +++ b/modules/core/02-client/types/router.go @@ -31,14 +31,14 @@ func NewRouter(key storetypes.StoreKey) *Router { // - or a module is already registered for the provided client type, // - or the client type is invalid. func (rtr *Router) AddRoute(clientType string, module exported.LightClientModule) *Router { - if err := ValidateClientType(clientType); err != nil { - panic(err) - } - if rtr.HasRoute(clientType) { panic(fmt.Errorf("route %s has already been registered", module)) } + if err := ValidateClientType(clientType); err != nil { + panic(fmt.Errorf("failed to add route: %w", err)) + } + rtr.routes[clientType] = module module.RegisterStoreProvider(rtr.storeProvider) diff --git a/modules/core/02-client/types/store.go b/modules/core/02-client/types/store.go index 5d98cbe6901..d8d67c101fd 100644 --- a/modules/core/02-client/types/store.go +++ b/modules/core/02-client/types/store.go @@ -26,14 +26,13 @@ func NewStoreProvider(storeKey storetypes.StoreKey) exported.ClientStoreProvider } } -// ClientStore returns isolated prefix store for each client so they can read/write in separate -// namespace without being able to read/write other client's data +// ClientStore returns isolated prefix store for each client so they can read/write in separate namespaces. func (s storeProvider) ClientStore(ctx sdk.Context, clientID string) storetypes.KVStore { clientPrefix := []byte(fmt.Sprintf("%s/%s/", host.KeyClientStorePrefix, clientID)) return prefix.NewStore(ctx.KVStore(s.storeKey), clientPrefix) } -// ModuleStore returns the 02-client module store -func (s storeProvider) ModuleStore(ctx sdk.Context, clientType string) storetypes.KVStore { +// ClientModuleStore returns the module store for a provided client type. +func (s storeProvider) ClientModuleStore(ctx sdk.Context, clientType string) storetypes.KVStore { return prefix.NewStore(ctx.KVStore(s.storeKey), host.PrefixedClientStoreKey([]byte(clientType))) } diff --git a/modules/core/04-channel/types/expected_keepers.go b/modules/core/04-channel/types/expected_keepers.go index b8dfea0d751..2d2fd8b7e65 100644 --- a/modules/core/04-channel/types/expected_keepers.go +++ b/modules/core/04-channel/types/expected_keepers.go @@ -1,8 +1,6 @@ package types import ( - storetypes "cosmossdk.io/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" @@ -13,7 +11,6 @@ import ( // ClientKeeper expected account IBC client keeper type ClientKeeper interface { - ClientStore(ctx sdk.Context, clientID string) storetypes.KVStore GetClientStatus(ctx sdk.Context, clientID string) exported.Status GetClientState(ctx sdk.Context, clientID string) (exported.ClientState, bool) GetClientConsensusState(ctx sdk.Context, clientID string, height exported.Height) (exported.ConsensusState, bool)