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

refactor: update icahost to use runtime.Environment #7600

Merged
merged 143 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 142 commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
a1ef65e
go mod changes
tac0turtle Sep 6, 2024
a0bf113
remove cometabci direct dep
tac0turtle Sep 6, 2024
5a331ed
fix all errors
tac0turtle Sep 8, 2024
6d49de2
appmodule & simapp cleanup
tac0turtle Sep 8, 2024
ad88b3c
08wasm fixes
tac0turtle Sep 8, 2024
fec6f52
get 08-wasm compiling
tac0turtle Sep 8, 2024
fc0f25a
another simapp
tac0turtle Sep 8, 2024
3e5029e
another simapp
tac0turtle Sep 8, 2024
10440c8
pass in environment
tac0turtle Sep 8, 2024
d779d86
fix compilation errors
tac0turtle Sep 8, 2024
2a11f2e
some fixes
tac0turtle Sep 9, 2024
d029e19
build
tac0turtle Sep 9, 2024
c055483
fix other simapps
tac0turtle Sep 9, 2024
26d765e
linting
tac0turtle Sep 9, 2024
2ee5548
remove unsed code
tac0turtle Sep 10, 2024
0832575
Merge branch 'feat/upgrade-sdk-v0.52' into marko/gomod_change
tac0turtle Sep 23, 2024
11e5c51
go mod changes
tac0turtle Sep 23, 2024
db4ab33
add pool module
tac0turtle Sep 23, 2024
da38c64
anothersimapp
tac0turtle Sep 23, 2024
455a2e8
linting fixes
tac0turtle Sep 23, 2024
471123e
protocol pool module accounts
tac0turtle Sep 23, 2024
8c99de3
callback fixes
tac0turtle Sep 23, 2024
c01a5ed
simapp fixes
tac0turtle Sep 23, 2024
16d4530
register interfaces
tac0turtle Sep 24, 2024
ab2191b
fix feeibc
tac0turtle Sep 24, 2024
4a5d564
changes++
tac0turtle Sep 24, 2024
b2978bb
Merge branch 'feat/upgrade-sdk-v0.52' into marko/gomod_change
tac0turtle Sep 24, 2024
97ce6b8
fix missed conflict
tac0turtle Sep 24, 2024
58e6cbe
fix wasm client
tac0turtle Sep 24, 2024
ba0f7ce
linting fixes
tac0turtle Sep 24, 2024
5e94346
Merge branch 'main' into marko/gomod_change
tac0turtle Oct 21, 2024
4af6896
fix tests
tac0turtle Oct 21, 2024
bb85a9a
linting
tac0turtle Oct 21, 2024
9dc1460
fix simapp tests
tac0turtle Oct 21, 2024
a073c5d
erge branch 'main' into marko/gomod_change
tac0turtle Nov 6, 2024
6ef7fc1
fix some tests
tac0turtle Nov 6, 2024
ac74c7d
fix e2e go mod
tac0turtle Nov 6, 2024
85c06e1
go mod changes
tac0turtle Nov 6, 2024
4eb9438
remove grandpa
tac0turtle Nov 6, 2024
e06d2c5
Gomod changes and minor updates (#7549)
alpe Nov 11, 2024
d9d7072
chore: use same tags for all go mods
chatton Nov 18, 2024
452a287
chore: update go mod files, revert callbacks simapp changes
chatton Nov 18, 2024
b24e6aa
chore: fix tendermint client test suite
chatton Nov 18, 2024
b02eb86
chore: fix tests in TestAnteDecoratorCheckTx
chatton Nov 19, 2024
b6e75a8
chore: fix event tests
chatton Nov 19, 2024
a9baeec
chore: fix compiler error in simapp
damiannolan Nov 19, 2024
b54b4b6
deps: update to latest of cosmossdk.io/store main to fix proofs test
damiannolan Nov 19, 2024
61aea60
chore: tidy all
chatton Nov 20, 2024
0eb8205
fix: remove ibcmock module acc from blocked addrs
damiannolan Nov 20, 2024
8c94751
chore: fix proto failures and Gov errors
chatton Nov 20, 2024
386b258
chore: fix ica test
chatton Nov 20, 2024
bfd2454
chore: fix a few compiler errs in 08-wasm
damiannolan Nov 20, 2024
0ec2d48
fix: update ica account already exists test to front run account crea…
damiannolan Nov 20, 2024
37da9f5
chore: fix ica test for address gen
damiannolan Nov 20, 2024
b75b061
Merge pull request #7580 from cosmos/cian/damian/sdk-52
damiannolan Nov 20, 2024
610ff2d
Merge branch 'main' into marko/gomod_change
damiannolan Nov 21, 2024
cec1953
chore: re-add log to returned error
chatton Nov 21, 2024
5f115f4
chore: update go mods
chatton Nov 21, 2024
d7d1713
chore: fixed build errors in wasm app.go
chatton Nov 21, 2024
a195296
chore: cleanup callbacks simapp
damiannolan Nov 21, 2024
47eb259
chore: fixing simulation functions
chatton Nov 21, 2024
6ca4a43
chore: reconfigure simd cmd and fix TestInitCmd
damiannolan Nov 21, 2024
346d83d
feat: adding runtime Environment
damiannolan Nov 21, 2024
29ce5f2
chore: run make lint-fix
damiannolan Nov 21, 2024
7e7d17d
chore: remove duplicate import
damiannolan Nov 21, 2024
7e2f699
chore: rm duplicate import
damiannolan Nov 22, 2024
7cb2468
chore: migrate to env KVStoreService in icacontroller
damiannolan Nov 25, 2024
cb93c24
chore: fix duplicate import
damiannolan Nov 25, 2024
f828f09
chore: rm kv store service
damiannolan Nov 25, 2024
d488054
chore: refactor events to use environment
damiannolan Nov 25, 2024
92ecec1
chore: make lint-fix
damiannolan Nov 25, 2024
4660322
chore: make tidy-all
damiannolan Nov 25, 2024
e267e42
chore: rm msg service router from icacontroller
damiannolan Nov 25, 2024
ab1f3f3
fix: remove 32 bit arm arch from callbacks ci builds
damiannolan Nov 25, 2024
8b67d8d
test: try cache false for callbacks linter
damiannolan Nov 25, 2024
e27966b
chore: pin to updated interchaintest fork
chatton Nov 26, 2024
b6fba89
chore: revert relayer count to 10
chatton Nov 26, 2024
c23234d
chore: continued work on upgrading e2e tests to 0.52
chatton Nov 26, 2024
d83116d
chore: transfer e2e passing
chatton Nov 27, 2024
82c5a66
chore: fix upgrade build errors
chatton Nov 27, 2024
06d40e4
chore: bump interchaintest
chatton Nov 27, 2024
a128c03
chore: update sample config
chatton Nov 27, 2024
55b4fbe
chore: reconfigure protoany to use gogoproto any in favour of codec t…
damiannolan Nov 27, 2024
b92bc67
chore: tidy imports in e2e
damiannolan Nov 27, 2024
f9b7314
fix: address failure in module safe query ica e2e test
damiannolan Dec 2, 2024
94a4685
bump golangci version to 1.60
bznein Dec 2, 2024
4f37cf6
lint: remove duplicate import
damiannolan Dec 2, 2024
e24c60f
chore: use gogoprotoany in favour of codec types any. rm ProtoCodecMa…
damiannolan Dec 4, 2024
d70f0c4
chore: bump go version in Dockerfile
damiannolan Dec 4, 2024
5b89030
chore: add todo
damiannolan Dec 4, 2024
5ea5802
lint: fix unnecessary cast
damiannolan Dec 4, 2024
0e64412
deps: upgrade sdk to head of release/v0.52.x, upgrade store to latest…
damiannolan Dec 4, 2024
1f9e8c4
refactor: update icahost to use runtime.Environment
damiannolan Nov 25, 2024
7d7690e
chore: update icahost to use env for events and header info
damiannolan Nov 26, 2024
68be8b5
chore: push temporary module safe query impl
damiannolan Nov 26, 2024
5cf7d7e
feat: add runtime Env to icacontroller and fix v0.52 e2e tests (#7587)
damiannolan Dec 6, 2024
2a56ea4
Merge branch 'main' into marko/gomod_change
damiannolan Dec 6, 2024
7cb2628
chore: linter fixes
damiannolan Dec 6, 2024
28f2db6
lint: ignore redunant import alias
damiannolan Dec 6, 2024
6774ad5
chore: rm redudant semi-colon in tendermint.proto
damiannolan Dec 6, 2024
ad342c1
chore: rm redundant doc string regarding e2e-compatibility tests - te…
damiannolan Dec 6, 2024
58eed17
chore: update dead links
damiannolan Dec 6, 2024
a18a926
Merge branch 'main' into marko/gomod_change
damiannolan Dec 6, 2024
a16a810
Merge branch 'main' into marko/gomod_change
damiannolan Dec 11, 2024
ea26a67
Merge branch 'marko/gomod_change' into damian/icahost-runtime-env
damiannolan Dec 11, 2024
3cfa20b
chore: rm cache: false in callbacks workflow
damiannolan Dec 11, 2024
227c0ca
refactor: revert to GRPCQueryRouter
damiannolan Dec 11, 2024
bb5582b
chore: update inline comments
damiannolan Dec 12, 2024
1af3870
fix: apply fix for x/tx cosmos-sdk #22574
damiannolan Dec 12, 2024
8ea3954
Merge branch 'main' into marko/gomod_change
damiannolan Dec 12, 2024
d20e48f
Merge branch 'main' into marko/gomod_change
damiannolan Dec 12, 2024
e37253f
Merge branch 'main' into marko/gomod_change
damiannolan Dec 12, 2024
e6da172
chore: make lint-fix
damiannolan Dec 12, 2024
e093d05
fix: use hermes v1.10.4 for ci configs
damiannolan Dec 12, 2024
6fbf716
fix: apply fix for cosmos-sdk #22779 and update dependencies
damiannolan Dec 13, 2024
355b87c
fix: unpin local sdk to HEAD of release/v0.52 in simapp go.mod
damiannolan Dec 13, 2024
a1327ec
chore: revert docs/versioned_docs to main
damiannolan Dec 13, 2024
95616c7
chore: ammendments to linter configs
damiannolan Dec 16, 2024
e2b440f
chore: update var name in expected keeper
damiannolan Dec 16, 2024
ddd8136
chore: revert diffs in clienttypes/height_test
damiannolan Dec 16, 2024
fd5f4a8
chore: propagate error from event emission in icacontroller
damiannolan Dec 16, 2024
f8bd778
test: revert unnecessary diffs in test fn
damiannolan Dec 16, 2024
d119a94
chore: update comment in test chain
damiannolan Dec 16, 2024
a585ff4
Update e2e/tests/interchain_accounts/base_test.go
damiannolan Dec 16, 2024
7ca6d53
chore: nit on import aliasing
damiannolan Dec 16, 2024
b867f2b
refactor: rename instances of expected keepers from accountKeeper -> …
damiannolan Dec 16, 2024
6dc1572
chore: readd TestABCICodeDeterminism to 04-channel types
damiannolan Dec 16, 2024
57cb8e8
refactor: remove redundant AppModuleBasics
damiannolan Dec 16, 2024
de75d2c
chore: rm GetStakingKeeper api from testing app
damiannolan Dec 16, 2024
6dd955d
chore: update version in wasm dockerfile
damiannolan Dec 16, 2024
d4644d0
chore: update the go work example file version
damiannolan Dec 16, 2024
4513f7f
chore: rm UnwrapSDKContext in ica where possible
damiannolan Dec 16, 2024
6d5937c
Merge branch 'main' into marko/gomod_change
damiannolan Dec 16, 2024
54c8646
Merge branch 'marko/gomod_change' into damian/icahost-runtime-env
damiannolan Dec 16, 2024
151c0cb
refactor: apply Frojdi chad fix with query router reflection
damiannolan Dec 16, 2024
531aeee
chore: linter fixes
damiannolan Dec 16, 2024
3d9ad80
fix: import path in e2e from suggestion
damiannolan Dec 16, 2024
277e606
Merge branch 'marko/gomod_change' into damian/icahost-runtime-env
damiannolan Dec 17, 2024
37be93c
chore: rm legacy queryRouter from icahost
damiannolan Dec 17, 2024
d456657
Merge branch 'main' into damian/icahost-runtime-env
damiannolan Dec 17, 2024
f639ca2
Merge branch 'main' into damian/icahost-runtime-env
damiannolan Dec 17, 2024
398931b
chore: use deterministic error msg when unmarshalling module safe que…
damiannolan Dec 17, 2024
8218641
Merge branch 'main' into damian/icahost-runtime-env
damiannolan Dec 17, 2024
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
2 changes: 1 addition & 1 deletion e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ require (
github.com/avast/retry-go/v4 v4.5.1 // indirect
github.com/aws/aws-sdk-go v1.55.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bgentry/speakeasy v0.2.0 // indirect
github.com/bits-and-blooms/bitset v1.12.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
Expand Down Expand Up @@ -255,6 +254,7 @@ require (
cosmossdk.io/x/nft v0.0.0-00010101000000-000000000000 // indirect
github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e // indirect
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bytedance/sonic v1.12.4 // indirect
github.com/bytedance/sonic/loader v0.2.1 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
Expand Down
15 changes: 10 additions & 5 deletions modules/apps/27-interchain-accounts/host/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,27 @@ func (im IBCModule) OnRecvPacket(
_ sdk.AccAddress,
) ibcexported.Acknowledgement {
if !im.keeper.GetParams(ctx).HostEnabled {
im.keeper.Logger(ctx).Info("host submodule is disabled")
keeper.EmitHostDisabledEvent(ctx, packet)
im.keeper.Logger.Info("host submodule is disabled")
if err := im.keeper.EmitHostDisabledEvent(ctx, packet); err != nil {
return channeltypes.NewErrorAcknowledgement(err)
}

return channeltypes.NewErrorAcknowledgement(types.ErrHostSubModuleDisabled)
}

txResponse, err := im.keeper.OnRecvPacket(ctx, packet)
ack := channeltypes.NewResultAcknowledgement(txResponse)
if err != nil {
ack = channeltypes.NewErrorAcknowledgement(err)
im.keeper.Logger(ctx).Error(fmt.Sprintf("%s sequence %d", err.Error(), packet.Sequence))
im.keeper.Logger.Error(fmt.Sprintf("%s sequence %d", err.Error(), packet.Sequence))
} else {
im.keeper.Logger(ctx).Info("successfully handled packet", "sequence", packet.Sequence)
im.keeper.Logger.Info("successfully handled packet", "sequence", packet.Sequence)
}

// Emit an event indicating a successful or failed acknowledgement.
keeper.EmitAcknowledgementEvent(ctx, packet, ack, err)
if err := im.keeper.EmitAcknowledgementEvent(ctx, packet, ack, err); err != nil {
return channeltypes.NewErrorAcknowledgement(err)
}

// NOTE: acknowledgement will be written synchronously during IBC handler execution.
return ack
Expand Down
41 changes: 19 additions & 22 deletions modules/apps/27-interchain-accounts/host/keeper/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"strconv"

"cosmossdk.io/core/event"

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

"github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/host/types"
Expand All @@ -14,35 +16,30 @@ import (

// EmitAcknowledgementEvent emits an event signalling a successful or failed acknowledgement and including the error
// details if any.
func EmitAcknowledgementEvent(ctx context.Context, packet channeltypes.Packet, ack exported.Acknowledgement, err error) {
attributes := []sdk.Attribute{
sdk.NewAttribute(sdk.AttributeKeyModule, icatypes.ModuleName),
sdk.NewAttribute(icatypes.AttributeKeyHostChannelID, packet.GetDestChannel()),
sdk.NewAttribute(icatypes.AttributeKeyAckSuccess, strconv.FormatBool(ack.Success())),
func (k *Keeper) EmitAcknowledgementEvent(ctx context.Context, packet channeltypes.Packet, ack exported.Acknowledgement, err error) error {
attributes := []event.Attribute{
event.NewAttribute(sdk.AttributeKeyModule, icatypes.ModuleName),
event.NewAttribute(icatypes.AttributeKeyHostChannelID, packet.GetDestChannel()),
event.NewAttribute(icatypes.AttributeKeyAckSuccess, strconv.FormatBool(ack.Success())),
}

if err != nil {
attributes = append(attributes, sdk.NewAttribute(icatypes.AttributeKeyAckError, err.Error()))
attributes = append(attributes, event.NewAttribute(icatypes.AttributeKeyAckError, err.Error()))
}
sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917
sdkCtx.EventManager().EmitEvent(
sdk.NewEvent(
icatypes.EventTypePacket,
attributes...,
),

return k.EventService.EventManager(ctx).EmitKV(
icatypes.EventTypePacket,
attributes...,
)
}

// EmitHostDisabledEvent emits an event signalling that the host submodule is disabled.
func EmitHostDisabledEvent(ctx context.Context, packet channeltypes.Packet) {
sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917
sdkCtx.EventManager().EmitEvent(
sdk.NewEvent(
icatypes.EventTypePacket,
sdk.NewAttribute(sdk.AttributeKeyModule, icatypes.ModuleName),
sdk.NewAttribute(icatypes.AttributeKeyHostChannelID, packet.GetDestChannel()),
sdk.NewAttribute(icatypes.AttributeKeyAckError, types.ErrHostSubModuleDisabled.Error()),
sdk.NewAttribute(icatypes.AttributeKeyAckSuccess, "false"),
),
func (k *Keeper) EmitHostDisabledEvent(ctx context.Context, packet channeltypes.Packet) error {
return k.EventService.EventManager(ctx).EmitKV(
icatypes.EventTypePacket,
event.NewAttribute(sdk.AttributeKeyModule, icatypes.ModuleName),
event.NewAttribute(icatypes.AttributeKeyHostChannelID, packet.GetDestChannel()),
event.NewAttribute(icatypes.AttributeKeyAckError, types.ErrHostSubModuleDisabled.Error()),
event.NewAttribute(icatypes.AttributeKeyAckSuccess, "false"),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (k Keeper) OnChanOpenTry(
return "", errorsmod.Wrapf(err, "failed to retrieve connection %s", connectionHops[0])
}

k.Logger(ctx).Debug("counterparty version is invalid, proposing default metadata")
k.Logger.Debug("counterparty version is invalid, proposing default metadata")
metadata = icatypes.NewDefaultMetadata(connection.Counterparty.ConnectionId, connectionHops[0])
}

Expand Down Expand Up @@ -72,7 +72,7 @@ func (k Keeper) OnChanOpenTry(
interchainAccAddr, found := k.GetInterchainAccountAddress(ctx, metadata.HostConnectionId, counterparty.PortId)
if found {
// reopening an interchain account
k.Logger(ctx).Info("reopening existing interchain account", "address", interchainAccAddr)
k.Logger.Info("reopening existing interchain account", "address", interchainAccAddr)
accAddress = sdk.MustAccAddressFromBech32(interchainAccAddr)
if _, ok := k.authKeeper.GetAccount(ctx, accAddress).(*icatypes.InterchainAccount); !ok {
return "", errorsmod.Wrapf(icatypes.ErrInvalidAccountReopening, "existing account address %s, does not have interchain account type", accAddress)
Expand All @@ -83,7 +83,7 @@ func (k Keeper) OnChanOpenTry(
if err != nil {
return "", err
}
k.Logger(ctx).Info("successfully created new interchain account", "host-connection-id", metadata.HostConnectionId, "port-id", counterparty.PortId, "address", accAddress)
k.Logger.Info("successfully created new interchain account", "host-connection-id", metadata.HostConnectionId, "port-id", counterparty.PortId, "address", accAddress)
}

metadata.Address = accAddress.String()
Expand Down
45 changes: 16 additions & 29 deletions modules/apps/27-interchain-accounts/host/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,33 @@ import (

msgv1 "cosmossdk.io/api/cosmos/msg/v1"
queryv1 "cosmossdk.io/api/cosmos/query/v1"
corestore "cosmossdk.io/core/store"
"cosmossdk.io/core/appmodule"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"

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

genesistypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/genesis/types"
"github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/types"
channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types"
porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types"
ibcerrors "github.com/cosmos/ibc-go/v9/modules/core/errors"
"github.com/cosmos/ibc-go/v9/modules/core/exported"
coretypes "github.com/cosmos/ibc-go/v9/modules/core/types"
)

// Keeper defines the IBC interchain accounts host keeper
type Keeper struct {
storeService corestore.KVStoreService
appmodule.Environment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the way this is supposed to be used? I feel like it would be clearer in the rest of the code if the Environment stuff was called with k.env.BranchService or whatever. But if this is meant to be the idiomatic SDK way, then we should obviously do it like this - otherwise we can discuss it at least :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is how its used in all the cosmos-sdk std modules from what I can see


cdc codec.Codec
legacySubspace icatypes.ParamSubspace

ics4Wrapper porttypes.ICS4Wrapper
channelKeeper icatypes.ChannelKeeper
authKeeper icatypes.AuthKeeper

msgRouter icatypes.MessageRouter
queryRouter icatypes.QueryRouter

// mqsAllowList is a list of all module safe query paths
mqsAllowList []string

Expand All @@ -54,9 +49,9 @@ type Keeper struct {

// NewKeeper creates a new interchain accounts host Keeper instance
func NewKeeper(
cdc codec.Codec, storeService corestore.KVStoreService, legacySubspace icatypes.ParamSubspace,
cdc codec.Codec, env appmodule.Environment, legacySubspace icatypes.ParamSubspace,
ics4Wrapper porttypes.ICS4Wrapper, channelKeeper icatypes.ChannelKeeper,
authKeeper icatypes.AuthKeeper, msgRouter icatypes.MessageRouter, queryRouter icatypes.QueryRouter, authority string,
authKeeper icatypes.AuthKeeper, authority string,
) Keeper {
// ensure ibc interchain accounts module account is set
if addr := authKeeper.GetModuleAddress(icatypes.ModuleName); addr == nil {
Expand All @@ -68,14 +63,12 @@ func NewKeeper(
}

return Keeper{
storeService: storeService,
Environment: env,
cdc: cdc,
legacySubspace: legacySubspace,
ics4Wrapper: ics4Wrapper,
channelKeeper: channelKeeper,
authKeeper: authKeeper,
msgRouter: msgRouter,
queryRouter: queryRouter,
mqsAllowList: newModuleQuerySafeAllowList(),
authority: authority,
}
Expand All @@ -93,12 +86,6 @@ func (k Keeper) GetICS4Wrapper() porttypes.ICS4Wrapper {
return k.ics4Wrapper
}

// Logger returns the application logger, scoped to the associated module
func (Keeper) Logger(ctx context.Context) log.Logger {
sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: remove after context.Context is removed from core IBC
return sdkCtx.Logger().With("module", fmt.Sprintf("x/%s-%s", exported.ModuleName, icatypes.ModuleName))
}

// getConnectionID returns the connection id for the given port and channelIDs.
func (k Keeper) getConnectionID(ctx context.Context, portID, channelID string) (string, error) {
channel, found := k.channelKeeper.GetChannel(ctx, portID, channelID)
Expand All @@ -110,7 +97,7 @@ func (k Keeper) getConnectionID(ctx context.Context, portID, channelID string) (

// setPort sets the provided portID in state.
func (k Keeper) setPort(ctx context.Context, portID string) {
store := k.storeService.OpenKVStore(ctx)
store := k.KVStoreService.OpenKVStore(ctx)
if err := store.Set(icatypes.KeyPort(portID), []byte{0x01}); err != nil {
panic(err)
}
Expand All @@ -133,7 +120,7 @@ func (k Keeper) getAppMetadata(ctx context.Context, portID, channelID string) (i

// GetActiveChannelID retrieves the active channelID from the store keyed by the provided connectionID and portID
func (k Keeper) GetActiveChannelID(ctx context.Context, connectionID, portID string) (string, bool) {
store := k.storeService.OpenKVStore(ctx)
store := k.KVStoreService.OpenKVStore(ctx)
key := icatypes.KeyActiveChannel(portID, connectionID)

bz, err := store.Get(key)
Expand Down Expand Up @@ -165,9 +152,9 @@ func (k Keeper) GetOpenActiveChannel(ctx context.Context, connectionID, portID s

// GetAllActiveChannels returns a list of all active interchain accounts host channels and their associated connection and port identifiers
func (k Keeper) GetAllActiveChannels(ctx context.Context) []genesistypes.ActiveChannel {
store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx))
iterator := storetypes.KVStorePrefixIterator(store, []byte(icatypes.ActiveChannelKeyPrefix))
defer coretypes.LogDeferred(k.Logger(ctx), func() error { return iterator.Close() })
defer coretypes.LogDeferred(k.Logger, func() error { return iterator.Close() })

var activeChannels []genesistypes.ActiveChannel
for ; iterator.Valid(); iterator.Next() {
Expand All @@ -187,7 +174,7 @@ func (k Keeper) GetAllActiveChannels(ctx context.Context) []genesistypes.ActiveC

// SetActiveChannelID stores the active channelID, keyed by the provided connectionID and portID
func (k Keeper) SetActiveChannelID(ctx context.Context, connectionID, portID, channelID string) {
store := k.storeService.OpenKVStore(ctx)
store := k.KVStoreService.OpenKVStore(ctx)
if err := store.Set(icatypes.KeyActiveChannel(portID, connectionID), []byte(channelID)); err != nil {
panic(err)
}
Expand All @@ -201,7 +188,7 @@ func (k Keeper) IsActiveChannel(ctx context.Context, connectionID, portID string

// GetInterchainAccountAddress retrieves the InterchainAccount address from the store associated with the provided connectionID and portID
func (k Keeper) GetInterchainAccountAddress(ctx context.Context, connectionID, portID string) (string, bool) {
store := k.storeService.OpenKVStore(ctx)
store := k.KVStoreService.OpenKVStore(ctx)
key := icatypes.KeyOwnerAccount(portID, connectionID)

bz, err := store.Get(key)
Expand All @@ -217,7 +204,7 @@ func (k Keeper) GetInterchainAccountAddress(ctx context.Context, connectionID, p

// GetAllInterchainAccounts returns a list of all registered interchain account addresses and their associated connection and controller port identifiers
func (k Keeper) GetAllInterchainAccounts(ctx context.Context) []genesistypes.RegisteredInterchainAccount {
store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx))
iterator := storetypes.KVStorePrefixIterator(store, []byte(icatypes.OwnerKeyPrefix))

var interchainAccounts []genesistypes.RegisteredInterchainAccount
Expand All @@ -238,7 +225,7 @@ func (k Keeper) GetAllInterchainAccounts(ctx context.Context) []genesistypes.Reg

// SetInterchainAccountAddress stores the InterchainAccount address, keyed by the associated connectionID and portID
func (k Keeper) SetInterchainAccountAddress(ctx context.Context, connectionID, portID, address string) {
store := k.storeService.OpenKVStore(ctx)
store := k.KVStoreService.OpenKVStore(ctx)
if err := store.Set(icatypes.KeyOwnerAccount(portID, connectionID), []byte(address)); err != nil {
panic(err)
}
Expand All @@ -251,7 +238,7 @@ func (k Keeper) GetAuthority() string {

// GetParams returns the total set of the host submodule parameters.
func (k Keeper) GetParams(ctx context.Context) types.Params {
store := k.storeService.OpenKVStore(ctx)
store := k.KVStoreService.OpenKVStore(ctx)
bz, err := store.Get([]byte(types.ParamsKey))
if err != nil {
panic(err)
Expand All @@ -267,7 +254,7 @@ func (k Keeper) GetParams(ctx context.Context) types.Params {

// SetParams sets the total set of the host submodule parameters.
func (k Keeper) SetParams(ctx context.Context, params types.Params) {
store := k.storeService.OpenKVStore(ctx)
store := k.KVStoreService.OpenKVStore(ctx)
bz := k.cdc.MustMarshal(&params)
if err := store.Set([]byte(types.ParamsKey), bz); err != nil {
panic(err)
Expand Down
14 changes: 5 additions & 9 deletions modules/apps/27-interchain-accounts/host/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (

testifysuite "github.com/stretchr/testify/suite"

"cosmossdk.io/log"

"github.com/cosmos/cosmos-sdk/runtime"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"

Expand Down Expand Up @@ -142,39 +144,33 @@ func (suite *KeeperTestSuite) TestNewKeeper() {
{"success", func() {
keeper.NewKeeper(
suite.chainA.GetSimApp().AppCodec(),
runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)),
runtime.NewEnvironment(runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)), log.NewNopLogger()),
suite.chainA.GetSimApp().GetSubspace(types.SubModuleName),
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().AuthKeeper,
suite.chainA.GetSimApp().MsgServiceRouter(),
suite.chainA.GetSimApp().GRPCQueryRouter(),
suite.chainA.GetSimApp().ICAHostKeeper.GetAuthority(),
)
}, ""},
{"failure: interchain accounts module account does not exist", func() {
keeper.NewKeeper(
suite.chainA.GetSimApp().AppCodec(),
runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)),
runtime.NewEnvironment(runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)), log.NewNopLogger()),
suite.chainA.GetSimApp().GetSubspace(types.SubModuleName),
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
authkeeper.AccountKeeper{}, // empty account keeper
suite.chainA.GetSimApp().MsgServiceRouter(),
suite.chainA.GetSimApp().GRPCQueryRouter(),
suite.chainA.GetSimApp().ICAHostKeeper.GetAuthority(),
)
}, "the Interchain Accounts module account has not been set"},
{"failure: empty mock staking keeper", func() {
keeper.NewKeeper(
suite.chainA.GetSimApp().AppCodec(),
runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)),
runtime.NewEnvironment(runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(types.StoreKey)), log.NewNopLogger()),
suite.chainA.GetSimApp().GetSubspace(types.SubModuleName),
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().AuthKeeper,
suite.chainA.GetSimApp().MsgServiceRouter(),
suite.chainA.GetSimApp().GRPCQueryRouter(),
"", // authority
)
}, "authority must be non-empty"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (m Migrator) MigrateParams(ctx context.Context) error {
return err
}
m.keeper.SetParams(ctx, params)
m.keeper.Logger(ctx).Info("successfully migrated ica/host submodule to self-manage params")
m.keeper.Logger.Info("successfully migrated ica/host submodule to self-manage params")
}
return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper_test
import (
"fmt"

"cosmossdk.io/log"
govtypes "cosmossdk.io/x/gov/types"

"github.com/cosmos/cosmos-sdk/runtime"
Expand Down Expand Up @@ -32,13 +33,11 @@ func (suite *KeeperTestSuite) TestMigratorMigrateParams() {
func() {
suite.chainA.GetSimApp().ICAHostKeeper = icahostkeeper.NewKeeper(
suite.chainA.Codec,
runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(icahosttypes.StoreKey)),
runtime.NewEnvironment(runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(icahosttypes.StoreKey)), log.NewNopLogger()),
nil, // assign a nil legacy param subspace
suite.chainA.GetSimApp().IBCFeeKeeper,
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().AuthKeeper,
suite.chainA.GetSimApp().MsgServiceRouter(),
suite.chainA.GetSimApp().GRPCQueryRouter(),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
},
Expand Down
Loading
Loading