Skip to content

Commit

Permalink
refactor: improve x/stakeibc admin check (#123)
Browse files Browse the repository at this point in the history
## Description

This PR improves the `x/stakeibc` admin account check by removing the
existing `ValidateAdminAccount` method that checks the validity of an
account using a hardcoded list of addresses. Instead, a dynamic check is
performed to make sure that the sending account is either:

1. the `authority` address of the `x/stakeibc` module, or
2. the `admin` address of the `x/opchild` module

This makes sure that if we start a chain with any arbitrary validator
address, they will always be able to perform these messages together
with the governance module.

Closes: #XXXX

<!-- Add a description of the changes that this PR introduces and the
files that
are the most critical to review. -->

---

### Author Checklist

*All items are required. Please add a note to the item if the item is
not applicable and
please add links to any relevant follow up issues.*

I have...

- [x] included the correct [type
prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json)
in the PR title
- [ ] added `!` to the type prefix if API or client breaking change
- [x] targeted the correct branch (see [PR
Targeting](https://github.com/milkyway-labs/milkyway/blob/master/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [x] followed the guidelines for [building
modules](https://docs.cosmos.network/v0.44/building-modules/intro.html)
- [ ] included the necessary unit and integration
[tests](https://github.com/milkyway-labs/milkyway/blob/master/CONTRIBUTING.md#testing)
- [ ] added a changelog entry to `CHANGELOG.md`
- [x] included comments for [documenting Go
code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [x] reviewed "Files changed" and left comments if necessary
- [x] confirmed all CI checks have passed

### Reviewers Checklist

*All items are required. Please add a note if the item is not applicable
and please add
your handle next to the items reviewed if you only reviewed selected
items.*

I have...

- [ ] confirmed the correct [type
prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json)
in the PR title
- [ ] confirmed `!` in the type prefix if API or client breaking change
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
  • Loading branch information
RiccardoM authored Oct 11, 2024
1 parent 691f0e1 commit d8a24df
Show file tree
Hide file tree
Showing 44 changed files with 250 additions and 246 deletions.
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@ func NewMilkyWayApp(
app.RecordsKeeper,
app.ICACallbacksKeeper,
app.RateLimitKeeper,
app.OPChildKeeper,
)
app.StakeIBCKeeper.SetHooks(stakeibctypes.NewMultiStakeIBCHooks())
icaCallbacksStack = stakeibc.NewIBCMiddleware(icaCallbacksStack, app.StakeIBCKeeper)
Expand Down
5 changes: 0 additions & 5 deletions utils/admins.go

This file was deleted.

20 changes: 0 additions & 20 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,6 @@ func FilterDepositRecords(arr []recordstypes.DepositRecord, condition func(recor
return ret
}

func Int64ToCoinString(amount int64, denom string) string {
return strconv.FormatInt(amount, 10) + denom
}

func ValidateAdminAddress(address string) error {
if !Admins[address] {
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "address (%s) is not an admin", address)
}
return nil
}

func Min(a int, b int) int {
if a < b {
return a
Expand All @@ -58,15 +47,6 @@ func StringMapKeys[V any](m map[string]V) []string {
return keys
}

func Int32MapKeys[V any](m map[int32]V) []int32 {
keys := make([]int32, 0, len(m))
for k := range m {
keys = append(keys, k)
}
sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] })
return keys
}

// ============================== ADDRESS VERIFICATION UTILS ================================
// ref: https://github.com/cosmos/cosmos-sdk/blob/b75c2ebcfab1a6b535723f1ac2889a2fc2509520/types/address.go#L177

Expand Down
2 changes: 1 addition & 1 deletion x/stakeibc/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (k Keeper) BeginBlocker(ctx sdk.Context) {

// set rate limit on stAsset
stDenom := types.StAssetDenomFromHostZoneDenom(hz.HostDenom)
k.RatelimitKeeper.AddDenomToBlacklist(ctx, stDenom)
k.rateLimitKeeper.AddDenomToBlacklist(ctx, stDenom)

k.Logger(ctx).Error(fmt.Sprintf("[INVARIANT BROKEN!!!] %s's RR is %s. ERR: %v", hz.GetChainId(), hz.RedemptionRate.String(), err.Error()))
ctx.EventManager().EmitEvent(
Expand Down
6 changes: 3 additions & 3 deletions x/stakeibc/keeper/claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,23 @@ func (k msgServer) ClaimUndelegatedTokens(goCtx context.Context, msg *types.MsgC

// Set claimIsPending to true, so that the record can't be double claimed
userRedemptionRecord.ClaimIsPending = true
k.RecordsKeeper.SetUserRedemptionRecord(ctx, *userRedemptionRecord)
k.recordsKeeper.SetUserRedemptionRecord(ctx, *userRedemptionRecord)

return &types.MsgClaimUndelegatedTokensResponse{}, nil
}

func (k Keeper) GetClaimableRedemptionRecord(ctx sdk.Context, msg *types.MsgClaimUndelegatedTokens) (*recordstypes.UserRedemptionRecord, error) {
// grab the UserRedemptionRecord from the store
userRedemptionRecordKey := recordstypes.UserRedemptionRecordKeyFormatter(msg.HostZoneId, msg.Epoch, msg.Receiver)
userRedemptionRecord, found := k.RecordsKeeper.GetUserRedemptionRecord(ctx, userRedemptionRecordKey)
userRedemptionRecord, found := k.recordsKeeper.GetUserRedemptionRecord(ctx, userRedemptionRecordKey)
if !found {
errMsg := fmt.Sprintf("User redemption record %s not found on host zone %s", userRedemptionRecordKey, msg.HostZoneId)
k.Logger(ctx).Error(errMsg)
return nil, errorsmod.Wrap(types.ErrInvalidUserRedemptionRecord, errMsg)
}

// check that the record is claimable
hostZoneUnbonding, found := k.RecordsKeeper.GetHostZoneUnbondingByChainId(ctx, userRedemptionRecord.EpochNumber, msg.HostZoneId)
hostZoneUnbonding, found := k.recordsKeeper.GetHostZoneUnbondingByChainId(ctx, userRedemptionRecord.EpochNumber, msg.HostZoneId)
if !found {
errMsg := fmt.Sprintf("Host zone unbonding record %s not found on host zone %s", userRedemptionRecordKey, msg.HostZoneId)
k.Logger(ctx).Error(errMsg)
Expand Down
2 changes: 1 addition & 1 deletion x/stakeibc/keeper/community_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (k Keeper) QueryCommunityPoolIcaBalance(
TimeoutDuration: timeoutDuration,
TimeoutPolicy: icqtypes.TimeoutPolicy_REJECT_QUERY_RESPONSE,
}
if err := k.InterchainQueryKeeper.SubmitICQRequest(ctx, query, false); err != nil {
if err := k.interchainQueryKeeper.SubmitICQRequest(ctx, query, false); err != nil {
return errorsmod.Wrapf(err, "Error submitting query for pool ica balance")
}

Expand Down
2 changes: 1 addition & 1 deletion x/stakeibc/keeper/delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (k Keeper) DelegateOnHost(ctx sdk.Context, hostZone types.HostZone, amt sdk

// update the record state to DELEGATION_IN_PROGRESS
depositRecord.Status = recordstypes.DepositRecord_DELEGATION_IN_PROGRESS
k.RecordsKeeper.SetDepositRecord(ctx, depositRecord)
k.recordsKeeper.SetDepositRecord(ctx, depositRecord)

return nil
}
Expand Down
10 changes: 5 additions & 5 deletions x/stakeibc/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (k Keeper) ModuleAddress(goCtx context.Context, req *types.QueryModuleAddre

ctx := sdk.UnwrapSDKContext(goCtx)

addr := k.AccountKeeper.GetModuleAccount(ctx, req.Name).GetAddress().String()
addr := k.accountKeeper.GetModuleAccount(ctx, req.Name).GetAddress().String()

return &types.QueryModuleAddressResponse{Addr: addr}, nil
}
Expand Down Expand Up @@ -121,7 +121,7 @@ func (k Keeper) AddressUnbondings(c context.Context, req *types.QueryAddressUnbo
}
currentDay := dayEpochTracker.EpochNumber

epochUnbondingRecords := k.RecordsKeeper.GetAllEpochUnbondingRecord(ctx)
epochUnbondingRecords := k.recordsKeeper.GetAllEpochUnbondingRecord(ctx)

for _, epochUnbondingRecord := range epochUnbondingRecords {
for _, hostZoneUnbonding := range epochUnbondingRecord.GetHostZoneUnbondings() {
Expand All @@ -142,7 +142,7 @@ func (k Keeper) AddressUnbondings(c context.Context, req *types.QueryAddressUnbo
}
}
if targetAddress {
userRedemptionRecord, found := k.RecordsKeeper.GetUserRedemptionRecord(ctx, userRedemptionRecordId)
userRedemptionRecord, found := k.recordsKeeper.GetUserRedemptionRecord(ctx, userRedemptionRecordId)
if !found {
continue // the record has already been claimed
}
Expand Down Expand Up @@ -229,7 +229,7 @@ func (k Keeper) InterchainAccountFromAddress(goCtx context.Context, req *types.Q
return nil, status.Errorf(codes.InvalidArgument, "could not find account: %s", err)
}

addr, found := k.ICAControllerKeeper.GetInterchainAccountAddress(ctx, req.ConnectionId, portID)
addr, found := k.icaControllerKeeper.GetInterchainAccountAddress(ctx, req.ConnectionId, portID)
if !found {
return nil, status.Errorf(codes.NotFound, "no account found for portID %s", portID)
}
Expand All @@ -243,7 +243,7 @@ func (k Keeper) NextPacketSequence(c context.Context, req *types.QueryGetNextPac
}

ctx := sdk.UnwrapSDKContext(c)
sequence, found := k.IBCKeeper.ChannelKeeper.GetNextSequenceSend(ctx, req.PortId, req.ChannelId)
sequence, found := k.ibcKeeper.ChannelKeeper.GetNextSequenceSend(ctx, req.PortId, req.ChannelId)
if !found {
return nil, status.Error(codes.InvalidArgument, "channel and port combination not found")
}
Expand Down
2 changes: 1 addition & 1 deletion x/stakeibc/keeper/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochInfo epochstypes.EpochInf

// Create a new deposit record for each host zone and the grab all deposit records
k.CreateDepositRecordsForEpoch(ctx, epochNumber)
depositRecords := k.RecordsKeeper.GetAllDepositRecord(ctx)
depositRecords := k.recordsKeeper.GetAllDepositRecord(ctx)

// TODO: move this to an external function that anyone can call, so that we don't have to call it every epoch
k.SetWithdrawalAddress(ctx)
Expand Down
34 changes: 17 additions & 17 deletions x/stakeibc/keeper/host_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (k Keeper) UnregisterHostZone(ctx sdk.Context, chainId string) error {

// Burn all outstanding stTokens
stTokenDenom := utils.StAssetDenomFromHostZoneDenom(hostZone.HostDenom)
for _, account := range k.AccountKeeper.GetAllAccounts(ctx) {
for _, account := range k.accountKeeper.GetAllAccounts(ctx) {
stTokenBalance := k.bankKeeper.GetBalance(ctx, account.GetAddress(), stTokenDenom)
stTokensToBurn := sdk.NewCoins(stTokenBalance)
if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, account.GetAddress(), types.ModuleName, stTokensToBurn); err != nil {
Expand All @@ -135,50 +135,50 @@ func (k Keeper) UnregisterHostZone(ctx sdk.Context, chainId string) error {
}

// Set the escrow'd tokens to 0 (all the escrowed tokens should have been burned from the above)
k.RecordsKeeper.TransferKeeper.SetTotalEscrowForDenom(ctx, sdk.NewCoin(stTokenDenom, sdkmath.ZeroInt()))
k.recordsKeeper.TransferKeeper.SetTotalEscrowForDenom(ctx, sdk.NewCoin(stTokenDenom, sdkmath.ZeroInt()))

// Remove module accounts
depositAddress := types.NewHostZoneDepositAddress(chainId)
communityPoolStakeAddress := types.NewHostZoneModuleAddress(chainId, CommunityPoolStakeHoldingAddressKey)
communityPoolRedeemAddress := types.NewHostZoneModuleAddress(chainId, CommunityPoolRedeemHoldingAddressKey)

k.AccountKeeper.RemoveAccount(ctx, k.AccountKeeper.GetAccount(ctx, depositAddress))
k.AccountKeeper.RemoveAccount(ctx, k.AccountKeeper.GetAccount(ctx, communityPoolStakeAddress))
k.AccountKeeper.RemoveAccount(ctx, k.AccountKeeper.GetAccount(ctx, communityPoolRedeemAddress))
k.accountKeeper.RemoveAccount(ctx, k.accountKeeper.GetAccount(ctx, depositAddress))
k.accountKeeper.RemoveAccount(ctx, k.accountKeeper.GetAccount(ctx, communityPoolStakeAddress))
k.accountKeeper.RemoveAccount(ctx, k.accountKeeper.GetAccount(ctx, communityPoolRedeemAddress))

// Remove all deposit records for the host zone
for _, depositRecord := range k.RecordsKeeper.GetAllDepositRecord(ctx) {
for _, depositRecord := range k.recordsKeeper.GetAllDepositRecord(ctx) {
if depositRecord.HostZoneId == chainId {
k.RecordsKeeper.RemoveDepositRecord(ctx, depositRecord.Id)
k.recordsKeeper.RemoveDepositRecord(ctx, depositRecord.Id)
}
}

// Remove all epoch unbonding records for the host zone
for _, epochUnbondingRecord := range k.RecordsKeeper.GetAllEpochUnbondingRecord(ctx) {
for _, epochUnbondingRecord := range k.recordsKeeper.GetAllEpochUnbondingRecord(ctx) {
updatedHostZoneUnbondings := []*recordstypes.HostZoneUnbonding{}
for _, hostZoneUnbonding := range epochUnbondingRecord.HostZoneUnbondings {
if hostZoneUnbonding.HostZoneId != chainId {
updatedHostZoneUnbondings = append(updatedHostZoneUnbondings, hostZoneUnbonding)
}
}
epochUnbondingRecord.HostZoneUnbondings = updatedHostZoneUnbondings
k.RecordsKeeper.SetEpochUnbondingRecord(ctx, epochUnbondingRecord)
k.recordsKeeper.SetEpochUnbondingRecord(ctx, epochUnbondingRecord)
}

// Remove all user redemption records for the host zone
for _, userRedemptionRecord := range k.RecordsKeeper.GetAllUserRedemptionRecord(ctx) {
for _, userRedemptionRecord := range k.recordsKeeper.GetAllUserRedemptionRecord(ctx) {
if userRedemptionRecord.HostZoneId == chainId {
k.RecordsKeeper.RemoveUserRedemptionRecord(ctx, userRedemptionRecord.Id)
k.recordsKeeper.RemoveUserRedemptionRecord(ctx, userRedemptionRecord.Id)
}
}

// Remove whitelisted address pairs from rate limit module
rewardCollectorAddress := k.AccountKeeper.GetModuleAccount(ctx, types.RewardCollectorName).GetAddress()
k.RatelimitKeeper.RemoveWhitelistedAddressPair(ctx, hostZone.DepositAddress, hostZone.DelegationIcaAddress)
k.RatelimitKeeper.RemoveWhitelistedAddressPair(ctx, hostZone.FeeIcaAddress, rewardCollectorAddress.String())
k.RatelimitKeeper.RemoveWhitelistedAddressPair(ctx, hostZone.CommunityPoolDepositIcaAddress, hostZone.CommunityPoolStakeHoldingAddress)
k.RatelimitKeeper.RemoveWhitelistedAddressPair(ctx, hostZone.CommunityPoolDepositIcaAddress, hostZone.CommunityPoolRedeemHoldingAddress)
k.RatelimitKeeper.RemoveWhitelistedAddressPair(ctx, hostZone.CommunityPoolStakeHoldingAddress, hostZone.CommunityPoolReturnIcaAddress)
rewardCollectorAddress := k.accountKeeper.GetModuleAccount(ctx, types.RewardCollectorName).GetAddress()
k.rateLimitKeeper.RemoveWhitelistedAddressPair(ctx, hostZone.DepositAddress, hostZone.DelegationIcaAddress)
k.rateLimitKeeper.RemoveWhitelistedAddressPair(ctx, hostZone.FeeIcaAddress, rewardCollectorAddress.String())
k.rateLimitKeeper.RemoveWhitelistedAddressPair(ctx, hostZone.CommunityPoolDepositIcaAddress, hostZone.CommunityPoolStakeHoldingAddress)
k.rateLimitKeeper.RemoveWhitelistedAddressPair(ctx, hostZone.CommunityPoolDepositIcaAddress, hostZone.CommunityPoolRedeemHoldingAddress)
k.rateLimitKeeper.RemoveWhitelistedAddressPair(ctx, hostZone.CommunityPoolStakeHoldingAddress, hostZone.CommunityPoolReturnIcaAddress)

// Finally, remove the host zone struct
k.RemoveHostZone(ctx, chainId)
Expand Down
28 changes: 14 additions & 14 deletions x/stakeibc/keeper/ibc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import (

func (k Keeper) OnChanOpenAck(ctx sdk.Context, portID, channelID string) error {
// Lookup connection ID, counterparty chain ID, and ICA address from the channel ID
controllerConnectionId, _, err := k.IBCKeeper.ChannelKeeper.GetChannelConnection(ctx, portID, channelID)
controllerConnectionId, _, err := k.ibcKeeper.ChannelKeeper.GetChannelConnection(ctx, portID, channelID)
if err != nil {
return err
}
address, found := k.ICAControllerKeeper.GetInterchainAccountAddress(ctx, controllerConnectionId, portID)
address, found := k.icaControllerKeeper.GetInterchainAccountAddress(ctx, controllerConnectionId, portID)
if !found {
k.Logger(ctx).Info(fmt.Sprintf("No ICA address associated with connection %s and port %s", controllerConnectionId, portID))
return nil
Expand Down Expand Up @@ -117,7 +117,7 @@ func (k Keeper) StoreHostZoneIcaAddress(ctx sdk.Context, chainId, portId, addres
// Once the delegation channel is registered, whitelist epochly transfers so they're not rate limited
// Epochly transfers go from the deposit address to the delegation address
if portId == delegationPortID {
k.RatelimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{
k.rateLimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{
Sender: hostZone.DepositAddress,
Receiver: hostZone.DelegationIcaAddress,
})
Expand All @@ -126,8 +126,8 @@ func (k Keeper) StoreHostZoneIcaAddress(ctx sdk.Context, chainId, portId, addres
// Once the fee channel is registered, whitelist reward transfers so they're not rate limited
// Reward transfers go from the fee address to the reward collector
if portId == feePortID {
rewardCollectorAddress := k.AccountKeeper.GetModuleAccount(ctx, types.RewardCollectorName).GetAddress()
k.RatelimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{
rewardCollectorAddress := k.accountKeeper.GetModuleAccount(ctx, types.RewardCollectorName).GetAddress()
k.rateLimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{
Sender: hostZone.FeeIcaAddress,
Receiver: rewardCollectorAddress.String(),
})
Expand All @@ -136,11 +136,11 @@ func (k Keeper) StoreHostZoneIcaAddress(ctx sdk.Context, chainId, portId, addres
// Once the community pool deposit ICA is registered, whitelist epochly community pool transfers
// from the deposit ICA to the community pool holding accounts
if portId == communityPoolDepositPortID {
k.RatelimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{
k.rateLimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{
Sender: hostZone.CommunityPoolDepositIcaAddress,
Receiver: hostZone.CommunityPoolStakeHoldingAddress,
})
k.RatelimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{
k.rateLimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{
Sender: hostZone.CommunityPoolDepositIcaAddress,
Receiver: hostZone.CommunityPoolRedeemHoldingAddress,
})
Expand All @@ -149,7 +149,7 @@ func (k Keeper) StoreHostZoneIcaAddress(ctx sdk.Context, chainId, portId, addres
// Once the community pool return ICA is registered, whitelist epochly community pool transfers
// from the community pool stake holding account to the community pool return ICA
if portId == communityPoolReturnPortID {
k.RatelimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{
k.rateLimitKeeper.SetWhitelistedAddressPair(ctx, ratelimittypes.WhitelistedAddressPair{
Sender: hostZone.CommunityPoolStakeHoldingAddress,
Receiver: hostZone.CommunityPoolReturnIcaAddress,
})
Expand Down Expand Up @@ -202,14 +202,14 @@ func (k Keeper) StoreTradeRouteIcaAddress(ctx sdk.Context, callbackChainId, call
// Retrieves the light client time for a given connection
func (k Keeper) GetLightClientTimeSafely(ctx sdk.Context, connectionID string) (uint64, error) {
// get light client's latest height
conn, found := k.IBCKeeper.ConnectionKeeper.GetConnection(ctx, connectionID)
conn, found := k.ibcKeeper.ConnectionKeeper.GetConnection(ctx, connectionID)
if !found {
errMsg := fmt.Sprintf("invalid connection id, %s not found", connectionID)
k.Logger(ctx).Error(errMsg)
return 0, fmt.Errorf(errMsg)
}
// TODO(TEST-112) make sure to update host LCs here!
latestConsensusClientState, found := k.IBCKeeper.ClientKeeper.GetLatestClientConsensusState(ctx, conn.ClientId)
latestConsensusClientState, found := k.ibcKeeper.ClientKeeper.GetLatestClientConsensusState(ctx, conn.ClientId)
if !found {
errMsg := fmt.Sprintf("client id %s not found for connection %s", conn.ClientId, connectionID)
k.Logger(ctx).Error(errMsg)
Expand All @@ -224,13 +224,13 @@ func (k Keeper) GetLightClientTimeSafely(ctx sdk.Context, connectionID string) (
// Retrieves the light client time for a given connection
func (k Keeper) GetLightClientHeightSafely(ctx sdk.Context, connectionID string) (uint64, error) {
// get light client's latest height
conn, found := k.IBCKeeper.ConnectionKeeper.GetConnection(ctx, connectionID)
conn, found := k.ibcKeeper.ConnectionKeeper.GetConnection(ctx, connectionID)
if !found {
errMsg := fmt.Sprintf("invalid connection id, %s not found", connectionID)
k.Logger(ctx).Error(errMsg)
return 0, fmt.Errorf(errMsg)
}
clientState, found := k.IBCKeeper.ClientKeeper.GetClientState(ctx, conn.ClientId)
clientState, found := k.ibcKeeper.ClientKeeper.GetClientState(ctx, conn.ClientId)
if !found {
errMsg := fmt.Sprintf("client id %s not found for connection %s", conn.ClientId, connectionID)
k.Logger(ctx).Error(errMsg)
Expand All @@ -248,11 +248,11 @@ func (k Keeper) GetLightClientHeightSafely(ctx sdk.Context, connectionID string)

// Lookup a chain ID from a connection ID by looking up the client state
func (k Keeper) GetChainIdFromConnectionId(ctx sdk.Context, connectionID string) (string, error) {
connection, found := k.IBCKeeper.ConnectionKeeper.GetConnection(ctx, connectionID)
connection, found := k.ibcKeeper.ConnectionKeeper.GetConnection(ctx, connectionID)
if !found {
return "", errorsmod.Wrapf(connectiontypes.ErrConnectionNotFound, "connection %s not found", connectionID)
}
clientState, found := k.IBCKeeper.ClientKeeper.GetClientState(ctx, connection.ClientId)
clientState, found := k.ibcKeeper.ClientKeeper.GetClientState(ctx, connection.ClientId)
if !found {
return "", errorsmod.Wrapf(clienttypes.ErrClientNotFound, "client %s not found", connection.ClientId)
}
Expand Down
Loading

0 comments on commit d8a24df

Please sign in to comment.