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 transfer to use runtime.Environment #7615

Merged
merged 105 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 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
ba1c328
refactor: update transfer to use runtime.Environment
Dec 2, 2024
da4f653
bump golangci version
Dec 2, 2024
fa84b79
use x/ibc-transfer instead of x/transfer
Dec 2, 2024
94a4685
bump golangci version to 1.60
Dec 2, 2024
30b52b3
Merge branch 'damian/runtime-env' into bznein/transferEnvironment
Dec 2, 2024
c8849fe
revert wrong edit
Dec 2, 2024
5cf7d7e
feat: add runtime Env to icacontroller and fix v0.52 e2e tests (#7587)
damiannolan Dec 6, 2024
acfc0e3
Update testing/simapp/app.go
Dec 6, 2024
b5a0791
Merge branch 'marko/gomod_change' into bznein/transferEnvironment
Dec 6, 2024
245c24a
use constants
Dec 6, 2024
7b005a1
fix double import
Dec 6, 2024
a91476e
fix double import
Dec 6, 2024
846575a
Update modules/apps/transfer/keeper/keeper.go
Dec 6, 2024
a919b87
Merge branch 'main' into bznein/transferEnvironment
damiannolan Dec 18, 2024
b12f783
Merge branch 'main' into bznein/transferEnvironment
damiannolan Dec 18, 2024
39a6d6a
chore: linter stuffs
damiannolan Dec 18, 2024
c790978
Merge branch 'main' into bznein/transferEnvironment
damiannolan Dec 18, 2024
e9de85a
chore: revert versioned docs to main
damiannolan Dec 18, 2024
2b4c3b8
chore: revert height_test and msg_server_test diffs
damiannolan Dec 18, 2024
76b6a8d
chore: remove more UnwrapSDKContext usage
damiannolan Dec 18, 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
4 changes: 3 additions & 1 deletion modules/apps/callbacks/testing/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,9 @@ func NewSimApp(
// since fee middleware will wrap the IBCKeeper for underlying application.
// NOTE: the Transfer Keeper's ICS4Wrapper can later be replaced.
app.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec, runtime.NewKVStoreService(keys[ibctransfertypes.StoreKey]), app.GetSubspace(ibctransfertypes.ModuleName),
appCodec,
runtime.NewEnvironment(runtime.NewKVStoreService(keys[ibctransfertypes.StoreKey]), logger.With(log.ModuleKey, fmt.Sprintf("x/%s-%s", ibcexported.ModuleName, ibctransfertypes.ModuleName))),
app.GetSubspace(ibctransfertypes.ModuleName),
app.IBCFeeKeeper, // ISC4 Wrapper: fee IBC middleware
app.IBCKeeper.ChannelKeeper,
app.AuthKeeper, app.BankKeeper,
Expand Down
10 changes: 5 additions & 5 deletions modules/apps/transfer/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (im IBCModule) OnChanOpenTry(
}

if !slices.Contains(types.SupportedVersions, counterpartyVersion) {
im.keeper.Logger(ctx).Debug("invalid counterparty version, proposing latest app version", "counterpartyVersion", counterpartyVersion, "version", types.V2)
im.keeper.Logger.Debug("invalid counterparty version, proposing latest app version", "counterpartyVersion", counterpartyVersion, "version", types.V2)
return types.V2, nil
}

Expand Down Expand Up @@ -187,17 +187,17 @@ func (im IBCModule) OnRecvPacket(
data, ackErr = types.UnmarshalPacketData(packet.GetData(), channelVersion)
if ackErr != nil {
ack = channeltypes.NewErrorAcknowledgement(ackErr)
im.keeper.Logger(ctx).Error(fmt.Sprintf("%s sequence %d", ackErr.Error(), packet.Sequence))
im.keeper.Logger.Error(fmt.Sprintf("%s sequence %d", ackErr.Error(), packet.Sequence))
return ack
}

if ackErr = im.keeper.OnRecvPacket(ctx, packet, data); ackErr != nil {
ack = channeltypes.NewErrorAcknowledgement(ackErr)
im.keeper.Logger(ctx).Error(fmt.Sprintf("%s sequence %d", ackErr.Error(), packet.Sequence))
im.keeper.Logger.Error(fmt.Sprintf("%s sequence %d", ackErr.Error(), packet.Sequence))
return ack
}

im.keeper.Logger(ctx).Info("successfully handled ICS-20 packet", "sequence", packet.Sequence)
im.keeper.Logger.Info("successfully handled ICS-20 packet", "sequence", packet.Sequence)

if data.HasForwarding() {
// NOTE: acknowledgement will be written asynchronously
Expand Down Expand Up @@ -276,7 +276,7 @@ func (im IBCModule) OnChanUpgradeTry(ctx context.Context, portID, channelID stri
}

if !slices.Contains(types.SupportedVersions, counterpartyVersion) {
im.keeper.Logger(ctx).Debug("invalid counterparty version, proposing latest app version", "counterpartyVersion", counterpartyVersion, "version", types.V2)
im.keeper.Logger.Debug("invalid counterparty version, proposing latest app version", "counterpartyVersion", counterpartyVersion, "version", types.V2)
return types.V2, nil
}

Expand Down
2 changes: 1 addition & 1 deletion modules/apps/transfer/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (k Keeper) Denoms(ctx context.Context, req *types.QueryDenomsRequest) (*typ
}

var denoms types.Denoms
store := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.DenomKey)
store := prefix.NewStore(runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)), types.DenomKey)

pageRes, err := query.Paginate(store, req.Pagination, func(_, value []byte) error {
var denom types.Denom
Expand Down
53 changes: 23 additions & 30 deletions modules/apps/transfer/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import (
"fmt"
"strings"

corestore "cosmossdk.io/core/store"
"cosmossdk.io/log"
"cosmossdk.io/core/appmodule"
sdkmath "cosmossdk.io/math"
"cosmossdk.io/store/prefix"
storetypes "cosmossdk.io/store/types"
Expand All @@ -23,13 +22,13 @@ import (
channeltypes "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types"
porttypes "github.com/cosmos/ibc-go/v9/modules/core/05-port/types"
host "github.com/cosmos/ibc-go/v9/modules/core/24-host"
"github.com/cosmos/ibc-go/v9/modules/core/exported"
coretypes "github.com/cosmos/ibc-go/v9/modules/core/types"
)

// Keeper defines the IBC fungible transfer keeper
type Keeper struct {
storeService corestore.KVStoreService
appmodule.Environment
bznein marked this conversation as resolved.
Show resolved Hide resolved

cdc codec.BinaryCodec
legacySubspace types.ParamSubspace

Expand All @@ -46,7 +45,7 @@ type Keeper struct {
// NewKeeper creates a new IBC transfer Keeper instance
func NewKeeper(
cdc codec.BinaryCodec,
storeService corestore.KVStoreService,
env appmodule.Environment,
legacySubspace types.ParamSubspace,
ics4Wrapper porttypes.ICS4Wrapper,
channelKeeper types.ChannelKeeper,
Expand All @@ -65,7 +64,7 @@ func NewKeeper(

return Keeper{
cdc: cdc,
storeService: storeService,
Environment: env,
legacySubspace: legacySubspace,
ics4Wrapper: ics4Wrapper,
channelKeeper: channelKeeper,
Expand All @@ -92,15 +91,9 @@ func (k Keeper) GetAuthority() string {
return k.authority
}

// Logger returns a module-specific logger.
func (Keeper) Logger(ctx context.Context) log.Logger {
sdkCtx := sdk.UnwrapSDKContext(ctx) // TODO: https://github.com/cosmos/ibc-go/issues/5917
return sdkCtx.Logger().With("module", "x/"+exported.ModuleName+"-"+types.ModuleName)
}

// GetPort returns the portID for the transfer module. Used in ExportGenesis
func (k Keeper) GetPort(ctx context.Context) string {
store := k.storeService.OpenKVStore(ctx)
store := k.KVStoreService.OpenKVStore(ctx)
bz, err := store.Get(types.PortKey)
if err != nil {
panic(err)
Expand All @@ -110,15 +103,15 @@ func (k Keeper) GetPort(ctx context.Context) string {

// SetPort sets the portID for the transfer module. Used in InitGenesis
func (k Keeper) SetPort(ctx context.Context, portID string) {
store := k.storeService.OpenKVStore(ctx)
store := k.KVStoreService.OpenKVStore(ctx)
if err := store.Set(types.PortKey, []byte(portID)); err != nil {
panic(err)
}
}

// GetParams returns the current transfer module 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 @@ -134,7 +127,7 @@ func (k Keeper) GetParams(ctx context.Context) types.Params {

// SetParams sets the transfer module 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 All @@ -143,7 +136,7 @@ func (k Keeper) SetParams(ctx context.Context, params types.Params) {

// GetDenom retrieves the denom from store given the hash of the denom.
func (k Keeper) GetDenom(ctx context.Context, denomHash cmtbytes.HexBytes) (types.Denom, bool) {
store := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.DenomKey)
store := prefix.NewStore(runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)), types.DenomKey)
bz := store.Get(denomHash)
if len(bz) == 0 {
return types.Denom{}, false
Expand All @@ -157,14 +150,14 @@ func (k Keeper) GetDenom(ctx context.Context, denomHash cmtbytes.HexBytes) (type

// HasDenom checks if a the key with the given denomination hash exists on the store.
func (k Keeper) HasDenom(ctx context.Context, denomHash cmtbytes.HexBytes) bool {
store := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.DenomKey)
store := prefix.NewStore(runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)), types.DenomKey)
return store.Has(denomHash)
}

// SetDenom sets a new {denom hash -> denom } pair to the store.
// This allows for reverse lookup of the denom given the hash.
func (k Keeper) SetDenom(ctx context.Context, denom types.Denom) {
store := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.DenomKey)
store := prefix.NewStore(runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)), types.DenomKey)
bz := k.cdc.MustMarshal(&denom)
store.Set(denom.Hash(), bz)
}
Expand All @@ -182,10 +175,10 @@ func (k Keeper) GetAllDenoms(ctx context.Context) types.Denoms {

// IterateDenoms iterates over the denominations in the store and performs a callback function.
func (k Keeper) IterateDenoms(ctx context.Context, cb func(denom types.Denom) bool) {
store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx))
iterator := storetypes.KVStorePrefixIterator(store, types.DenomKey)

defer coretypes.LogDeferred(k.Logger(ctx), func() error { return iterator.Close() })
defer coretypes.LogDeferred(k.Logger, func() error { return iterator.Close() })
for ; iterator.Valid(); iterator.Next() {
var denom types.Denom
k.cdc.MustUnmarshal(iterator.Value(), &denom)
Expand Down Expand Up @@ -224,7 +217,7 @@ func (k Keeper) setDenomMetadata(ctx context.Context, denom types.Denom) {
// NOTE: if there is no value stored in state for the provided denom then a new Coin is returned for the denom with an initial value of zero.
// This accommodates callers to simply call `Add()` on the returned Coin as an empty Coin literal (e.g. sdk.Coin{}) will trigger a panic due to the absence of a denom.
func (k Keeper) GetTotalEscrowForDenom(ctx context.Context, denom string) sdk.Coin {
store := k.storeService.OpenKVStore(ctx)
store := k.KVStoreService.OpenKVStore(ctx)
bz, err := store.Get(types.TotalEscrowForDenomKey(denom))
if err != nil {
panic(err)
Expand All @@ -249,7 +242,7 @@ func (k Keeper) SetTotalEscrowForDenom(ctx context.Context, coin sdk.Coin) {
panic(fmt.Errorf("amount cannot be negative: %s", coin.Amount))
}

store := k.storeService.OpenKVStore(ctx)
store := k.KVStoreService.OpenKVStore(ctx)
key := types.TotalEscrowForDenomKey(coin.Denom)

if coin.Amount.IsZero() {
Expand Down Expand Up @@ -283,10 +276,10 @@ func (k Keeper) GetAllTotalEscrowed(ctx context.Context) sdk.Coins {
// and performs a callback function. Denominations for which an invalid value
// (i.e. not integer) is stored, will be skipped.
func (k Keeper) IterateTokensInEscrow(ctx context.Context, storeprefix []byte, cb func(denomEscrow sdk.Coin) bool) {
store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx))
iterator := storetypes.KVStorePrefixIterator(store, storeprefix)

defer coretypes.LogDeferred(k.Logger(ctx), func() error { return iterator.Close() })
defer coretypes.LogDeferred(k.Logger, func() error { return iterator.Close() })
for ; iterator.Valid(); iterator.Next() {
denom := strings.TrimPrefix(string(iterator.Key()), fmt.Sprintf("%s/", types.KeyTotalEscrowPrefix))
if strings.TrimSpace(denom) == "" {
Expand All @@ -307,7 +300,7 @@ func (k Keeper) IterateTokensInEscrow(ctx context.Context, storeprefix []byte, c

// setForwardedPacket sets the forwarded packet in the store.
func (k Keeper) setForwardedPacket(ctx context.Context, portID, channelID string, sequence uint64, packet channeltypes.Packet) {
store := k.storeService.OpenKVStore(ctx)
store := k.KVStoreService.OpenKVStore(ctx)
bz := k.cdc.MustMarshal(&packet)
if err := store.Set(types.PacketForwardKey(portID, channelID, sequence), bz); err != nil {
panic(err)
Expand All @@ -316,7 +309,7 @@ func (k Keeper) setForwardedPacket(ctx context.Context, portID, channelID string

// getForwardedPacket gets the forwarded packet from the store.
func (k Keeper) getForwardedPacket(ctx context.Context, portID, channelID string, sequence uint64) (channeltypes.Packet, bool) {
store := k.storeService.OpenKVStore(ctx)
store := k.KVStoreService.OpenKVStore(ctx)
bz, err := store.Get(types.PacketForwardKey(portID, channelID, sequence))
if err != nil {
panic(err)
Expand All @@ -333,7 +326,7 @@ func (k Keeper) getForwardedPacket(ctx context.Context, portID, channelID string

// deleteForwardedPacket deletes the forwarded packet from the store.
func (k Keeper) deleteForwardedPacket(ctx context.Context, portID, channelID string, sequence uint64) {
store := k.storeService.OpenKVStore(ctx)
store := k.KVStoreService.OpenKVStore(ctx)
packetKey := types.PacketForwardKey(portID, channelID, sequence)

if err := store.Delete(packetKey); err != nil {
Expand All @@ -354,10 +347,10 @@ func (k Keeper) getAllForwardedPackets(ctx context.Context) []types.ForwardedPac

// iterateForwardedPackets iterates over the forward packets in the store and performs a callback function.
func (k Keeper) iterateForwardedPackets(ctx context.Context, cb func(packet types.ForwardedPacket) bool) {
store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx))
iterator := storetypes.KVStorePrefixIterator(store, types.ForwardedPacketKey)

defer coretypes.LogDeferred(k.Logger(ctx), func() error { return iterator.Close() })
defer coretypes.LogDeferred(k.Logger, func() error { return iterator.Close() })
for ; iterator.Valid(); iterator.Next() {
var forwardPacket types.ForwardedPacket
k.cdc.MustUnmarshal(iterator.Value(), &forwardPacket.Packet)
Expand Down
7 changes: 4 additions & 3 deletions modules/apps/transfer/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

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

"cosmossdk.io/log"
sdkmath "cosmossdk.io/math"
storetypes "cosmossdk.io/store/types"
minttypes "cosmossdk.io/x/mint/types"
Expand Down Expand Up @@ -57,7 +58,7 @@ 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.ModuleName),
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
Expand All @@ -69,7 +70,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() {
{"failure: transfer 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.ModuleName),
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
Expand All @@ -81,7 +82,7 @@ func (suite *KeeperTestSuite) TestNewKeeper() {
{"failure: empty authority", 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.ModuleName),
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper,
Expand Down
14 changes: 7 additions & 7 deletions modules/apps/transfer/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (m Migrator) MigrateParams(ctx sdk.Context) error {
m.keeper.legacySubspace.GetParamSet(ctx, &params)

m.keeper.SetParams(ctx, params)
m.keeper.Logger(ctx).Info("successfully migrated transfer app self-manage params")
m.keeper.Logger.Info("successfully migrated transfer app self-manage params")
return nil
}

Expand All @@ -50,7 +50,7 @@ func (m Migrator) MigrateDenomMetadata(ctx sdk.Context) error {
return false
})

m.keeper.Logger(ctx).Info("successfully added metadata to IBC voucher denominations")
m.keeper.Logger.Info("successfully added metadata to IBC voucher denominations")
return nil
}

Expand All @@ -71,7 +71,7 @@ func (m Migrator) MigrateTotalEscrowForDenom(ctx sdk.Context) error {
m.keeper.SetTotalEscrowForDenom(ctx, totalEscrow)
}

m.keeper.Logger(ctx).Info("successfully set total escrow", "number of denominations", totalEscrowed.Len())
m.keeper.Logger.Info("successfully set total escrow", "number of denominations", totalEscrowed.Len())
return nil
}

Expand Down Expand Up @@ -117,25 +117,25 @@ func (m Migrator) MigrateDenomTraceToDenom(ctx sdk.Context) error {

// setDenomTrace sets a new {trace hash -> denom trace} pair to the store.
func (k Keeper) setDenomTrace(ctx context.Context, denomTrace internaltypes.DenomTrace) {
store := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.DenomTraceKey)
store := prefix.NewStore(runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)), types.DenomTraceKey)
bz := k.cdc.MustMarshal(&denomTrace)

store.Set(denomTrace.Hash(), bz)
}

// deleteDenomTrace deletes the denom trace
func (k Keeper) deleteDenomTrace(ctx context.Context, denomTrace internaltypes.DenomTrace) {
store := prefix.NewStore(runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)), types.DenomTraceKey)
store := prefix.NewStore(runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx)), types.DenomTraceKey)
store.Delete(denomTrace.Hash())
}

// iterateDenomTraces iterates over the denomination traces in the store
// and performs a callback function.
func (k Keeper) iterateDenomTraces(ctx context.Context, cb func(denomTrace internaltypes.DenomTrace) bool) {
store := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx))
store := runtime.KVStoreAdapter(k.KVStoreService.OpenKVStore(ctx))
iterator := storetypes.KVStorePrefixIterator(store, types.DenomTraceKey)

defer coretypes.LogDeferred(k.Logger(ctx), func() error { return iterator.Close() })
defer coretypes.LogDeferred(k.Logger, func() error { return iterator.Close() })
for ; iterator.Valid(); iterator.Next() {
var denomTrace internaltypes.DenomTrace
k.cdc.MustUnmarshal(iterator.Value(), &denomTrace)
Expand Down
13 changes: 5 additions & 8 deletions modules/apps/transfer/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ import (
var _ types.MsgServer = (*Keeper)(nil)

// Transfer defines an rpc handler method for MsgTransfer.
func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types.MsgTransferResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

func (k Keeper) Transfer(ctx context.Context, msg *types.MsgTransfer) (*types.MsgTransferResponse, error) {
if !k.GetParams(ctx).SendEnabled {
return nil, types.ErrSendDisabled
}
Expand Down Expand Up @@ -51,18 +49,17 @@ func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types.
return nil, err
}

k.Logger(ctx).Info("IBC fungible token transfer", "tokens", coins, "sender", msg.Sender, "receiver", msg.Receiver)
k.Logger.Info("IBC fungible token transfer", "tokens", coins, "sender", msg.Sender, "receiver", msg.Receiver)

return &types.MsgTransferResponse{Sequence: sequence}, nil
}

// UpdateParams defines an rpc handler method for MsgUpdateParams. Updates the ibc-transfer module's parameters.
func (k Keeper) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) {
func (k Keeper) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) {
if k.GetAuthority() != msg.Signer {
return nil, errorsmod.Wrapf(ibcerrors.ErrUnauthorized, "expected %s, got %s", k.GetAuthority(), msg.Signer)
}

ctx := sdk.UnwrapSDKContext(goCtx)
k.SetParams(ctx, msg.Params)

return &types.MsgUpdateParamsResponse{}, nil
Expand All @@ -71,7 +68,7 @@ func (k Keeper) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams)
// unwindHops unwinds the hops present in the tokens denomination and returns the message modified to reflect
// the unwound path to take. It assumes that only a single token is present (as this is verified in ValidateBasic)
// in the tokens list and ensures that the token is not native to the chain.
func (k Keeper) unwindHops(ctx sdk.Context, msg *types.MsgTransfer) (*types.MsgTransfer, error) {
func (k Keeper) unwindHops(ctx context.Context, msg *types.MsgTransfer) (*types.MsgTransfer, error) {
unwindHops, err := k.getUnwindHops(ctx, msg.GetCoins())
if err != nil {
return nil, err
Expand All @@ -92,7 +89,7 @@ func (k Keeper) unwindHops(ctx sdk.Context, msg *types.MsgTransfer) (*types.MsgT
// getUnwindHops returns the hops to be used during unwinding. If coins consists of more than
// one coin, all coins must have the exact same trace, else an error is returned. getUnwindHops
// also validates that the coins are not native to the chain.
func (k Keeper) getUnwindHops(ctx sdk.Context, coins sdk.Coins) ([]types.Hop, error) {
func (k Keeper) getUnwindHops(ctx context.Context, coins sdk.Coins) ([]types.Hop, error) {
// Sanity: validation for MsgTransfer ensures coins are not empty.
if len(coins) == 0 {
return nil, errorsmod.Wrap(types.ErrInvalidForwarding, "coins cannot be empty")
Expand Down
Loading
Loading