diff --git a/docs/docs/05-migrations/13-v8-to-v9.md b/docs/docs/05-migrations/13-v8-to-v9.md index 02d0ae5bcff..facc3fa01ce 100644 --- a/docs/docs/05-migrations/13-v8-to-v9.md +++ b/docs/docs/05-migrations/13-v8-to-v9.md @@ -31,6 +31,7 @@ The `exported.ConnectionI` and `exported.CounterpartyConnectionI` interfaces hav The functions `GetState()`, `GetOrdering()`, `GetCounterparty()`, `GetConnectionHops()`, `GetVersion()` of the `Channel` type have been removed. The functions `GetPortID()`, `GetChannelID()` of the `CounterpartyChannel` type have been removed. +The function `GetClientID()`, `GetState()`, `GetCounterparty()`, `GetVersions()`, and `GetDelayPeriod` of the `Connection` type have been removed. ### API deprecation notice diff --git a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go index fbbccc7d07f..12844a00023 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/handshake.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/handshake.go @@ -48,7 +48,7 @@ func (k Keeper) OnChanOpenInit( return "", err } - metadata = icatypes.NewDefaultMetadata(connectionHops[0], connection.GetCounterparty().GetConnectionID()) + metadata = icatypes.NewDefaultMetadata(connectionHops[0], connection.Counterparty.GetConnectionID()) } else { metadata, err = icatypes.MetadataFromVersion(version) if err != nil { diff --git a/modules/apps/27-interchain-accounts/types/metadata.go b/modules/apps/27-interchain-accounts/types/metadata.go index a63e4a93083..61058b5e201 100644 --- a/modules/apps/27-interchain-accounts/types/metadata.go +++ b/modules/apps/27-interchain-accounts/types/metadata.go @@ -94,7 +94,7 @@ func ValidateControllerMetadata(ctx sdk.Context, channelKeeper ChannelKeeper, co return err } - if err := validateConnectionParams(metadata, connectionHops[0], connection.GetCounterparty().GetConnectionID()); err != nil { + if err := validateConnectionParams(metadata, connectionHops[0], connection.Counterparty.GetConnectionID()); err != nil { return err } @@ -126,7 +126,7 @@ func ValidateHostMetadata(ctx sdk.Context, channelKeeper ChannelKeeper, connecti return err } - if err := validateConnectionParams(metadata, connection.GetCounterparty().GetConnectionID(), connectionHops[0]); err != nil { + if err := validateConnectionParams(metadata, connection.Counterparty.GetConnectionID(), connectionHops[0]); err != nil { return err } diff --git a/modules/core/03-connection/keeper/keeper.go b/modules/core/03-connection/keeper/keeper.go index cd18555f56e..169991b0c98 100644 --- a/modules/core/03-connection/keeper/keeper.go +++ b/modules/core/03-connection/keeper/keeper.go @@ -90,14 +90,14 @@ func (k Keeper) SetConnection(ctx sdk.Context, connectionID string, connection t // GetTimestampAtHeight returns the timestamp in nanoseconds of the consensus state at the // given height. func (k Keeper) GetTimestampAtHeight(ctx sdk.Context, connection types.ConnectionEnd, height exported.Height) (uint64, error) { - clientState, found := k.clientKeeper.GetClientState(ctx, connection.GetClientID()) + clientState, found := k.clientKeeper.GetClientState(ctx, connection.ClientId) if !found { return 0, errorsmod.Wrapf( - clienttypes.ErrClientNotFound, "clientID (%s)", connection.GetClientID(), + clienttypes.ErrClientNotFound, "clientID (%s)", connection.ClientId, ) } - timestamp, err := clientState.GetTimestampAtHeight(ctx, k.clientKeeper.ClientStore(ctx, connection.GetClientID()), k.cdc, height) + timestamp, err := clientState.GetTimestampAtHeight(ctx, k.clientKeeper.ClientStore(ctx, connection.ClientId), k.cdc, height) if err != nil { return 0, err } diff --git a/modules/core/03-connection/keeper/verify.go b/modules/core/03-connection/keeper/verify.go index 847b7c77d49..d5e95acf851 100644 --- a/modules/core/03-connection/keeper/verify.go +++ b/modules/core/03-connection/keeper/verify.go @@ -25,7 +25,7 @@ func (k Keeper) VerifyClientState( proof []byte, clientState exported.ClientState, ) error { - clientID := connection.GetClientID() + clientID := connection.ClientId targetClient, clientStore, err := k.getClientStateAndVerificationStore(ctx, clientID) if err != nil { return err @@ -35,8 +35,8 @@ func (k Keeper) VerifyClientState( return errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientID, status) } - merklePath := commitmenttypes.NewMerklePath(host.FullClientStatePath(connection.GetCounterparty().GetClientID())) - merklePath, err = commitmenttypes.ApplyPrefix(connection.GetCounterparty().GetPrefix(), merklePath) + merklePath := commitmenttypes.NewMerklePath(host.FullClientStatePath(connection.Counterparty.ClientId)) + merklePath, err = commitmenttypes.ApplyPrefix(connection.Counterparty.GetPrefix(), merklePath) if err != nil { return err } @@ -67,7 +67,7 @@ func (k Keeper) VerifyClientConsensusState( proof []byte, consensusState exported.ConsensusState, ) error { - clientID := connection.GetClientID() + clientID := connection.ClientId clientState, clientStore, err := k.getClientStateAndVerificationStore(ctx, clientID) if err != nil { return err @@ -77,8 +77,8 @@ func (k Keeper) VerifyClientConsensusState( return errorsmod.Wrapf(clienttypes.ErrClientNotActive, "client (%s) status is %s", clientID, status) } - merklePath := commitmenttypes.NewMerklePath(host.FullConsensusStatePath(connection.GetCounterparty().GetClientID(), consensusHeight)) - merklePath, err = commitmenttypes.ApplyPrefix(connection.GetCounterparty().GetPrefix(), merklePath) + merklePath := commitmenttypes.NewMerklePath(host.FullConsensusStatePath(connection.Counterparty.ClientId, consensusHeight)) + merklePath, err = commitmenttypes.ApplyPrefix(connection.Counterparty.GetPrefix(), merklePath) if err != nil { return err } @@ -109,7 +109,7 @@ func (k Keeper) VerifyConnectionState( connectionID string, counterpartyConnection types.ConnectionEnd, // opposite connection ) error { - clientID := connection.GetClientID() + clientID := connection.ClientId clientState, clientStore, err := k.getClientStateAndVerificationStore(ctx, clientID) if err != nil { return err @@ -120,7 +120,7 @@ func (k Keeper) VerifyConnectionState( } merklePath := commitmenttypes.NewMerklePath(host.ConnectionPath(connectionID)) - merklePath, err = commitmenttypes.ApplyPrefix(connection.GetCounterparty().GetPrefix(), merklePath) + merklePath, err = commitmenttypes.ApplyPrefix(connection.Counterparty.GetPrefix(), merklePath) if err != nil { return err } @@ -152,7 +152,7 @@ func (k Keeper) VerifyChannelState( channelID string, channel channeltypes.Channel, ) error { - clientID := connection.GetClientID() + clientID := connection.ClientId clientState, clientStore, err := k.getClientStateAndVerificationStore(ctx, clientID) if err != nil { return err @@ -163,7 +163,7 @@ func (k Keeper) VerifyChannelState( } merklePath := commitmenttypes.NewMerklePath(host.ChannelPath(portID, channelID)) - merklePath, err = commitmenttypes.ApplyPrefix(connection.GetCounterparty().GetPrefix(), merklePath) + merklePath, err = commitmenttypes.ApplyPrefix(connection.Counterparty.GetPrefix(), merklePath) if err != nil { return err } @@ -196,7 +196,7 @@ func (k Keeper) VerifyPacketCommitment( sequence uint64, commitmentBytes []byte, ) error { - clientID := connection.GetClientID() + clientID := connection.ClientId clientState, clientStore, err := k.getClientStateAndVerificationStore(ctx, clientID) if err != nil { return err @@ -207,11 +207,11 @@ func (k Keeper) VerifyPacketCommitment( } // get time and block delays - timeDelay := connection.GetDelayPeriod() + timeDelay := connection.DelayPeriod blockDelay := k.getBlockDelay(ctx, connection) merklePath := commitmenttypes.NewMerklePath(host.PacketCommitmentPath(portID, channelID, sequence)) - merklePath, err = commitmenttypes.ApplyPrefix(connection.GetCounterparty().GetPrefix(), merklePath) + merklePath, err = commitmenttypes.ApplyPrefix(connection.Counterparty.GetPrefix(), merklePath) if err != nil { return err } @@ -239,7 +239,7 @@ func (k Keeper) VerifyPacketAcknowledgement( sequence uint64, acknowledgement []byte, ) error { - clientID := connection.GetClientID() + clientID := connection.ClientId clientState, clientStore, err := k.getClientStateAndVerificationStore(ctx, clientID) if err != nil { return err @@ -250,11 +250,11 @@ func (k Keeper) VerifyPacketAcknowledgement( } // get time and block delays - timeDelay := connection.GetDelayPeriod() + timeDelay := connection.DelayPeriod blockDelay := k.getBlockDelay(ctx, connection) merklePath := commitmenttypes.NewMerklePath(host.PacketAcknowledgementPath(portID, channelID, sequence)) - merklePath, err = commitmenttypes.ApplyPrefix(connection.GetCounterparty().GetPrefix(), merklePath) + merklePath, err = commitmenttypes.ApplyPrefix(connection.Counterparty.GetPrefix(), merklePath) if err != nil { return err } @@ -282,7 +282,7 @@ func (k Keeper) VerifyPacketReceiptAbsence( channelID string, sequence uint64, ) error { - clientID := connection.GetClientID() + clientID := connection.ClientId clientState, clientStore, err := k.getClientStateAndVerificationStore(ctx, clientID) if err != nil { return err @@ -293,11 +293,11 @@ func (k Keeper) VerifyPacketReceiptAbsence( } // get time and block delays - timeDelay := connection.GetDelayPeriod() + timeDelay := connection.DelayPeriod blockDelay := k.getBlockDelay(ctx, connection) merklePath := commitmenttypes.NewMerklePath(host.PacketReceiptPath(portID, channelID, sequence)) - merklePath, err = commitmenttypes.ApplyPrefix(connection.GetCounterparty().GetPrefix(), merklePath) + merklePath, err = commitmenttypes.ApplyPrefix(connection.Counterparty.GetPrefix(), merklePath) if err != nil { return err } @@ -324,7 +324,7 @@ func (k Keeper) VerifyNextSequenceRecv( channelID string, nextSequenceRecv uint64, ) error { - clientID := connection.GetClientID() + clientID := connection.ClientId clientState, clientStore, err := k.getClientStateAndVerificationStore(ctx, clientID) if err != nil { return err @@ -335,11 +335,11 @@ func (k Keeper) VerifyNextSequenceRecv( } // get time and block delays - timeDelay := connection.GetDelayPeriod() + timeDelay := connection.DelayPeriod blockDelay := k.getBlockDelay(ctx, connection) merklePath := commitmenttypes.NewMerklePath(host.NextSequenceRecvPath(portID, channelID)) - merklePath, err = commitmenttypes.ApplyPrefix(connection.GetCounterparty().GetPrefix(), merklePath) + merklePath, err = commitmenttypes.ApplyPrefix(connection.Counterparty.GetPrefix(), merklePath) if err != nil { return err } @@ -365,7 +365,7 @@ func (k Keeper) VerifyChannelUpgradeError( channelID string, errorReceipt channeltypes.ErrorReceipt, ) error { - clientID := connection.GetClientID() + clientID := connection.ClientId clientState, clientStore, err := k.getClientStateAndVerificationStore(ctx, clientID) if err != nil { return err @@ -376,7 +376,7 @@ func (k Keeper) VerifyChannelUpgradeError( } merklePath := commitmenttypes.NewMerklePath(host.ChannelUpgradeErrorPath(portID, channelID)) - merklePath, err = commitmenttypes.ApplyPrefix(connection.GetCounterparty().GetPrefix(), merklePath) + merklePath, err = commitmenttypes.ApplyPrefix(connection.Counterparty.GetPrefix(), merklePath) if err != nil { return err } @@ -407,7 +407,7 @@ func (k Keeper) VerifyChannelUpgrade( channelID string, upgrade channeltypes.Upgrade, ) error { - clientID := connection.GetClientID() + clientID := connection.ClientId clientState, clientStore, err := k.getClientStateAndVerificationStore(ctx, clientID) if err != nil { return err @@ -418,7 +418,7 @@ func (k Keeper) VerifyChannelUpgrade( } merklePath := commitmenttypes.NewMerklePath(host.ChannelUpgradePath(portID, channelID)) - merklePath, err = commitmenttypes.ApplyPrefix(connection.GetCounterparty().GetPrefix(), merklePath) + merklePath, err = commitmenttypes.ApplyPrefix(connection.Counterparty.GetPrefix(), merklePath) if err != nil { return err } @@ -450,7 +450,7 @@ func (k Keeper) getBlockDelay(ctx sdk.Context, connection types.ConnectionEnd) u } // calculate minimum block delay by dividing time delay period // by the expected time per block. Round up the block delay. - timeDelay := connection.GetDelayPeriod() + timeDelay := connection.DelayPeriod return uint64(math.Ceil(float64(timeDelay) / float64(expectedTimePerBlock))) } diff --git a/modules/core/03-connection/types/connection.go b/modules/core/03-connection/types/connection.go index a3c5fac54c1..0e638b585da 100644 --- a/modules/core/03-connection/types/connection.go +++ b/modules/core/03-connection/types/connection.go @@ -20,26 +20,6 @@ func NewConnectionEnd(state State, clientID string, counterparty Counterparty, v } } -// GetClientID implements the Connection interface -func (c ConnectionEnd) GetClientID() string { - return c.ClientId -} - -// GetCounterparty implements the Connection interface -func (c ConnectionEnd) GetCounterparty() Counterparty { - return c.Counterparty -} - -// GetVersions implements the Connection interface -func (c ConnectionEnd) GetVersions() []*Version { - return c.Versions -} - -// GetDelayPeriod implements the Connection interface -func (c ConnectionEnd) GetDelayPeriod() uint64 { - return c.DelayPeriod -} - // ValidateBasic implements the Connection interface. // NOTE: the protocol supports that the connection and client IDs match the // counterparty's. diff --git a/modules/core/04-channel/keeper/handshake.go b/modules/core/04-channel/keeper/handshake.go index eebefb94717..a3a58233852 100644 --- a/modules/core/04-channel/keeper/handshake.go +++ b/modules/core/04-channel/keeper/handshake.go @@ -35,7 +35,7 @@ func (k Keeper) ChanOpenInit( return "", nil, errorsmod.Wrap(connectiontypes.ErrConnectionNotFound, connectionHops[0]) } - getVersions := connectionEnd.GetVersions() + getVersions := connectionEnd.Versions if len(getVersions) != 1 { return "", nil, errorsmod.Wrapf( connectiontypes.ErrInvalidVersion, @@ -135,7 +135,7 @@ func (k Keeper) ChanOpenTry( return "", nil, errorsmod.Wrapf(connectiontypes.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connectionEnd.State) } - getVersions := connectionEnd.GetVersions() + getVersions := connectionEnd.Versions if len(getVersions) != 1 { return "", nil, errorsmod.Wrapf( connectiontypes.ErrInvalidVersion, @@ -152,7 +152,7 @@ func (k Keeper) ChanOpenTry( ) } - counterpartyHops := []string{connectionEnd.GetCounterparty().GetConnectionID()} + counterpartyHops := []string{connectionEnd.Counterparty.GetConnectionID()} // expectedCounterpaty is the counterparty of the counterparty's channel end // (i.e self) @@ -243,7 +243,7 @@ func (k Keeper) ChanOpenAck( return errorsmod.Wrapf(connectiontypes.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connectionEnd.State) } - counterpartyHops := []string{connectionEnd.GetCounterparty().GetConnectionID()} + counterpartyHops := []string{connectionEnd.Counterparty.GetConnectionID()} // counterparty of the counterparty channel end (i.e self) expectedCounterparty := types.NewCounterparty(portID, channelID) @@ -319,7 +319,7 @@ func (k Keeper) ChanOpenConfirm( return errorsmod.Wrapf(connectiontypes.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connectionEnd.State) } - counterpartyHops := []string{connectionEnd.GetCounterparty().GetConnectionID()} + counterpartyHops := []string{connectionEnd.Counterparty.GetConnectionID()} counterparty := types.NewCounterparty(portID, channelID) expectedChannel := types.NewChannel( @@ -445,7 +445,7 @@ func (k Keeper) ChanCloseConfirm( return errorsmod.Wrapf(connectiontypes.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connectionEnd.State) } - counterpartyHops := []string{connectionEnd.GetCounterparty().GetConnectionID()} + counterpartyHops := []string{connectionEnd.Counterparty.GetConnectionID()} counterparty := types.NewCounterparty(portID, channelID) expectedChannel := types.Channel{ diff --git a/modules/core/04-channel/keeper/packet.go b/modules/core/04-channel/keeper/packet.go index a5bdac63dfc..d4019b32f0e 100644 --- a/modules/core/04-channel/keeper/packet.go +++ b/modules/core/04-channel/keeper/packet.go @@ -63,14 +63,14 @@ func (k Keeper) SendPacket( return 0, errorsmod.Wrap(connectiontypes.ErrConnectionNotFound, channel.ConnectionHops[0]) } - clientState, found := k.clientKeeper.GetClientState(ctx, connectionEnd.GetClientID()) + clientState, found := k.clientKeeper.GetClientState(ctx, connectionEnd.ClientId) if !found { return 0, clienttypes.ErrClientNotFound } // prevent accidental sends with clients that cannot be updated - if status := k.clientKeeper.GetClientStatus(ctx, clientState, connectionEnd.GetClientID()); status != exported.Active { - return 0, errorsmod.Wrapf(clienttypes.ErrClientNotActive, "cannot send packet using client (%s) with status %s", connectionEnd.GetClientID(), status) + if status := k.clientKeeper.GetClientStatus(ctx, clientState, connectionEnd.ClientId); status != exported.Active { + return 0, errorsmod.Wrapf(clienttypes.ErrClientNotActive, "cannot send packet using client (%s) with status %s", connectionEnd.ClientId, status) } latestHeight := clientState.GetLatestHeight() diff --git a/modules/core/04-channel/keeper/timeout.go b/modules/core/04-channel/keeper/timeout.go index 05c3f1738d6..77df0ea7f63 100644 --- a/modules/core/04-channel/keeper/timeout.go +++ b/modules/core/04-channel/keeper/timeout.go @@ -263,7 +263,7 @@ func (k Keeper) TimeoutOnClose( return errorsmod.Wrapf(types.ErrInvalidPacket, "packet commitment bytes are not equal: got (%v), expected (%v)", commitment, packetCommitment) } - counterpartyHops := []string{connectionEnd.GetCounterparty().GetConnectionID()} + counterpartyHops := []string{connectionEnd.Counterparty.GetConnectionID()} counterparty := types.NewCounterparty(packet.GetSourcePort(), packet.GetSourceChannel()) expectedChannel := types.Channel{ diff --git a/modules/core/04-channel/keeper/upgrade.go b/modules/core/04-channel/keeper/upgrade.go index 8e3a9e5ede0..df7c8c30226 100644 --- a/modules/core/04-channel/keeper/upgrade.go +++ b/modules/core/04-channel/keeper/upgrade.go @@ -104,7 +104,7 @@ func (k Keeper) ChanUpgradeTry( // construct expected counterparty channel from information in state // only the counterpartyUpgradeSequence is provided by the relayer - counterpartyConnectionHops := []string{connection.GetCounterparty().GetConnectionID()} + counterpartyConnectionHops := []string{connection.Counterparty.GetConnectionID()} counterpartyChannel := types.Channel{ State: types.OPEN, Ordering: channel.Ordering, @@ -278,7 +278,7 @@ func (k Keeper) ChanUpgradeAck( return errorsmod.Wrapf(connectiontypes.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connection.State) } - counterpartyHops := []string{connection.GetCounterparty().GetConnectionID()} + counterpartyHops := []string{connection.Counterparty.GetConnectionID()} counterpartyChannel := types.Channel{ State: types.FLUSHING, Ordering: channel.Ordering, @@ -414,7 +414,7 @@ func (k Keeper) ChanUpgradeConfirm( return errorsmod.Wrapf(connectiontypes.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connection.State) } - counterpartyHops := []string{connection.GetCounterparty().GetConnectionID()} + counterpartyHops := []string{connection.Counterparty.GetConnectionID()} counterpartyChannel := types.Channel{ State: counterpartyChannelState, Ordering: channel.Ordering, @@ -537,7 +537,7 @@ func (k Keeper) ChanUpgradeOpen( counterpartyChannel = types.Channel{ State: types.OPEN, Ordering: upgrade.Fields.Ordering, - ConnectionHops: []string{upgradeConnection.GetCounterparty().GetConnectionID()}, + ConnectionHops: []string{upgradeConnection.Counterparty.GetConnectionID()}, Counterparty: types.NewCounterparty(portID, channelID), Version: upgrade.Fields.Version, UpgradeSequence: counterpartyUpgradeSequence, @@ -547,7 +547,7 @@ func (k Keeper) ChanUpgradeOpen( counterpartyChannel = types.Channel{ State: types.FLUSHCOMPLETE, Ordering: channel.Ordering, - ConnectionHops: []string{connection.GetCounterparty().GetConnectionID()}, + ConnectionHops: []string{connection.Counterparty.GetConnectionID()}, Counterparty: types.NewCounterparty(portID, channelID), Version: channel.Version, UpgradeSequence: channel.UpgradeSequence, @@ -769,7 +769,7 @@ func (k Keeper) ChanUpgradeTimeout( upgrade.Fields.ConnectionHops[0], ) } - counterpartyHops := []string{upgradeConnection.GetCounterparty().GetConnectionID()} + counterpartyHops := []string{upgradeConnection.Counterparty.GetConnectionID()} upgradeAlreadyComplete := upgrade.Fields.Version == counterpartyChannel.Version && upgrade.Fields.Ordering == counterpartyChannel.Ordering && upgrade.Fields.ConnectionHops[0] == counterpartyHops[0] if upgradeAlreadyComplete { @@ -895,9 +895,9 @@ func (k Keeper) checkForUpgradeCompatibility(ctx sdk.Context, upgradeFields, cou } // connectionHops can change in a channelUpgrade, however both sides must still be each other's counterparty. - if counterpartyUpgradeFields.ConnectionHops[0] != connection.GetCounterparty().GetConnectionID() { + if counterpartyUpgradeFields.ConnectionHops[0] != connection.Counterparty.GetConnectionID() { return errorsmod.Wrapf( - types.ErrIncompatibleCounterpartyUpgrade, "counterparty upgrade connection end is not a counterparty of self proposed connection end (%s != %s)", counterpartyUpgradeFields.ConnectionHops[0], connection.GetCounterparty().GetConnectionID()) + types.ErrIncompatibleCounterpartyUpgrade, "counterparty upgrade connection end is not a counterparty of self proposed connection end (%s != %s)", counterpartyUpgradeFields.ConnectionHops[0], connection.Counterparty.GetConnectionID()) } return nil @@ -926,7 +926,7 @@ func (k Keeper) validateSelfUpgradeFields(ctx sdk.Context, proposedUpgrade types return errorsmod.Wrapf(connectiontypes.ErrInvalidConnectionState, "connection state is not OPEN (got %s)", connection.State) } - getVersions := connection.GetVersions() + getVersions := connection.Versions if len(getVersions) != 1 { return errorsmod.Wrapf( connectiontypes.ErrInvalidVersion,