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

feat(transfer)!: migrate transfer parameters to be self managed #3553

Merged
merged 116 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from 107 commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
20e1c44
added 'UpdateParams' rpc endpoint and its messages to 'tx.proto'
srdtrk May 3, 2023
1658827
ran 'make proto-gen'
srdtrk May 3, 2023
df392d6
implemented 'sdk.Msg' for 'MsgUpdateParams' in 'types/msgs.go'
srdtrk May 3, 2023
964f97e
'msgs_test.go' updated - todo test tests + create a 'NewMsgUpdatePara…
srdtrk May 3, 2023
369d399
added 'NewMsgUpdateParams' function to 'types/msgs.go'
srdtrk May 3, 2023
2b0a739
improved test styling and used helper functions more
srdtrk May 3, 2023
c8383bb
added boilerplate 'UpdateParams' function to MsgServer - todo impleme…
srdtrk May 3, 2023
a53233f
removed paramtypes and added authority to Keeper struct - todo Keeper…
srdtrk May 3, 2023
829c8a5
updated Keeper functions - todo add ParamsKey to types + update keepe…
srdtrk May 3, 2023
5af4e23
deleted unneeded keeper/params.go as this should be managed in keeper.go
srdtrk May 3, 2023
5accc5d
moved params test from params_test to keeper_test as this is where th…
srdtrk May 3, 2023
0a950ef
added ParamsKey to 'types/keys.go'
srdtrk May 3, 2023
3bfcbdb
replaced 'k.GetSendEnabled(ctx)' with 'k.GetParams(ctx).SendEnabled' …
srdtrk May 3, 2023
6d5bf05
replaced 'k.GetReceiveEnabled(ctx)' with 'k.GetParams(ctx).ReceiveEna…
srdtrk May 3, 2023
464c385
added 'MsgUpdateParams' to InterfaceRegistry
srdtrk May 3, 2023
98be444
implemented 'UpdateParams' in msg_server
srdtrk May 3, 2023
990e663
added one more test case to msgs_test for ParamsValidation
srdtrk May 3, 2023
83c550c
wrote tests for 'TestUpdateParams' rpc handler
srdtrk May 3, 2023
8ab5596
removed params subspace - todo: add subspaces back as legacy for migr…
srdtrk May 3, 2023
e27637a
removed test cases that didn't make sense
srdtrk May 3, 2023
859c0bb
fixed the tests here
srdtrk May 3, 2023
300600a
fixed typo in function comment
srdtrk May 3, 2023
838c495
fixed keeper tests
srdtrk May 3, 2023
f6df036
merge with main
srdtrk May 4, 2023
9dc8bc8
ran 'golangci-lint' on 'transfer/types/...'
srdtrk May 4, 2023
f07dab2
added validation to SetParams keeper method
srdtrk May 4, 2023
637babc
handled the case where 'SetParams' returns an error 'InitGenesis'
srdtrk May 4, 2023
cc3b07e
fix: forgot to check value of '.SetParams' to ensure it is not an error
srdtrk May 4, 2023
ffbd6b2
ran 'gofumpt' on 'transfer/keeper/'
srdtrk May 4, 2023
c244ad2
split 'types/params.go' into a legacy part
srdtrk May 4, 2023
63788a4
created 'exported.go' for migration purposes
srdtrk May 4, 2023
5673df4
added migration code to 'keeper/migrations.go'
srdtrk May 4, 2023
e9317e9
increased module.go version and registered param migration
srdtrk May 4, 2023
b2018cf
passed legacySubspace to transfer for migration
srdtrk May 4, 2023
54ef45d
allow tests to compile and pass by passing the subspace to the migrat…
srdtrk May 4, 2023
12d93e3
removed unneeded if statement
srdtrk May 4, 2023
0395da8
ran gofumpt
srdtrk May 4, 2023
027ab9e
added integration tests for successful migration of params
srdtrk May 4, 2023
ba60fc5
fix: forgot to check if '.SetParams' returns an err
srdtrk May 4, 2023
6ee83a7
ran gofumpt
srdtrk May 4, 2023
c93bf8d
broken: this test is work in progress and will fail
srdtrk May 4, 2023
ffcbd01
uncommented the two lines in test
srdtrk May 4, 2023
5d8fcc8
fixed an important error on params_legacy.go
srdtrk May 5, 2023
e2c0a65
initialize ParamKeyTable for ibctransfer in app.go now
srdtrk May 5, 2023
01637a7
finally a working version of the test
srdtrk May 5, 2023
280bdfa
style changes on the test
srdtrk May 5, 2023
1acf716
ran 'gofumpt'
srdtrk May 5, 2023
a52f1d0
moved comment
srdtrk May 5, 2023
280b25d
updated GetParams function's comment
srdtrk May 5, 2023
cd5e83a
updated docs
srdtrk May 5, 2023
9cdb411
Merge remote-tracking branch 'origin' into serdar/issue#3502-self-man…
srdtrk May 5, 2023
2efb934
e2e: changed x/params query to fallback behavior
srdtrk May 5, 2023
8e22f05
e2e: changed x/params query to fallback behavior
srdtrk May 5, 2023
222df20
e2e: dropped the fallback behavior
srdtrk May 5, 2023
8825b0d
e2e: trying to use the new gov proposal v1 to change params
srdtrk May 6, 2023
50c8003
e2e: created 'isSelfManagingParams' function
srdtrk May 6, 2023
86dae68
e2e: created fallback behaviour for param update gov proposal
srdtrk May 6, 2023
b8e6098
chore: e2e code cleanup
srdtrk May 6, 2023
1b51575
chore: ran 'gofumpt' in e2e
srdtrk May 6, 2023
7300d40
style(transfer/test): moved success case to top
srdtrk May 16, 2023
50ea74f
style(transfer/test): replaced request with msg
srdtrk May 16, 2023
383cd9d
refactor(transfer): moved MsgUpdateParams' registry to Interface Regi…
srdtrk May 16, 2023
a6b1859
style(transfer/test): ran gofumpt
srdtrk May 16, 2023
0c6fbb7
style(transfer): moved UpdateParams function to the bottom of the file
srdtrk May 16, 2023
557f431
imp(transfer): using 'ibcerrors.ErrInvalidAddress' instead of 'govtyp…
srdtrk May 16, 2023
18b53f6
refactor(transfer/test): used ibctesting constants instead of definin…
srdtrk May 16, 2023
296a140
feat(e2e/transfer): using semver to handle gov prop fallback instead …
srdtrk May 16, 2023
0d5bd67
style(e2e/transfer): renamed 'selfParamFeatureReleases' to 'transferS…
srdtrk May 16, 2023
bd46565
merge: merge remote-tracking branch 'origin' into serdar/issue#3502-s…
srdtrk May 16, 2023
c81bedb
feat(transfer): keeping paramSpace in keeper and removing exported to…
srdtrk May 18, 2023
aa7866d
feat(simapp): reduced the modifications to app.go to only one
srdtrk May 18, 2023
51cdced
fix(transfer/test): updated migration tests
srdtrk May 18, 2023
40f63e2
imp(transfer/test): improved the efficiency and style of the test
srdtrk May 18, 2023
f560320
style(transfer): ran gofumpt
srdtrk May 18, 2023
8cd90eb
merge: remote-tracking branch 'origin' into serdar/issue#3502-self-ma…
srdtrk May 18, 2023
cf03c5b
style(transfer): ParamsKey is now stored via a string rather than bytes
srdtrk May 18, 2023
06cade8
imp(transfer): retired the old validate function, and new one makes m…
srdtrk May 18, 2023
a33610e
style(transfer): ran gofumpt
srdtrk May 18, 2023
9beef82
refactor(transfer): removed the validate function for params as it cu…
srdtrk May 20, 2023
485360e
fix(transfer): refactored to not use validate
srdtrk May 20, 2023
4dcf47a
imp(transfer): GetParams now panics if params are not set
srdtrk May 20, 2023
e73f8c1
imp(transfer/test): added a new test case to test when Params are unset
srdtrk May 20, 2023
3763e9c
style(transfer/test): updated the test messages
srdtrk May 20, 2023
4fef125
merge: remote-tracking branch 'origin' into serdar/issue#3502-self-ma…
srdtrk May 20, 2023
c8fe227
docs(transfer): added tracking issue for removing params_legacy.go
srdtrk May 20, 2023
d6a0dfb
imp(transfer): added a new error type for invalid authority
srdtrk May 22, 2023
3ba800d
style(e2e/transfer): fixed typo
srdtrk May 22, 2023
98b8ba3
style(transfer/test): stopped using field names in test case declaration
srdtrk May 22, 2023
764bedb
style(transfer/test): stopped using field names in test case declaration
srdtrk May 22, 2023
d6496bb
style(transfer/test): renamed test case
srdtrk May 22, 2023
6466de8
imp(transfer): added more info to the error message
srdtrk May 22, 2023
4d90658
style(e2e/transfer): updated ordering of deps
srdtrk May 22, 2023
0d60d6a
imp(transfer/test): reduced the test size
srdtrk May 22, 2023
7813b39
style(transfer): changed the err message for 'ErrInvalidAuthority'
srdtrk May 22, 2023
29b0f93
imp(transfer): removed ErrInvalidAuthority
srdtrk May 22, 2023
e5f3960
style(transfer): using 'len(bz) == 0' instead of 'bz == nil'
srdtrk May 22, 2023
6de4b5e
style(transfer): removed unneeded comment
srdtrk May 22, 2023
948acf8
merge: remote-tracking branch 'origin' into serdar/issue#3502-self-ma…
srdtrk May 22, 2023
4c163f0
imp(transfer): switched back to using 'bz == nil'
srdtrk May 22, 2023
a336e68
revert: '7813b39d7835eec26a3655bcd77587198ae90bea'
srdtrk May 22, 2023
be96b41
revert: "style(transfer): changed the err message for 'ErrInvalidAuth…
srdtrk May 22, 2023
bb83f08
revert: e5f396073d3e08fefe3507036b067a2b6af16cd7
srdtrk May 22, 2023
33807c6
revert: 4c163f0e4a1c6853a1c7a3e0dc4cfad8c91ef282
srdtrk May 22, 2023
c672221
style(transfer): added code comment
srdtrk May 22, 2023
2b425ce
merge: remote-tracking branch 'origin' into serdar/issue#3502-self-ma…
srdtrk May 24, 2023
b63e056
docs(migrations): added migration docs for changes in app.go
srdtrk May 24, 2023
759c1ae
imp(transfer): improved ValidateBasic err message
srdtrk May 24, 2023
db60e4f
style(transfer/test): improved the styling of the test
srdtrk May 24, 2023
3ad8090
style(transfer/test): improved the styling of the test
srdtrk May 24, 2023
9aaf717
docs(transfer): added godoc for UpdateParams method
srdtrk May 24, 2023
97c74b5
style(transfer): removed named return arg
srdtrk May 24, 2023
18c35c8
merge: remote-tracking branch 'origin' into serdar/issue#3502-self-ma…
srdtrk May 24, 2023
73fadd2
merge: remote-tracking branch 'origin' into serdar/issue#3502-self-ma…
srdtrk May 24, 2023
305dc88
imp(e2e/transfer): reduced code duplication
srdtrk May 24, 2023
7d66ac3
style(transfer/test): updated test case names
srdtrk May 24, 2023
04b2591
imp(transfer/test): added whitespace test case
srdtrk May 24, 2023
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
66 changes: 63 additions & 3 deletions docs/apps/transfer/params.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,26 @@ order: 7

The IBC transfer application module contains the following parameters:

| Key | Type | Default Value |
|------------------|------|---------------|
| Name | Type | Default Value |
| ---------------- | ---- | ------------- |
| `SendEnabled` | bool | `true` |
| `ReceiveEnabled` | bool | `true` |

The IBC transfer module stores its parameters in its keeper with the prefix of `0x03`.

## `SendEnabled`

The transfers enabled parameter controls send cross-chain transfer capabilities for all fungible tokens.
The `SendEnabled` parameter controls send cross-chain transfer capabilities for all fungible tokens.

To prevent a single token from being transferred from the chain, set the `SendEnabled` parameter to `true` and then, depending on the Cosmos SDK version, do one of the following:

- For Cosmos SDK v0.46.x or earlier, set the bank module's [`SendEnabled` parameter](https://github.com/cosmos/cosmos-sdk/blob/release/v0.46.x/x/bank/spec/05_params.md#sendenabled) for the denomination to `false`.
- For Cosmos SDK versions above v0.46.x, set the bank module's `SendEnabled` entry for the denomination to `false` using `MsgSetSendEnabled` as a governance proposal.

::: warning
Doing so will prevent the token from being transferred between any accounts in the blockchain.
:::

## `ReceiveEnabled`

The transfers enabled parameter controls receive cross-chain transfer capabilities for all fungible tokens.
Expand All @@ -28,3 +34,57 @@ To prevent a single token from being transferred to the chain, set the `ReceiveE

- For Cosmos SDK v0.46.x or earlier, set the bank module's [`SendEnabled` parameter](https://github.com/cosmos/cosmos-sdk/blob/release/v0.46.x/x/bank/spec/05_params.md#sendenabled) for the denomination to `false`.
- For Cosmos SDK versions above v0.46.x, set the bank module's `SendEnabled` entry for the denomination to `false` using `MsgSetSendEnabled` as a governance proposal.

::: warning
Doing so will prevent the token from being transferred between any accounts in the blockchain.
:::

## Queries
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add this a Client section like we have for ICA? I am also adding one for transfer in this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

In another docs related PR?


Current parameter values can be queried via a query message.

<!-- Turn it into a github code snippet in docusaurus: -->

```protobuf
// proto/ibc/applications/transfer/v1/query.proto

// QueryParamsRequest is the request type for the Query/Params RPC method.
message QueryParamsRequest {}

// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
// params defines the parameters of the module.
Params params = 1;
}
```

To execute the query in `simd`, you use the following command:

```bash
simd query ibc-transfer params
```

## Changing Parameters

To change the parameter values, you must make a governance proposal that executes the `MsgUpdateParams` message.

<!-- Turn it into a github code snippet in docusaurus: -->

```protobuf
// proto/ibc/applications/transfer/v1/tx.proto

// MsgUpdateParams is the Msg/UpdateParams request type.
message MsgUpdateParams {
// authority is the address that controls the module (defaults to x/gov unless overwritten).
string authority = 1;

// params defines the transfer parameters to update.
//
// NOTE: All parameters must be supplied.
Params params = 2 [(gogoproto.nullable) = false];
}

// MsgUpdateParamsResponse defines the response structure for executing a
// MsgUpdateParams message.
message MsgUpdateParamsResponse {}
```
24 changes: 20 additions & 4 deletions docs/migrations/v7-to-v8.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ This guide provides instructions for migrating to version `v8.0.0` of ibc-go.
There are four sections based on the four potential user groups of this document:

- [Migrating from v7 to v8](#migrating-from-v7-to-v8)
- [Chains](#chains)
- [IBC Apps](#ibc-apps)
- [Relayers](#relayers)
- [IBC Light Clients](#ibc-light-clients)
- [Chains](#chains)
- [IBC Apps](#ibc-apps)
- [Relayers](#relayers)
- [IBC Light Clients](#ibc-light-clients)

**Note:** ibc-go supports golang semantic versioning and therefore all imports must be updated on major version releases.

Expand All @@ -31,6 +31,22 @@ TODO: https://github.com/cosmos/ibc-go/pull/3505 (extra parameter added to trans
)
```

- You should pass the `authority` to the ibctransfer keeper. ([#3520](https://github.com/cosmos/ibc-go/pull/3520)) See [diff](https://github.com/cosmos/ibc-go/pull/3520/files#diff-d18972debee5e64f16e40807b2ae112ddbe609504a93ea5e1c80a5d489c3a08a). ([#3553](https://github.com/cosmos/ibc-go/pull/3553))

```diff
// app.go

// Create Transfer Keeper and pass IBCFeeKeeper as expected Channel and PortKeeper
// since fee middleware will wrap the IBCKeeper for underlying application.
app.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName),
app.IBCFeeKeeper, // ISC4 Wrapper: fee IBC middleware
app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper,
app.AccountKeeper, app.BankKeeper, scopedTransferKeeper,
+ authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
```

## IBC Apps

TODO: https://github.com/cosmos/ibc-go/pull/3303
Expand Down
79 changes: 47 additions & 32 deletions e2e/tests/transfer/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package transfer

import (
"context"
"strconv"
"testing"
"time"

"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
paramsproposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"

"github.com/strangelove-ventures/interchaintest/v7/ibc"
test "github.com/strangelove-ventures/interchaintest/v7/testutil"
Expand All @@ -17,7 +18,6 @@ import (
"github.com/cosmos/ibc-go/e2e/semverutil"
"github.com/cosmos/ibc-go/e2e/testsuite"
"github.com/cosmos/ibc-go/e2e/testvalues"
transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
ibctesting "github.com/cosmos/ibc-go/v7/testing"
)

Expand All @@ -29,34 +29,25 @@ type TransferTestSuite struct {
testsuite.E2ETestSuite
}

// transferSelfParamsFeatureReleases represents the releases the transfer module started managing its own params.
var transferSelfParamsFeatureReleases = semverutil.FeatureReleases{
MajorVersion: "v8",
}
Copy link
Member

Choose a reason for hiding this comment

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

feature release matrices are being grouped together in test values in #3558, just noting this for resolving merge conflicts


// QueryTransferSendEnabledParam queries the on-chain send enabled param for the transfer module
func (s *TransferTestSuite) QueryTransferSendEnabledParam(ctx context.Context, chain ibc.Chain) bool {
srdtrk marked this conversation as resolved.
Show resolved Hide resolved
queryClient := s.GetChainGRCPClients(chain).ParamsQueryClient
res, err := queryClient.Params(ctx, &paramsproposaltypes.QueryParamsRequest{
Subspace: transfertypes.StoreKey,
Key: string(transfertypes.KeySendEnabled),
})
s.Require().NoError(err)

enabled, err := strconv.ParseBool(res.Param.Value)
queryClient := s.GetChainGRCPClients(chain).TransferQueryClient
res, err := queryClient.Params(ctx, &transfertypes.QueryParamsRequest{})
s.Require().NoError(err)

return enabled
return res.Params.SendEnabled
}

// QueryTransferReceiveEnabledParam queries the on-chain receive enabled param for the transfer module
func (s *TransferTestSuite) QueryTransferReceiveEnabledParam(ctx context.Context, chain ibc.Chain) bool {
queryClient := s.GetChainGRCPClients(chain).ParamsQueryClient
res, err := queryClient.Params(ctx, &paramsproposaltypes.QueryParamsRequest{
Subspace: transfertypes.StoreKey,
Key: string(transfertypes.KeyReceiveEnabled),
})
s.Require().NoError(err)

enabled, err := strconv.ParseBool(res.Param.Value)
queryClient := s.GetChainGRCPClients(chain).TransferQueryClient
res, err := queryClient.Params(ctx, &transfertypes.QueryParamsRequest{})
s.Require().NoError(err)

return enabled
return res.Params.ReceiveEnabled
}

// TestMsgTransfer_Succeeds_Nonincentivized will test sending successful IBC transfers from chainA to chainB.
Expand Down Expand Up @@ -258,6 +249,13 @@ func (s *TransferTestSuite) TestSendEnabledParam() {
chainBWallet := s.CreateUserOnChainB(ctx, testvalues.StartingTokenAmount)
chainBAddress := chainBWallet.FormattedAddress()

chainAVersion := chainA.Config().Images[0].Version
isSelfManagingParams := transferSelfParamsFeatureReleases.IsSupported(chainAVersion)

govModuleAddress, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA)
s.Require().NoError(err)
s.Require().NotNil(govModuleAddress)

s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks")

t.Run("ensure transfer sending is enabled", func(t *testing.T) {
Expand All @@ -271,12 +269,17 @@ func (s *TransferTestSuite) TestSendEnabledParam() {
})

t.Run("change send enabled parameter to disabled", func(t *testing.T) {
changes := []paramsproposaltypes.ParamChange{
paramsproposaltypes.NewParamChange(transfertypes.StoreKey, string(transfertypes.KeySendEnabled), "false"),
}
if isSelfManagingParams {
srdtrk marked this conversation as resolved.
Show resolved Hide resolved
msg := transfertypes.NewMsgUpdateParams(govModuleAddress.String(), transfertypes.NewParams(false, true))
s.ExecuteGovProposalV1(ctx, msg, chainA, chainAWallet, 1)
} else {
changes := []paramsproposaltypes.ParamChange{
paramsproposaltypes.NewParamChange(transfertypes.StoreKey, string(transfertypes.KeySendEnabled), "false"),
}

proposal := paramsproposaltypes.NewParameterChangeProposal(ibctesting.Title, ibctesting.Description, changes)
s.ExecuteGovProposal(ctx, chainA, chainAWallet, proposal)
proposal := paramsproposaltypes.NewParameterChangeProposal(ibctesting.Title, ibctesting.Description, changes)
s.ExecuteGovProposal(ctx, chainA, chainAWallet, proposal)
}
})

t.Run("ensure transfer params are disabled", func(t *testing.T) {
Expand Down Expand Up @@ -309,6 +312,13 @@ func (s *TransferTestSuite) TestReceiveEnabledParam() {
chainBAddress = chainBWallet.FormattedAddress()
)

chainAVersion := chainA.Config().Images[0].Version
isSelfManagingParams := transferSelfParamsFeatureReleases.IsSupported(chainAVersion)

govModuleAddress, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA)
s.Require().NoError(err)
s.Require().NotNil(govModuleAddress)

s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks")

t.Run("ensure transfer receive is enabled", func(t *testing.T) {
Expand Down Expand Up @@ -350,12 +360,17 @@ func (s *TransferTestSuite) TestReceiveEnabledParam() {
})

t.Run("change receive enabled parameter to disabled ", func(t *testing.T) {
changes := []paramsproposaltypes.ParamChange{
paramsproposaltypes.NewParamChange(transfertypes.StoreKey, string(transfertypes.KeyReceiveEnabled), "false"),
}
if isSelfManagingParams {
msg := transfertypes.NewMsgUpdateParams(govModuleAddress.String(), transfertypes.NewParams(false, false))
s.ExecuteGovProposalV1(ctx, msg, chainA, chainAWallet, 1)
} else {
changes := []paramsproposaltypes.ParamChange{
paramsproposaltypes.NewParamChange(transfertypes.StoreKey, string(transfertypes.KeyReceiveEnabled), "false"),
}

proposal := paramsproposaltypes.NewParameterChangeProposal(ibctesting.Title, ibctesting.Description, changes)
s.ExecuteGovProposal(ctx, chainA, chainAWallet, proposal)
proposal := paramsproposaltypes.NewParameterChangeProposal(ibctesting.Title, ibctesting.Description, changes)
s.ExecuteGovProposal(ctx, chainA, chainAWallet, proposal)
}
})

t.Run("ensure transfer params are disabled", func(t *testing.T) {
Expand Down
71 changes: 53 additions & 18 deletions modules/apps/transfer/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"

capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"

"github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
Expand All @@ -22,47 +21,64 @@ import (

// Keeper defines the IBC fungible transfer keeper
type Keeper struct {
storeKey storetypes.StoreKey
cdc codec.BinaryCodec
paramSpace paramtypes.Subspace
storeKey storetypes.StoreKey
cdc codec.BinaryCodec
legacySubspace paramtypes.Subspace
crodriguezvega marked this conversation as resolved.
Show resolved Hide resolved

ics4Wrapper porttypes.ICS4Wrapper
channelKeeper types.ChannelKeeper
portKeeper types.PortKeeper
authKeeper types.AccountKeeper
bankKeeper types.BankKeeper
scopedKeeper exported.ScopedKeeper

// the address capable of executing a MsgUpdateParams message. Typically, this
// should be the x/gov module account.
authority string
}

// NewKeeper creates a new IBC transfer Keeper instance
func NewKeeper(
cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace paramtypes.Subspace,
ics4Wrapper porttypes.ICS4Wrapper, channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper,
authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, scopedKeeper exported.ScopedKeeper,
cdc codec.BinaryCodec,
key storetypes.StoreKey,
legacySubspace paramtypes.Subspace,
ics4Wrapper porttypes.ICS4Wrapper,
channelKeeper types.ChannelKeeper,
portKeeper types.PortKeeper,
authKeeper types.AccountKeeper,
bankKeeper types.BankKeeper,
scopedKeeper exported.ScopedKeeper,
authority string,
) Keeper {
// ensure ibc transfer module account is set
if addr := authKeeper.GetModuleAddress(types.ModuleName); addr == nil {
panic("the IBC transfer module account has not been set")
}

// set KeyTable if it has not already been set
if !paramSpace.HasKeyTable() {
paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable())
if !legacySubspace.HasKeyTable() {
legacySubspace = legacySubspace.WithKeyTable(types.ParamKeyTable())
}

return Keeper{
cdc: cdc,
storeKey: key,
paramSpace: paramSpace,
ics4Wrapper: ics4Wrapper,
channelKeeper: channelKeeper,
portKeeper: portKeeper,
authKeeper: authKeeper,
bankKeeper: bankKeeper,
scopedKeeper: scopedKeeper,
cdc: cdc,
storeKey: key,
legacySubspace: legacySubspace,
ics4Wrapper: ics4Wrapper,
channelKeeper: channelKeeper,
portKeeper: portKeeper,
authKeeper: authKeeper,
bankKeeper: bankKeeper,
scopedKeeper: scopedKeeper,
authority: authority,
}
}

// GetAuthority returns the transfer module's authority.
func (k Keeper) GetAuthority() string {
return k.authority
}

// Logger returns a module-specific logger.
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("module", "x/"+exported.ModuleName+"-"+types.ModuleName)
Expand Down Expand Up @@ -93,6 +109,25 @@ func (k Keeper) SetPort(ctx sdk.Context, portID string) {
store.Set(types.PortKey, []byte(portID))
}

// GetParams returns the current transfer module parameters.
func (k Keeper) GetParams(ctx sdk.Context) (p types.Params) {
srdtrk marked this conversation as resolved.
Show resolved Hide resolved
store := ctx.KVStore(k.storeKey)
bz := store.Get([]byte(types.ParamsKey))
if bz == nil { // only panics on unset params and not on empty params
panic("ibc transfer params are not set in store")
crodriguezvega marked this conversation as resolved.
Show resolved Hide resolved
}

k.cdc.MustUnmarshal(bz, &p)
return p
}

// SetParams sets the transfer module parameters.
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
store := ctx.KVStore(k.storeKey)
bz := k.cdc.MustMarshal(&params)
store.Set([]byte(types.ParamsKey), bz)
}

// GetDenomTrace retreives the full identifiers trace and base denomination from the store.
func (k Keeper) GetDenomTrace(ctx sdk.Context, denomTraceHash tmbytes.HexBytes) (types.DenomTrace, bool) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.DenomTraceKey)
Expand Down
Loading