Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

02-client routing: fix linter warnings #5818

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
sdkmath "cosmossdk.io/math"

govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"

"github.com/cosmos/ibc-go/e2e/relayer"
"github.com/cosmos/ibc-go/e2e/testsuite/diagnostics"
feetypes "github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types"
Expand Down
2 changes: 1 addition & 1 deletion modules/core/02-client/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (k Keeper) GetRouter() *types.Router {
func (k Keeper) CreateLocalhostClient(ctx sdk.Context) error {
localhostModule, found := k.router.GetRoute(exported.Localhost)
if !found {
errorsmod.Wrap(types.ErrRouteNotFound, exported.Localhost)
return errorsmod.Wrap(types.ErrRouteNotFound, exported.Localhost)
}

return localhostModule.Initialize(ctx, exported.LocalhostClientID, nil, nil)
Expand Down
1 change: 1 addition & 0 deletions modules/core/02-client/types/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
storetypes "cosmossdk.io/store/types"

sdk "github.com/cosmos/cosmos-sdk/types"

host "github.com/cosmos/ibc-go/v8/modules/core/24-host"
"github.com/cosmos/ibc-go/v8/modules/core/exported"
)
Expand Down
4 changes: 2 additions & 2 deletions modules/core/exported/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ type LightClientModule interface {

// CheckSubstituteAndUpdateState must verify that the provided substitute may be used to update the subject client.
// The light client must set the updated client and consensus states within the clientStore for the subject client.
// DEPRECATED: will be removed as performs internal functionality
// Deprecated: will be removed as performs internal functionality
RecoverClient(ctx sdk.Context, clientID, substituteClientID string) error

// Upgrade functions
Expand All @@ -122,7 +122,7 @@ type LightClientModule interface {
// This is to ensure that no premature upgrades occur, since upgrade plans committed to by the counterparty
// may be cancelled or modified before the last planned height.
// If the upgrade is verified, the upgraded client and consensus states must be set in the client store.
// DEPRECATED: will be removed as performs internal functionality
// Deprecated: will be removed as performs internal functionality
VerifyUpgradeAndUpdateState(
ctx sdk.Context,
clientID string,
Expand Down
86 changes: 43 additions & 43 deletions modules/light-clients/06-solomachine/light_client_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ func NewLightClientModule(cdc codec.BinaryCodec) LightClientModule {
}
}

func (l *LightClientModule) RegisterStoreProvider(storeProvider exported.ClientStoreProvider) {
l.storeProvider = storeProvider
func (lcm *LightClientModule) RegisterStoreProvider(storeProvider exported.ClientStoreProvider) {
lcm.storeProvider = storeProvider
}

// Initialize is called upon client creation, it allows the client to perform validation on the initial consensus state and set the
// client state, consensus state and any client-specific metadata necessary for correct light client operation in the provided client store.
func (l LightClientModule) Initialize(ctx sdk.Context, clientID string, clientStateBz, consensusStateBz []byte) error {
func (lcm LightClientModule) Initialize(ctx sdk.Context, clientID string, clientStateBz, consensusStateBz []byte) error {
if err := validateClientID(clientID); err != nil {
return err
}

var clientState ClientState
if err := l.cdc.Unmarshal(clientStateBz, &clientState); err != nil {
if err := lcm.cdc.Unmarshal(clientStateBz, &clientState); err != nil {
return err
}

Expand All @@ -46,86 +46,86 @@ func (l LightClientModule) Initialize(ctx sdk.Context, clientID string, clientSt
}

var consensusState ConsensusState
if err := l.cdc.Unmarshal(consensusStateBz, &consensusState); err != nil {
if err := lcm.cdc.Unmarshal(consensusStateBz, &consensusState); err != nil {
return err
}

if err := consensusState.ValidateBasic(); err != nil {
return err
}

clientStore := l.storeProvider.ClientStore(ctx, clientID)
return clientState.Initialize(ctx, l.cdc, clientStore, &consensusState)
clientStore := lcm.storeProvider.ClientStore(ctx, clientID)
return clientState.Initialize(ctx, lcm.cdc, clientStore, &consensusState)
}

// VerifyClientMessage must verify a ClientMessage. A ClientMessage could be a Header, Misbehaviour, or batch update.
// It must handle each type of ClientMessage appropriately. Calls to CheckForMisbehaviour, UpdateState, and UpdateStateOnMisbehaviour
// will assume that the content of the ClientMessage has been verified and can be trusted. An error should be returned
// if the ClientMessage fails to verify.
func (l LightClientModule) VerifyClientMessage(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) error {
func (lcm LightClientModule) VerifyClientMessage(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) error {
if err := validateClientID(clientID); err != nil {
return err
}

clientStore := l.storeProvider.ClientStore(ctx, clientID)
clientState, found := getClientState(clientStore, l.cdc)
clientStore := lcm.storeProvider.ClientStore(ctx, clientID)
clientState, found := getClientState(clientStore, lcm.cdc)
if !found {
return errorsmod.Wrap(clienttypes.ErrClientNotFound, clientID)
}

return clientState.VerifyClientMessage(ctx, l.cdc, clientStore, clientMsg)
return clientState.VerifyClientMessage(ctx, lcm.cdc, clientStore, clientMsg)
}

// Checks for evidence of a misbehaviour in Header or Misbehaviour type. It assumes the ClientMessage
// has already been verified.
func (l LightClientModule) CheckForMisbehaviour(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) bool {
func (lcm LightClientModule) CheckForMisbehaviour(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) bool {
if err := validateClientID(clientID); err != nil {
panic(err)
}

clientStore := l.storeProvider.ClientStore(ctx, clientID)
clientState, found := getClientState(clientStore, l.cdc)
clientStore := lcm.storeProvider.ClientStore(ctx, clientID)
clientState, found := getClientState(clientStore, lcm.cdc)
if !found {
panic(errorsmod.Wrap(clienttypes.ErrClientNotFound, clientID))
}

return clientState.CheckForMisbehaviour(ctx, l.cdc, clientStore, clientMsg)
return clientState.CheckForMisbehaviour(ctx, lcm.cdc, clientStore, clientMsg)
}

// UpdateStateOnMisbehaviour should perform appropriate state changes on a client state given that misbehaviour has been detected and verified
func (l LightClientModule) UpdateStateOnMisbehaviour(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) {
func (lcm LightClientModule) UpdateStateOnMisbehaviour(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) {
if err := validateClientID(clientID); err != nil {
panic(err)
}

clientStore := l.storeProvider.ClientStore(ctx, clientID)
clientState, found := getClientState(clientStore, l.cdc)
clientStore := lcm.storeProvider.ClientStore(ctx, clientID)
clientState, found := getClientState(clientStore, lcm.cdc)
if !found {
panic(errorsmod.Wrap(clienttypes.ErrClientNotFound, clientID))
}

clientState.UpdateStateOnMisbehaviour(ctx, l.cdc, clientStore, clientMsg)
clientState.UpdateStateOnMisbehaviour(ctx, lcm.cdc, clientStore, clientMsg)
}

// UpdateState updates and stores as necessary any associated information for an IBC client, such as the ClientState and corresponding ConsensusState.
// Upon successful update, a list of consensus heights is returned. It assumes the ClientMessage has already been verified.
func (l LightClientModule) UpdateState(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) []exported.Height {
func (lcm LightClientModule) UpdateState(ctx sdk.Context, clientID string, clientMsg exported.ClientMessage) []exported.Height {
if err := validateClientID(clientID); err != nil {
panic(err)
}

clientStore := l.storeProvider.ClientStore(ctx, clientID)
clientState, found := getClientState(clientStore, l.cdc)
clientStore := lcm.storeProvider.ClientStore(ctx, clientID)
clientState, found := getClientState(clientStore, lcm.cdc)
if !found {
panic(errorsmod.Wrap(clienttypes.ErrClientNotFound, clientID))
}

return clientState.UpdateState(ctx, l.cdc, clientStore, clientMsg)
return clientState.UpdateState(ctx, lcm.cdc, clientStore, clientMsg)
}

// VerifyMembership is a generic proof verification method which verifies a proof of the existence of a value at a given CommitmentPath at the specified height.
// The caller is expected to construct the full CommitmentPath from a CommitmentPrefix and a standardized path (as defined in ICS 24).
func (l LightClientModule) VerifyMembership(
func (lcm LightClientModule) VerifyMembership(
ctx sdk.Context,
clientID string,
height exported.Height, // TODO: change to concrete type
Expand All @@ -139,18 +139,18 @@ func (l LightClientModule) VerifyMembership(
return err
}

clientStore := l.storeProvider.ClientStore(ctx, clientID)
clientState, found := getClientState(clientStore, l.cdc)
clientStore := lcm.storeProvider.ClientStore(ctx, clientID)
clientState, found := getClientState(clientStore, lcm.cdc)
if !found {
return errorsmod.Wrap(clienttypes.ErrClientNotFound, clientID)
}

return clientState.VerifyMembership(ctx, clientStore, l.cdc, height, delayTimePeriod, delayBlockPeriod, proof, path, value)
return clientState.VerifyMembership(ctx, clientStore, lcm.cdc, height, delayTimePeriod, delayBlockPeriod, proof, path, value)
}

// VerifyNonMembership is a generic proof verification method which verifies the absence of a given CommitmentPath at a specified height.
// The caller is expected to construct the full CommitmentPath from a CommitmentPrefix and a standardized path (as defined in ICS 24).
func (l LightClientModule) VerifyNonMembership(
func (lcm LightClientModule) VerifyNonMembership(
ctx sdk.Context,
clientID string,
height exported.Height, // TODO: change to concrete type
Expand All @@ -163,43 +163,43 @@ func (l LightClientModule) VerifyNonMembership(
return err
}

clientStore := l.storeProvider.ClientStore(ctx, clientID)
clientState, found := getClientState(clientStore, l.cdc)
clientStore := lcm.storeProvider.ClientStore(ctx, clientID)
clientState, found := getClientState(clientStore, lcm.cdc)
if !found {
return errorsmod.Wrap(clienttypes.ErrClientNotFound, clientID)
}

return clientState.VerifyNonMembership(ctx, clientStore, l.cdc, height, delayTimePeriod, delayBlockPeriod, proof, path)
return clientState.VerifyNonMembership(ctx, clientStore, lcm.cdc, height, delayTimePeriod, delayBlockPeriod, proof, path)
}

// Status must return the status of the client. Only Active clients are allowed to process packets.
func (l LightClientModule) Status(ctx sdk.Context, clientID string) exported.Status {
func (lcm LightClientModule) Status(ctx sdk.Context, clientID string) exported.Status {
if err := validateClientID(clientID); err != nil {
return exported.Unknown // TODO: or panic
}

clientStore := l.storeProvider.ClientStore(ctx, clientID)
clientState, found := getClientState(clientStore, l.cdc)
clientStore := lcm.storeProvider.ClientStore(ctx, clientID)
clientState, found := getClientState(clientStore, lcm.cdc)
if !found {
return exported.Unknown
}

return clientState.Status(ctx, clientStore, l.cdc)
return clientState.Status(ctx, clientStore, lcm.cdc)
}

// TimestampAtHeight must return the timestamp for the consensus state associated with the provided height.
func (l LightClientModule) TimestampAtHeight(ctx sdk.Context, clientID string, height exported.Height) (uint64, error) {
func (lcm LightClientModule) TimestampAtHeight(ctx sdk.Context, clientID string, height exported.Height) (uint64, error) {
if err := validateClientID(clientID); err != nil {
return 0, err
}

clientStore := l.storeProvider.ClientStore(ctx, clientID)
clientState, found := getClientState(clientStore, l.cdc)
clientStore := lcm.storeProvider.ClientStore(ctx, clientID)
clientState, found := getClientState(clientStore, lcm.cdc)
if !found {
return 0, errorsmod.Wrap(clienttypes.ErrClientNotFound, clientID)
}

return clientState.GetTimestampAtHeight(ctx, clientStore, l.cdc, height)
return clientState.GetTimestampAtHeight(ctx, clientStore, lcm.cdc, height)
}

func validateClientID(clientID string) error {
Expand All @@ -217,8 +217,8 @@ func validateClientID(clientID string) error {

// // CheckSubstituteAndUpdateState must verify that the provided substitute may be used to update the subject client.
// // The light client must set the updated client and consensus states within the clientStore for the subject client.
// // DEPRECATED: will be removed as performs internal functionality
func (l LightClientModule) RecoverClient(ctx sdk.Context, clientID, substituteClientID string) error {
// // Deprecated: will be removed as performs internal functionality
func (LightClientModule) RecoverClient(ctx sdk.Context, clientID, substituteClientID string) error {
return nil
}

Expand All @@ -229,7 +229,7 @@ func (l LightClientModule) RecoverClient(ctx sdk.Context, clientID, substituteCl
// // This is to ensure that no premature upgrades occur, since upgrade plans committed to by the counterparty
// // may be cancelled or modified before the last planned height.
// // If the upgrade is verified, the upgraded client and consensus states must be set in the client store.
// // DEPRECATED: will be removed as performs internal functionality
func (l LightClientModule) VerifyUpgradeAndUpdateState(ctx sdk.Context, clientID string, newClient []byte, newConsState []byte, upgradeClientProof, upgradeConsensusStateProof []byte) error {
// // Deprecated: will be removed as performs internal functionality
func (LightClientModule) VerifyUpgradeAndUpdateState(ctx sdk.Context, clientID string, newClient []byte, newConsState []byte, upgradeClientProof, upgradeConsensusStateProof []byte) error {
return nil
}
Loading
Loading