From e3704c683eb171a4c74658af631a1b7a6d035c4d Mon Sep 17 00:00:00 2001 From: Sean King Date: Wed, 8 Sep 2021 13:29:49 +0200 Subject: [PATCH 1/4] feat: #258 Register Counterparty Address (#376) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: adding MsgServer for RegisterCounterPartyAddress & EscrowPacketFree * test: adding test for ValidateBasic * fix: removing validate basic check * fix: removing empty file * Update modules/apps/29-fee/keeper/msg_server.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * Update modules/apps/29-fee/types/msgs.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * Update modules/apps/29-fee/types/keys.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * Update modules/apps/29-fee/keeper/keeper.go Co-authored-by: Aditya * fix: fixing typos, variable names, comments * fix: updating import comments * test: adding test for KeyRelayerAddress * update: comments & key_test * Update modules/apps/29-fee/keeper/msg_server.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * fix: error message * docs: updating RegisterCounterpartyAddress fn description Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> Co-authored-by: Aditya --- docs/ibc/proto-docs.md | 24 ++-- modules/apps/29-fee/client/cli/cli.go | 4 +- modules/apps/29-fee/keeper/keeper.go | 37 +++-- modules/apps/29-fee/keeper/keeper_test.go | 17 +-- modules/apps/29-fee/keeper/msg_server.go | 33 ++++- modules/apps/29-fee/types/expected_keepers.go | 5 +- modules/apps/29-fee/types/keys.go | 14 ++ modules/apps/29-fee/types/keys_test.go | 19 +++ modules/apps/29-fee/types/msgs.go | 38 +++-- modules/apps/29-fee/types/msgs_test.go | 38 ++--- modules/apps/29-fee/types/tx.pb.go | 132 +++++++++--------- proto/ibc/applications/fee/v1/tx.proto | 6 +- 12 files changed, 222 insertions(+), 145 deletions(-) create mode 100644 modules/apps/29-fee/types/keys_test.go diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index f571101508f..ff79278b80a 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -49,8 +49,8 @@ - [ibc/applications/fee/v1/tx.proto](#ibc/applications/fee/v1/tx.proto) - [MsgEscrowPacketFee](#ibc.applications.fee.v1.MsgEscrowPacketFee) - [MsgEscrowPacketFeeResponse](#ibc.applications.fee.v1.MsgEscrowPacketFeeResponse) - - [MsgRegisterCounterPartyAddressResponse](#ibc.applications.fee.v1.MsgRegisterCounterPartyAddressResponse) - [MsgRegisterCounterpartyAddress](#ibc.applications.fee.v1.MsgRegisterCounterpartyAddress) + - [MsgRegisterCounterpartyAddressResponse](#ibc.applications.fee.v1.MsgRegisterCounterpartyAddressResponse) - [Msg](#ibc.applications.fee.v1.Msg) @@ -915,16 +915,6 @@ MsgEscrowPacketFeeResponse defines the response type for Msg/EscrowPacketFee - - -### MsgRegisterCounterPartyAddressResponse -MsgRegisterCounterPartyAddressResponse defines the Msg/RegisterCounteryPartyAddress response type - - - - - - ### MsgRegisterCounterpartyAddress @@ -940,6 +930,16 @@ MsgRegisterCounterpartyAddress is the request type for registering the counter p + + + +### MsgRegisterCounterpartyAddressResponse +MsgRegisterCounterpartyAddressResponse defines the Msg/RegisterCounterypartyAddress response type + + + + + @@ -954,7 +954,7 @@ Msg defines the ibc/fee Msg service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `RegisterCounterPartyAddress` | [MsgRegisterCounterpartyAddress](#ibc.applications.fee.v1.MsgRegisterCounterpartyAddress) | [MsgRegisterCounterPartyAddressResponse](#ibc.applications.fee.v1.MsgRegisterCounterPartyAddressResponse) | RegisterCounterpartyAddress defines a rpc handler method for MsgRegisterCounterpartyAddress RegisterCounterpartyAddress is called by the relayer on each channelEnd and allows them to specify their counterparty address before relaying. This ensures they will be properly compensated for forward relaying since destination chain must send back relayer's source address (counterparty address) in acknowledgement. This function may be called more than once by a relayer, in which case, latest counterparty address is always used. | | +| `RegisterCounterpartyAddress` | [MsgRegisterCounterpartyAddress](#ibc.applications.fee.v1.MsgRegisterCounterpartyAddress) | [MsgRegisterCounterpartyAddressResponse](#ibc.applications.fee.v1.MsgRegisterCounterpartyAddressResponse) | RegisterCounterpartyAddress defines a rpc handler method for MsgRegisterCounterpartyAddress RegisterCounterpartyAddress is called by the relayer on each channelEnd and allows them to specify their counterparty address before relaying. This ensures they will be properly compensated for forward relaying since destination chain must send back relayer's source address (counterparty address) in acknowledgement. This function may be called more than once by a relayer, in which case, latest counterparty address is always used. | | | `EscrowPacketFee` | [MsgEscrowPacketFee](#ibc.applications.fee.v1.MsgEscrowPacketFee) | [MsgEscrowPacketFeeResponse](#ibc.applications.fee.v1.MsgEscrowPacketFeeResponse) | EscrowPacketFee defines a rpc handler method for MsgEscrowPacketFee EscrowPacketFee is an open callback that may be called by any module/user that wishes to escrow funds in order to incentivize the relaying of the given packet. | | diff --git a/modules/apps/29-fee/client/cli/cli.go b/modules/apps/29-fee/client/cli/cli.go index fb8b9db8320..c7be975a534 100644 --- a/modules/apps/29-fee/client/cli/cli.go +++ b/modules/apps/29-fee/client/cli/cli.go @@ -1,9 +1,9 @@ package cli import ( - "github.com/spf13/cobra" - + // external library imports "github.com/cosmos/cosmos-sdk/client" + "github.com/spf13/cobra" ) // GetQueryCmd returns the query commands for 29-fee diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index db304dd4cf9..a8319944613 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -1,15 +1,15 @@ package keeper -/* import ( - "github.com/tendermint/tendermint/libs/log" - + // external library imports "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/cosmos/ibc-go/modules/apps/transfer/types" + "github.com/tendermint/tendermint/libs/log" + + // ibc-go imports + "github.com/cosmos/ibc-go/modules/apps/29-fee/types" host "github.com/cosmos/ibc-go/modules/core/24-host" ) @@ -25,7 +25,6 @@ type Keeper struct { scopedKeeper capabilitykeeper.ScopedKeeper } - // NewKeeper creates a new 29-fee Keeper instance func NewKeeper( cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace, @@ -49,6 +48,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+host.ModuleName+"-"+types.ModuleName) } +/* // IsBound checks if the transfer module is already bound to the desired port func (k Keeper) IsBound(ctx sdk.Context, portID string) bool { _, ok := k.scopedKeeper.GetCapability(ctx, host.PortPath(portID)) @@ -62,12 +62,6 @@ func (k Keeper) BindPort(ctx sdk.Context, portID string) error { return k.ClaimCapability(ctx, cap, host.PortPath(portID)) } -// GetPort returns the portID for the transfer module. Used in ExportGenesis -func (k Keeper) GetPort(ctx sdk.Context) string { - store := ctx.KVStore(k.storeKey) - return string(store.Get(types.PortKey)) -} - // SetPort sets the portID for the transfer module. Used in InitGenesis func (k Keeper) SetPort(ctx sdk.Context, portID string) { store := ctx.KVStore(k.storeKey) @@ -85,3 +79,22 @@ func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability return k.scopedKeeper.ClaimCapability(ctx, cap, name) } */ + +// SetCounterpartyAddress maps the destination chain relayer address to the source relayer address +// The receiving chain must store the mapping from: address -> counterpartyAddress for the given channel +func (k Keeper) SetCounterpartyAddress(ctx sdk.Context, address, counterpartyAddress string) { + store := ctx.KVStore(k.storeKey) + store.Set(types.KeyRelayerAddress(address), []byte(counterpartyAddress)) +} + +// GetCounterpartyAddress gets the relayer counterparty address given a destination relayer address +func (k Keeper) GetCounterpartyAddress(ctx sdk.Context, address sdk.AccAddress) (sdk.AccAddress, bool) { + store := ctx.KVStore(k.storeKey) + key := types.KeyRelayerAddress(address.String()) + + if !store.Has(key) { + return []byte{}, false + } + + return store.Get(key), true +} diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index b355ccfe847..11c1768a1cf 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -1,15 +1,13 @@ package keeper_test -/* import ( + // standard library importsn "testing" + // external library imports "github.com/stretchr/testify/suite" - "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/baseapp" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/ibc-go/modules/apps/transfer/types" + // ibc-go imports ibctesting "github.com/cosmos/ibc-go/testing" ) @@ -31,15 +29,6 @@ func (suite *KeeperTestSuite) SetupTest() { suite.chainC = suite.coordinator.GetChain(ibctesting.GetChainID(2)) } -func NewFeePath(chainA, chainB *ibctesting.TestChain) *ibctesting.Path { - path := ibctesting.NewPath(chainA, chainB) - path.EndpointA.ChannelConfig.PortID = ibctesting.FeePort - path.EndpointB.ChannelConfig.PortID = ibctesting.FeePort - - return path -} - func TestKeeperTestSuite(t *testing.T) { suite.Run(t, new(KeeperTestSuite)) } -*/ diff --git a/modules/apps/29-fee/keeper/msg_server.go b/modules/apps/29-fee/keeper/msg_server.go index 2194eed8a68..54b0dadbc37 100644 --- a/modules/apps/29-fee/keeper/msg_server.go +++ b/modules/apps/29-fee/keeper/msg_server.go @@ -1,4 +1,33 @@ package keeper -// TODO -//var _ types.MsgServer = Keeper{} +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/ibc-go/modules/apps/29-fee/types" +) + +var _ types.MsgServer = Keeper{} + +// RegisterCounterpartyAddress is called by the relayer on each channelEnd and allows them to specify their counterparty address before relaying +// This ensures they will be properly compensated for forward relaying on the source chain since the destination chain must send back relayer's source address (counterparty address) in acknowledgement +// This function may be called more than once by relayers, in which case, the previous counterparty address will be overwritten by the new counterparty address +func (k Keeper) RegisterCounterpartyAddress(goCtx context.Context, msg *types.MsgRegisterCounterpartyAddress) (*types.MsgRegisterCounterpartyAddressResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + k.SetCounterpartyAddress( + ctx, msg.Address, msg.CounterpartyAddress, + ) + + k.Logger(ctx).Info("Registering counterparty address for relayer.", "Address:", msg.Address, "Counterparty Address:", msg.CounterpartyAddress) + + return &types.MsgRegisterCounterpartyAddressResponse{}, nil +} + +// EscrowPacketFee defines a rpc handler method for MsgEscrowPacketFee +// EscrowPacketFee is an open callback that may be called by any module/user that wishes to escrow funds in order to +// incentivize the relaying of the given packet. +func (k Keeper) EscrowPacketFee(goCtx context.Context, msg *types.MsgEscrowPacketFee) (*types.MsgEscrowPacketFeeResponse, error) { + return &types.MsgEscrowPacketFeeResponse{}, nil +} diff --git a/modules/apps/29-fee/types/expected_keepers.go b/modules/apps/29-fee/types/expected_keepers.go index 68513b476a5..a17a443623d 100644 --- a/modules/apps/29-fee/types/expected_keepers.go +++ b/modules/apps/29-fee/types/expected_keepers.go @@ -1,10 +1,12 @@ package types -/* import ( + //external library imports sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + + // ibc-go imports connectiontypes "github.com/cosmos/ibc-go/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" ibcexported "github.com/cosmos/ibc-go/modules/core/exported" @@ -47,4 +49,3 @@ type ConnectionKeeper interface { type PortKeeper interface { BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability } -*/ diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index 769113f504a..5d1057dccca 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -1,5 +1,8 @@ package types +// standard library imports +import "fmt" + const ( // ModuleName defines the 29-fee name ModuleName = "ibcfee" @@ -7,9 +10,20 @@ const ( // StoreKey is the store key string for IBC transfer StoreKey = ModuleName + // PortKey is the port id that is wrapped by fee middleware + PortKey = "feetransfer" + // RouterKey is the message route for IBC transfer RouterKey = ModuleName // QuerierRoute is the querier route for IBC transfer QuerierRoute = ModuleName + + // RelayerAddressKeyPrefix is the key prefix for relayer address mapping + RelayerAddressKeyPrefix = "relayerAddress" ) + +// KeyRelayerAddress returns the key for relayer address -> counteryparty address mapping +func KeyRelayerAddress(address string) []byte { + return []byte(fmt.Sprintf("%s/%s", RelayerAddressKeyPrefix, address)) +} diff --git a/modules/apps/29-fee/types/keys_test.go b/modules/apps/29-fee/types/keys_test.go new file mode 100644 index 00000000000..312188c5e21 --- /dev/null +++ b/modules/apps/29-fee/types/keys_test.go @@ -0,0 +1,19 @@ +package types_test + +import ( + fmt "fmt" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/ibc-go/modules/apps/29-fee/types" +) + +func TestKeyRelayerAddress(t *testing.T) { + var ( + relayerAddress = "relayer_address" + ) + + key := types.KeyRelayerAddress(relayerAddress) + require.Equal(t, string(key), fmt.Sprintf("%s/relayer_address", types.RelayerAddressKeyPrefix)) +} diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index 4df0e84ff1a..6d1a92ef945 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -1,32 +1,44 @@ package types -/* import ( - "strings" - + // external library imports sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" - host "github.com/cosmos/ibc-go/modules/core/24-host" ) -// NewMsg -func NewMsg() *Msg { - return &Msg{ +// msg types +const ( + TypeMsgRegisterCounterpartyAddress = "registerCounterpartyAddress" +) + +// NewMsgRegisterCounterpartyAddress creates a new instance of MsgRegisterCounterpartyAddress +func NewMsgRegisterCounterpartyAddress(address, counterpartyAddress string) *MsgRegisterCounterpartyAddress { + return &MsgRegisterCounterpartyAddress{ + Address: address, + CounterpartyAddress: counterpartyAddress, } } -// ValidateBasic performs a basic check of the Msg fields. -func (msg Msg) ValidateBasic() error { +// ValidateBasic performs a basic check of the MsgRegisterCounterpartyAddress fields +func (msg MsgRegisterCounterpartyAddress) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Address) + if err != nil { + return sdkerrors.Wrap(err, "failed to convert msg.Address into sdk.AccAddress") + } + + _, err = sdk.AccAddressFromBech32(msg.CounterpartyAddress) + if err != nil { + return sdkerrors.Wrap(err, "failed to convert msg.CounterpartyAddress into sdk.AccAddress") + } + return nil } // GetSigners implements sdk.Msg -func (msg MsgTransfer) GetSigners() []sdk.AccAddress { - signer, err := sdk.AccAddressFromBech32(msg.Sender) +func (msg MsgRegisterCounterpartyAddress) GetSigners() []sdk.AccAddress { + signer, err := sdk.AccAddressFromBech32(msg.Address) if err != nil { panic(err) } return []sdk.AccAddress{signer} } -*/ diff --git a/modules/apps/29-fee/types/msgs_test.go b/modules/apps/29-fee/types/msgs_test.go index 132bde75752..d29073f75a7 100644 --- a/modules/apps/29-fee/types/msgs_test.go +++ b/modules/apps/29-fee/types/msgs_test.go @@ -1,36 +1,36 @@ package types -/* import ( - "fmt" "testing" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/secp256k1" +) - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" - sdk "github.com/cosmos/cosmos-sdk/types" +var ( + validAddr = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() + invalidAddr = "invalid_address" ) -func (suite *TypesTestSuite) TestMsgValidateBasic() { +// TestMsgTransferValidation tests ValidateBasic for MsgTransfer +func TestMsgRegisterCountepartyAddressValidation(t *testing.T) { testCases := []struct { name string - msg *types.Msg + msg *MsgRegisterCounterpartyAddress expPass bool }{ - {"", types.NewMsg(), true}, + {"validate with correct sdk.AccAddress", NewMsgRegisterCounterpartyAddress(validAddr, validAddr), true}, + {"validate with incorrect destination relayer address", NewMsgRegisterCounterpartyAddress(invalidAddr, validAddr), false}, + {"validate with incorrect counterparty relayer address", NewMsgRegisterCounterpartyAddress(validAddr, invalidAddr), false}, } - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - err := tc.msg.ValidateBasic() - if tc.expPass { - suite.Require().NoError(err) - } else { - suite.Require().Error(err) - } - }) + for i, tc := range testCases { + err := tc.msg.ValidateBasic() + if tc.expPass { + require.NoError(t, err, "valid test case %d failed: %s", i, tc.name) + } else { + require.Error(t, err, "invalid test case %d passed: %s", i, tc.name) + } } } -*/ diff --git a/modules/apps/29-fee/types/tx.pb.go b/modules/apps/29-fee/types/tx.pb.go index cb46345e9f1..c9fb330d12b 100644 --- a/modules/apps/29-fee/types/tx.pb.go +++ b/modules/apps/29-fee/types/tx.pb.go @@ -68,24 +68,24 @@ func (m *MsgRegisterCounterpartyAddress) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRegisterCounterpartyAddress proto.InternalMessageInfo -// MsgRegisterCounterPartyAddressResponse defines the Msg/RegisterCounteryPartyAddress response type -type MsgRegisterCounterPartyAddressResponse struct { +// MsgRegisterCounterpartyAddressResponse defines the Msg/RegisterCounterypartyAddress response type +type MsgRegisterCounterpartyAddressResponse struct { } -func (m *MsgRegisterCounterPartyAddressResponse) Reset() { - *m = MsgRegisterCounterPartyAddressResponse{} +func (m *MsgRegisterCounterpartyAddressResponse) Reset() { + *m = MsgRegisterCounterpartyAddressResponse{} } -func (m *MsgRegisterCounterPartyAddressResponse) String() string { return proto.CompactTextString(m) } -func (*MsgRegisterCounterPartyAddressResponse) ProtoMessage() {} -func (*MsgRegisterCounterPartyAddressResponse) Descriptor() ([]byte, []int) { +func (m *MsgRegisterCounterpartyAddressResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterCounterpartyAddressResponse) ProtoMessage() {} +func (*MsgRegisterCounterpartyAddressResponse) Descriptor() ([]byte, []int) { return fileDescriptor_05c93128649f1b96, []int{1} } -func (m *MsgRegisterCounterPartyAddressResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgRegisterCounterpartyAddressResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgRegisterCounterPartyAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgRegisterCounterpartyAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgRegisterCounterPartyAddressResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgRegisterCounterpartyAddressResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -95,17 +95,17 @@ func (m *MsgRegisterCounterPartyAddressResponse) XXX_Marshal(b []byte, determini return b[:n], nil } } -func (m *MsgRegisterCounterPartyAddressResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRegisterCounterPartyAddressResponse.Merge(m, src) +func (m *MsgRegisterCounterpartyAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterCounterpartyAddressResponse.Merge(m, src) } -func (m *MsgRegisterCounterPartyAddressResponse) XXX_Size() int { +func (m *MsgRegisterCounterpartyAddressResponse) XXX_Size() int { return m.Size() } -func (m *MsgRegisterCounterPartyAddressResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRegisterCounterPartyAddressResponse.DiscardUnknown(m) +func (m *MsgRegisterCounterpartyAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterCounterpartyAddressResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgRegisterCounterPartyAddressResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgRegisterCounterpartyAddressResponse proto.InternalMessageInfo // MsgEscrowPacketFee defines the request type EscrowPacketFee RPC type MsgEscrowPacketFee struct { @@ -185,7 +185,7 @@ var xxx_messageInfo_MsgEscrowPacketFeeResponse proto.InternalMessageInfo func init() { proto.RegisterType((*MsgRegisterCounterpartyAddress)(nil), "ibc.applications.fee.v1.MsgRegisterCounterpartyAddress") - proto.RegisterType((*MsgRegisterCounterPartyAddressResponse)(nil), "ibc.applications.fee.v1.MsgRegisterCounterPartyAddressResponse") + proto.RegisterType((*MsgRegisterCounterpartyAddressResponse)(nil), "ibc.applications.fee.v1.MsgRegisterCounterpartyAddressResponse") proto.RegisterType((*MsgEscrowPacketFee)(nil), "ibc.applications.fee.v1.MsgEscrowPacketFee") proto.RegisterType((*MsgEscrowPacketFeeResponse)(nil), "ibc.applications.fee.v1.MsgEscrowPacketFeeResponse") } @@ -193,36 +193,36 @@ func init() { func init() { proto.RegisterFile("ibc/applications/fee/v1/tx.proto", fileDescriptor_05c93128649f1b96) } var fileDescriptor_05c93128649f1b96 = []byte{ - // 454 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xcf, 0x6b, 0xd4, 0x40, + // 451 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x41, 0x6b, 0xd4, 0x40, 0x14, 0xc7, 0x93, 0x16, 0xb4, 0x1d, 0x0f, 0xc2, 0xb4, 0x60, 0x49, 0x25, 0xa9, 0x39, 0xc8, 0x82, - 0x36, 0x43, 0xb7, 0x07, 0xb1, 0x17, 0x71, 0x45, 0x41, 0x70, 0xa1, 0xe4, 0xe8, 0xa5, 0x4c, 0x26, - 0x6f, 0xa7, 0x83, 0xd9, 0x4c, 0x98, 0x37, 0xbb, 0xba, 0x82, 0x77, 0x8f, 0x1e, 0x04, 0x3d, 0xf6, - 0xdf, 0xf0, 0x3f, 0xf0, 0xd8, 0xa3, 0xa7, 0x22, 0xbb, 0x17, 0xcf, 0xfd, 0x0b, 0x64, 0x36, 0xdd, - 0x12, 0xba, 0x3f, 0xa0, 0xb7, 0x37, 0x99, 0xcf, 0xf7, 0xcd, 0xfb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0xec, + 0xc9, 0x28, 0x4b, 0x84, 0x1e, 0x32, 0xa1, 0x71, 0xa8, 0x91, 0xa9, 0x4c, 0xec, 0x4b, 0xcd, 0x86, + 0x3a, 0x1f, 0x15, 0x80, 0x6e, 0x65, 0x90, 0x75, 0x1f, 0xef, 0xbb, 0x6d, 0xb1, 0x93, 0x0a, 0x30, + 0xbb, 0x31, 0x5f, 0x85, 0xc3, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x9e, 0xf3, 0xe6, 0xf1, 0xa3, + 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -242,7 +242,7 @@ type MsgClient interface { // counterparty address before relaying. This ensures they will be properly compensated for forward relaying since // destination chain must send back relayer's source address (counterparty address) in acknowledgement. This function // may be called more than once by a relayer, in which case, latest counterparty address is always used. - RegisterCounterPartyAddress(ctx context.Context, in *MsgRegisterCounterpartyAddress, opts ...grpc.CallOption) (*MsgRegisterCounterPartyAddressResponse, error) + RegisterCounterpartyAddress(ctx context.Context, in *MsgRegisterCounterpartyAddress, opts ...grpc.CallOption) (*MsgRegisterCounterpartyAddressResponse, error) // EscrowPacketFee defines a rpc handler method for MsgEscrowPacketFee // EscrowPacketFee is an open callback that may be called by any module/user that wishes to escrow funds in order to // incentivize the relaying of the given packet. @@ -257,9 +257,9 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) RegisterCounterPartyAddress(ctx context.Context, in *MsgRegisterCounterpartyAddress, opts ...grpc.CallOption) (*MsgRegisterCounterPartyAddressResponse, error) { - out := new(MsgRegisterCounterPartyAddressResponse) - err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Msg/RegisterCounterPartyAddress", in, out, opts...) +func (c *msgClient) RegisterCounterpartyAddress(ctx context.Context, in *MsgRegisterCounterpartyAddress, opts ...grpc.CallOption) (*MsgRegisterCounterpartyAddressResponse, error) { + out := new(MsgRegisterCounterpartyAddressResponse) + err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Msg/RegisterCounterpartyAddress", in, out, opts...) if err != nil { return nil, err } @@ -282,7 +282,7 @@ type MsgServer interface { // counterparty address before relaying. This ensures they will be properly compensated for forward relaying since // destination chain must send back relayer's source address (counterparty address) in acknowledgement. This function // may be called more than once by a relayer, in which case, latest counterparty address is always used. - RegisterCounterPartyAddress(context.Context, *MsgRegisterCounterpartyAddress) (*MsgRegisterCounterPartyAddressResponse, error) + RegisterCounterpartyAddress(context.Context, *MsgRegisterCounterpartyAddress) (*MsgRegisterCounterpartyAddressResponse, error) // EscrowPacketFee defines a rpc handler method for MsgEscrowPacketFee // EscrowPacketFee is an open callback that may be called by any module/user that wishes to escrow funds in order to // incentivize the relaying of the given packet. @@ -293,8 +293,8 @@ type MsgServer interface { type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) RegisterCounterPartyAddress(ctx context.Context, req *MsgRegisterCounterpartyAddress) (*MsgRegisterCounterPartyAddressResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RegisterCounterPartyAddress not implemented") +func (*UnimplementedMsgServer) RegisterCounterpartyAddress(ctx context.Context, req *MsgRegisterCounterpartyAddress) (*MsgRegisterCounterpartyAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RegisterCounterpartyAddress not implemented") } func (*UnimplementedMsgServer) EscrowPacketFee(ctx context.Context, req *MsgEscrowPacketFee) (*MsgEscrowPacketFeeResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method EscrowPacketFee not implemented") @@ -304,20 +304,20 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_RegisterCounterPartyAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Msg_RegisterCounterpartyAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgRegisterCounterpartyAddress) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).RegisterCounterPartyAddress(ctx, in) + return srv.(MsgServer).RegisterCounterpartyAddress(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ibc.applications.fee.v1.Msg/RegisterCounterPartyAddress", + FullMethod: "/ibc.applications.fee.v1.Msg/RegisterCounterpartyAddress", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).RegisterCounterPartyAddress(ctx, req.(*MsgRegisterCounterpartyAddress)) + return srv.(MsgServer).RegisterCounterpartyAddress(ctx, req.(*MsgRegisterCounterpartyAddress)) } return interceptor(ctx, in, info, handler) } @@ -345,8 +345,8 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "RegisterCounterPartyAddress", - Handler: _Msg_RegisterCounterPartyAddress_Handler, + MethodName: "RegisterCounterpartyAddress", + Handler: _Msg_RegisterCounterpartyAddress_Handler, }, { MethodName: "EscrowPacketFee", @@ -394,7 +394,7 @@ func (m *MsgRegisterCounterpartyAddress) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *MsgRegisterCounterPartyAddressResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgRegisterCounterpartyAddressResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -404,12 +404,12 @@ func (m *MsgRegisterCounterPartyAddressResponse) Marshal() (dAtA []byte, err err return dAtA[:n], nil } -func (m *MsgRegisterCounterPartyAddressResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRegisterCounterpartyAddressResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgRegisterCounterPartyAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRegisterCounterpartyAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -512,7 +512,7 @@ func (m *MsgRegisterCounterpartyAddress) Size() (n int) { return n } -func (m *MsgRegisterCounterPartyAddressResponse) Size() (n int) { +func (m *MsgRegisterCounterpartyAddressResponse) Size() (n int) { if m == nil { return 0 } @@ -669,7 +669,7 @@ func (m *MsgRegisterCounterpartyAddress) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgRegisterCounterPartyAddressResponse) Unmarshal(dAtA []byte) error { +func (m *MsgRegisterCounterpartyAddressResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -692,10 +692,10 @@ func (m *MsgRegisterCounterPartyAddressResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgRegisterCounterPartyAddressResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgRegisterCounterpartyAddressResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRegisterCounterPartyAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgRegisterCounterpartyAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: diff --git a/proto/ibc/applications/fee/v1/tx.proto b/proto/ibc/applications/fee/v1/tx.proto index 85ee09d0672..f9b56cf5011 100644 --- a/proto/ibc/applications/fee/v1/tx.proto +++ b/proto/ibc/applications/fee/v1/tx.proto @@ -14,7 +14,7 @@ service Msg { // counterparty address before relaying. This ensures they will be properly compensated for forward relaying since // destination chain must send back relayer's source address (counterparty address) in acknowledgement. This function // may be called more than once by a relayer, in which case, latest counterparty address is always used. - rpc RegisterCounterPartyAddress(MsgRegisterCounterpartyAddress) returns (MsgRegisterCounterPartyAddressResponse); + rpc RegisterCounterpartyAddress(MsgRegisterCounterpartyAddress) returns (MsgRegisterCounterpartyAddressResponse); // EscrowPacketFee defines a rpc handler method for MsgEscrowPacketFee // EscrowPacketFee is an open callback that may be called by any module/user that wishes to escrow funds in order to // incentivize the relaying of the given packet. @@ -30,8 +30,8 @@ message MsgRegisterCounterpartyAddress { string counterparty_address = 2 [(gogoproto.moretags) = "yaml:\"counterparty_address\""]; } -// MsgRegisterCounterPartyAddressResponse defines the Msg/RegisterCounteryPartyAddress response type -message MsgRegisterCounterPartyAddressResponse {} +// MsgRegisterCounterpartyAddressResponse defines the Msg/RegisterCounterypartyAddress response type +message MsgRegisterCounterpartyAddressResponse {} // MsgEscrowPacketFee defines the request type EscrowPacketFee RPC message MsgEscrowPacketFee { From 70c58afa9738857f849de459195e3c153011d1f5 Mon Sep 17 00:00:00 2001 From: Sean King Date: Thu, 9 Sep 2021 10:43:11 +0200 Subject: [PATCH 2/4] fix: remove comments for imports (#385) --- modules/apps/29-fee/client/cli/cli.go | 1 - modules/apps/29-fee/keeper/keeper.go | 2 -- modules/apps/29-fee/keeper/keeper_test.go | 3 --- modules/apps/29-fee/types/expected_keepers.go | 2 -- modules/apps/29-fee/types/keys.go | 1 - modules/apps/29-fee/types/msgs.go | 1 - 6 files changed, 10 deletions(-) diff --git a/modules/apps/29-fee/client/cli/cli.go b/modules/apps/29-fee/client/cli/cli.go index c7be975a534..e5ff524dee7 100644 --- a/modules/apps/29-fee/client/cli/cli.go +++ b/modules/apps/29-fee/client/cli/cli.go @@ -1,7 +1,6 @@ package cli import ( - // external library imports "github.com/cosmos/cosmos-sdk/client" "github.com/spf13/cobra" ) diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index a8319944613..8dd7ab03af2 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -1,14 +1,12 @@ package keeper import ( - // external library imports "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/tendermint/tendermint/libs/log" - // ibc-go imports "github.com/cosmos/ibc-go/modules/apps/29-fee/types" host "github.com/cosmos/ibc-go/modules/core/24-host" ) diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index 11c1768a1cf..f227c98171c 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -1,13 +1,10 @@ package keeper_test import ( - // standard library importsn "testing" - // external library imports "github.com/stretchr/testify/suite" - // ibc-go imports ibctesting "github.com/cosmos/ibc-go/testing" ) diff --git a/modules/apps/29-fee/types/expected_keepers.go b/modules/apps/29-fee/types/expected_keepers.go index a17a443623d..07f9bce4b8f 100644 --- a/modules/apps/29-fee/types/expected_keepers.go +++ b/modules/apps/29-fee/types/expected_keepers.go @@ -1,12 +1,10 @@ package types import ( - //external library imports sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - // ibc-go imports connectiontypes "github.com/cosmos/ibc-go/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" ibcexported "github.com/cosmos/ibc-go/modules/core/exported" diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index 5d1057dccca..474f27fb87a 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -1,6 +1,5 @@ package types -// standard library imports import "fmt" const ( diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index 6d1a92ef945..7e330d547bb 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -1,7 +1,6 @@ package types import ( - // external library imports sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) From e90d0e12084db0f7a8cf69adee3a2a5d545dee3a Mon Sep 17 00:00:00 2001 From: Sean King Date: Fri, 10 Sep 2021 15:26:00 +0200 Subject: [PATCH 3/4] test: adding msg_server.go tests & codec wiring --- modules/apps/29-fee/keeper/keeper.go | 22 +++++------- modules/apps/29-fee/keeper/keeper_test.go | 3 +- modules/apps/29-fee/keeper/msg_server_test.go | 32 +++++++++++++++++ modules/apps/29-fee/module.go | 4 +-- modules/apps/29-fee/types/codec.go | 34 ++++++++++++++++--- modules/apps/29-fee/types/keys.go | 3 -- modules/apps/29-fee/types/msgs.go | 21 ++++++++++++ 7 files changed, 94 insertions(+), 25 deletions(-) create mode 100644 modules/apps/29-fee/keeper/msg_server_test.go diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index ba656e5529e..93a62531fb6 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -8,6 +8,7 @@ import ( "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" host "github.com/cosmos/ibc-go/modules/core/24-host" ) @@ -46,7 +47,6 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+host.ModuleName+"-"+types.ModuleName) } -/* // IsBound checks if the transfer module is already bound to the desired port func (k Keeper) IsBound(ctx sdk.Context, portID string) bool { _, ok := k.scopedKeeper.GetCapability(ctx, host.PortPath(portID)) @@ -60,23 +60,17 @@ func (k Keeper) BindPort(ctx sdk.Context, portID string) error { return k.scopedKeeper.ClaimCapability(ctx, cap, host.PortPath(portID)) } -// SetPort sets the portID for the transfer module. Used in InitGenesis -func (k Keeper) SetPort(ctx sdk.Context, portID string) { +// GetPort returns the portID for the transfer module. Used in ExportGenesis +func (k Keeper) GetPort(ctx sdk.Context) string { store := ctx.KVStore(k.storeKey) - store.Set(types.PortKey, []byte(portID)) -} - -// AuthenticateCapability wraps the scopedKeeper's AuthenticateCapability function -func (k Keeper) AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool { - return k.scopedKeeper.AuthenticateCapability(ctx, cap, name) + return string(store.Get(transfertypes.PortKey)) } -// ClaimCapability allows the transfer module that can claim a capability that IBC module -// passes to it -func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error { - return k.scopedKeeper.ClaimCapability(ctx, cap, name) +// SetPort sets the portID for the transfer module. Used in InitGenesis +func (k Keeper) SetPort(ctx sdk.Context, portID string) { + store := ctx.KVStore(k.storeKey) + store.Set(transfertypes.PortKey, []byte(portID)) } -*/ // SetCounterpartyAddress maps the destination chain relayer address to the source relayer address // The receiving chain must store the mapping from: address -> counterpartyAddress for the given channel diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index f227c98171c..e41f3680e0f 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -20,10 +20,9 @@ type KeeperTestSuite struct { } func (suite *KeeperTestSuite) SetupTest() { - suite.coordinator = ibctesting.NewCoordinator(suite.T(), 3) + suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(0)) suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1)) - suite.chainC = suite.coordinator.GetChain(ibctesting.GetChainID(2)) } func TestKeeperTestSuite(t *testing.T) { diff --git a/modules/apps/29-fee/keeper/msg_server_test.go b/modules/apps/29-fee/keeper/msg_server_test.go new file mode 100644 index 00000000000..e546fed6f91 --- /dev/null +++ b/modules/apps/29-fee/keeper/msg_server_test.go @@ -0,0 +1,32 @@ +package keeper_test + +import ( + "github.com/cosmos/ibc-go/modules/apps/29-fee/types" +) + +func (suite *KeeperTestSuite) TestRegisterCounterpartyAddress() { + validAddr := suite.chainA.SenderAccount.GetAddress().String() + validAddr2 := suite.chainB.SenderAccount.GetAddress().String() + + testCases := []struct { + msg *types.MsgRegisterCounterpartyAddress + expPass bool + }{ + { + types.NewMsgRegisterCounterpartyAddress(validAddr, validAddr2), + true, + }, + } + + for _, tc := range testCases { + suite.SetupTest() + _, err := suite.chainA.SendMsgs(tc.msg) + + if tc.expPass { + suite.Require().NoError(err) // message committed + } else { + suite.Require().Error(err) + } + + } +} diff --git a/modules/apps/29-fee/module.go b/modules/apps/29-fee/module.go index a6840c6b476..ad7579167de 100644 --- a/modules/apps/29-fee/module.go +++ b/modules/apps/29-fee/module.go @@ -50,7 +50,7 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} // RegisterInterfaces registers module concrete types into protobuf Any. func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { - // types.RegisterInterfaces(registry) + types.RegisterInterfaces(registry) } // DefaultGenesis returns default genesis state as raw bytes for the ibc @@ -129,7 +129,7 @@ func (am AppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier { // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { - // types.RegisterMsgServer(cfg.MsgServer(), am.keeper) + types.RegisterMsgServer(cfg.MsgServer(), am.keeper) // types.RegisterQueryServer(cfg.QueryServer(), am.keeper) } diff --git a/modules/apps/29-fee/types/codec.go b/modules/apps/29-fee/types/codec.go index c9dac580ea5..0ba7184a05b 100644 --- a/modules/apps/29-fee/types/codec.go +++ b/modules/apps/29-fee/types/codec.go @@ -1,16 +1,42 @@ package types -/* import ( + "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) +// RegisterLegacyAminoCodec registers the necessary x/ibc 29-fee interfaces and concrete types +// on the provided LegacyAmino codec. These types are used for Amino JSON serialization. +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgRegisterCounterpartyAddress{}, "cosmos-sdk/MsgRegisterCounterpartyAddress", nil) + cdc.RegisterConcrete(&MsgEscrowPacketFee{}, "cosmos-sdk/MsgEscrowPacketFee", nil) +} + // RegisterInterfaces register the 29-fee module interfaces to protobuf // Any. func RegisterInterfaces(registry codectypes.InterfaceRegistry) { - // registry.RegisterImplementations((*sdk.Msg)(nil), &Msg{}) - + registry.RegisterImplementations((*sdk.Msg)(nil), &MsgRegisterCounterpartyAddress{}) + registry.RegisterImplementations((*sdk.Msg)(nil), &MsgEscrowPacketFee{}) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } -*/ + +var ( + amino = codec.NewLegacyAmino() + + // ModuleCdc references the global x/ibc-transfer module codec. Note, the codec + // should ONLY be used in certain instances of tests and for JSON encoding. + // + // The actual codec used for serialization should be provided to x/ibc transfer and + // defined at the application level. + ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) + + // AminoCdc is a amino codec created to support amino json compatible msgs. + AminoCdc = codec.NewAminoCodec(amino) +) + +func init() { + RegisterLegacyAminoCodec(amino) + amino.Seal() +} diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index b41765779a3..4718667a16c 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -9,9 +9,6 @@ const ( // StoreKey is the store key string for IBC transfer StoreKey = ModuleName - // PortKey is the port id that is wrapped by fee middleware - PortKey = "feetransfer" - // RouterKey is the message route for IBC transfer RouterKey = ModuleName diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index 7e330d547bb..7ee58204805 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -8,6 +8,7 @@ import ( // msg types const ( TypeMsgRegisterCounterpartyAddress = "registerCounterpartyAddress" + TypeMsgEscrowPacketFee = "escrowPacketFee" ) // NewMsgRegisterCounterpartyAddress creates a new instance of MsgRegisterCounterpartyAddress @@ -41,3 +42,23 @@ func (msg MsgRegisterCounterpartyAddress) GetSigners() []sdk.AccAddress { } return []sdk.AccAddress{signer} } + +// NewMsgEscrowPacketFee creates a new instance of MsgEscrowPacketFee +func NewMsgEscrowPacketFee(incentivizedPacket *IdentifiedPacketFee, relayers []string) *MsgEscrowPacketFee { + return &MsgEscrowPacketFee{ + IncentivizedPacket: incentivizedPacket, + Relayers: relayers, + } +} + +// ValidateBasic performs a basic check of the MsgEscrowPacketFee fields +func (msg MsgEscrowPacketFee) ValidateBasic() error { + //TODO + return nil +} + +// GetSigners implements sdk.Msg +func (msg MsgEscrowPacketFee) GetSigners() []sdk.AccAddress { + //TODO + return []sdk.AccAddress{} +} From 3c5e5688091dfcdcfea653e47dc1e8956be451fb Mon Sep 17 00:00:00 2001 From: Sean King Date: Mon, 13 Sep 2021 14:13:40 +0200 Subject: [PATCH 4/4] test: updating setter + adding test --- modules/apps/29-fee/keeper/keeper.go | 4 +-- modules/apps/29-fee/keeper/msg_server.go | 7 ++++- modules/apps/29-fee/keeper/msg_server_test.go | 27 ++++++++++++++----- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index 93a62531fb6..6e9a1f4733b 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -74,9 +74,9 @@ func (k Keeper) SetPort(ctx sdk.Context, portID string) { // SetCounterpartyAddress maps the destination chain relayer address to the source relayer address // The receiving chain must store the mapping from: address -> counterpartyAddress for the given channel -func (k Keeper) SetCounterpartyAddress(ctx sdk.Context, address, counterpartyAddress string) { +func (k Keeper) SetCounterpartyAddress(ctx sdk.Context, address string, counterpartyAddress sdk.AccAddress) { store := ctx.KVStore(k.storeKey) - store.Set(types.KeyRelayerAddress(address), []byte(counterpartyAddress)) + store.Set(types.KeyRelayerAddress(address), counterpartyAddress) } // GetCounterpartyAddress gets the relayer counterparty address given a destination relayer address diff --git a/modules/apps/29-fee/keeper/msg_server.go b/modules/apps/29-fee/keeper/msg_server.go index 54b0dadbc37..697e4d086f4 100644 --- a/modules/apps/29-fee/keeper/msg_server.go +++ b/modules/apps/29-fee/keeper/msg_server.go @@ -16,8 +16,13 @@ var _ types.MsgServer = Keeper{} func (k Keeper) RegisterCounterpartyAddress(goCtx context.Context, msg *types.MsgRegisterCounterpartyAddress) (*types.MsgRegisterCounterpartyAddressResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) + counterpartyAddress, err := sdk.AccAddressFromBech32(msg.CounterpartyAddress) + if err != nil { + return &types.MsgRegisterCounterpartyAddressResponse{}, err + } + k.SetCounterpartyAddress( - ctx, msg.Address, msg.CounterpartyAddress, + ctx, msg.Address, counterpartyAddress, ) k.Logger(ctx).Info("Registering counterparty address for relayer.", "Address:", msg.Address, "Counterparty Address:", msg.CounterpartyAddress) diff --git a/modules/apps/29-fee/keeper/msg_server_test.go b/modules/apps/29-fee/keeper/msg_server_test.go index e546fed6f91..fb3ca4f0e5f 100644 --- a/modules/apps/29-fee/keeper/msg_server_test.go +++ b/modules/apps/29-fee/keeper/msg_server_test.go @@ -5,28 +5,41 @@ import ( ) func (suite *KeeperTestSuite) TestRegisterCounterpartyAddress() { - validAddr := suite.chainA.SenderAccount.GetAddress().String() - validAddr2 := suite.chainB.SenderAccount.GetAddress().String() + var ( + addr string + addr2 string + ) testCases := []struct { - msg *types.MsgRegisterCounterpartyAddress - expPass bool + name string + expPass bool + malleate func() }{ { - types.NewMsgRegisterCounterpartyAddress(validAddr, validAddr2), + "CounterpartyAddress registered", true, + func() {}, }, } for _, tc := range testCases { suite.SetupTest() - _, err := suite.chainA.SendMsgs(tc.msg) + ctx := suite.chainA.GetContext() + + addr = suite.chainA.SenderAccount.GetAddress().String() + addr2 = suite.chainB.SenderAccount.GetAddress().String() + msg := types.NewMsgRegisterCounterpartyAddress(addr, addr2) + tc.malleate() + + _, err := suite.chainA.SendMsgs(msg) if tc.expPass { suite.Require().NoError(err) // message committed + + counterpartyAddress, _ := suite.chainA.GetSimApp().IBCFeeKeeper.GetCounterpartyAddress(ctx, suite.chainA.SenderAccount.GetAddress()) + suite.Require().Equal(addr2, counterpartyAddress.String()) } else { suite.Require().Error(err) } - } }