From 18feadf1a41f178a551a903d0653192a2886c599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Wed, 21 Jul 2021 11:43:14 +0200 Subject: [PATCH 01/79] scaffolding for 29-fee (#274) * scaffolding for 29-fee * fix build * update keeper test * remove module test --- modules/apps/29-fee/client/cli/cli.go | 40 +++ modules/apps/29-fee/client/cli/query.go | 3 + modules/apps/29-fee/client/cli/tx.go | 3 + modules/apps/29-fee/keeper/genesis.go | 16 + modules/apps/29-fee/keeper/grpc_query.go | 5 + modules/apps/29-fee/keeper/keeper.go | 87 ++++++ modules/apps/29-fee/keeper/keeper_test.go | 45 +++ modules/apps/29-fee/keeper/msg_server.go | 4 + modules/apps/29-fee/module.go | 277 ++++++++++++++++++ modules/apps/29-fee/spec/01_concepts.md | 6 + modules/apps/29-fee/spec/02_state.md | 6 + .../apps/29-fee/spec/03_state_transitions.md | 6 + modules/apps/29-fee/spec/04_messages.md | 6 + modules/apps/29-fee/spec/05_events.md | 6 + modules/apps/29-fee/spec/06_metrics.md | 6 + modules/apps/29-fee/spec/07_params.md | 6 + modules/apps/29-fee/spec/README.md | 11 + modules/apps/29-fee/types/codec.go | 16 + modules/apps/29-fee/types/errors.go | 8 + modules/apps/29-fee/types/events.go | 4 + modules/apps/29-fee/types/expected_keepers.go | 50 ++++ modules/apps/29-fee/types/genesis.go | 29 ++ modules/apps/29-fee/types/genesis_test.go | 49 ++++ modules/apps/29-fee/types/keys.go | 15 + modules/apps/29-fee/types/msgs.go | 32 ++ modules/apps/29-fee/types/msgs_test.go | 36 +++ 26 files changed, 772 insertions(+) create mode 100644 modules/apps/29-fee/client/cli/cli.go create mode 100644 modules/apps/29-fee/client/cli/query.go create mode 100644 modules/apps/29-fee/client/cli/tx.go create mode 100644 modules/apps/29-fee/keeper/genesis.go create mode 100644 modules/apps/29-fee/keeper/grpc_query.go create mode 100644 modules/apps/29-fee/keeper/keeper.go create mode 100644 modules/apps/29-fee/keeper/keeper_test.go create mode 100644 modules/apps/29-fee/keeper/msg_server.go create mode 100644 modules/apps/29-fee/module.go create mode 100644 modules/apps/29-fee/spec/01_concepts.md create mode 100644 modules/apps/29-fee/spec/02_state.md create mode 100644 modules/apps/29-fee/spec/03_state_transitions.md create mode 100644 modules/apps/29-fee/spec/04_messages.md create mode 100644 modules/apps/29-fee/spec/05_events.md create mode 100644 modules/apps/29-fee/spec/06_metrics.md create mode 100644 modules/apps/29-fee/spec/07_params.md create mode 100644 modules/apps/29-fee/spec/README.md create mode 100644 modules/apps/29-fee/types/codec.go create mode 100644 modules/apps/29-fee/types/errors.go create mode 100644 modules/apps/29-fee/types/events.go create mode 100644 modules/apps/29-fee/types/expected_keepers.go create mode 100644 modules/apps/29-fee/types/genesis.go create mode 100644 modules/apps/29-fee/types/genesis_test.go create mode 100644 modules/apps/29-fee/types/keys.go create mode 100644 modules/apps/29-fee/types/msgs.go create mode 100644 modules/apps/29-fee/types/msgs_test.go diff --git a/modules/apps/29-fee/client/cli/cli.go b/modules/apps/29-fee/client/cli/cli.go new file mode 100644 index 00000000000..fb8b9db8320 --- /dev/null +++ b/modules/apps/29-fee/client/cli/cli.go @@ -0,0 +1,40 @@ +package cli + +import ( + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" +) + +// GetQueryCmd returns the query commands for 29-fee +func GetQueryCmd() *cobra.Command { + queryCmd := &cobra.Command{ + Use: "ibc-fee", + Short: "", // TODO + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + } + + queryCmd.AddCommand( + // TODO + ) + + return queryCmd +} + +// NewTxCmd returns the transaction commands for 29-fee +func NewTxCmd() *cobra.Command { + txCmd := &cobra.Command{ + Use: "ibc-fee", + Short: "", // TODO + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + txCmd.AddCommand( + // TODO + ) + + return txCmd +} diff --git a/modules/apps/29-fee/client/cli/query.go b/modules/apps/29-fee/client/cli/query.go new file mode 100644 index 00000000000..e8878f3e042 --- /dev/null +++ b/modules/apps/29-fee/client/cli/query.go @@ -0,0 +1,3 @@ +package cli + +// TODO diff --git a/modules/apps/29-fee/client/cli/tx.go b/modules/apps/29-fee/client/cli/tx.go new file mode 100644 index 00000000000..e8878f3e042 --- /dev/null +++ b/modules/apps/29-fee/client/cli/tx.go @@ -0,0 +1,3 @@ +package cli + +// TODO diff --git a/modules/apps/29-fee/keeper/genesis.go b/modules/apps/29-fee/keeper/genesis.go new file mode 100644 index 00000000000..cb500443231 --- /dev/null +++ b/modules/apps/29-fee/keeper/genesis.go @@ -0,0 +1,16 @@ +package keeper + +/* +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// InitGenesis +func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) { +} + +// ExportGenesis +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + return &types.GenesisState{} +} +*/ diff --git a/modules/apps/29-fee/keeper/grpc_query.go b/modules/apps/29-fee/keeper/grpc_query.go new file mode 100644 index 00000000000..185ad775c93 --- /dev/null +++ b/modules/apps/29-fee/keeper/grpc_query.go @@ -0,0 +1,5 @@ +package keeper + +// TODO + +//var _ types.QueryServer = Keeper{} diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go new file mode 100644 index 00000000000..db304dd4cf9 --- /dev/null +++ b/modules/apps/29-fee/keeper/keeper.go @@ -0,0 +1,87 @@ +package keeper + +/* +import ( + "github.com/tendermint/tendermint/libs/log" + + "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" + host "github.com/cosmos/ibc-go/modules/core/24-host" +) + +// Keeper defines the IBC fungible transfer keeper +type Keeper struct { + storeKey sdk.StoreKey + cdc codec.BinaryCodec + + channelKeeper types.ChannelKeeper + portKeeper types.PortKeeper + authKeeper types.AccountKeeper + bankKeeper types.BankKeeper + scopedKeeper capabilitykeeper.ScopedKeeper +} + + +// NewKeeper creates a new 29-fee Keeper instance +func NewKeeper( + cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace, + channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper, + authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, scopedKeeper capabilitykeeper.ScopedKeeper, +) Keeper { + + return Keeper{ + cdc: cdc, + storeKey: key, + channelKeeper: channelKeeper, + portKeeper: portKeeper, + authKeeper: authKeeper, + bankKeeper: bankKeeper, + scopedKeeper: scopedKeeper, + } +} + +// Logger returns a module-specific logger. +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)) + return ok +} + +// BindPort defines a wrapper function for the ort Keeper's function in +// order to expose it to module's InitGenesis function +func (k Keeper) BindPort(ctx sdk.Context, portID string) error { + cap := k.portKeeper.BindPort(ctx, portID) + 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) + 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) +} + +// 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) +} +*/ diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go new file mode 100644 index 00000000000..b355ccfe847 --- /dev/null +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -0,0 +1,45 @@ +package keeper_test + +/* +import ( + "testing" + + "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" + ibctesting "github.com/cosmos/ibc-go/testing" +) + +type KeeperTestSuite struct { + suite.Suite + + coordinator *ibctesting.Coordinator + + // testing chains used for convenience and readability + chainA *ibctesting.TestChain + chainB *ibctesting.TestChain + chainC *ibctesting.TestChain +} + +func (suite *KeeperTestSuite) SetupTest() { + suite.coordinator = ibctesting.NewCoordinator(suite.T(), 3) + 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 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 new file mode 100644 index 00000000000..2194eed8a68 --- /dev/null +++ b/modules/apps/29-fee/keeper/msg_server.go @@ -0,0 +1,4 @@ +package keeper + +// TODO +//var _ types.MsgServer = Keeper{} diff --git a/modules/apps/29-fee/module.go b/modules/apps/29-fee/module.go new file mode 100644 index 00000000000..c0645e3db78 --- /dev/null +++ b/modules/apps/29-fee/module.go @@ -0,0 +1,277 @@ +package fee + +/* +import ( + "context" + "encoding/json" + "fmt" + "math/rand" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/cosmos/ibc-go/modules/apps/transfer/client/cli" + "github.com/cosmos/ibc-go/modules/apps/transfer/keeper" + "github.com/cosmos/ibc-go/modules/apps/transfer/simulation" + "github.com/cosmos/ibc-go/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/modules/core/05-port/types" + ibcexported "github.com/cosmos/ibc-go/modules/core/exported" +) + +var ( + _ module.AppModule = AppModule{} + _ porttypes.IBCModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// AppModuleBasic is the 29-fee AppModuleBasic +type AppModuleBasic struct{} + +// Name implements AppModuleBasic interface +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec implements AppModuleBasic interface +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} + +// RegisterInterfaces registers module concrete types into protobuf Any. +func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) +} + +// DefaultGenesis returns default genesis state as raw bytes for the ibc +// transfer module. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesisState()) +} + +// ValidateGenesis performs genesis state validation for the 29-fee module. +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var gs types.GenesisState + if err := cdc.UnmarshalJSON(bz, &gs); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + + return gs.Validate() +} + +// RegisterRESTRoutes implements AppModuleBasic interface +func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the ibc-transfer module. +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) +} + +// GetTxCmd implements AppModuleBasic interface +func (AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.NewTxCmd() +} + +// GetQueryCmd implements AppModuleBasic interface +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// AppModule represents the AppModule for this module +type AppModule struct { + AppModuleBasic + keeper keeper.Keeper +} + +// NewAppModule creates a new 29-fee module +func NewAppModule(k keeper.Keeper) AppModule { + return AppModule{ + keeper: k, + } +} + +// RegisterInvariants implements the AppModule interface +func (AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { + // TODO +} + +// Route implements the AppModule interface +func (am AppModule) Route() sdk.Route { + return sdk.Route{} +} + +// QuerierRoute implements the AppModule interface +func (AppModule) QuerierRoute() string { + return types.QuerierRoute +} + +// LegacyQuerierHandler implements the AppModule interface +func (am AppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier { + return nil +} + +// RegisterServices registers module services. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), am.keeper) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// InitGenesis performs genesis initialization for the ibc-transfer module. It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { + var genesisState types.GenesisState + cdc.MustUnmarshalJSON(data, &genesisState) + am.keeper.InitGenesis(ctx, genesisState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the exported genesis state as raw bytes for the ibc-transfer +// module. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + gs := am.keeper.ExportGenesis(ctx) + return cdc.MustMarshalJSON(gs) +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock implements the AppModule interface +func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { +} + +// EndBlock implements the AppModule interface +func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} + +// AppModuleSimulation functions + +// GenerateGenesisState creates a randomized GenState of the transfer module. +func (AppModule) GenerateGenesisState(simState *module.SimulationState) { + simulation.RandomizedGenState(simState) +} + +// ProposalContents doesn't return any content functions for governance proposals. +func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent { + return nil +} + +// RandomizedParams creates randomized ibc-transfer param changes for the simulator. +func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { + return simulation.ParamChanges(r) +} + +// RegisterStoreDecoder registers a decoder for transfer module's types +func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { + sdr[types.StoreKey] = simulation.NewDecodeStore(am.keeper) +} + +// WeightedOperations returns the all the transfer module operations with their respective weights. +func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { + return nil +} + +// OnChanOpenInit implements the IBCModule interface +func (am AppModule) OnChanOpenInit( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID string, + channelID string, + chanCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + version string, +) error { + return nil +} + +// OnChanOpenTry implements the IBCModule interface +func (am AppModule) OnChanOpenTry( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID, + channelID string, + chanCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + version, + counterpartyVersion string, +) error { + return nil +} + +// OnChanOpenAck implements the IBCModule interface +func (am AppModule) OnChanOpenAck( + ctx sdk.Context, + portID, + channelID string, + counterpartyVersion string, +) error { + return nil +} + +// OnChanOpenConfirm implements the IBCModule interface +func (am AppModule) OnChanOpenConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + return nil +} + +// OnChanCloseInit implements the IBCModule interface +func (am AppModule) OnChanCloseInit( + ctx sdk.Context, + portID, + channelID string, +) error { + // Disallow user-initiated channel closing for 29-fee channels + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "user cannot close channel") +} + +// OnChanCloseConfirm implements the IBCModule interface +func (am AppModule) OnChanCloseConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + return nil +} + +// OnRecvPacket implements the IBCModule interface. +func (am AppModule) OnRecvPacket( + ctx sdk.Context, + packet channeltypes.Packet, + relayer sdk.AccAddress, +) ibcexported.Acknowledgement { + return nil +} + +// OnAcknowledgementPacket implements the IBCModule interface +func (am AppModule) OnAcknowledgementPacket( + ctx sdk.Context, + packet channeltypes.Packet, + acknowledgement []byte, + relayer sdk.AccAddress, +) error { + return nil +} + +// OnTimeoutPacket implements the IBCModule interface +func (am AppModule) OnTimeoutPacket( + ctx sdk.Context, + packet channeltypes.Packet, + relayer sdk.AccAddress, +) error { + return nil +} +*/ diff --git a/modules/apps/29-fee/spec/01_concepts.md b/modules/apps/29-fee/spec/01_concepts.md new file mode 100644 index 00000000000..119c857b0cc --- /dev/null +++ b/modules/apps/29-fee/spec/01_concepts.md @@ -0,0 +1,6 @@ + + +# Concepts + diff --git a/modules/apps/29-fee/spec/02_state.md b/modules/apps/29-fee/spec/02_state.md new file mode 100644 index 00000000000..336ed0f5b65 --- /dev/null +++ b/modules/apps/29-fee/spec/02_state.md @@ -0,0 +1,6 @@ + + +# State + diff --git a/modules/apps/29-fee/spec/03_state_transitions.md b/modules/apps/29-fee/spec/03_state_transitions.md new file mode 100644 index 00000000000..dc70ea002c6 --- /dev/null +++ b/modules/apps/29-fee/spec/03_state_transitions.md @@ -0,0 +1,6 @@ + + +# State Transitions + diff --git a/modules/apps/29-fee/spec/04_messages.md b/modules/apps/29-fee/spec/04_messages.md new file mode 100644 index 00000000000..0a97f2d6b9d --- /dev/null +++ b/modules/apps/29-fee/spec/04_messages.md @@ -0,0 +1,6 @@ + + +# Messages + diff --git a/modules/apps/29-fee/spec/05_events.md b/modules/apps/29-fee/spec/05_events.md new file mode 100644 index 00000000000..eb988be063a --- /dev/null +++ b/modules/apps/29-fee/spec/05_events.md @@ -0,0 +1,6 @@ + + +# Events + diff --git a/modules/apps/29-fee/spec/06_metrics.md b/modules/apps/29-fee/spec/06_metrics.md new file mode 100644 index 00000000000..24996d36b3d --- /dev/null +++ b/modules/apps/29-fee/spec/06_metrics.md @@ -0,0 +1,6 @@ + + +# Metrics + diff --git a/modules/apps/29-fee/spec/07_params.md b/modules/apps/29-fee/spec/07_params.md new file mode 100644 index 00000000000..77d7696b559 --- /dev/null +++ b/modules/apps/29-fee/spec/07_params.md @@ -0,0 +1,6 @@ + + +# Parameters + diff --git a/modules/apps/29-fee/spec/README.md b/modules/apps/29-fee/spec/README.md new file mode 100644 index 00000000000..c5c926f7b9f --- /dev/null +++ b/modules/apps/29-fee/spec/README.md @@ -0,0 +1,11 @@ + + +# `29-fee` + +## Abstract + diff --git a/modules/apps/29-fee/types/codec.go b/modules/apps/29-fee/types/codec.go new file mode 100644 index 00000000000..c9dac580ea5 --- /dev/null +++ b/modules/apps/29-fee/types/codec.go @@ -0,0 +1,16 @@ +package types + +/* +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +// RegisterInterfaces register the 29-fee module interfaces to protobuf +// Any. +func RegisterInterfaces(registry codectypes.InterfaceRegistry) { + // registry.RegisterImplementations((*sdk.Msg)(nil), &Msg{}) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} +*/ diff --git a/modules/apps/29-fee/types/errors.go b/modules/apps/29-fee/types/errors.go new file mode 100644 index 00000000000..9ed5755a9a0 --- /dev/null +++ b/modules/apps/29-fee/types/errors.go @@ -0,0 +1,8 @@ +package types + +import ( +// sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// 29-fee sentinel errors +var () diff --git a/modules/apps/29-fee/types/events.go b/modules/apps/29-fee/types/events.go new file mode 100644 index 00000000000..4b8d5ee8c95 --- /dev/null +++ b/modules/apps/29-fee/types/events.go @@ -0,0 +1,4 @@ +package types + +// 29-fee events +const () diff --git a/modules/apps/29-fee/types/expected_keepers.go b/modules/apps/29-fee/types/expected_keepers.go new file mode 100644 index 00000000000..68513b476a5 --- /dev/null +++ b/modules/apps/29-fee/types/expected_keepers.go @@ -0,0 +1,50 @@ +package types + +/* +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + 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" +) + +// AccountKeeper defines the contract required for account APIs. +type AccountKeeper interface { + GetModuleAddress(name string) sdk.AccAddress + GetModuleAccount(ctx sdk.Context, name string) types.ModuleAccountI +} + +// BankKeeper defines the expected bank keeper +type BankKeeper interface { + SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error + MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error + BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error +} + +// ChannelKeeper defines the expected IBC channel keeper +type ChannelKeeper interface { + GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channeltypes.Channel, found bool) + GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) + SendPacket(ctx sdk.Context, channelCap *capabilitytypes.Capability, packet ibcexported.PacketI) error + ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capabilitytypes.Capability) error +} + +// ClientKeeper defines the expected IBC client keeper +type ClientKeeper interface { + GetClientConsensusState(ctx sdk.Context, clientID string) (connection ibcexported.ConsensusState, found bool) +} + +// ConnectionKeeper defines the expected IBC connection keeper +type ConnectionKeeper interface { + GetConnection(ctx sdk.Context, connectionID string) (connection connectiontypes.ConnectionEnd, found bool) +} + +// PortKeeper defines the expected IBC port keeper +type PortKeeper interface { + BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability +} +*/ diff --git a/modules/apps/29-fee/types/genesis.go b/modules/apps/29-fee/types/genesis.go new file mode 100644 index 00000000000..4086325bebb --- /dev/null +++ b/modules/apps/29-fee/types/genesis.go @@ -0,0 +1,29 @@ +package types + +/* +import ( + host "github.com/cosmos/ibc-go/modules/core/24-host" +) + +// NewGenesisState creates a 29-fee GenesisState instance. +func NewGenesisState(portID string, denomTraces Traces, params Params) *GenesisState { + return &GenesisState{ + Params: params, + } +} + +// DefaultGenesisState returns a GenesisState with "transfer" as the default PortID. +func DefaultGenesisState() *GenesisState { + return &GenesisState{ + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + if err := host.PortIdentifierValidator(gs.PortId); err != nil { + return err + } + return nil +} +*/ diff --git a/modules/apps/29-fee/types/genesis_test.go b/modules/apps/29-fee/types/genesis_test.go new file mode 100644 index 00000000000..30516612cce --- /dev/null +++ b/modules/apps/29-fee/types/genesis_test.go @@ -0,0 +1,49 @@ +package types_test + +/* +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/ibc-go/modules/apps/transfer/types" +) + +func TestValidateGenesis(t *testing.T) { + testCases := []struct { + name string + genState *types.GenesisState + expPass bool + }{ + { + name: "default", + genState: types.DefaultGenesisState(), + expPass: true, + }, + { + "valid genesis", + &types.GenesisState{ + PortId: "portidone", + }, + true, + }, + { + "invalid client", + &types.GenesisState{ + PortId: "(INVALIDPORT)", + }, + false, + }, + } + + for _, tc := range testCases { + tc := tc + err := tc.genState.Validate() + if tc.expPass { + require.NoError(t, err, tc.name) + } else { + require.Error(t, err, tc.name) + } + } +} +*/ diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go new file mode 100644 index 00000000000..769113f504a --- /dev/null +++ b/modules/apps/29-fee/types/keys.go @@ -0,0 +1,15 @@ +package types + +const ( + // ModuleName defines the 29-fee name + ModuleName = "ibcfee" + + // StoreKey is the store key string for IBC transfer + StoreKey = ModuleName + + // RouterKey is the message route for IBC transfer + RouterKey = ModuleName + + // QuerierRoute is the querier route for IBC transfer + QuerierRoute = ModuleName +) diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go new file mode 100644 index 00000000000..4df0e84ff1a --- /dev/null +++ b/modules/apps/29-fee/types/msgs.go @@ -0,0 +1,32 @@ +package types + +/* +import ( + "strings" + + 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{ + } +} + +// ValidateBasic performs a basic check of the Msg fields. +func (msg Msg) ValidateBasic() error { + return nil +} + +// GetSigners implements sdk.Msg +func (msg MsgTransfer) GetSigners() []sdk.AccAddress { + signer, err := sdk.AccAddressFromBech32(msg.Sender) + 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 new file mode 100644 index 00000000000..132bde75752 --- /dev/null +++ b/modules/apps/29-fee/types/msgs_test.go @@ -0,0 +1,36 @@ +package types + +/* +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (suite *TypesTestSuite) TestMsgValidateBasic() { + testCases := []struct { + name string + msg *types.Msg + expPass bool + }{ + {"", types.NewMsg(), true}, + } + + 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) + } + }) + } +} +*/ From 4b9a8320fdee6fbeb37a184b6adb82820d0d02de Mon Sep 17 00:00:00 2001 From: Sean King Date: Mon, 26 Jul 2021 13:03:36 +0200 Subject: [PATCH 02/79] feat: adding proto files for fee payment middleware (#272) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: adding proto files for fee payment middleware * grammar * fix: remove generated .pb files * fix: comment * feat: adding PacketId type * refactor: fee / genesis * refactor: escrowed fees map * Apply suggestions from code review Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * Update proto/ibc/applications/middleware/fee/v1/tx.proto Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * Update proto/ibc/applications/middleware/fee/v1/tx.proto Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * Update proto/ibc/applications/middleware/fee/v1/tx.proto Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * refactor: use packetID + minor changes * feat: adding query for all incentivized packets + some fixes * feat: adding pagination to incentivized query * fix: removing generated ibc directory + adding import/yaml * fix: naming * increase max depth for proto file searching and make proto all * Update proto/ibc/applications/middleware/fee/v1/fee.proto Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * refactor: remove file imports/add yaml/add argument for requests * refactor: updating IdentifiedPacketFee * fix: remove hidden file * removing middleware dir & adding query * remove junk file and update query rpcs * Apply suggestions from code review * Apply suggestions from code review * remove query yaml, make proto-all Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> Co-authored-by: Aditya Sripal --- docs/ibc/proto-docs.md | 958 +++++-- modules/apps/29-fee/types/fee.pb.go | 765 ++++++ modules/apps/29-fee/types/genesis.pb.go | 337 +++ modules/apps/29-fee/types/query.pb.go | 2574 +++++++++++++++++++ modules/apps/29-fee/types/query.pb.gw.go | 996 +++++++ modules/apps/29-fee/types/tx.pb.go | 1137 ++++++++ modules/core/04-channel/types/channel.pb.go | 360 ++- proto/ibc/applications/fee/v1/fee.proto | 24 + proto/ibc/applications/fee/v1/genesis.proto | 13 + proto/ibc/applications/fee/v1/query.proto | 121 + proto/ibc/applications/fee/v1/tx.proto | 49 + proto/ibc/core/channel/v1/channel.proto | 14 + scripts/protocgen.sh | 2 +- 13 files changed, 7012 insertions(+), 338 deletions(-) create mode 100644 modules/apps/29-fee/types/fee.pb.go create mode 100644 modules/apps/29-fee/types/genesis.pb.go create mode 100644 modules/apps/29-fee/types/query.pb.go create mode 100644 modules/apps/29-fee/types/query.pb.gw.go create mode 100644 modules/apps/29-fee/types/tx.pb.go create mode 100644 proto/ibc/applications/fee/v1/fee.proto create mode 100644 proto/ibc/applications/fee/v1/genesis.proto create mode 100644 proto/ibc/applications/fee/v1/query.proto create mode 100644 proto/ibc/applications/fee/v1/tx.proto diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index cae068cf68c..5e9a088d7bb 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -4,6 +4,56 @@ ## Table of Contents +- [ibc/core/client/v1/client.proto](#ibc/core/client/v1/client.proto) + - [ClientConsensusStates](#ibc.core.client.v1.ClientConsensusStates) + - [ClientUpdateProposal](#ibc.core.client.v1.ClientUpdateProposal) + - [ConsensusStateWithHeight](#ibc.core.client.v1.ConsensusStateWithHeight) + - [Height](#ibc.core.client.v1.Height) + - [IdentifiedClientState](#ibc.core.client.v1.IdentifiedClientState) + - [Params](#ibc.core.client.v1.Params) + - [UpgradeProposal](#ibc.core.client.v1.UpgradeProposal) + +- [ibc/core/channel/v1/channel.proto](#ibc/core/channel/v1/channel.proto) + - [Acknowledgement](#ibc.core.channel.v1.Acknowledgement) + - [Channel](#ibc.core.channel.v1.Channel) + - [Counterparty](#ibc.core.channel.v1.Counterparty) + - [IdentifiedChannel](#ibc.core.channel.v1.IdentifiedChannel) + - [Packet](#ibc.core.channel.v1.Packet) + - [PacketId](#ibc.core.channel.v1.PacketId) + - [PacketState](#ibc.core.channel.v1.PacketState) + + - [Order](#ibc.core.channel.v1.Order) + - [State](#ibc.core.channel.v1.State) + +- [ibc/applications/fee/v1/fee.proto](#ibc/applications/fee/v1/fee.proto) + - [Fee](#ibc.applications.fee.v1.Fee) + - [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) + +- [ibc/applications/fee/v1/genesis.proto](#ibc/applications/fee/v1/genesis.proto) + - [GenesisState](#ibc.applications.fee.v1.GenesisState) + +- [ibc/applications/fee/v1/query.proto](#ibc/applications/fee/v1/query.proto) + - [QueryAckFeeRequest](#ibc.applications.fee.v1.QueryAckFeeRequest) + - [QueryAckFeeResponse](#ibc.applications.fee.v1.QueryAckFeeResponse) + - [QueryIncentivizedPacketRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketRequest) + - [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) + - [QueryIncentivizedPacketsRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsRequest) + - [QueryIncentivizedPacketsResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsResponse) + - [QueryReceiveFeeRequest](#ibc.applications.fee.v1.QueryReceiveFeeRequest) + - [QueryReceiveFeeResponse](#ibc.applications.fee.v1.QueryReceiveFeeResponse) + - [QueryTimeoutFeeRequest](#ibc.applications.fee.v1.QueryTimeoutFeeRequest) + - [QueryTimeoutFeeResponse](#ibc.applications.fee.v1.QueryTimeoutFeeResponse) + + - [Query](#ibc.applications.fee.v1.Query) + +- [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) + + - [Msg](#ibc.applications.fee.v1.Msg) + - [ibc/applications/transfer/v1/transfer.proto](#ibc/applications/transfer/v1/transfer.proto) - [DenomTrace](#ibc.applications.transfer.v1.DenomTrace) - [FungibleTokenPacketData](#ibc.applications.transfer.v1.FungibleTokenPacketData) @@ -22,32 +72,12 @@ - [Query](#ibc.applications.transfer.v1.Query) -- [ibc/core/client/v1/client.proto](#ibc/core/client/v1/client.proto) - - [ClientConsensusStates](#ibc.core.client.v1.ClientConsensusStates) - - [ClientUpdateProposal](#ibc.core.client.v1.ClientUpdateProposal) - - [ConsensusStateWithHeight](#ibc.core.client.v1.ConsensusStateWithHeight) - - [Height](#ibc.core.client.v1.Height) - - [IdentifiedClientState](#ibc.core.client.v1.IdentifiedClientState) - - [Params](#ibc.core.client.v1.Params) - - [UpgradeProposal](#ibc.core.client.v1.UpgradeProposal) - - [ibc/applications/transfer/v1/tx.proto](#ibc/applications/transfer/v1/tx.proto) - [MsgTransfer](#ibc.applications.transfer.v1.MsgTransfer) - [MsgTransferResponse](#ibc.applications.transfer.v1.MsgTransferResponse) - [Msg](#ibc.applications.transfer.v1.Msg) -- [ibc/core/channel/v1/channel.proto](#ibc/core/channel/v1/channel.proto) - - [Acknowledgement](#ibc.core.channel.v1.Acknowledgement) - - [Channel](#ibc.core.channel.v1.Channel) - - [Counterparty](#ibc.core.channel.v1.Counterparty) - - [IdentifiedChannel](#ibc.core.channel.v1.IdentifiedChannel) - - [Packet](#ibc.core.channel.v1.Packet) - - [PacketState](#ibc.core.channel.v1.PacketState) - - - [Order](#ibc.core.channel.v1.Order) - - [State](#ibc.core.channel.v1.State) - - [ibc/core/channel/v1/genesis.proto](#ibc/core/channel/v1/genesis.proto) - [GenesisState](#ibc.core.channel.v1.GenesisState) - [PacketSequence](#ibc.core.channel.v1.PacketSequence) @@ -246,361 +276,409 @@ - +

Top

-## ibc/applications/transfer/v1/transfer.proto +## ibc/core/client/v1/client.proto - + -### DenomTrace -DenomTrace contains the base denomination for ICS20 fungible tokens and the -source tracing information path. +### ClientConsensusStates +ClientConsensusStates defines all the stored consensus states for a given +client. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `path` | [string](#string) | | path defines the chain of port/channel identifiers used for tracing the source of the fungible token. | -| `base_denom` | [string](#string) | | base denomination of the relayed fungible token. | +| `client_id` | [string](#string) | | client identifier | +| `consensus_states` | [ConsensusStateWithHeight](#ibc.core.client.v1.ConsensusStateWithHeight) | repeated | consensus states and their heights associated with the client | - + -### FungibleTokenPacketData -FungibleTokenPacketData defines a struct for the packet payload -See FungibleTokenPacketData spec: -https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures +### ClientUpdateProposal +ClientUpdateProposal is a governance proposal. If it passes, the substitute +client's latest consensus state is copied over to the subject client. The proposal +handler may fail if the subject and the substitute do not match in client and +chain parameters (with exception to latest height, frozen height, and chain-id). | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `denom` | [string](#string) | | the token denomination to be transferred | -| `amount` | [uint64](#uint64) | | the token amount to be transferred | -| `sender` | [string](#string) | | the sender address | -| `receiver` | [string](#string) | | the recipient address on the destination chain | +| `title` | [string](#string) | | the title of the update proposal | +| `description` | [string](#string) | | the description of the proposal | +| `subject_client_id` | [string](#string) | | the client identifier for the client to be updated if the proposal passes | +| `substitute_client_id` | [string](#string) | | the substitute client identifier for the client standing in for the subject client | - + -### Params -Params defines the set of IBC transfer parameters. -NOTE: To prevent a single token from being transferred, set the -TransfersEnabled parameter to true and then set the bank module's SendEnabled -parameter for the denomination to false. +### ConsensusStateWithHeight +ConsensusStateWithHeight defines a consensus state with an additional height +field. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `send_enabled` | [bool](#bool) | | send_enabled enables or disables all cross-chain token transfers from this chain. | -| `receive_enabled` | [bool](#bool) | | receive_enabled enables or disables all cross-chain token transfers to this chain. | +| `height` | [Height](#ibc.core.client.v1.Height) | | consensus state height | +| `consensus_state` | [google.protobuf.Any](#google.protobuf.Any) | | consensus state | - - + - +### Height +Height is a monotonically increasing data type +that can be compared against another Height for the purposes of updating and +freezing clients - +Normally the RevisionHeight is incremented at each height while keeping +RevisionNumber the same. However some consensus algorithms may choose to +reset the height in certain conditions e.g. hard forks, state-machine +breaking changes In these cases, the RevisionNumber is incremented so that +height continues to be monitonically increasing even as the RevisionHeight +gets reset +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `revision_number` | [uint64](#uint64) | | the revision that the client is currently on | +| `revision_height` | [uint64](#uint64) | | the height within the given revision | + - -

Top

-## ibc/applications/transfer/v1/genesis.proto - + -### GenesisState -GenesisState defines the ibc-transfer genesis state +### IdentifiedClientState +IdentifiedClientState defines a client state with an additional client +identifier field. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | | -| `denom_traces` | [DenomTrace](#ibc.applications.transfer.v1.DenomTrace) | repeated | | -| `params` | [Params](#ibc.applications.transfer.v1.Params) | | | +| `client_id` | [string](#string) | | client identifier | +| `client_state` | [google.protobuf.Any](#google.protobuf.Any) | | client state | - - + - +### Params +Params defines the set of IBC light client parameters. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `allowed_clients` | [string](#string) | repeated | allowed_clients defines the list of allowed client state types. | - -

Top

-## ibc/applications/transfer/v1/query.proto - + -### QueryDenomTraceRequest -QueryDenomTraceRequest is the request type for the Query/DenomTrace RPC -method +### UpgradeProposal +UpgradeProposal is a gov Content type for initiating an IBC breaking +upgrade. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `hash` | [string](#string) | | hash (in hex format) of the denomination trace information. | +| `title` | [string](#string) | | | +| `description` | [string](#string) | | | +| `plan` | [cosmos.upgrade.v1beta1.Plan](#cosmos.upgrade.v1beta1.Plan) | | | +| `upgraded_client_state` | [google.protobuf.Any](#google.protobuf.Any) | | An UpgradedClientState must be provided to perform an IBC breaking upgrade. This will make the chain commit to the correct upgraded (self) client state before the upgrade occurs, so that connecting chains can verify that the new upgraded client is valid by verifying a proof on the previous version of the chain. This will allow IBC connections to persist smoothly across planned chain upgrades | + - + -### QueryDenomTraceResponse -QueryDenomTraceResponse is the response type for the Query/DenomTrace RPC -method. + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `denom_trace` | [DenomTrace](#ibc.applications.transfer.v1.DenomTrace) | | denom_trace returns the requested denomination trace information. | + +

Top

+## ibc/core/channel/v1/channel.proto - + -### QueryDenomTracesRequest -QueryConnectionsRequest is the request type for the Query/DenomTraces RPC -method +### Acknowledgement +Acknowledgement is the recommended acknowledgement format to be used by +app-specific protocols. +NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental +conflicts with other protobuf message formats used for acknowledgements. +The first byte of any message with this format will be the non-ASCII values +`0xaa` (result) or `0xb2` (error). Implemented as defined by ICS: +https://github.com/cosmos/ics/tree/master/spec/ics-004-channel-and-packet-semantics#acknowledgement-envelope | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | +| `result` | [bytes](#bytes) | | | +| `error` | [string](#string) | | | - + -### QueryDenomTracesResponse -QueryConnectionsResponse is the response type for the Query/DenomTraces RPC -method. +### Channel +Channel defines pipeline for exactly-once packet delivery between specific +modules on separate blockchains, which has at least one end capable of +sending packets and one end capable of receiving packets. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `denom_traces` | [DenomTrace](#ibc.applications.transfer.v1.DenomTrace) | repeated | denom_traces returns all denominations trace information. | -| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | +| `state` | [State](#ibc.core.channel.v1.State) | | current state of the channel end | +| `ordering` | [Order](#ibc.core.channel.v1.Order) | | whether the channel is ordered or unordered | +| `counterparty` | [Counterparty](#ibc.core.channel.v1.Counterparty) | | counterparty channel end | +| `connection_hops` | [string](#string) | repeated | list of connection identifiers, in order, along which packets sent on this channel will travel | +| `version` | [string](#string) | | opaque channel version, which is agreed upon during the handshake | - + -### QueryParamsRequest -QueryParamsRequest is the request type for the Query/Params RPC method. +### Counterparty +Counterparty defines a channel end counterparty +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `port_id` | [string](#string) | | port on the counterparty chain which owns the other end of the channel. | +| `channel_id` | [string](#string) | | channel end on the counterparty chain | - -### QueryParamsResponse -QueryParamsResponse is the response type for the Query/Params RPC method. + + + +### IdentifiedChannel +IdentifiedChannel defines a channel with additional port and channel +identifier fields. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#ibc.applications.transfer.v1.Params) | | params defines the parameters of the module. | +| `state` | [State](#ibc.core.channel.v1.State) | | current state of the channel end | +| `ordering` | [Order](#ibc.core.channel.v1.Order) | | whether the channel is ordered or unordered | +| `counterparty` | [Counterparty](#ibc.core.channel.v1.Counterparty) | | counterparty channel end | +| `connection_hops` | [string](#string) | repeated | list of connection identifiers, in order, along which packets sent on this channel will travel | +| `version` | [string](#string) | | opaque channel version, which is agreed upon during the handshake | +| `port_id` | [string](#string) | | port identifier | +| `channel_id` | [string](#string) | | channel identifier | - - + - +### Packet +Packet defines a type that carries data across different chains through IBC - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `sequence` | [uint64](#uint64) | | number corresponds to the order of sends and receives, where a Packet with an earlier sequence number must be sent and received before a Packet with a later sequence number. | +| `source_port` | [string](#string) | | identifies the port on the sending chain. | +| `source_channel` | [string](#string) | | identifies the channel end on the sending chain. | +| `destination_port` | [string](#string) | | identifies the port on the receiving chain. | +| `destination_channel` | [string](#string) | | identifies the channel end on the receiving chain. | +| `data` | [bytes](#bytes) | | actual opaque bytes transferred directly to the application module | +| `timeout_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | block height after which the packet times out | +| `timeout_timestamp` | [uint64](#uint64) | | block timestamp (in nanoseconds) after which the packet times out | -### Query -Query provides defines the gRPC querier service. -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `DenomTrace` | [QueryDenomTraceRequest](#ibc.applications.transfer.v1.QueryDenomTraceRequest) | [QueryDenomTraceResponse](#ibc.applications.transfer.v1.QueryDenomTraceResponse) | DenomTrace queries a denomination trace information. | GET|/ibc/apps/transfer/v1/denom_traces/{hash}| -| `DenomTraces` | [QueryDenomTracesRequest](#ibc.applications.transfer.v1.QueryDenomTracesRequest) | [QueryDenomTracesResponse](#ibc.applications.transfer.v1.QueryDenomTracesResponse) | DenomTraces queries all denomination traces. | GET|/ibc/apps/transfer/v1/denom_traces| -| `Params` | [QueryParamsRequest](#ibc.applications.transfer.v1.QueryParamsRequest) | [QueryParamsResponse](#ibc.applications.transfer.v1.QueryParamsResponse) | Params queries all parameters of the ibc-transfer module. | GET|/ibc/apps/transfer/v1/params| - - -

Top

+ -## ibc/core/client/v1/client.proto +### PacketId +PacketId is an identifer for a unique Packet +Source chains refer to packets by source port/channel +Destination chains refer to packets by destination port/channel +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `port_id` | [string](#string) | | channel port identifier | +| `channel_id` | [string](#string) | | channel unique identifier | +| `sequence` | [uint64](#uint64) | | packet sequence | - -### ClientConsensusStates -ClientConsensusStates defines all the stored consensus states for a given -client. + + + + + + +### PacketState +PacketState defines the generic type necessary to retrieve and store +packet commitments, acknowledgements, and receipts. +Caller is responsible for knowing the context necessary to interpret this +state as a commitment, acknowledgement, or a receipt. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `client_id` | [string](#string) | | client identifier | -| `consensus_states` | [ConsensusStateWithHeight](#ibc.core.client.v1.ConsensusStateWithHeight) | repeated | consensus states and their heights associated with the client | +| `port_id` | [string](#string) | | channel port identifier. | +| `channel_id` | [string](#string) | | channel unique identifier. | +| `sequence` | [uint64](#uint64) | | packet sequence. | +| `data` | [bytes](#bytes) | | embedded data that represents packet state. | + - -### ClientUpdateProposal -ClientUpdateProposal is a governance proposal. If it passes, the substitute -client's latest consensus state is copied over to the subject client. The proposal -handler may fail if the subject and the substitute do not match in client and -chain parameters (with exception to latest height, frozen height, and chain-id). + +### Order +Order defines if a channel is ORDERED or UNORDERED -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `title` | [string](#string) | | the title of the update proposal | -| `description` | [string](#string) | | the description of the proposal | -| `subject_client_id` | [string](#string) | | the client identifier for the client to be updated if the proposal passes | -| `substitute_client_id` | [string](#string) | | the substitute client identifier for the client standing in for the subject client | +| Name | Number | Description | +| ---- | ------ | ----------- | +| ORDER_NONE_UNSPECIFIED | 0 | zero-value for channel ordering | +| ORDER_UNORDERED | 1 | packets can be delivered in any order, which may differ from the order in which they were sent. | +| ORDER_ORDERED | 2 | packets are delivered exactly in the order which they were sent | + +### State +State defines if a channel is in one of the following states: +CLOSED, INIT, TRYOPEN, OPEN or UNINITIALIZED. +| Name | Number | Description | +| ---- | ------ | ----------- | +| STATE_UNINITIALIZED_UNSPECIFIED | 0 | Default State | +| STATE_INIT | 1 | A channel has just started the opening handshake. | +| STATE_TRYOPEN | 2 | A channel has acknowledged the handshake step on the counterparty chain. | +| STATE_OPEN | 3 | A channel has completed the handshake. Open channels are ready to send and receive packets. | +| STATE_CLOSED | 4 | A channel has been closed and can no longer be used to send or receive packets. | - -### ConsensusStateWithHeight -ConsensusStateWithHeight defines a consensus state with an additional height -field. + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `height` | [Height](#ibc.core.client.v1.Height) | | consensus state height | -| `consensus_state` | [google.protobuf.Any](#google.protobuf.Any) | | consensus state | + + +

Top

+## ibc/applications/fee/v1/fee.proto - -### Height -Height is a monotonically increasing data type -that can be compared against another Height for the purposes of updating and -freezing clients + -Normally the RevisionHeight is incremented at each height while keeping -RevisionNumber the same. However some consensus algorithms may choose to -reset the height in certain conditions e.g. hard forks, state-machine -breaking changes In these cases, the RevisionNumber is incremented so that -height continues to be monitonically increasing even as the RevisionHeight -gets reset +### Fee +Fee interface +See Fee Payment Middleware spec: +https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middleware-contract | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `revision_number` | [uint64](#uint64) | | the revision that the client is currently on | -| `revision_height` | [uint64](#uint64) | | the height within the given revision | +| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | - + -### IdentifiedClientState -IdentifiedClientState defines a client state with an additional client -identifier field. +### IdentifiedPacketFee +Fee associated with a packet_id | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `client_id` | [string](#string) | | client identifier | -| `client_state` | [google.protobuf.Any](#google.protobuf.Any) | | client state | +| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | | +| `receive_fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | +| `ack_fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | +| `timeout_fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | +| `relayers` | [string](#string) | repeated | | + - + -### Params -Params defines the set of IBC light client parameters. + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `allowed_clients` | [string](#string) | repeated | allowed_clients defines the list of allowed client state types. | + +

Top

+## ibc/applications/fee/v1/genesis.proto - + -### UpgradeProposal -UpgradeProposal is a gov Content type for initiating an IBC breaking -upgrade. +### GenesisState +GenesisState defines the fee middleware genesis state | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `title` | [string](#string) | | | -| `description` | [string](#string) | | | -| `plan` | [cosmos.upgrade.v1beta1.Plan](#cosmos.upgrade.v1beta1.Plan) | | | -| `upgraded_client_state` | [google.protobuf.Any](#google.protobuf.Any) | | An UpgradedClientState must be provided to perform an IBC breaking upgrade. This will make the chain commit to the correct upgraded (self) client state before the upgrade occurs, so that connecting chains can verify that the new upgraded client is valid by verifying a proof on the previous version of the chain. This will allow IBC connections to persist smoothly across planned chain upgrades | +| `packets_fees` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | repeated | A mapping of packets -> escrowed fees | @@ -616,190 +694,165 @@ upgrade. - +

Top

-## ibc/applications/transfer/v1/tx.proto +## ibc/applications/fee/v1/query.proto - + -### MsgTransfer -MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) between -ICS20 enabled chains. See ICS Spec here: -https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures +### QueryAckFeeRequest +QueryAckFeeRequest is the request type for querying the acknowledgement fee | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `source_port` | [string](#string) | | the port on which the packet will be sent | -| `source_channel` | [string](#string) | | the channel by which the packet will be sent | -| `token` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | the tokens to be transferred | -| `sender` | [string](#string) | | the sender address | -| `receiver` | [string](#string) | | the recipient address on the destination chain | -| `timeout_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | Timeout height relative to the current block height. The timeout is disabled when set to 0. | -| `timeout_timestamp` | [uint64](#uint64) | | Timeout timestamp (in nanoseconds) relative to the current block timestamp. The timeout is disabled when set to 0. | +| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | PacketID | +| `relayer_address` | [string](#string) | | Caller should provide the intended relayer address in case the fee is dependent on specific relayer(s). | +| `query_height` | [uint64](#uint64) | | Height to query at | - + -### MsgTransferResponse -MsgTransferResponse defines the Msg/Transfer response type. +### QueryAckFeeResponse +QueryAckFeeResponse is the response type for the AckFee RPC + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | - - + - +### QueryIncentivizedPacketRequest +QueryIncentivizedPacketRequest is the request type for querying for all incentivized packets - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | PacketID | +| `query_height` | [uint64](#uint64) | | Height to query at | -### Msg -Msg defines the ibc/transfer Msg service. -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Transfer` | [MsgTransfer](#ibc.applications.transfer.v1.MsgTransfer) | [MsgTransferResponse](#ibc.applications.transfer.v1.MsgTransferResponse) | Transfer defines a rpc handler method for MsgTransfer. | | - - -

Top

+ -## ibc/core/channel/v1/channel.proto +### QueryIncentivizedPacketResponse +QueryIncentivizedPacketsResponse is the response type for the incentivized packet RPC +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `incentivized_packet` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | | Incentivized_packet | - -### Acknowledgement -Acknowledgement is the recommended acknowledgement format to be used by -app-specific protocols. -NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental -conflicts with other protobuf message formats used for acknowledgements. -The first byte of any message with this format will be the non-ASCII values -`0xaa` (result) or `0xb2` (error). Implemented as defined by ICS: -https://github.com/cosmos/ics/tree/master/spec/ics-004-channel-and-packet-semantics#acknowledgement-envelope + + + + + + +### QueryIncentivizedPacketsRequest +QueryIncentivizedPacketsRequest is the request type for querying for all incentivized packets | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `result` | [bytes](#bytes) | | | -| `error` | [string](#string) | | | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | +| `query_height` | [uint64](#uint64) | | Height to query at | - + -### Channel -Channel defines pipeline for exactly-once packet delivery between specific -modules on separate blockchains, which has at least one end capable of -sending packets and one end capable of receiving packets. +### QueryIncentivizedPacketsResponse +QueryIncentivizedPacketsResponse is the response type for the incentivized packets RPC | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `state` | [State](#ibc.core.channel.v1.State) | | current state of the channel end | -| `ordering` | [Order](#ibc.core.channel.v1.Order) | | whether the channel is ordered or unordered | -| `counterparty` | [Counterparty](#ibc.core.channel.v1.Counterparty) | | counterparty channel end | -| `connection_hops` | [string](#string) | repeated | list of connection identifiers, in order, along which packets sent on this channel will travel | -| `version` | [string](#string) | | opaque channel version, which is agreed upon during the handshake | +| `incentivized_packets` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | repeated | Map of all incentivized_packets | - + -### Counterparty -Counterparty defines a channel end counterparty +### QueryReceiveFeeRequest +QueryReceiveFeeRequest is the request type for querying the receive fee | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | port on the counterparty chain which owns the other end of the channel. | -| `channel_id` | [string](#string) | | channel end on the counterparty chain | +| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | PacketID | +| `relayer_address` | [string](#string) | | Caller should provide the intended relayer address in case the fee is dependent on specific relayer(s). | +| `query_height` | [uint64](#uint64) | | Height to query at | - + -### IdentifiedChannel -IdentifiedChannel defines a channel with additional port and channel -identifier fields. +### QueryReceiveFeeResponse +QueryReceiveFeeResponse is the response type for the ReceiveFee RPC | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `state` | [State](#ibc.core.channel.v1.State) | | current state of the channel end | -| `ordering` | [Order](#ibc.core.channel.v1.Order) | | whether the channel is ordered or unordered | -| `counterparty` | [Counterparty](#ibc.core.channel.v1.Counterparty) | | counterparty channel end | -| `connection_hops` | [string](#string) | repeated | list of connection identifiers, in order, along which packets sent on this channel will travel | -| `version` | [string](#string) | | opaque channel version, which is agreed upon during the handshake | -| `port_id` | [string](#string) | | port identifier | -| `channel_id` | [string](#string) | | channel identifier | +| `fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | - + -### Packet -Packet defines a type that carries data across different chains through IBC +### QueryTimeoutFeeRequest +QueryTimeoutFeeRequest is the request type for querying the timeout fee | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `sequence` | [uint64](#uint64) | | number corresponds to the order of sends and receives, where a Packet with an earlier sequence number must be sent and received before a Packet with a later sequence number. | -| `source_port` | [string](#string) | | identifies the port on the sending chain. | -| `source_channel` | [string](#string) | | identifies the channel end on the sending chain. | -| `destination_port` | [string](#string) | | identifies the port on the receiving chain. | -| `destination_channel` | [string](#string) | | identifies the channel end on the receiving chain. | -| `data` | [bytes](#bytes) | | actual opaque bytes transferred directly to the application module | -| `timeout_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | block height after which the packet times out | -| `timeout_timestamp` | [uint64](#uint64) | | block timestamp (in nanoseconds) after which the packet times out | +| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | PacketID | +| `relayer_address` | [string](#string) | | Caller should provide the intended relayer address in case the fee is dependent on specific relayer(s). | +| `query_height` | [uint64](#uint64) | | Height to query at | - + -### PacketState -PacketState defines the generic type necessary to retrieve and store -packet commitments, acknowledgements, and receipts. -Caller is responsible for knowing the context necessary to interpret this -state as a commitment, acknowledgement, or a receipt. +### QueryTimeoutFeeResponse +QueryTimeoutFeeResponse is the response type for the timeout RPC | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | channel port identifier. | -| `channel_id` | [string](#string) | | channel unique identifier. | -| `sequence` | [uint64](#uint64) | | packet sequence. | -| `data` | [bytes](#bytes) | | embedded data that represents packet state. | +| `fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | @@ -807,38 +860,387 @@ state as a commitment, acknowledgement, or a receipt. + - + -### Order -Order defines if a channel is ORDERED or UNORDERED -| Name | Number | Description | -| ---- | ------ | ----------- | -| ORDER_NONE_UNSPECIFIED | 0 | zero-value for channel ordering | -| ORDER_UNORDERED | 1 | packets can be delivered in any order, which may differ from the order in which they were sent. | -| ORDER_ORDERED | 2 | packets are delivered exactly in the order which they were sent | + + +### Query +Query provides defines the gRPC querier service. +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `ReceiveFee` | [QueryReceiveFeeRequest](#ibc.applications.fee.v1.QueryReceiveFeeRequest) | [QueryReceiveFeeResponse](#ibc.applications.fee.v1.QueryReceiveFeeResponse) | Gets the fee expected for submitting ReceivePacket msg for the given packet | GET|/ibc/apps/fee/v1/receive_fee/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}/relayer/{relayer_address}/height/{query_height}| +| `AckFee` | [QueryAckFeeRequest](#ibc.applications.fee.v1.QueryAckFeeRequest) | [QueryAckFeeResponse](#ibc.applications.fee.v1.QueryAckFeeResponse) | Gets the fee expected for submitting AcknowledgePacket msg for the given packet | GET|/ibc/apps/fee/v1/ack_fee/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}/relayer/{relayer_address}/height/{query_height}| +| `TimeoutFee` | [QueryTimeoutFeeRequest](#ibc.applications.fee.v1.QueryTimeoutFeeRequest) | [QueryTimeoutFeeResponse](#ibc.applications.fee.v1.QueryTimeoutFeeResponse) | Gets the fee expected for submitting TimeoutPacket msg for the given packet | GET|/ibc/apps/fee/v1/timeout_fee/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}/{relayer_address}/height/{query_height}| +| `IncentivizedPackets` | [QueryIncentivizedPacketsRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsRequest) | [QueryIncentivizedPacketsResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsResponse) | Gets all incentivized packets | GET|/ibc/apps/fee/v1/incentivized_packets/height/{query_height}| +| `IncentivizedPacket` | [QueryIncentivizedPacketRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketRequest) | [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) | Gets the specified incentivized packet | GET|/ibc/apps/fee/v1/incentivized_packet/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}/height/{query_height}| + - -### State -State defines if a channel is in one of the following states: -CLOSED, INIT, TRYOPEN, OPEN or UNINITIALIZED. -| Name | Number | Description | -| ---- | ------ | ----------- | -| STATE_UNINITIALIZED_UNSPECIFIED | 0 | Default State | -| STATE_INIT | 1 | A channel has just started the opening handshake. | -| STATE_TRYOPEN | 2 | A channel has acknowledged the handshake step on the counterparty chain. | -| STATE_OPEN | 3 | A channel has completed the handshake. Open channels are ready to send and receive packets. | -| STATE_CLOSED | 4 | A channel has been closed and can no longer be used to send or receive packets. | + +

Top

+## ibc/applications/fee/v1/tx.proto - - + + + +### MsgEscrowPacketFee +MsgEscrowPacketFee defines the request type EscrowPacketFee RPC + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | | +| `receive_fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | +| `ack_fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | +| `timeout_fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | +| `relayers` | [string](#string) | repeated | | + + + + + + + + +### MsgEscrowPacketFeeResponse +MsgEscrowPacketFeeResponse defines the response type for Msg/EscrowPacketFee + + + + + + + + +### MsgRegisterCounterPartyAddressResponse +MsgRegisterCounterPartyAddressResponse defines the Msg/RegisterCounteryPartyAddress response type + + + + + + + + +### MsgRegisterCounterpartyAddress +MsgRegisterCounterpartyAddress is the request type for registering the counter party address + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [string](#string) | | | +| `counterparty_address` | [string](#string) | | | + + + + + + + + + + + + + + +### Msg +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. | | +| `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. | | + + + + + + +

Top

+ +## ibc/applications/transfer/v1/transfer.proto + + + + + +### DenomTrace +DenomTrace contains the base denomination for ICS20 fungible tokens and the +source tracing information path. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `path` | [string](#string) | | path defines the chain of port/channel identifiers used for tracing the source of the fungible token. | +| `base_denom` | [string](#string) | | base denomination of the relayed fungible token. | + + + + + + + + +### FungibleTokenPacketData +FungibleTokenPacketData defines a struct for the packet payload +See FungibleTokenPacketData spec: +https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `denom` | [string](#string) | | the token denomination to be transferred | +| `amount` | [uint64](#uint64) | | the token amount to be transferred | +| `sender` | [string](#string) | | the sender address | +| `receiver` | [string](#string) | | the recipient address on the destination chain | + + + + + + + + +### Params +Params defines the set of IBC transfer parameters. +NOTE: To prevent a single token from being transferred, set the +TransfersEnabled parameter to true and then set the bank module's SendEnabled +parameter for the denomination to false. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `send_enabled` | [bool](#bool) | | send_enabled enables or disables all cross-chain token transfers from this chain. | +| `receive_enabled` | [bool](#bool) | | receive_enabled enables or disables all cross-chain token transfers to this chain. | + + + + + + + + + + + + + + + + +

Top

+ +## ibc/applications/transfer/v1/genesis.proto + + + + + +### GenesisState +GenesisState defines the ibc-transfer genesis state + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `port_id` | [string](#string) | | | +| `denom_traces` | [DenomTrace](#ibc.applications.transfer.v1.DenomTrace) | repeated | | +| `params` | [Params](#ibc.applications.transfer.v1.Params) | | | + + + + + + + + + + + + + + + + +

Top

+ +## ibc/applications/transfer/v1/query.proto + + + + + +### QueryDenomTraceRequest +QueryDenomTraceRequest is the request type for the Query/DenomTrace RPC +method + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `hash` | [string](#string) | | hash (in hex format) of the denomination trace information. | + + + + + + + + +### QueryDenomTraceResponse +QueryDenomTraceResponse is the response type for the Query/DenomTrace RPC +method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `denom_trace` | [DenomTrace](#ibc.applications.transfer.v1.DenomTrace) | | denom_trace returns the requested denomination trace information. | + + + + + + + + +### QueryDenomTracesRequest +QueryConnectionsRequest is the request type for the Query/DenomTraces RPC +method + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | + + + + + + + + +### QueryDenomTracesResponse +QueryConnectionsResponse is the response type for the Query/DenomTraces RPC +method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `denom_traces` | [DenomTrace](#ibc.applications.transfer.v1.DenomTrace) | repeated | denom_traces returns all denominations trace information. | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | + + + + + + + + +### QueryParamsRequest +QueryParamsRequest is the request type for the Query/Params RPC method. + + + + + + + + +### QueryParamsResponse +QueryParamsResponse is the response type for the Query/Params RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `params` | [Params](#ibc.applications.transfer.v1.Params) | | params defines the parameters of the module. | + + + + + + + + + + + + + + +### Query +Query provides defines the gRPC querier service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `DenomTrace` | [QueryDenomTraceRequest](#ibc.applications.transfer.v1.QueryDenomTraceRequest) | [QueryDenomTraceResponse](#ibc.applications.transfer.v1.QueryDenomTraceResponse) | DenomTrace queries a denomination trace information. | GET|/ibc/apps/transfer/v1/denom_traces/{hash}| +| `DenomTraces` | [QueryDenomTracesRequest](#ibc.applications.transfer.v1.QueryDenomTracesRequest) | [QueryDenomTracesResponse](#ibc.applications.transfer.v1.QueryDenomTracesResponse) | DenomTraces queries all denomination traces. | GET|/ibc/apps/transfer/v1/denom_traces| +| `Params` | [QueryParamsRequest](#ibc.applications.transfer.v1.QueryParamsRequest) | [QueryParamsResponse](#ibc.applications.transfer.v1.QueryParamsResponse) | Params queries all parameters of the ibc-transfer module. | GET|/ibc/apps/transfer/v1/params| + + + + + + +

Top

+ +## ibc/applications/transfer/v1/tx.proto + + + + + +### MsgTransfer +MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) between +ICS20 enabled chains. See ICS Spec here: +https://github.com/cosmos/ics/tree/master/spec/ics-020-fungible-token-transfer#data-structures + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `source_port` | [string](#string) | | the port on which the packet will be sent | +| `source_channel` | [string](#string) | | the channel by which the packet will be sent | +| `token` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | the tokens to be transferred | +| `sender` | [string](#string) | | the sender address | +| `receiver` | [string](#string) | | the recipient address on the destination chain | +| `timeout_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | Timeout height relative to the current block height. The timeout is disabled when set to 0. | +| `timeout_timestamp` | [uint64](#uint64) | | Timeout timestamp (in nanoseconds) relative to the current block timestamp. The timeout is disabled when set to 0. | + + + + + + + + +### MsgTransferResponse +MsgTransferResponse defines the Msg/Transfer response type. + + + + + + + + + + + + + + +### Msg +Msg defines the ibc/transfer Msg service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Transfer` | [MsgTransfer](#ibc.applications.transfer.v1.MsgTransfer) | [MsgTransferResponse](#ibc.applications.transfer.v1.MsgTransferResponse) | Transfer defines a rpc handler method for MsgTransfer. | | diff --git a/modules/apps/29-fee/types/fee.pb.go b/modules/apps/29-fee/types/fee.pb.go new file mode 100644 index 00000000000..d6597e1c0f8 --- /dev/null +++ b/modules/apps/29-fee/types/fee.pb.go @@ -0,0 +1,765 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/applications/fee/v1/fee.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + types1 "github.com/cosmos/ibc-go/modules/core/04-channel/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Fee interface +// See Fee Payment Middleware spec: +// https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middleware-contract +type Fee struct { + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` +} + +func (m *Fee) Reset() { *m = Fee{} } +func (m *Fee) String() string { return proto.CompactTextString(m) } +func (*Fee) ProtoMessage() {} +func (*Fee) Descriptor() ([]byte, []int) { + return fileDescriptor_cb3319f1af2a53e5, []int{0} +} +func (m *Fee) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Fee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Fee.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Fee) XXX_Merge(src proto.Message) { + xxx_messageInfo_Fee.Merge(m, src) +} +func (m *Fee) XXX_Size() int { + return m.Size() +} +func (m *Fee) XXX_DiscardUnknown() { + xxx_messageInfo_Fee.DiscardUnknown(m) +} + +var xxx_messageInfo_Fee proto.InternalMessageInfo + +func (m *Fee) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Amount + } + return nil +} + +// Fee associated with a packet_id +type IdentifiedPacketFee struct { + PacketId *types1.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id,omitempty" yaml:"packet_id"` + ReceiveFee *Fee `protobuf:"bytes,2,opt,name=receive_fee,json=receiveFee,proto3" json:"receive_fee,omitempty" yaml:"receive_fee"` + AckFee *Fee `protobuf:"bytes,3,opt,name=ack_fee,json=ackFee,proto3" json:"ack_fee,omitempty" yaml:"ack_fee"` + TimeoutFee *Fee `protobuf:"bytes,4,opt,name=timeout_fee,json=timeoutFee,proto3" json:"timeout_fee,omitempty" yaml:"timeout_fee"` + Relayers []string `protobuf:"bytes,5,rep,name=relayers,proto3" json:"relayers,omitempty"` +} + +func (m *IdentifiedPacketFee) Reset() { *m = IdentifiedPacketFee{} } +func (m *IdentifiedPacketFee) String() string { return proto.CompactTextString(m) } +func (*IdentifiedPacketFee) ProtoMessage() {} +func (*IdentifiedPacketFee) Descriptor() ([]byte, []int) { + return fileDescriptor_cb3319f1af2a53e5, []int{1} +} +func (m *IdentifiedPacketFee) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IdentifiedPacketFee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IdentifiedPacketFee.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *IdentifiedPacketFee) XXX_Merge(src proto.Message) { + xxx_messageInfo_IdentifiedPacketFee.Merge(m, src) +} +func (m *IdentifiedPacketFee) XXX_Size() int { + return m.Size() +} +func (m *IdentifiedPacketFee) XXX_DiscardUnknown() { + xxx_messageInfo_IdentifiedPacketFee.DiscardUnknown(m) +} + +var xxx_messageInfo_IdentifiedPacketFee proto.InternalMessageInfo + +func (m *IdentifiedPacketFee) GetPacketId() *types1.PacketId { + if m != nil { + return m.PacketId + } + return nil +} + +func (m *IdentifiedPacketFee) GetReceiveFee() *Fee { + if m != nil { + return m.ReceiveFee + } + return nil +} + +func (m *IdentifiedPacketFee) GetAckFee() *Fee { + if m != nil { + return m.AckFee + } + return nil +} + +func (m *IdentifiedPacketFee) GetTimeoutFee() *Fee { + if m != nil { + return m.TimeoutFee + } + return nil +} + +func (m *IdentifiedPacketFee) GetRelayers() []string { + if m != nil { + return m.Relayers + } + return nil +} + +func init() { + proto.RegisterType((*Fee)(nil), "ibc.applications.fee.v1.Fee") + proto.RegisterType((*IdentifiedPacketFee)(nil), "ibc.applications.fee.v1.IdentifiedPacketFee") +} + +func init() { proto.RegisterFile("ibc/applications/fee/v1/fee.proto", fileDescriptor_cb3319f1af2a53e5) } + +var fileDescriptor_cb3319f1af2a53e5 = []byte{ + // 443 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0x3f, 0x8f, 0xd3, 0x30, + 0x18, 0xc6, 0x9b, 0x2b, 0x94, 0x3b, 0x57, 0x42, 0x28, 0x9c, 0xa0, 0x54, 0x90, 0x94, 0x4c, 0x5d, + 0x6a, 0xd3, 0x32, 0xc1, 0x18, 0xa4, 0x93, 0x2a, 0x31, 0x9c, 0x22, 0xdd, 0xc2, 0x72, 0x72, 0x9c, + 0xb7, 0x39, 0x93, 0x3f, 0x8e, 0x62, 0x27, 0x52, 0xbf, 0x05, 0x9f, 0x83, 0x4f, 0x72, 0xe3, 0x8d, + 0x4c, 0x01, 0xb5, 0xdf, 0xa0, 0x33, 0x03, 0xb2, 0x63, 0x4e, 0x95, 0x10, 0x12, 0x4c, 0x7e, 0x5f, + 0xdb, 0xcf, 0xef, 0x79, 0x64, 0xbf, 0xe8, 0x35, 0x8f, 0x19, 0xa1, 0x55, 0x95, 0x73, 0x46, 0x15, + 0x17, 0xa5, 0x24, 0x1b, 0x00, 0xd2, 0x2e, 0xf5, 0x82, 0xab, 0x5a, 0x28, 0xe1, 0x3e, 0xe7, 0x31, + 0xc3, 0xc7, 0x57, 0xb0, 0x3e, 0x6b, 0x97, 0x53, 0x8f, 0x09, 0x59, 0x08, 0x49, 0x62, 0x2a, 0xb5, + 0x24, 0x06, 0x45, 0x97, 0x84, 0x09, 0x5e, 0xf6, 0xc2, 0xe9, 0x79, 0x2a, 0x52, 0x61, 0x4a, 0xa2, + 0x2b, 0xbb, 0x6b, 0x1c, 0x99, 0xa8, 0x81, 0xb0, 0x1b, 0x5a, 0x96, 0x90, 0x6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 0x99, 0x46, 0x5d, 0xa1, 0xb1, 0xe2, 0x05, 0x88, 0x46, 0x19, 0xdc, 0x83, 0xff, + 0x4b, 0x78, 0x24, 0x0d, 0x22, 0x64, 0x3b, 0x8d, 0x9d, 0xa2, 0xd3, 0x1a, 0x72, 0xba, 0x85, 0x5a, + 0x4e, 0x1e, 0xce, 0x86, 0xf3, 0xb3, 0xe8, 0xbe, 0x0f, 0x3f, 0xde, 0xee, 0x3c, 0xe7, 0x6e, 0xe7, + 0x39, 0x3f, 0x76, 0x9e, 0xf3, 0x65, 0xef, 0x0d, 0xee, 0xf6, 0xde, 0xe0, 0xdb, 0xde, 0x1b, 0x7c, + 0x5a, 0xfd, 0xf9, 0x95, 0x3c, 0x66, 0x8b, 0x54, 0x90, 0x42, 0x24, 0x4d, 0x0e, 0x52, 0x8f, 0xad, + 0x24, 0xab, 0x77, 0x0b, 0x3d, 0xb1, 0xe6, 0x6b, 0xe3, 0x91, 0x99, 0x9f, 0xb7, 0xbf, 0x02, 0x00, + 0x00, 0xff, 0xff, 0x94, 0x57, 0xcf, 0x1b, 0xd6, 0x02, 0x00, 0x00, +} + +func (m *Fee) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Fee) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Fee) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFee(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *IdentifiedPacketFee) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *IdentifiedPacketFee) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IdentifiedPacketFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Relayers) > 0 { + for iNdEx := len(m.Relayers) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Relayers[iNdEx]) + copy(dAtA[i:], m.Relayers[iNdEx]) + i = encodeVarintFee(dAtA, i, uint64(len(m.Relayers[iNdEx]))) + i-- + dAtA[i] = 0x2a + } + } + if m.TimeoutFee != nil { + { + size, err := m.TimeoutFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFee(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.AckFee != nil { + { + size, err := m.AckFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFee(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.ReceiveFee != nil { + { + size, err := m.ReceiveFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFee(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.PacketId != nil { + { + size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFee(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintFee(dAtA []byte, offset int, v uint64) int { + offset -= sovFee(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Fee) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovFee(uint64(l)) + } + } + return n +} + +func (m *IdentifiedPacketFee) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PacketId != nil { + l = m.PacketId.Size() + n += 1 + l + sovFee(uint64(l)) + } + if m.ReceiveFee != nil { + l = m.ReceiveFee.Size() + n += 1 + l + sovFee(uint64(l)) + } + if m.AckFee != nil { + l = m.AckFee.Size() + n += 1 + l + sovFee(uint64(l)) + } + if m.TimeoutFee != nil { + l = m.TimeoutFee.Size() + n += 1 + l + sovFee(uint64(l)) + } + if len(m.Relayers) > 0 { + for _, s := range m.Relayers { + l = len(s) + n += 1 + l + sovFee(uint64(l)) + } + } + return n +} + +func sovFee(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozFee(x uint64) (n int) { + return sovFee(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Fee) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFee + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Fee: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Fee: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFee + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFee + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFee + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFee(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFee + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *IdentifiedPacketFee) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFee + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: IdentifiedPacketFee: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IdentifiedPacketFee: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFee + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFee + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFee + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PacketId == nil { + m.PacketId = &types1.PacketId{} + } + if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ReceiveFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFee + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFee + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFee + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ReceiveFee == nil { + m.ReceiveFee = &Fee{} + } + if err := m.ReceiveFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AckFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFee + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFee + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFee + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.AckFee == nil { + m.AckFee = &Fee{} + } + if err := m.AckFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TimeoutFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFee + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFee + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFee + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.TimeoutFee == nil { + m.TimeoutFee = &Fee{} + } + if err := m.TimeoutFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Relayers", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFee + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFee + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFee + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Relayers = append(m.Relayers, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFee(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFee + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipFee(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowFee + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowFee + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowFee + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthFee + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupFee + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthFee + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthFee = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowFee = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupFee = fmt.Errorf("proto: unexpected end of group") +) diff --git a/modules/apps/29-fee/types/genesis.pb.go b/modules/apps/29-fee/types/genesis.pb.go new file mode 100644 index 00000000000..e108131adfc --- /dev/null +++ b/modules/apps/29-fee/types/genesis.pb.go @@ -0,0 +1,337 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/applications/fee/v1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the fee middleware genesis state +type GenesisState struct { + // A mapping of packets -> escrowed fees + PacketsFees []*IdentifiedPacketFee `protobuf:"bytes,1,rep,name=packets_fees,json=packetsFees,proto3" json:"packets_fees,omitempty" yaml:"packets_fees"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_7191992e856dff95, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetPacketsFees() []*IdentifiedPacketFee { + if m != nil { + return m.PacketsFees + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "ibc.applications.fee.v1.GenesisState") +} + +func init() { + proto.RegisterFile("ibc/applications/fee/v1/genesis.proto", fileDescriptor_7191992e856dff95) +} + +var fileDescriptor_7191992e856dff95 = []byte{ + // 260 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x8f, 0xb1, 0x4a, 0xc3, 0x50, + 0x14, 0x86, 0x13, 0x04, 0x87, 0xb4, 0x53, 0x15, 0x2a, 0x1d, 0xae, 0x1a, 0x10, 0x1c, 0xec, 0xbd, + 0x34, 0x4e, 0x3a, 0x76, 0xa8, 0x08, 0x0e, 0xa2, 0x9b, 0x8b, 0xe4, 0xde, 0x9c, 0xdc, 0x1e, 0x4c,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 0x65, 0x8b, 0x02, 0xb8, 0x75, 0x62, 0x95, 0xdc, 0x8c, 0x5b, 0x1d, 0xbf, + 0x72, 0xc0, 0xfa, 0xb0, 0xd3, 0xb9, 0xfe, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x42, 0xac, 0xef, 0xaa, + 0x49, 0x01, 0x00, 0x00, +} + +func (m *GenesisState) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PacketsFees) > 0 { + for iNdEx := len(m.PacketsFees) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PacketsFees[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.PacketsFees) > 0 { + for _, e := range m.PacketsFees { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PacketsFees", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PacketsFees = append(m.PacketsFees, &IdentifiedPacketFee{}) + if err := m.PacketsFees[len(m.PacketsFees)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/modules/apps/29-fee/types/query.pb.go b/modules/apps/29-fee/types/query.pb.go new file mode 100644 index 00000000000..bfcae7cdd88 --- /dev/null +++ b/modules/apps/29-fee/types/query.pb.go @@ -0,0 +1,2574 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/applications/fee/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + query "github.com/cosmos/cosmos-sdk/types/query" + types "github.com/cosmos/ibc-go/modules/core/04-channel/types" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryReceiveFeeRequest is the request type for querying the receive fee +type QueryReceiveFeeRequest struct { + // PacketID + PacketId *types.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id,omitempty"` + // Caller should provide the intended relayer address in case the fee is dependent on specific relayer(s). + RelayerAddress string `protobuf:"bytes,2,opt,name=relayer_address,json=relayerAddress,proto3" json:"relayer_address,omitempty"` + // Height to query at + QueryHeight uint64 `protobuf:"varint,3,opt,name=query_height,json=queryHeight,proto3" json:"query_height,omitempty"` +} + +func (m *QueryReceiveFeeRequest) Reset() { *m = QueryReceiveFeeRequest{} } +func (m *QueryReceiveFeeRequest) String() string { return proto.CompactTextString(m) } +func (*QueryReceiveFeeRequest) ProtoMessage() {} +func (*QueryReceiveFeeRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{0} +} +func (m *QueryReceiveFeeRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryReceiveFeeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryReceiveFeeRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryReceiveFeeRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryReceiveFeeRequest.Merge(m, src) +} +func (m *QueryReceiveFeeRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryReceiveFeeRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryReceiveFeeRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryReceiveFeeRequest proto.InternalMessageInfo + +func (m *QueryReceiveFeeRequest) GetPacketId() *types.PacketId { + if m != nil { + return m.PacketId + } + return nil +} + +func (m *QueryReceiveFeeRequest) GetRelayerAddress() string { + if m != nil { + return m.RelayerAddress + } + return "" +} + +func (m *QueryReceiveFeeRequest) GetQueryHeight() uint64 { + if m != nil { + return m.QueryHeight + } + return 0 +} + +// QueryReceiveFeeResponse is the response type for the ReceiveFee RPC +type QueryReceiveFeeResponse struct { + Fee *Fee `protobuf:"bytes,1,opt,name=fee,proto3" json:"fee,omitempty"` +} + +func (m *QueryReceiveFeeResponse) Reset() { *m = QueryReceiveFeeResponse{} } +func (m *QueryReceiveFeeResponse) String() string { return proto.CompactTextString(m) } +func (*QueryReceiveFeeResponse) ProtoMessage() {} +func (*QueryReceiveFeeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{1} +} +func (m *QueryReceiveFeeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryReceiveFeeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryReceiveFeeResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryReceiveFeeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryReceiveFeeResponse.Merge(m, src) +} +func (m *QueryReceiveFeeResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryReceiveFeeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryReceiveFeeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryReceiveFeeResponse proto.InternalMessageInfo + +func (m *QueryReceiveFeeResponse) GetFee() *Fee { + if m != nil { + return m.Fee + } + return nil +} + +// QueryAckFeeRequest is the request type for querying the acknowledgement fee +type QueryAckFeeRequest struct { + // PacketID + PacketId *types.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id,omitempty"` + // Caller should provide the intended relayer address in case the fee is dependent on specific relayer(s). + RelayerAddress string `protobuf:"bytes,2,opt,name=relayer_address,json=relayerAddress,proto3" json:"relayer_address,omitempty"` + // Height to query at + QueryHeight uint64 `protobuf:"varint,3,opt,name=query_height,json=queryHeight,proto3" json:"query_height,omitempty"` +} + +func (m *QueryAckFeeRequest) Reset() { *m = QueryAckFeeRequest{} } +func (m *QueryAckFeeRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAckFeeRequest) ProtoMessage() {} +func (*QueryAckFeeRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{2} +} +func (m *QueryAckFeeRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAckFeeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAckFeeRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAckFeeRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAckFeeRequest.Merge(m, src) +} +func (m *QueryAckFeeRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAckFeeRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAckFeeRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAckFeeRequest proto.InternalMessageInfo + +func (m *QueryAckFeeRequest) GetPacketId() *types.PacketId { + if m != nil { + return m.PacketId + } + return nil +} + +func (m *QueryAckFeeRequest) GetRelayerAddress() string { + if m != nil { + return m.RelayerAddress + } + return "" +} + +func (m *QueryAckFeeRequest) GetQueryHeight() uint64 { + if m != nil { + return m.QueryHeight + } + return 0 +} + +// QueryAckFeeResponse is the response type for the AckFee RPC +type QueryAckFeeResponse struct { + Fee *Fee `protobuf:"bytes,1,opt,name=fee,proto3" json:"fee,omitempty"` +} + +func (m *QueryAckFeeResponse) Reset() { *m = QueryAckFeeResponse{} } +func (m *QueryAckFeeResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAckFeeResponse) ProtoMessage() {} +func (*QueryAckFeeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{3} +} +func (m *QueryAckFeeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAckFeeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAckFeeResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryAckFeeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAckFeeResponse.Merge(m, src) +} +func (m *QueryAckFeeResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAckFeeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAckFeeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAckFeeResponse proto.InternalMessageInfo + +func (m *QueryAckFeeResponse) GetFee() *Fee { + if m != nil { + return m.Fee + } + return nil +} + +// QueryTimeoutFeeRequest is the request type for querying the timeout fee +type QueryTimeoutFeeRequest struct { + // PacketID + PacketId *types.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id,omitempty"` + // Caller should provide the intended relayer address in case the fee is dependent on specific relayer(s). + RelayerAddress string `protobuf:"bytes,2,opt,name=relayer_address,json=relayerAddress,proto3" json:"relayer_address,omitempty"` + // Height to query at + QueryHeight uint64 `protobuf:"varint,3,opt,name=query_height,json=queryHeight,proto3" json:"query_height,omitempty"` +} + +func (m *QueryTimeoutFeeRequest) Reset() { *m = QueryTimeoutFeeRequest{} } +func (m *QueryTimeoutFeeRequest) String() string { return proto.CompactTextString(m) } +func (*QueryTimeoutFeeRequest) ProtoMessage() {} +func (*QueryTimeoutFeeRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{4} +} +func (m *QueryTimeoutFeeRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTimeoutFeeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTimeoutFeeRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryTimeoutFeeRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTimeoutFeeRequest.Merge(m, src) +} +func (m *QueryTimeoutFeeRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryTimeoutFeeRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTimeoutFeeRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTimeoutFeeRequest proto.InternalMessageInfo + +func (m *QueryTimeoutFeeRequest) GetPacketId() *types.PacketId { + if m != nil { + return m.PacketId + } + return nil +} + +func (m *QueryTimeoutFeeRequest) GetRelayerAddress() string { + if m != nil { + return m.RelayerAddress + } + return "" +} + +func (m *QueryTimeoutFeeRequest) GetQueryHeight() uint64 { + if m != nil { + return m.QueryHeight + } + return 0 +} + +// QueryTimeoutFeeResponse is the response type for the timeout RPC +type QueryTimeoutFeeResponse struct { + Fee *Fee `protobuf:"bytes,1,opt,name=fee,proto3" json:"fee,omitempty"` +} + +func (m *QueryTimeoutFeeResponse) Reset() { *m = QueryTimeoutFeeResponse{} } +func (m *QueryTimeoutFeeResponse) String() string { return proto.CompactTextString(m) } +func (*QueryTimeoutFeeResponse) ProtoMessage() {} +func (*QueryTimeoutFeeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{5} +} +func (m *QueryTimeoutFeeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTimeoutFeeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTimeoutFeeResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryTimeoutFeeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTimeoutFeeResponse.Merge(m, src) +} +func (m *QueryTimeoutFeeResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryTimeoutFeeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTimeoutFeeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTimeoutFeeResponse proto.InternalMessageInfo + +func (m *QueryTimeoutFeeResponse) GetFee() *Fee { + if m != nil { + return m.Fee + } + return nil +} + +// QueryIncentivizedPacketsRequest is the request type for querying for all incentivized packets +type QueryIncentivizedPacketsRequest struct { + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` + // Height to query at + QueryHeight uint64 `protobuf:"varint,2,opt,name=query_height,json=queryHeight,proto3" json:"query_height,omitempty"` +} + +func (m *QueryIncentivizedPacketsRequest) Reset() { *m = QueryIncentivizedPacketsRequest{} } +func (m *QueryIncentivizedPacketsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryIncentivizedPacketsRequest) ProtoMessage() {} +func (*QueryIncentivizedPacketsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{6} +} +func (m *QueryIncentivizedPacketsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryIncentivizedPacketsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryIncentivizedPacketsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryIncentivizedPacketsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryIncentivizedPacketsRequest.Merge(m, src) +} +func (m *QueryIncentivizedPacketsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryIncentivizedPacketsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryIncentivizedPacketsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryIncentivizedPacketsRequest proto.InternalMessageInfo + +func (m *QueryIncentivizedPacketsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +func (m *QueryIncentivizedPacketsRequest) GetQueryHeight() uint64 { + if m != nil { + return m.QueryHeight + } + return 0 +} + +// QueryIncentivizedPacketsResponse is the response type for the incentivized packets RPC +type QueryIncentivizedPacketsResponse struct { + // Map of all incentivized_packets + IncentivizedPackets []*IdentifiedPacketFee `protobuf:"bytes,1,rep,name=incentivized_packets,json=incentivizedPackets,proto3" json:"incentivized_packets,omitempty"` +} + +func (m *QueryIncentivizedPacketsResponse) Reset() { *m = QueryIncentivizedPacketsResponse{} } +func (m *QueryIncentivizedPacketsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryIncentivizedPacketsResponse) ProtoMessage() {} +func (*QueryIncentivizedPacketsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{7} +} +func (m *QueryIncentivizedPacketsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryIncentivizedPacketsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryIncentivizedPacketsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryIncentivizedPacketsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryIncentivizedPacketsResponse.Merge(m, src) +} +func (m *QueryIncentivizedPacketsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryIncentivizedPacketsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryIncentivizedPacketsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryIncentivizedPacketsResponse proto.InternalMessageInfo + +func (m *QueryIncentivizedPacketsResponse) GetIncentivizedPackets() []*IdentifiedPacketFee { + if m != nil { + return m.IncentivizedPackets + } + return nil +} + +// QueryIncentivizedPacketRequest is the request type for querying for all incentivized packets +type QueryIncentivizedPacketRequest struct { + // PacketID + PacketId *types.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id,omitempty"` + // Height to query at + QueryHeight uint64 `protobuf:"varint,2,opt,name=query_height,json=queryHeight,proto3" json:"query_height,omitempty"` +} + +func (m *QueryIncentivizedPacketRequest) Reset() { *m = QueryIncentivizedPacketRequest{} } +func (m *QueryIncentivizedPacketRequest) String() string { return proto.CompactTextString(m) } +func (*QueryIncentivizedPacketRequest) ProtoMessage() {} +func (*QueryIncentivizedPacketRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{8} +} +func (m *QueryIncentivizedPacketRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryIncentivizedPacketRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryIncentivizedPacketRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryIncentivizedPacketRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryIncentivizedPacketRequest.Merge(m, src) +} +func (m *QueryIncentivizedPacketRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryIncentivizedPacketRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryIncentivizedPacketRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryIncentivizedPacketRequest proto.InternalMessageInfo + +func (m *QueryIncentivizedPacketRequest) GetPacketId() *types.PacketId { + if m != nil { + return m.PacketId + } + return nil +} + +func (m *QueryIncentivizedPacketRequest) GetQueryHeight() uint64 { + if m != nil { + return m.QueryHeight + } + return 0 +} + +// QueryIncentivizedPacketsResponse is the response type for the incentivized packet RPC +type QueryIncentivizedPacketResponse struct { + // Incentivized_packet + IncentivizedPacket *IdentifiedPacketFee `protobuf:"bytes,1,opt,name=incentivized_packet,json=incentivizedPacket,proto3" json:"incentivized_packet,omitempty"` +} + +func (m *QueryIncentivizedPacketResponse) Reset() { *m = QueryIncentivizedPacketResponse{} } +func (m *QueryIncentivizedPacketResponse) String() string { return proto.CompactTextString(m) } +func (*QueryIncentivizedPacketResponse) ProtoMessage() {} +func (*QueryIncentivizedPacketResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{9} +} +func (m *QueryIncentivizedPacketResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryIncentivizedPacketResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryIncentivizedPacketResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryIncentivizedPacketResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryIncentivizedPacketResponse.Merge(m, src) +} +func (m *QueryIncentivizedPacketResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryIncentivizedPacketResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryIncentivizedPacketResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryIncentivizedPacketResponse proto.InternalMessageInfo + +func (m *QueryIncentivizedPacketResponse) GetIncentivizedPacket() *IdentifiedPacketFee { + if m != nil { + return m.IncentivizedPacket + } + return nil +} + +func init() { + proto.RegisterType((*QueryReceiveFeeRequest)(nil), "ibc.applications.fee.v1.QueryReceiveFeeRequest") + proto.RegisterType((*QueryReceiveFeeResponse)(nil), "ibc.applications.fee.v1.QueryReceiveFeeResponse") + proto.RegisterType((*QueryAckFeeRequest)(nil), "ibc.applications.fee.v1.QueryAckFeeRequest") + proto.RegisterType((*QueryAckFeeResponse)(nil), "ibc.applications.fee.v1.QueryAckFeeResponse") + proto.RegisterType((*QueryTimeoutFeeRequest)(nil), "ibc.applications.fee.v1.QueryTimeoutFeeRequest") + proto.RegisterType((*QueryTimeoutFeeResponse)(nil), "ibc.applications.fee.v1.QueryTimeoutFeeResponse") + proto.RegisterType((*QueryIncentivizedPacketsRequest)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketsRequest") + proto.RegisterType((*QueryIncentivizedPacketsResponse)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketsResponse") + proto.RegisterType((*QueryIncentivizedPacketRequest)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketRequest") + proto.RegisterType((*QueryIncentivizedPacketResponse)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketResponse") +} + +func init() { + proto.RegisterFile("ibc/applications/fee/v1/query.proto", fileDescriptor_0638a8a78ca2503c) +} + +var fileDescriptor_0638a8a78ca2503c = []byte{ + // 793 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0x51, 0x6b, 0x13, 0x4b, + 0x14, 0xee, 0xa4, 0xf7, 0x96, 0xdb, 0xe9, 0xe5, 0x5e, 0x98, 0x94, 0xdb, 0x10, 0x7a, 0x73, 0xd3, + 0x5c, 0xd0, 0xa0, 0xed, 0x8c, 0x89, 0x0f, 0xb6, 0x8a, 0x0f, 0x55, 0x2c, 0x06, 0x7c, 0xa8, 0xc1, + 0x27, 0x41, 0xc2, 0x66, 0xf7, 0x64, 0x33, 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+ 0xff, 0x1e, 0xb8, 0x07, 0x20, 0x8f, 0x0b, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Gets the fee expected for submitting ReceivePacket msg for the given packet + ReceiveFee(ctx context.Context, in *QueryReceiveFeeRequest, opts ...grpc.CallOption) (*QueryReceiveFeeResponse, error) + // Gets the fee expected for submitting AcknowledgePacket msg for the given packet + AckFee(ctx context.Context, in *QueryAckFeeRequest, opts ...grpc.CallOption) (*QueryAckFeeResponse, error) + // Gets the fee expected for submitting TimeoutPacket msg for the given packet + TimeoutFee(ctx context.Context, in *QueryTimeoutFeeRequest, opts ...grpc.CallOption) (*QueryTimeoutFeeResponse, error) + // Gets all incentivized packets + IncentivizedPackets(ctx context.Context, in *QueryIncentivizedPacketsRequest, opts ...grpc.CallOption) (*QueryIncentivizedPacketsResponse, error) + // Gets the specified incentivized packet + IncentivizedPacket(ctx context.Context, in *QueryIncentivizedPacketRequest, opts ...grpc.CallOption) (*QueryIncentivizedPacketResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) ReceiveFee(ctx context.Context, in *QueryReceiveFeeRequest, opts ...grpc.CallOption) (*QueryReceiveFeeResponse, error) { + out := new(QueryReceiveFeeResponse) + err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Query/ReceiveFee", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) AckFee(ctx context.Context, in *QueryAckFeeRequest, opts ...grpc.CallOption) (*QueryAckFeeResponse, error) { + out := new(QueryAckFeeResponse) + err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Query/AckFee", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) TimeoutFee(ctx context.Context, in *QueryTimeoutFeeRequest, opts ...grpc.CallOption) (*QueryTimeoutFeeResponse, error) { + out := new(QueryTimeoutFeeResponse) + err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Query/TimeoutFee", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) IncentivizedPackets(ctx context.Context, in *QueryIncentivizedPacketsRequest, opts ...grpc.CallOption) (*QueryIncentivizedPacketsResponse, error) { + out := new(QueryIncentivizedPacketsResponse) + err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Query/IncentivizedPackets", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) IncentivizedPacket(ctx context.Context, in *QueryIncentivizedPacketRequest, opts ...grpc.CallOption) (*QueryIncentivizedPacketResponse, error) { + out := new(QueryIncentivizedPacketResponse) + err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Query/IncentivizedPacket", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Gets the fee expected for submitting ReceivePacket msg for the given packet + ReceiveFee(context.Context, *QueryReceiveFeeRequest) (*QueryReceiveFeeResponse, error) + // Gets the fee expected for submitting AcknowledgePacket msg for the given packet + AckFee(context.Context, *QueryAckFeeRequest) (*QueryAckFeeResponse, error) + // Gets the fee expected for submitting TimeoutPacket msg for the given packet + TimeoutFee(context.Context, *QueryTimeoutFeeRequest) (*QueryTimeoutFeeResponse, error) + // Gets all incentivized packets + IncentivizedPackets(context.Context, *QueryIncentivizedPacketsRequest) (*QueryIncentivizedPacketsResponse, error) + // Gets the specified incentivized packet + IncentivizedPacket(context.Context, *QueryIncentivizedPacketRequest) (*QueryIncentivizedPacketResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) ReceiveFee(ctx context.Context, req *QueryReceiveFeeRequest) (*QueryReceiveFeeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ReceiveFee not implemented") +} +func (*UnimplementedQueryServer) AckFee(ctx context.Context, req *QueryAckFeeRequest) (*QueryAckFeeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AckFee not implemented") +} +func (*UnimplementedQueryServer) TimeoutFee(ctx context.Context, req *QueryTimeoutFeeRequest) (*QueryTimeoutFeeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TimeoutFee not implemented") +} +func (*UnimplementedQueryServer) IncentivizedPackets(ctx context.Context, req *QueryIncentivizedPacketsRequest) (*QueryIncentivizedPacketsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method IncentivizedPackets not implemented") +} +func (*UnimplementedQueryServer) IncentivizedPacket(ctx context.Context, req *QueryIncentivizedPacketRequest) (*QueryIncentivizedPacketResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method IncentivizedPacket not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_ReceiveFee_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryReceiveFeeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ReceiveFee(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.applications.fee.v1.Query/ReceiveFee", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ReceiveFee(ctx, req.(*QueryReceiveFeeRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_AckFee_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAckFeeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).AckFee(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.applications.fee.v1.Query/AckFee", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).AckFee(ctx, req.(*QueryAckFeeRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_TimeoutFee_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryTimeoutFeeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).TimeoutFee(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.applications.fee.v1.Query/TimeoutFee", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).TimeoutFee(ctx, req.(*QueryTimeoutFeeRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_IncentivizedPackets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryIncentivizedPacketsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).IncentivizedPackets(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.applications.fee.v1.Query/IncentivizedPackets", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).IncentivizedPackets(ctx, req.(*QueryIncentivizedPacketsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_IncentivizedPacket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryIncentivizedPacketRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).IncentivizedPacket(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.applications.fee.v1.Query/IncentivizedPacket", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).IncentivizedPacket(ctx, req.(*QueryIncentivizedPacketRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "ibc.applications.fee.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ReceiveFee", + Handler: _Query_ReceiveFee_Handler, + }, + { + MethodName: "AckFee", + Handler: _Query_AckFee_Handler, + }, + { + MethodName: "TimeoutFee", + Handler: _Query_TimeoutFee_Handler, + }, + { + MethodName: "IncentivizedPackets", + Handler: _Query_IncentivizedPackets_Handler, + }, + { + MethodName: "IncentivizedPacket", + Handler: _Query_IncentivizedPacket_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "ibc/applications/fee/v1/query.proto", +} + +func (m *QueryReceiveFeeRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryReceiveFeeRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryReceiveFeeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.QueryHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.QueryHeight)) + i-- + dAtA[i] = 0x18 + } + if len(m.RelayerAddress) > 0 { + i -= len(m.RelayerAddress) + copy(dAtA[i:], m.RelayerAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.RelayerAddress))) + i-- + dAtA[i] = 0x12 + } + if m.PacketId != nil { + { + size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryReceiveFeeResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryReceiveFeeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryReceiveFeeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Fee != nil { + { + size, err := m.Fee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAckFeeRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAckFeeRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAckFeeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.QueryHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.QueryHeight)) + i-- + dAtA[i] = 0x18 + } + if len(m.RelayerAddress) > 0 { + i -= len(m.RelayerAddress) + copy(dAtA[i:], m.RelayerAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.RelayerAddress))) + i-- + dAtA[i] = 0x12 + } + if m.PacketId != nil { + { + size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryAckFeeResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryAckFeeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAckFeeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Fee != nil { + { + size, err := m.Fee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryTimeoutFeeRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryTimeoutFeeRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTimeoutFeeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.QueryHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.QueryHeight)) + i-- + dAtA[i] = 0x18 + } + if len(m.RelayerAddress) > 0 { + i -= len(m.RelayerAddress) + copy(dAtA[i:], m.RelayerAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.RelayerAddress))) + i-- + dAtA[i] = 0x12 + } + if m.PacketId != nil { + { + size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryTimeoutFeeResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryTimeoutFeeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTimeoutFeeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Fee != nil { + { + size, err := m.Fee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryIncentivizedPacketsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryIncentivizedPacketsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryIncentivizedPacketsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.QueryHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.QueryHeight)) + i-- + dAtA[i] = 0x10 + } + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryIncentivizedPacketsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryIncentivizedPacketsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryIncentivizedPacketsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.IncentivizedPackets) > 0 { + for iNdEx := len(m.IncentivizedPackets) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.IncentivizedPackets[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryIncentivizedPacketRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryIncentivizedPacketRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryIncentivizedPacketRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.QueryHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.QueryHeight)) + i-- + dAtA[i] = 0x10 + } + if m.PacketId != nil { + { + size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryIncentivizedPacketResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryIncentivizedPacketResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryIncentivizedPacketResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IncentivizedPacket != nil { + { + size, err := m.IncentivizedPacket.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryReceiveFeeRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PacketId != nil { + l = m.PacketId.Size() + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.RelayerAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.QueryHeight != 0 { + n += 1 + sovQuery(uint64(m.QueryHeight)) + } + return n +} + +func (m *QueryReceiveFeeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Fee != nil { + l = m.Fee.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAckFeeRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PacketId != nil { + l = m.PacketId.Size() + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.RelayerAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.QueryHeight != 0 { + n += 1 + sovQuery(uint64(m.QueryHeight)) + } + return n +} + +func (m *QueryAckFeeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Fee != nil { + l = m.Fee.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryTimeoutFeeRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PacketId != nil { + l = m.PacketId.Size() + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.RelayerAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.QueryHeight != 0 { + n += 1 + sovQuery(uint64(m.QueryHeight)) + } + return n +} + +func (m *QueryTimeoutFeeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Fee != nil { + l = m.Fee.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryIncentivizedPacketsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.QueryHeight != 0 { + n += 1 + sovQuery(uint64(m.QueryHeight)) + } + return n +} + +func (m *QueryIncentivizedPacketsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.IncentivizedPackets) > 0 { + for _, e := range m.IncentivizedPackets { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryIncentivizedPacketRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PacketId != nil { + l = m.PacketId.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.QueryHeight != 0 { + n += 1 + sovQuery(uint64(m.QueryHeight)) + } + return n +} + +func (m *QueryIncentivizedPacketResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.IncentivizedPacket != nil { + l = m.IncentivizedPacket.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryReceiveFeeRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryReceiveFeeRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryReceiveFeeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PacketId == nil { + m.PacketId = &types.PacketId{} + } + if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RelayerAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RelayerAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QueryHeight", wireType) + } + m.QueryHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.QueryHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryReceiveFeeResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryReceiveFeeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryReceiveFeeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Fee == nil { + m.Fee = &Fee{} + } + if err := m.Fee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAckFeeRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAckFeeRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAckFeeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PacketId == nil { + m.PacketId = &types.PacketId{} + } + if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RelayerAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RelayerAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QueryHeight", wireType) + } + m.QueryHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.QueryHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryAckFeeResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryAckFeeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAckFeeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Fee == nil { + m.Fee = &Fee{} + } + if err := m.Fee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryTimeoutFeeRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryTimeoutFeeRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTimeoutFeeRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PacketId == nil { + m.PacketId = &types.PacketId{} + } + if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RelayerAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RelayerAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QueryHeight", wireType) + } + m.QueryHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.QueryHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryTimeoutFeeResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryTimeoutFeeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTimeoutFeeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Fee == nil { + m.Fee = &Fee{} + } + if err := m.Fee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryIncentivizedPacketsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryIncentivizedPacketsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryIncentivizedPacketsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QueryHeight", wireType) + } + m.QueryHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.QueryHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryIncentivizedPacketsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryIncentivizedPacketsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryIncentivizedPacketsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IncentivizedPackets", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.IncentivizedPackets = append(m.IncentivizedPackets, &IdentifiedPacketFee{}) + if err := m.IncentivizedPackets[len(m.IncentivizedPackets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryIncentivizedPacketRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryIncentivizedPacketRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryIncentivizedPacketRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PacketId == nil { + m.PacketId = &types.PacketId{} + } + if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QueryHeight", wireType) + } + m.QueryHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.QueryHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryIncentivizedPacketResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryIncentivizedPacketResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryIncentivizedPacketResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IncentivizedPacket", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.IncentivizedPacket == nil { + m.IncentivizedPacket = &IdentifiedPacketFee{} + } + if err := m.IncentivizedPacket.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/modules/apps/29-fee/types/query.pb.gw.go b/modules/apps/29-fee/types/query.pb.gw.go new file mode 100644 index 00000000000..40df38d4bf9 --- /dev/null +++ b/modules/apps/29-fee/types/query.pb.gw.go @@ -0,0 +1,996 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: ibc/applications/fee/v1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage + +var ( + filter_Query_ReceiveFee_0 = &utilities.DoubleArray{Encoding: map[string]int{"packet_id": 0, "port_id": 1, "channel_id": 2, "sequence": 3, "relayer_address": 4, "query_height": 5}, Base: []int{1, 1, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0}, Check: []int{0, 1, 2, 2, 2, 1, 1, 3, 4, 5, 6, 7}} +) + +func request_Query_ReceiveFee_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryReceiveFeeRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["packet_id.port_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) + } + + val, ok = pathParams["packet_id.channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) + } + + val, ok = pathParams["packet_id.sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) + } + + val, ok = pathParams["relayer_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "relayer_address") + } + + protoReq.RelayerAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "relayer_address", err) + } + + val, ok = pathParams["query_height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "query_height") + } + + protoReq.QueryHeight, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "query_height", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ReceiveFee_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ReceiveFee(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ReceiveFee_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryReceiveFeeRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["packet_id.port_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) + } + + val, ok = pathParams["packet_id.channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) + } + + val, ok = pathParams["packet_id.sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) + } + + val, ok = pathParams["relayer_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "relayer_address") + } + + protoReq.RelayerAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "relayer_address", err) + } + + val, ok = pathParams["query_height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "query_height") + } + + protoReq.QueryHeight, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "query_height", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ReceiveFee_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ReceiveFee(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_AckFee_0 = &utilities.DoubleArray{Encoding: map[string]int{"packet_id": 0, "port_id": 1, "channel_id": 2, "sequence": 3, "relayer_address": 4, "query_height": 5}, Base: []int{1, 1, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0}, Check: []int{0, 1, 2, 2, 2, 1, 1, 3, 4, 5, 6, 7}} +) + +func request_Query_AckFee_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAckFeeRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["packet_id.port_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) + } + + val, ok = pathParams["packet_id.channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) + } + + val, ok = pathParams["packet_id.sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) + } + + val, ok = pathParams["relayer_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "relayer_address") + } + + protoReq.RelayerAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "relayer_address", err) + } + + val, ok = pathParams["query_height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "query_height") + } + + protoReq.QueryHeight, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "query_height", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AckFee_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.AckFee(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_AckFee_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAckFeeRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["packet_id.port_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) + } + + val, ok = pathParams["packet_id.channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) + } + + val, ok = pathParams["packet_id.sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) + } + + val, ok = pathParams["relayer_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "relayer_address") + } + + protoReq.RelayerAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "relayer_address", err) + } + + val, ok = pathParams["query_height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "query_height") + } + + protoReq.QueryHeight, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "query_height", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AckFee_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.AckFee(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_TimeoutFee_0 = &utilities.DoubleArray{Encoding: map[string]int{"packet_id": 0, "port_id": 1, "channel_id": 2, "sequence": 3, "relayer_address": 4, "query_height": 5}, Base: []int{1, 1, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0}, Check: []int{0, 1, 2, 2, 2, 1, 1, 3, 4, 5, 6, 7}} +) + +func request_Query_TimeoutFee_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTimeoutFeeRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["packet_id.port_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) + } + + val, ok = pathParams["packet_id.channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) + } + + val, ok = pathParams["packet_id.sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) + } + + val, ok = pathParams["relayer_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "relayer_address") + } + + protoReq.RelayerAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "relayer_address", err) + } + + val, ok = pathParams["query_height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "query_height") + } + + protoReq.QueryHeight, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "query_height", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TimeoutFee_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.TimeoutFee(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_TimeoutFee_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTimeoutFeeRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["packet_id.port_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) + } + + val, ok = pathParams["packet_id.channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) + } + + val, ok = pathParams["packet_id.sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) + } + + val, ok = pathParams["relayer_address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "relayer_address") + } + + protoReq.RelayerAddress, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "relayer_address", err) + } + + val, ok = pathParams["query_height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "query_height") + } + + protoReq.QueryHeight, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "query_height", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TimeoutFee_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.TimeoutFee(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_IncentivizedPackets_0 = &utilities.DoubleArray{Encoding: map[string]int{"query_height": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_IncentivizedPackets_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryIncentivizedPacketsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["query_height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "query_height") + } + + protoReq.QueryHeight, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "query_height", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_IncentivizedPackets_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.IncentivizedPackets(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_IncentivizedPackets_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryIncentivizedPacketsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["query_height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "query_height") + } + + protoReq.QueryHeight, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "query_height", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_IncentivizedPackets_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.IncentivizedPackets(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_IncentivizedPacket_0 = &utilities.DoubleArray{Encoding: map[string]int{"packet_id": 0, "port_id": 1, "channel_id": 2, "sequence": 3, "query_height": 4}, Base: []int{1, 1, 1, 2, 3, 4, 0, 0, 0, 0}, Check: []int{0, 1, 2, 2, 2, 1, 3, 4, 5, 6}} +) + +func request_Query_IncentivizedPacket_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryIncentivizedPacketRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["packet_id.port_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) + } + + val, ok = pathParams["packet_id.channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) + } + + val, ok = pathParams["packet_id.sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) + } + + val, ok = pathParams["query_height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "query_height") + } + + protoReq.QueryHeight, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "query_height", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_IncentivizedPacket_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.IncentivizedPacket(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_IncentivizedPacket_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryIncentivizedPacketRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["packet_id.port_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) + } + + val, ok = pathParams["packet_id.channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) + } + + val, ok = pathParams["packet_id.sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) + } + + val, ok = pathParams["query_height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "query_height") + } + + protoReq.QueryHeight, err = runtime.Uint64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "query_height", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_IncentivizedPacket_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.IncentivizedPacket(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_ReceiveFee_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_ReceiveFee_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ReceiveFee_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AckFee_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_AckFee_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AckFee_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_TimeoutFee_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_TimeoutFee_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TimeoutFee_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_IncentivizedPackets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_IncentivizedPackets_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_IncentivizedPackets_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_IncentivizedPacket_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_IncentivizedPacket_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_IncentivizedPacket_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_ReceiveFee_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_ReceiveFee_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_ReceiveFee_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_AckFee_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_AckFee_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_AckFee_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_TimeoutFee_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_TimeoutFee_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TimeoutFee_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_IncentivizedPackets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_IncentivizedPackets_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_IncentivizedPackets_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_IncentivizedPacket_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_IncentivizedPacket_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_IncentivizedPacket_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_ReceiveFee_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10, 2, 11, 1, 0, 4, 1, 5, 12, 2, 13, 1, 0, 4, 1, 5, 14}, []string{"ibc", "apps", "fee", "v1", "receive_fee", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence", "relayer", "relayer_address", "height", "query_height"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_AckFee_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10, 2, 11, 1, 0, 4, 1, 5, 12, 2, 13, 1, 0, 4, 1, 5, 14}, []string{"ibc", "apps", "fee", "v1", "ack_fee", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence", "relayer", "relayer_address", "height", "query_height"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_TimeoutFee_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10, 1, 0, 4, 1, 5, 11, 2, 12, 1, 0, 4, 1, 5, 13}, []string{"ibc", "apps", "fee", "v1", "timeout_fee", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence", "relayer_address", "height", "query_height"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_IncentivizedPackets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6}, []string{"ibc", "apps", "fee", "v1", "incentivized_packets", "height", "query_height"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_IncentivizedPacket_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10, 2, 11, 1, 0, 4, 1, 5, 12}, []string{"ibc", "apps", "fee", "v1", "incentivized_packet", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence", "height", "query_height"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_ReceiveFee_0 = runtime.ForwardResponseMessage + + forward_Query_AckFee_0 = runtime.ForwardResponseMessage + + forward_Query_TimeoutFee_0 = runtime.ForwardResponseMessage + + forward_Query_IncentivizedPackets_0 = runtime.ForwardResponseMessage + + forward_Query_IncentivizedPacket_0 = runtime.ForwardResponseMessage +) diff --git a/modules/apps/29-fee/types/tx.pb.go b/modules/apps/29-fee/types/tx.pb.go new file mode 100644 index 00000000000..be4b2c6eb8a --- /dev/null +++ b/modules/apps/29-fee/types/tx.pb.go @@ -0,0 +1,1137 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/applications/fee/v1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + types "github.com/cosmos/ibc-go/modules/core/04-channel/types" + _ "github.com/gogo/protobuf/gogoproto" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgRegisterCounterpartyAddress is the request type for registering the counter party address +type MsgRegisterCounterpartyAddress struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + CounterpartyAddress string `protobuf:"bytes,2,opt,name=counterparty_address,json=counterpartyAddress,proto3" json:"counterparty_address,omitempty" yaml:"counterparty_address"` +} + +func (m *MsgRegisterCounterpartyAddress) Reset() { *m = MsgRegisterCounterpartyAddress{} } +func (m *MsgRegisterCounterpartyAddress) String() string { return proto.CompactTextString(m) } +func (*MsgRegisterCounterpartyAddress) ProtoMessage() {} +func (*MsgRegisterCounterpartyAddress) Descriptor() ([]byte, []int) { + return fileDescriptor_05c93128649f1b96, []int{0} +} +func (m *MsgRegisterCounterpartyAddress) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRegisterCounterpartyAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterCounterpartyAddress.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgRegisterCounterpartyAddress) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterCounterpartyAddress.Merge(m, src) +} +func (m *MsgRegisterCounterpartyAddress) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterCounterpartyAddress) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterCounterpartyAddress.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterCounterpartyAddress proto.InternalMessageInfo + +// MsgRegisterCounterPartyAddressResponse defines the Msg/RegisterCounteryPartyAddress response type +type MsgRegisterCounterPartyAddressResponse struct { +} + +func (m *MsgRegisterCounterPartyAddressResponse) Reset() { + *m = MsgRegisterCounterPartyAddressResponse{} +} +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 { + return m.Unmarshal(b) +} +func (m *MsgRegisterCounterPartyAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRegisterCounterPartyAddressResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgRegisterCounterPartyAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRegisterCounterPartyAddressResponse.Merge(m, src) +} +func (m *MsgRegisterCounterPartyAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRegisterCounterPartyAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRegisterCounterPartyAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRegisterCounterPartyAddressResponse proto.InternalMessageInfo + +// MsgEscrowPacketFee defines the request type EscrowPacketFee RPC +type MsgEscrowPacketFee struct { + PacketId *types.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id,omitempty" yaml:"packet_id"` + ReceiveFee *Fee `protobuf:"bytes,2,opt,name=receive_fee,json=receiveFee,proto3" json:"receive_fee,omitempty" yaml:"receive_fee"` + AckFee *Fee `protobuf:"bytes,3,opt,name=ack_fee,json=ackFee,proto3" json:"ack_fee,omitempty" yaml:"ack_fee"` + TimeoutFee *Fee `protobuf:"bytes,4,opt,name=timeout_fee,json=timeoutFee,proto3" json:"timeout_fee,omitempty" yaml:"timeout_fee"` + Relayers []string `protobuf:"bytes,5,rep,name=relayers,proto3" json:"relayers,omitempty"` +} + +func (m *MsgEscrowPacketFee) Reset() { *m = MsgEscrowPacketFee{} } +func (m *MsgEscrowPacketFee) String() string { return proto.CompactTextString(m) } +func (*MsgEscrowPacketFee) ProtoMessage() {} +func (*MsgEscrowPacketFee) Descriptor() ([]byte, []int) { + return fileDescriptor_05c93128649f1b96, []int{2} +} +func (m *MsgEscrowPacketFee) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgEscrowPacketFee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgEscrowPacketFee.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgEscrowPacketFee) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgEscrowPacketFee.Merge(m, src) +} +func (m *MsgEscrowPacketFee) XXX_Size() int { + return m.Size() +} +func (m *MsgEscrowPacketFee) XXX_DiscardUnknown() { + xxx_messageInfo_MsgEscrowPacketFee.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgEscrowPacketFee proto.InternalMessageInfo + +// MsgEscrowPacketFeeResponse defines the response type for Msg/EscrowPacketFee +type MsgEscrowPacketFeeResponse struct { +} + +func (m *MsgEscrowPacketFeeResponse) Reset() { *m = MsgEscrowPacketFeeResponse{} } +func (m *MsgEscrowPacketFeeResponse) String() string { return proto.CompactTextString(m) } +func (*MsgEscrowPacketFeeResponse) ProtoMessage() {} +func (*MsgEscrowPacketFeeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_05c93128649f1b96, []int{3} +} +func (m *MsgEscrowPacketFeeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgEscrowPacketFeeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgEscrowPacketFeeResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgEscrowPacketFeeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgEscrowPacketFeeResponse.Merge(m, src) +} +func (m *MsgEscrowPacketFeeResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgEscrowPacketFeeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgEscrowPacketFeeResponse.DiscardUnknown(m) +} + +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((*MsgEscrowPacketFee)(nil), "ibc.applications.fee.v1.MsgEscrowPacketFee") + proto.RegisterType((*MsgEscrowPacketFeeResponse)(nil), "ibc.applications.fee.v1.MsgEscrowPacketFeeResponse") +} + +func init() { proto.RegisterFile("ibc/applications/fee/v1/tx.proto", fileDescriptor_05c93128649f1b96) } + +var fileDescriptor_05c93128649f1b96 = []byte{ + // 531 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x4f, 0x6b, 0x13, 0x41, + 0x18, 0xc6, 0xb3, 0x8d, 0xb6, 0xc9, 0x04, 0x54, 0xc6, 0xa0, 0x61, 0x5b, 0x77, 0xe3, 0x1e, 0x24, + 0x20, 0xdd, 0x25, 0xe9, 0x41, 0xec, 0x45, 0x8c, 0x58, 0x28, 0x18, 0x08, 0x03, 0xbd, 0x78, 0x09, + 0x93, 0xc9, 0x9b, 0xed, 0x90, 0x3f, 0xb3, 0xcc, 0x4c, 0xa2, 0xf9, 0x00, 0x82, 0x47, 0x0f, 0x82, + 0x1e, 0xfb, 0x71, 0x3c, 0xf6, 0xe8, 0x29, 0x48, 0x72, 0xf1, 0x9c, 0x4f, 0x20, 0xb3, 0x9b, 0x94, + 0xa5, 0x69, 0x82, 0xb9, 0xcd, 0xcb, 0xfe, 0x9e, 0x67, 0x9e, 0x9d, 0xf7, 0x7d, 0x51, 0x99, 0xb7, + 0x59, 0x40, 0xa3, 0xa8, 0xcf, 0x19, 0xd5, 0x5c, 0x0c, 0x55, 0xd0, 0x05, 0x08, 0xc6, 0xd5, 0x40, + 0x7f, 0xf6, 0x23, 0x29, 0xb4, 0xc0, 0x4f, 0x79, 0x9b, 0xf9, 0x69, 0xc2, 0xef, 0x02, 0xf8, 0xe3, + 0xaa, 0x5d, 0x0c, 0x45, 0x28, 0x62, 0x26, 0x30, 0xa7, 0x04, 0xb7, 0x9f, 0x6f, 0x32, 0x34, 0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 0x49, 0x04, 0xaa, + 0xbd, 0x1f, 0xaf, 0xf5, 0xc9, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe1, 0xc9, 0x06, 0xc0, 0x6f, + 0x04, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + // 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(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. + EscrowPacketFee(ctx context.Context, in *MsgEscrowPacketFee, opts ...grpc.CallOption) (*MsgEscrowPacketFeeResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +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...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) EscrowPacketFee(ctx context.Context, in *MsgEscrowPacketFee, opts ...grpc.CallOption) (*MsgEscrowPacketFeeResponse, error) { + out := new(MsgEscrowPacketFeeResponse) + err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Msg/EscrowPacketFee", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // 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(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. + EscrowPacketFee(context.Context, *MsgEscrowPacketFee) (*MsgEscrowPacketFeeResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +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) EscrowPacketFee(ctx context.Context, req *MsgEscrowPacketFee) (*MsgEscrowPacketFeeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method EscrowPacketFee not implemented") +} + +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) { + in := new(MsgRegisterCounterpartyAddress) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RegisterCounterPartyAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.applications.fee.v1.Msg/RegisterCounterPartyAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RegisterCounterPartyAddress(ctx, req.(*MsgRegisterCounterpartyAddress)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_EscrowPacketFee_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgEscrowPacketFee) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).EscrowPacketFee(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.applications.fee.v1.Msg/EscrowPacketFee", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).EscrowPacketFee(ctx, req.(*MsgEscrowPacketFee)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "ibc.applications.fee.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RegisterCounterPartyAddress", + Handler: _Msg_RegisterCounterPartyAddress_Handler, + }, + { + MethodName: "EscrowPacketFee", + Handler: _Msg_EscrowPacketFee_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "ibc/applications/fee/v1/tx.proto", +} + +func (m *MsgRegisterCounterpartyAddress) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgRegisterCounterpartyAddress) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterCounterpartyAddress) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CounterpartyAddress) > 0 { + i -= len(m.CounterpartyAddress) + copy(dAtA[i:], m.CounterpartyAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.CounterpartyAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTx(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRegisterCounterPartyAddressResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgRegisterCounterPartyAddressResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRegisterCounterPartyAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgEscrowPacketFee) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgEscrowPacketFee) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgEscrowPacketFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Relayers) > 0 { + for iNdEx := len(m.Relayers) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Relayers[iNdEx]) + copy(dAtA[i:], m.Relayers[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Relayers[iNdEx]))) + i-- + dAtA[i] = 0x2a + } + } + if m.TimeoutFee != nil { + { + size, err := m.TimeoutFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + if m.AckFee != nil { + { + size, err := m.AckFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.ReceiveFee != nil { + { + size, err := m.ReceiveFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.PacketId != nil { + { + size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgEscrowPacketFeeResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgEscrowPacketFeeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgEscrowPacketFeeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgRegisterCounterpartyAddress) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.CounterpartyAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRegisterCounterPartyAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgEscrowPacketFee) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PacketId != nil { + l = m.PacketId.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.ReceiveFee != nil { + l = m.ReceiveFee.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.AckFee != nil { + l = m.AckFee.Size() + n += 1 + l + sovTx(uint64(l)) + } + if m.TimeoutFee != nil { + l = m.TimeoutFee.Size() + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Relayers) > 0 { + for _, s := range m.Relayers { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgEscrowPacketFeeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgRegisterCounterpartyAddress) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgRegisterCounterpartyAddress: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRegisterCounterpartyAddress: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CounterpartyAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRegisterCounterPartyAddressResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + 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) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgEscrowPacketFee) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgEscrowPacketFee: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgEscrowPacketFee: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PacketId == nil { + m.PacketId = &types.PacketId{} + } + if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ReceiveFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ReceiveFee == nil { + m.ReceiveFee = &Fee{} + } + if err := m.ReceiveFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AckFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.AckFee == nil { + m.AckFee = &Fee{} + } + if err := m.AckFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TimeoutFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.TimeoutFee == nil { + m.TimeoutFee = &Fee{} + } + if err := m.TimeoutFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Relayers", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Relayers = append(m.Relayers, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgEscrowPacketFeeResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgEscrowPacketFeeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgEscrowPacketFeeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/modules/core/04-channel/types/channel.pb.go b/modules/core/04-channel/types/channel.pb.go index 166d836c5ab..2d68308fb85 100644 --- a/modules/core/04-channel/types/channel.pb.go +++ b/modules/core/04-channel/types/channel.pb.go @@ -347,6 +347,51 @@ func (m *PacketState) XXX_DiscardUnknown() { var xxx_messageInfo_PacketState proto.InternalMessageInfo +// PacketId is an identifer for a unique Packet +// Source chains refer to packets by source port/channel +// Destination chains refer to packets by destination port/channel +type PacketId struct { + // channel port identifier + PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty" yaml:"port_id"` + // channel unique identifier + ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` + // packet sequence + Sequence uint64 `protobuf:"varint,3,opt,name=sequence,proto3" json:"sequence,omitempty"` +} + +func (m *PacketId) Reset() { *m = PacketId{} } +func (m *PacketId) String() string { return proto.CompactTextString(m) } +func (*PacketId) ProtoMessage() {} +func (*PacketId) Descriptor() ([]byte, []int) { + return fileDescriptor_c3a07336710636a0, []int{5} +} +func (m *PacketId) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PacketId) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PacketId.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PacketId) XXX_Merge(src proto.Message) { + xxx_messageInfo_PacketId.Merge(m, src) +} +func (m *PacketId) XXX_Size() int { + return m.Size() +} +func (m *PacketId) XXX_DiscardUnknown() { + xxx_messageInfo_PacketId.DiscardUnknown(m) +} + +var xxx_messageInfo_PacketId proto.InternalMessageInfo + // Acknowledgement is the recommended acknowledgement format to be used by // app-specific protocols. // NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental @@ -367,7 +412,7 @@ func (m *Acknowledgement) Reset() { *m = Acknowledgement{} } func (m *Acknowledgement) String() string { return proto.CompactTextString(m) } func (*Acknowledgement) ProtoMessage() {} func (*Acknowledgement) Descriptor() ([]byte, []int) { - return fileDescriptor_c3a07336710636a0, []int{5} + return fileDescriptor_c3a07336710636a0, []int{6} } func (m *Acknowledgement) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -449,70 +494,72 @@ func init() { proto.RegisterType((*Counterparty)(nil), "ibc.core.channel.v1.Counterparty") proto.RegisterType((*Packet)(nil), "ibc.core.channel.v1.Packet") proto.RegisterType((*PacketState)(nil), "ibc.core.channel.v1.PacketState") + proto.RegisterType((*PacketId)(nil), "ibc.core.channel.v1.PacketId") proto.RegisterType((*Acknowledgement)(nil), "ibc.core.channel.v1.Acknowledgement") } func init() { proto.RegisterFile("ibc/core/channel/v1/channel.proto", fileDescriptor_c3a07336710636a0) } var fileDescriptor_c3a07336710636a0 = []byte{ - // 908 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x55, 0xcd, 0x8e, 0xda, 0x56, - 0x14, 0xc6, 0x60, 0xfe, 0x0e, 0x03, 0xc3, 0xdc, 0x34, 0xc4, 0x75, 0x13, 0x4c, 0xac, 0x2e, 0x46, - 0xa9, 0x02, 0x99, 0x34, 0x4a, 0xa5, 0xac, 0x3a, 0xfc, 0x44, 0x63, 0x35, 0x02, 0x64, 0x98, 0x45, - 0xb3, 0xa1, 0x60, 0xdf, 0x82, 0x15, 0xf0, 0xa5, 0xf6, 0x65, 0x46, 0xf3, 0x06, 0x11, 0xab, 0xbe, - 0x00, 0x52, 0xa5, 0xaa, 0x7d, 0x85, 0xbe, 0x42, 0x96, 0x59, 0x76, 0x65, 0x55, 0x33, 0x8b, 0xee, - 0x79, 0x81, 0x56, 0xbe, 0xf7, 0x9a, 0x9f, 0x49, 0x94, 0x65, 0x57, 0x5d, 0x71, 0xcf, 0xf7, 0x7d, - 0xe7, 0xc7, 0xe7, 0x1c, 0xee, 0x85, 0x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, 0x5f, 0xd7, 0x65, 0xe9, 0xe7, 0x9b, 0x72, 0xec, 0xfd, 0x4d, 0x39, 0xf6, 0xe7, 0x4d, 0x39, - 0xf6, 0xfa, 0xf9, 0xd8, 0xa1, 0x93, 0xc5, 0xa8, 0x6a, 0x91, 0x59, 0xcd, 0x22, 0xfe, 0x8c, 0xf8, - 0x35, 0x67, 0x64, 0x3d, 0x1e, 0x93, 0xda, 0x8c, 0xd8, 0x8b, 0x29, 0xf6, 0xf9, 0x8b, 0xfc, 0xe4, - 0xd9, 0xe3, 0xe8, 0x89, 0xa7, 0x57, 0x73, 0xec, 0x8f, 0x52, 0xec, 0x49, 0xfe, 0xfa, 0xdf, 0x00, - 0x00, 0x00, 0xff, 0xff, 0xf8, 0x7f, 0x8d, 0x61, 0x03, 0x08, 0x00, 0x00, + // 922 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0xcd, 0x6e, 0xdb, 0x46, + 0x10, 0x16, 0x2d, 0xea, 0x6f, 0x64, 0xc9, 0xf2, 0xa6, 0x56, 0x58, 0x36, 0x11, 0x15, 0xa2, 0x07, + 0x23, 0x45, 0xa4, 0x38, 0x0d, 0x52, 0x20, 0xa7, 0x5a, 0x3f, 0x81, 0x89, 0x06, 0x92, 0x40, 0xc9, + 0x87, 0xe6, 0xa2, 0x4a, 0xe4, 0x56, 0x22, 0x22, 0x71, 0x55, 0x72, 0x65, 0xc3, 0x6f, 0x10, 0xe8, + 0xd2, 0xbe, 0x80, 0x80, 0x02, 0x45, 0xfb, 0x0a, 0x7d, 0x85, 0x1c, 0x73, 0xec, 0x89, 0x28, 0xec, + 0x43, 0xef, 0x7a, 0x81, 0x16, 0xdc, 0x5d, 0xea, 0xc7, 0x09, 0x72, 0x6c, 0x2f, 0x3d, 0x69, 0x67, + 0xbe, 0x6f, 0x66, 0x3e, 0xce, 0x8c, 0x16, 0x0b, 0x0f, 0x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x42, 0xb0, 0x30, 0x79, 0xe1, 0x5a, 0xe7, 0xed, 0x75, 0x49, 0x7a, 0x77, 0x5d, 0x92, 0xfe, + 0xbc, 0x2e, 0x49, 0x3f, 0xdd, 0x94, 0x62, 0xef, 0x6e, 0x4a, 0xb1, 0x3f, 0x6e, 0x4a, 0xb1, 0x57, + 0xcf, 0x46, 0x0e, 0x1d, 0xcf, 0x87, 0x15, 0x8b, 0x4c, 0xab, 0x16, 0xf1, 0xa7, 0xc4, 0xaf, 0x3a, + 0x43, 0xeb, 0xd1, 0x88, 0x54, 0xa7, 0xc4, 0x9e, 0x4f, 0xb0, 0xcf, 0xdf, 0x08, 0x8f, 0x9f, 0x3e, + 0x8a, 0x1e, 0x1d, 0xf4, 0x6a, 0x86, 0xfd, 0x61, 0x92, 0x3d, 0x12, 0xbe, 0xfc, 0x27, 0x00, 0x00, + 0xff, 0xff, 0x98, 0x4c, 0x54, 0xee, 0x95, 0x08, 0x00, 0x00, } func (m *Channel) Marshal() (dAtA []byte, err error) { @@ -811,6 +858,48 @@ func (m *PacketState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *PacketId) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PacketId) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PacketId) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Sequence != 0 { + i = encodeVarintChannel(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x18 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintChannel(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortId) > 0 { + i -= len(m.PortId) + copy(dAtA[i:], m.PortId) + i = encodeVarintChannel(dAtA, i, uint64(len(m.PortId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *Acknowledgement) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1028,6 +1117,26 @@ func (m *PacketState) Size() (n int) { return n } +func (m *PacketId) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortId) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovChannel(uint64(l)) + } + if m.Sequence != 0 { + n += 1 + sovChannel(uint64(m.Sequence)) + } + return n +} + func (m *Acknowledgement) Size() (n int) { if m == nil { return 0 @@ -2067,6 +2176,139 @@ func (m *PacketState) Unmarshal(dAtA []byte) error { } return nil } +func (m *PacketId) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PacketId: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PacketId: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthChannel + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthChannel + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + m.Sequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowChannel + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipChannel(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthChannel + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *Acknowledgement) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/proto/ibc/applications/fee/v1/fee.proto b/proto/ibc/applications/fee/v1/fee.proto new file mode 100644 index 00000000000..888ade35acb --- /dev/null +++ b/proto/ibc/applications/fee/v1/fee.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; + +package ibc.applications.fee.v1; +import "cosmos/base/v1beta1/coin.proto"; +import "gogoproto/gogo.proto"; +import "ibc/core/channel/v1/channel.proto"; +option go_package = "github.com/cosmos/ibc-go/modules/apps/29-fee/types"; + +// Fee interface +// See Fee Payment Middleware spec: +// https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middleware-contract +message Fee { + repeated cosmos.base.v1beta1.Coin amount = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; +} + +// Fee associated with a packet_id +message IdentifiedPacketFee { + ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.moretags) = "yaml:\"packet_id\""]; + Fee receive_fee = 2 [(gogoproto.moretags) = "yaml:\"receive_fee\""]; + Fee ack_fee = 3 [(gogoproto.moretags) = "yaml:\"ack_fee\""]; + Fee timeout_fee = 4 [(gogoproto.moretags) = "yaml:\"timeout_fee\""]; + repeated string relayers = 5; +} diff --git a/proto/ibc/applications/fee/v1/genesis.proto b/proto/ibc/applications/fee/v1/genesis.proto new file mode 100644 index 00000000000..373fd7786c4 --- /dev/null +++ b/proto/ibc/applications/fee/v1/genesis.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; + +package ibc.applications.fee.v1; +import "gogoproto/gogo.proto"; +import "ibc/applications/fee/v1/fee.proto"; +option go_package = "github.com/cosmos/ibc-go/modules/apps/29-fee/types"; + +// GenesisState defines the fee middleware genesis state +message GenesisState { + // A mapping of packets -> escrowed fees + repeated ibc.applications.fee.v1.IdentifiedPacketFee packets_fees = 1 + [(gogoproto.moretags) = "yaml:\"packets_fees\""]; +} diff --git a/proto/ibc/applications/fee/v1/query.proto b/proto/ibc/applications/fee/v1/query.proto new file mode 100644 index 00000000000..c4411da5b0e --- /dev/null +++ b/proto/ibc/applications/fee/v1/query.proto @@ -0,0 +1,121 @@ +syntax = "proto3"; + +package ibc.applications.fee.v1; + +import "gogoproto/gogo.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "ibc/applications/fee/v1/fee.proto"; +import "google/api/annotations.proto"; +import "ibc/core/channel/v1/channel.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; + +option go_package = "github.com/cosmos/ibc-go/modules/apps/29-fee/types"; + +// Query provides defines the gRPC querier service. +service Query { + // Gets the fee expected for submitting ReceivePacket msg for the given packet + rpc ReceiveFee(QueryReceiveFeeRequest) returns (QueryReceiveFeeResponse) { + option (google.api.http).get = + "/ibc/apps/fee/v1/receive_fee/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/" + "{packet_id.sequence}/relayer/{relayer_address}/height/{query_height}"; + } + + // Gets the fee expected for submitting AcknowledgePacket msg for the given packet + rpc AckFee(QueryAckFeeRequest) returns (QueryAckFeeResponse) { + option (google.api.http).get = + "/ibc/apps/fee/v1/ack_fee/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/" + "{packet_id.sequence}/relayer/{relayer_address}/height/{query_height}"; + } + + // Gets the fee expected for submitting TimeoutPacket msg for the given packet + rpc TimeoutFee(QueryTimeoutFeeRequest) returns (QueryTimeoutFeeResponse) { + option (google.api.http).get = + "/ibc/apps/fee/v1/timeout_fee/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/" + "{packet_id.sequence}/{relayer_address}/height/{query_height}"; + } + + // Gets all incentivized packets + rpc IncentivizedPackets(QueryIncentivizedPacketsRequest) returns (QueryIncentivizedPacketsResponse) { + option (google.api.http).get = "/ibc/apps/fee/v1/incentivized_packets/height/{query_height}"; + } + + // Gets the specified incentivized packet + rpc IncentivizedPacket(QueryIncentivizedPacketRequest) returns (QueryIncentivizedPacketResponse) { + option (google.api.http).get = + "/ibc/apps/fee/v1/incentivized_packet/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/" + "{packet_id.sequence}/height/{query_height}"; + } +} + +// QueryReceiveFeeRequest is the request type for querying the receive fee +message QueryReceiveFeeRequest { + // PacketID + ibc.core.channel.v1.PacketId packet_id = 1; + // Caller should provide the intended relayer address in case the fee is dependent on specific relayer(s). + string relayer_address = 2; + // Height to query at + uint64 query_height = 3; +} + +// QueryReceiveFeeResponse is the response type for the ReceiveFee RPC +message QueryReceiveFeeResponse { + ibc.applications.fee.v1.Fee fee = 1; +} + +// QueryAckFeeRequest is the request type for querying the acknowledgement fee +message QueryAckFeeRequest { + // PacketID + ibc.core.channel.v1.PacketId packet_id = 1; + // Caller should provide the intended relayer address in case the fee is dependent on specific relayer(s). + string relayer_address = 2; + // Height to query at + uint64 query_height = 3; +} + +// QueryAckFeeResponse is the response type for the AckFee RPC +message QueryAckFeeResponse { + ibc.applications.fee.v1.Fee fee = 1; +} + +// QueryTimeoutFeeRequest is the request type for querying the timeout fee +message QueryTimeoutFeeRequest { + // PacketID + ibc.core.channel.v1.PacketId packet_id = 1; + // Caller should provide the intended relayer address in case the fee is dependent on specific relayer(s). + string relayer_address = 2; + // Height to query at + uint64 query_height = 3; +} + +// QueryTimeoutFeeResponse is the response type for the timeout RPC +message QueryTimeoutFeeResponse { + ibc.applications.fee.v1.Fee fee = 1; +} + +// QueryIncentivizedPacketsRequest is the request type for querying for all incentivized packets +message QueryIncentivizedPacketsRequest { + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; + // Height to query at + uint64 query_height = 2; +} + +// QueryIncentivizedPacketsResponse is the response type for the incentivized packets RPC +message QueryIncentivizedPacketsResponse { + // Map of all incentivized_packets + repeated ibc.applications.fee.v1.IdentifiedPacketFee incentivized_packets = 1; +} + +// QueryIncentivizedPacketRequest is the request type for querying for all incentivized packets +message QueryIncentivizedPacketRequest { + // PacketID + ibc.core.channel.v1.PacketId packet_id = 1; + // Height to query at + uint64 query_height = 2; +} + +// QueryIncentivizedPacketsResponse is the response type for the incentivized packet RPC +message QueryIncentivizedPacketResponse { + // Incentivized_packet + ibc.applications.fee.v1.IdentifiedPacketFee incentivized_packet = 1; +} diff --git a/proto/ibc/applications/fee/v1/tx.proto b/proto/ibc/applications/fee/v1/tx.proto new file mode 100644 index 00000000000..65bc727f0eb --- /dev/null +++ b/proto/ibc/applications/fee/v1/tx.proto @@ -0,0 +1,49 @@ +syntax = "proto3"; + +package ibc.applications.fee.v1; + +import "gogoproto/gogo.proto"; +import "ibc/applications/fee/v1/fee.proto"; +import "ibc/core/channel/v1/channel.proto"; +option go_package = "github.com/cosmos/ibc-go/modules/apps/29-fee/types"; + +// Msg defines the ibc/fee Msg service. +service Msg { + // 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. + 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. + rpc EscrowPacketFee(MsgEscrowPacketFee) returns (MsgEscrowPacketFeeResponse); +} + +// MsgRegisterCounterpartyAddress is the request type for registering the counter party address +message MsgRegisterCounterpartyAddress { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string address = 1; + string counterparty_address = 2 [(gogoproto.moretags) = "yaml:\"counterparty_address\""]; +} + +// MsgRegisterCounterPartyAddressResponse defines the Msg/RegisterCounteryPartyAddress response type +message MsgRegisterCounterPartyAddressResponse {} + +// MsgEscrowPacketFee defines the request type EscrowPacketFee RPC +message MsgEscrowPacketFee { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.moretags) = "yaml:\"packet_id\""]; + ibc.applications.fee.v1.Fee receive_fee = 2 [(gogoproto.moretags) = "yaml:\"receive_fee\""]; + ibc.applications.fee.v1.Fee ack_fee = 3 [(gogoproto.moretags) = "yaml:\"ack_fee\""]; + ibc.applications.fee.v1.Fee timeout_fee = 4 [(gogoproto.moretags) = "yaml:\"timeout_fee\""]; + repeated string relayers = 5; +} + +// MsgEscrowPacketFeeResponse defines the response type for Msg/EscrowPacketFee +message MsgEscrowPacketFeeResponse {} diff --git a/proto/ibc/core/channel/v1/channel.proto b/proto/ibc/core/channel/v1/channel.proto index edb39d04b59..b0ac3f9997c 100644 --- a/proto/ibc/core/channel/v1/channel.proto +++ b/proto/ibc/core/channel/v1/channel.proto @@ -132,6 +132,20 @@ message PacketState { bytes data = 4; } +// PacketId is an identifer for a unique Packet +// Source chains refer to packets by source port/channel +// Destination chains refer to packets by destination port/channel +message PacketId { + option (gogoproto.goproto_getters) = false; + + // channel port identifier + string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; + // channel unique identifier + string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""]; + // packet sequence + uint64 sequence = 3; +} + // Acknowledgement is the recommended acknowledgement format to be used by // app-specific protocols. // NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index 1c22cdda784..603f307e805 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -31,7 +31,7 @@ buf protoc \ -I "third_party/proto" \ --doc_out=./docs/ibc \ --doc_opt=./docs/protodoc-markdown.tmpl,proto-docs.md \ - $(find "$(pwd)/proto" -maxdepth 5 -name '*.proto') + $(find "$(pwd)/proto" -maxdepth 7 -name '*.proto') go mod tidy From 158a2516a2283c460b233c900863725c0303f7f4 Mon Sep 17 00:00:00 2001 From: Sean King Date: Tue, 27 Jul 2021 12:23:25 +0200 Subject: [PATCH 03/79] fix: removing unncessary fields MsgEscrow & adding query params (#300) * fix: removing unncessary fields MsgEscrow & adding query params * fix: grammar * fix: add yaml --- docs/ibc/proto-docs.md | 15 +- modules/apps/29-fee/types/query.pb.go | 99 +++++---- modules/apps/29-fee/types/query.pb.gw.go | 210 +----------------- modules/apps/29-fee/types/tx.pb.go | 248 ++++------------------ proto/ibc/applications/fee/v1/query.proto | 10 +- proto/ibc/applications/fee/v1/tx.proto | 8 +- 6 files changed, 114 insertions(+), 476 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 5e9a088d7bb..f571101508f 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -872,11 +872,11 @@ Query provides defines the gRPC querier service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `ReceiveFee` | [QueryReceiveFeeRequest](#ibc.applications.fee.v1.QueryReceiveFeeRequest) | [QueryReceiveFeeResponse](#ibc.applications.fee.v1.QueryReceiveFeeResponse) | Gets the fee expected for submitting ReceivePacket msg for the given packet | GET|/ibc/apps/fee/v1/receive_fee/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}/relayer/{relayer_address}/height/{query_height}| -| `AckFee` | [QueryAckFeeRequest](#ibc.applications.fee.v1.QueryAckFeeRequest) | [QueryAckFeeResponse](#ibc.applications.fee.v1.QueryAckFeeResponse) | Gets the fee expected for submitting AcknowledgePacket msg for the given packet | GET|/ibc/apps/fee/v1/ack_fee/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}/relayer/{relayer_address}/height/{query_height}| -| `TimeoutFee` | [QueryTimeoutFeeRequest](#ibc.applications.fee.v1.QueryTimeoutFeeRequest) | [QueryTimeoutFeeResponse](#ibc.applications.fee.v1.QueryTimeoutFeeResponse) | Gets the fee expected for submitting TimeoutPacket msg for the given packet | GET|/ibc/apps/fee/v1/timeout_fee/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}/{relayer_address}/height/{query_height}| -| `IncentivizedPackets` | [QueryIncentivizedPacketsRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsRequest) | [QueryIncentivizedPacketsResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsResponse) | Gets all incentivized packets | GET|/ibc/apps/fee/v1/incentivized_packets/height/{query_height}| -| `IncentivizedPacket` | [QueryIncentivizedPacketRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketRequest) | [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) | Gets the specified incentivized packet | GET|/ibc/apps/fee/v1/incentivized_packet/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}/height/{query_height}| +| `ReceiveFee` | [QueryReceiveFeeRequest](#ibc.applications.fee.v1.QueryReceiveFeeRequest) | [QueryReceiveFeeResponse](#ibc.applications.fee.v1.QueryReceiveFeeResponse) | Gets the fee expected for submitting ReceivePacket msg for the given packet | GET|/ibc/apps/fee/v1/receive_fee/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| +| `AckFee` | [QueryAckFeeRequest](#ibc.applications.fee.v1.QueryAckFeeRequest) | [QueryAckFeeResponse](#ibc.applications.fee.v1.QueryAckFeeResponse) | Gets the fee expected for submitting AcknowledgePacket msg for the given packet | GET|/ibc/apps/fee/v1/ack_fee/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| +| `TimeoutFee` | [QueryTimeoutFeeRequest](#ibc.applications.fee.v1.QueryTimeoutFeeRequest) | [QueryTimeoutFeeResponse](#ibc.applications.fee.v1.QueryTimeoutFeeResponse) | Gets the fee expected for submitting TimeoutPacket msg for the given packet | GET|/ibc/apps/fee/v1/timeout_fee/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| +| `IncentivizedPackets` | [QueryIncentivizedPacketsRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsRequest) | [QueryIncentivizedPacketsResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsResponse) | Gets all incentivized packets | GET|/ibc/apps/fee/v1/incentivized_packets| +| `IncentivizedPacket` | [QueryIncentivizedPacketRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketRequest) | [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) | Gets the specified incentivized packet | GET|/ibc/apps/fee/v1/incentivized_packet/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| @@ -897,10 +897,7 @@ MsgEscrowPacketFee defines the request type EscrowPacketFee RPC | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | | -| `receive_fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | -| `ack_fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | -| `timeout_fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | +| `incentivized_packet` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | | | | `relayers` | [string](#string) | repeated | | diff --git a/modules/apps/29-fee/types/query.pb.go b/modules/apps/29-fee/types/query.pb.go index bfcae7cdd88..dfc07f81fee 100644 --- a/modules/apps/29-fee/types/query.pb.go +++ b/modules/apps/29-fee/types/query.pb.go @@ -578,57 +578,54 @@ func init() { } var fileDescriptor_0638a8a78ca2503c = []byte{ - // 793 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0x51, 0x6b, 0x13, 0x4b, - 0x14, 0xee, 0xa4, 0xf7, 0x96, 0xdb, 0xe9, 0xe5, 0x5e, 0x98, 0x94, 0xdb, 0x10, 0x7a, 0x73, 0xd3, - 0x5c, 0xd0, 0xa0, 0xed, 0x8c, 0x89, 0x0f, 0xb6, 0x8a, 0x0f, 0x55, 0x2c, 0x06, 0x7c, 0xa8, 0xc1, - 0x27, 0x41, 0xc2, 0x66, 0xf7, 0x64, 0x33, 0x34, 0xd9, 0xd9, 0xee, 0x6e, 0x02, 0xb5, 0x04, 0x45, - 0x5f, 0x45, 0x0a, 0x05, 0x1f, 0x8a, 0x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 0x33, 0x24, 0xc8, 0x8b, 0x04, 0xc6, 0x07, 0xde, - 0x74, 0xdc, 0x8b, 0x89, 0xf8, 0xec, 0x71, 0x2f, 0x26, 0x6a, 0x7b, 0xb9, 0x1d, 0x29, 0xce, 0x2b, - 0x44, 0xb6, 0xa2, 0xe2, 0x78, 0x32, 0xfe, 0x14, 0x05, 0x1a, 0x54, 0x98, 0xcf, 0x08, 0x27, 0xfb, - 0x38, 0x1b, 0x99, 0x3f, 0x9a, 0x70, 0xbc, 0x37, 0xa7, 0x17, 0x4e, 0x90, 0xa9, 0x34, 0xbb, 0x19, - 0x48, 0x76, 0x9d, 0x5c, 0x8b, 0x08, 0xd6, 0xcf, 0x5d, 0x63, 0x18, 0xed, 0x24, 0x30, 0x89, 0x5e, - 0x42, 0xae, 0x0c, 0x0b, 0xab, 0xcb, 0x67, 0x7e, 0xf8, 0x44, 0x45, 0x67, 0x4b, 0x3e, 0x81, 0x4d, - 0x44, 0x36, 0xd0, 0x20, 0x8c, 0x4e, 0xe9, 0x29, 0xf4, 0x95, 0xe9, 0xc6, 0x9d, 0x8f, 0x7b, 0x19, - 0xb4, 0xbb, 0x97, 0x41, 0xdf, 0xf6, 0x32, 0x68, 0x63, 0x3f, 0x33, 0xb2, 0xbb, 0x9f, 0x19, 0xf9, - 0xba, 0x9f, 0x19, 0xb9, 0x5f, 0x34, 0xb9, 0x57, 0x6f, 0x55, 0xa9, 0x2e, 0x9a, 0x4c, 0xfd, 0x79, - 0xf2, 0xaa, 0x3e, 0x67, 0x0a, 0xd6, 0x14, 0x46, 0xab, 0x01, 0xae, 0xe4, 0x51, 0x5c, 0x98, 0xf3, - 0xa9, 0x78, 0x6b, 0x36, 0xb8, 0xd5, 0xb1, 0xe0, 0xef, 0xf3, 0xf2, 0x8f, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x1e, 0xb8, 0x07, 0x20, 0x8f, 0x0b, 0x00, 0x00, + // 746 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0xc1, 0x6b, 0x13, 0x4f, + 0x18, 0xed, 0xa4, 0xbf, 0x5f, 0xb1, 0x53, 0x51, 0x98, 0x14, 0x1b, 0x42, 0x8d, 0x69, 0x44, 0x1b, + 0xb4, 0x9d, 0x31, 0xf1, 0x60, 0xeb, 0xad, 0x82, 0xc5, 0x80, 0x87, 0x1a, 0x3c, 0x09, 0x12, 0x36, + 0xbb, 0x5f, 0x36, 0x43, 0x93, 0x9d, 0xed, 0xee, 0x24, 0xd0, 0x6a, 0x51, 0xea, 0xb5, 0x07, 0xc1, + 0xab, 0x07, 0xff, 0x0d, 0xff, 0x03, 0x8f, 0x05, 0x2f, 0x82, 0x17, 0x69, 0xbd, 0xf9, 0x4f, 0xc8, + 0xcc, 0x4e, 0xd2, 0x94, 0xcd, 0xb6, 0x49, 0xb1, 0xd0, 0xdb, 0xee, 0xcc, 0xfb, 0xbe, 0x79, 0xef, + 0x7d, 0x3b, 0x8f, 0xc5, 0xb7, 0x79, 0xdd, 0x66, 0x96, 0xef, 0xb7, 0xb8, 0x6d, 0x49, 0x2e, 0xbc, + 0x90, 0x35, 0x00, 0x58, 0xb7, 0xc4, 0xb6, 0x3a, 0x10, 0x6c, 0x53, 0x3f, 0x10, 0x52, 0x90, 0x39, + 0x5e, 0xb7, 0xe9, 0x20, 0x88, 0x36, 0x00, 0x68, 0xb7, 0x94, 0x9d, 0x75, 0x85, 0x2b, 0x34, 0x86, + 0xa9, 0xa7, 0x08, 0x9e, 0xbd, 0x67, 0x8b, 0xb0, 0x2d, 0x42, 0x56, 0xb7, 0x42, 0x88, 0xfa, 0xb0, + 0x6e, 0xa9, 0x0e, 0xd2, 0x2a, 0x31, 0xdf, 0x72, 0xb9, 0xa7, 0x7b, 0x18, 0xec, 0x42, 0xd2, 0xf9, + 0xea, 0x84, 0x08, 0x32, 0xef, 0x0a, 0xe1, 0xb6, 0x80, 0x59, 0x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x7f, 0x03, 0x00, 0x00, + 0xff, 0xff, 0x4c, 0x6f, 0x7f, 0x1d, 0xd0, 0x0a, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/modules/apps/29-fee/types/query.pb.gw.go b/modules/apps/29-fee/types/query.pb.gw.go index 40df38d4bf9..884d410092d 100644 --- a/modules/apps/29-fee/types/query.pb.gw.go +++ b/modules/apps/29-fee/types/query.pb.gw.go @@ -32,7 +32,7 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var ( - filter_Query_ReceiveFee_0 = &utilities.DoubleArray{Encoding: map[string]int{"packet_id": 0, "port_id": 1, "channel_id": 2, "sequence": 3, "relayer_address": 4, "query_height": 5}, Base: []int{1, 1, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0}, Check: []int{0, 1, 2, 2, 2, 1, 1, 3, 4, 5, 6, 7}} + filter_Query_ReceiveFee_0 = &utilities.DoubleArray{Encoding: map[string]int{"packet_id": 0, "port_id": 1, "channel_id": 2, "sequence": 3}, Base: []int{1, 1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 2, 2, 2, 3, 4, 5}} ) func request_Query_ReceiveFee_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -79,28 +79,6 @@ func request_Query_ReceiveFee_0(ctx context.Context, marshaler runtime.Marshaler return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) } - val, ok = pathParams["relayer_address"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "relayer_address") - } - - protoReq.RelayerAddress, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "relayer_address", err) - } - - val, ok = pathParams["query_height"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "query_height") - } - - protoReq.QueryHeight, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "query_height", err) - } - if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -157,28 +135,6 @@ func local_request_Query_ReceiveFee_0(ctx context.Context, marshaler runtime.Mar return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) } - val, ok = pathParams["relayer_address"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "relayer_address") - } - - protoReq.RelayerAddress, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "relayer_address", err) - } - - val, ok = pathParams["query_height"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "query_height") - } - - protoReq.QueryHeight, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "query_height", err) - } - if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -192,7 +148,7 @@ func local_request_Query_ReceiveFee_0(ctx context.Context, marshaler runtime.Mar } var ( - filter_Query_AckFee_0 = &utilities.DoubleArray{Encoding: map[string]int{"packet_id": 0, "port_id": 1, "channel_id": 2, "sequence": 3, "relayer_address": 4, "query_height": 5}, Base: []int{1, 1, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0}, Check: []int{0, 1, 2, 2, 2, 1, 1, 3, 4, 5, 6, 7}} + filter_Query_AckFee_0 = &utilities.DoubleArray{Encoding: map[string]int{"packet_id": 0, "port_id": 1, "channel_id": 2, "sequence": 3}, Base: []int{1, 1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 2, 2, 2, 3, 4, 5}} ) func request_Query_AckFee_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -239,28 +195,6 @@ func request_Query_AckFee_0(ctx context.Context, marshaler runtime.Marshaler, cl return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) } - val, ok = pathParams["relayer_address"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "relayer_address") - } - - protoReq.RelayerAddress, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "relayer_address", err) - } - - val, ok = pathParams["query_height"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "query_height") - } - - protoReq.QueryHeight, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "query_height", err) - } - if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -317,28 +251,6 @@ func local_request_Query_AckFee_0(ctx context.Context, marshaler runtime.Marshal return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) } - val, ok = pathParams["relayer_address"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "relayer_address") - } - - protoReq.RelayerAddress, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "relayer_address", err) - } - - val, ok = pathParams["query_height"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "query_height") - } - - protoReq.QueryHeight, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "query_height", err) - } - if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -352,7 +264,7 @@ func local_request_Query_AckFee_0(ctx context.Context, marshaler runtime.Marshal } var ( - filter_Query_TimeoutFee_0 = &utilities.DoubleArray{Encoding: map[string]int{"packet_id": 0, "port_id": 1, "channel_id": 2, "sequence": 3, "relayer_address": 4, "query_height": 5}, Base: []int{1, 1, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0}, Check: []int{0, 1, 2, 2, 2, 1, 1, 3, 4, 5, 6, 7}} + filter_Query_TimeoutFee_0 = &utilities.DoubleArray{Encoding: map[string]int{"packet_id": 0, "port_id": 1, "channel_id": 2, "sequence": 3}, Base: []int{1, 1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 2, 2, 2, 3, 4, 5}} ) func request_Query_TimeoutFee_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -399,28 +311,6 @@ func request_Query_TimeoutFee_0(ctx context.Context, marshaler runtime.Marshaler return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) } - val, ok = pathParams["relayer_address"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "relayer_address") - } - - protoReq.RelayerAddress, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "relayer_address", err) - } - - val, ok = pathParams["query_height"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "query_height") - } - - protoReq.QueryHeight, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "query_height", err) - } - if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -477,28 +367,6 @@ func local_request_Query_TimeoutFee_0(ctx context.Context, marshaler runtime.Mar return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) } - val, ok = pathParams["relayer_address"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "relayer_address") - } - - protoReq.RelayerAddress, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "relayer_address", err) - } - - val, ok = pathParams["query_height"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "query_height") - } - - protoReq.QueryHeight, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "query_height", err) - } - if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -512,31 +380,13 @@ func local_request_Query_TimeoutFee_0(ctx context.Context, marshaler runtime.Mar } var ( - filter_Query_IncentivizedPackets_0 = &utilities.DoubleArray{Encoding: map[string]int{"query_height": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} + filter_Query_IncentivizedPackets_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) func request_Query_IncentivizedPackets_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryIncentivizedPacketsRequest var metadata runtime.ServerMetadata - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["query_height"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "query_height") - } - - protoReq.QueryHeight, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "query_height", err) - } - if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -553,24 +403,6 @@ func local_request_Query_IncentivizedPackets_0(ctx context.Context, marshaler ru var protoReq QueryIncentivizedPacketsRequest var metadata runtime.ServerMetadata - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["query_height"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "query_height") - } - - protoReq.QueryHeight, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "query_height", err) - } - if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -584,7 +416,7 @@ func local_request_Query_IncentivizedPackets_0(ctx context.Context, marshaler ru } var ( - filter_Query_IncentivizedPacket_0 = &utilities.DoubleArray{Encoding: map[string]int{"packet_id": 0, "port_id": 1, "channel_id": 2, "sequence": 3, "query_height": 4}, Base: []int{1, 1, 1, 2, 3, 4, 0, 0, 0, 0}, Check: []int{0, 1, 2, 2, 2, 1, 3, 4, 5, 6}} + filter_Query_IncentivizedPacket_0 = &utilities.DoubleArray{Encoding: map[string]int{"packet_id": 0, "port_id": 1, "channel_id": 2, "sequence": 3}, Base: []int{1, 1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 2, 2, 2, 3, 4, 5}} ) func request_Query_IncentivizedPacket_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -631,17 +463,6 @@ func request_Query_IncentivizedPacket_0(ctx context.Context, marshaler runtime.M return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) } - val, ok = pathParams["query_height"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "query_height") - } - - protoReq.QueryHeight, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "query_height", err) - } - if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -698,17 +519,6 @@ func local_request_Query_IncentivizedPacket_0(ctx context.Context, marshaler run return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) } - val, ok = pathParams["query_height"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "query_height") - } - - protoReq.QueryHeight, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "query_height", err) - } - if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -972,15 +782,15 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_ReceiveFee_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10, 2, 11, 1, 0, 4, 1, 5, 12, 2, 13, 1, 0, 4, 1, 5, 14}, []string{"ibc", "apps", "fee", "v1", "receive_fee", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence", "relayer", "relayer_address", "height", "query_height"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_ReceiveFee_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "receive_fee", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_AckFee_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10, 2, 11, 1, 0, 4, 1, 5, 12, 2, 13, 1, 0, 4, 1, 5, 14}, []string{"ibc", "apps", "fee", "v1", "ack_fee", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence", "relayer", "relayer_address", "height", "query_height"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_AckFee_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "ack_fee", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_TimeoutFee_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10, 1, 0, 4, 1, 5, 11, 2, 12, 1, 0, 4, 1, 5, 13}, []string{"ibc", "apps", "fee", "v1", "timeout_fee", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence", "relayer_address", "height", "query_height"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_TimeoutFee_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "timeout_fee", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_IncentivizedPackets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6}, []string{"ibc", "apps", "fee", "v1", "incentivized_packets", "height", "query_height"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_IncentivizedPackets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"ibc", "apps", "fee", "v1", "incentivized_packets"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_IncentivizedPacket_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10, 2, 11, 1, 0, 4, 1, 5, 12}, []string{"ibc", "apps", "fee", "v1", "incentivized_packet", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence", "height", "query_height"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_IncentivizedPacket_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "incentivized_packet", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( diff --git a/modules/apps/29-fee/types/tx.pb.go b/modules/apps/29-fee/types/tx.pb.go index be4b2c6eb8a..cb46345e9f1 100644 --- a/modules/apps/29-fee/types/tx.pb.go +++ b/modules/apps/29-fee/types/tx.pb.go @@ -6,7 +6,7 @@ package types import ( context "context" fmt "fmt" - types "github.com/cosmos/ibc-go/modules/core/04-channel/types" + _ "github.com/cosmos/ibc-go/modules/core/04-channel/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -109,11 +109,8 @@ var xxx_messageInfo_MsgRegisterCounterPartyAddressResponse proto.InternalMessage // MsgEscrowPacketFee defines the request type EscrowPacketFee RPC type MsgEscrowPacketFee struct { - PacketId *types.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id,omitempty" yaml:"packet_id"` - ReceiveFee *Fee `protobuf:"bytes,2,opt,name=receive_fee,json=receiveFee,proto3" json:"receive_fee,omitempty" yaml:"receive_fee"` - AckFee *Fee `protobuf:"bytes,3,opt,name=ack_fee,json=ackFee,proto3" json:"ack_fee,omitempty" yaml:"ack_fee"` - TimeoutFee *Fee `protobuf:"bytes,4,opt,name=timeout_fee,json=timeoutFee,proto3" json:"timeout_fee,omitempty" yaml:"timeout_fee"` - Relayers []string `protobuf:"bytes,5,rep,name=relayers,proto3" json:"relayers,omitempty"` + IncentivizedPacket *IdentifiedPacketFee `protobuf:"bytes,1,opt,name=incentivized_packet,json=incentivizedPacket,proto3" json:"incentivized_packet,omitempty" yaml:"incentivized_packet"` + Relayers []string `protobuf:"bytes,2,rep,name=relayers,proto3" json:"relayers,omitempty"` } func (m *MsgEscrowPacketFee) Reset() { *m = MsgEscrowPacketFee{} } @@ -196,41 +193,36 @@ func init() { func init() { proto.RegisterFile("ibc/applications/fee/v1/tx.proto", fileDescriptor_05c93128649f1b96) } var fileDescriptor_05c93128649f1b96 = []byte{ - // 531 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x4f, 0x6b, 0x13, 0x41, - 0x18, 0xc6, 0xb3, 0x8d, 0xb6, 0xc9, 0x04, 0x54, 0xc6, 0xa0, 0x61, 0x5b, 0x77, 0xe3, 0x1e, 0x24, - 0x20, 0xdd, 0x25, 0xe9, 0x41, 0xec, 0x45, 0x8c, 0x58, 0x28, 0x18, 0x08, 0x03, 0xbd, 0x78, 0x09, - 0x93, 0xc9, 0x9b, 0xed, 0x90, 0x3f, 0xb3, 0xcc, 0x4c, 0xa2, 0xf9, 0x00, 0x82, 0x47, 0x0f,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 0xc4, 0x50, 0x81, 0xf7, 0x25, 0x8b, 0x70, 0x43, 0x85, 0xef, 0x15, 0x93, - 0xe2, 0x53, 0x93, 0xb2, 0x1e, 0xe8, 0x33, 0x00, 0xdc, 0x44, 0xf9, 0x28, 0x2e, 0x5a, 0xbc, 0x13, - 0x47, 0x2f, 0xd4, 0x9e, 0xf9, 0xe6, 0x91, 0xcd, 0x93, 0xf8, 0xab, 0x77, 0x18, 0x57, 0xfd, 0x44, - 0x72, 0xde, 0xa9, 0x17, 0x17, 0x53, 0xf7, 0x51, 0x12, 0xf9, 0x46, 0xe9, 0x91, 0x5c, 0xb4, 0xfc, - 0x8e, 0x2f, 0x50, 0x41, 0x02, 0x03, 0x3e, 0x86, 0x56, 0x17, 0x20, 0xfe, 0xcf, 0x42, 0xed, 0xc8, - 0xdf, 0xd0, 0x38, 0xff, 0x0c, 0xa0, 0xfe, 0x64, 0x31, 0x75, 0x71, 0x62, 0x99, 0x92, 0x7a, 0x04, - 0x2d, 0x2b, 0x13, 0xf4, 0x1c, 0x1d, 0x50, 0xd6, 0x8b, 0x2d, 0xb3, 0xff, 0x61, 0x89, 0x17, 0x53, - 0xf7, 0x41, 0x62, 0xb9, 0x94, 0x79, 0x64, 0x9f, 0xb2, 0x9e, 0xb1, 0xba, 0x40, 0x05, 0xcd, 0x07, - 0x20, 0x46, 0x3a, 0xb6, 0xbb, 0xb7, 0x5b, 0xc2, 0x94, 0xd4, 0x23, 0x68, 0x59, 0x19, 0x5b, 0x1b, - 0xe5, 0x24, 0xf4, 0xe9, 0x04, 0xa4, 0x2a, 0xdd, 0x2f, 0x67, 0x2b, 0x79, 0x72, 0x53, 0xa7, 0x3a, - 0x76, 0x84, 0xec, 0xf5, 0x36, 0xac, 0xba, 0x54, 0xfb, 0xbe, 0x87, 0xb2, 0x0d, 0x15, 0xe2, 0x1f, - 0x16, 0x3a, 0xdc, 0xd2, 0x55, 0xfc, 0x6a, 0x63, 0xda, 0xed, 0x83, 0x6a, 0xbf, 0xd9, 0x41, 0x78, - 0xd7, 0x1c, 0x61, 0x85, 0x1e, 0xde, 0x9e, 0xa1, 0x97, 0xdb, 0x3c, 0x6f, 0xc1, 0xf6, 0xc9, 0x0e, - 0xf0, 0xea, 0xd2, 0xfa, 0x87, 0x5f, 0x33, 0xc7, 0xba, 0x9e, 0x39, 0xd6, 0x9f, 0x99, 0x63, 0x7d, - 0x9b, 0x3b, 0x99, 0xeb, 0xb9, 0x93, 0xf9, 0x3d, 0x77, 0x32, 0x1f, 0x6b, 0x21, 0xd7, 0x97, 0xa3, - 0xb6, 0xcf, 0xc4, 0x20, 0x60, 0x42, 0x0d, 0x84, 0x0a, 0x78, 0x9b, 0x1d, 0x87, 0x22, 0x18, 0x88, - 0xce, 0xa8, 0x0f, 0xca, 0xac, 0xbf, 0x0a, 0x6a, 0xaf, 0x8f, 0xcd, 0xe6, 0xeb, 0x49, 0x04, 0xaa, - 0xbd, 0x1f, 0xaf, 0xf5, 0xc9, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe1, 0xc9, 0x06, 0xc0, 0x6f, - 0x04, 0x00, 0x00, + // 454 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xcf, 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,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3f, 0x00, 0x00, 0xff, 0xff, 0x58, 0x35, + 0x6c, 0xa4, 0xa3, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -451,48 +443,12 @@ func (m *MsgEscrowPacketFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Relayers[iNdEx]) i = encodeVarintTx(dAtA, i, uint64(len(m.Relayers[iNdEx]))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x12 } } - if m.TimeoutFee != nil { + if m.IncentivizedPacket != nil { { - size, err := m.TimeoutFee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - if m.AckFee != nil { - { - size, err := m.AckFee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.ReceiveFee != nil { - { - size, err := m.ReceiveFee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.PacketId != nil { - { - size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.IncentivizedPacket.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -571,20 +527,8 @@ func (m *MsgEscrowPacketFee) Size() (n int) { } var l int _ = l - if m.PacketId != nil { - l = m.PacketId.Size() - n += 1 + l + sovTx(uint64(l)) - } - if m.ReceiveFee != nil { - l = m.ReceiveFee.Size() - n += 1 + l + sovTx(uint64(l)) - } - if m.AckFee != nil { - l = m.AckFee.Size() - n += 1 + l + sovTx(uint64(l)) - } - if m.TimeoutFee != nil { - l = m.TimeoutFee.Size() + if m.IncentivizedPacket != nil { + l = m.IncentivizedPacket.Size() n += 1 + l + sovTx(uint64(l)) } if len(m.Relayers) > 0 { @@ -806,7 +750,7 @@ func (m *MsgEscrowPacketFee) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field IncentivizedPacket", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -833,122 +777,14 @@ func (m *MsgEscrowPacketFee) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.PacketId == nil { - m.PacketId = &types.PacketId{} + if m.IncentivizedPacket == nil { + m.IncentivizedPacket = &IdentifiedPacketFee{} } - if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.IncentivizedPacket.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ReceiveFee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ReceiveFee == nil { - m.ReceiveFee = &Fee{} - } - if err := m.ReceiveFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AckFee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.AckFee == nil { - m.AckFee = &Fee{} - } - if err := m.AckFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TimeoutFee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.TimeoutFee == nil { - m.TimeoutFee = &Fee{} - } - if err := m.TimeoutFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Relayers", wireType) } diff --git a/proto/ibc/applications/fee/v1/query.proto b/proto/ibc/applications/fee/v1/query.proto index c4411da5b0e..e2fd5c141fd 100644 --- a/proto/ibc/applications/fee/v1/query.proto +++ b/proto/ibc/applications/fee/v1/query.proto @@ -17,33 +17,33 @@ service Query { rpc ReceiveFee(QueryReceiveFeeRequest) returns (QueryReceiveFeeResponse) { option (google.api.http).get = "/ibc/apps/fee/v1/receive_fee/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/" - "{packet_id.sequence}/relayer/{relayer_address}/height/{query_height}"; + "{packet_id.sequence}"; } // Gets the fee expected for submitting AcknowledgePacket msg for the given packet rpc AckFee(QueryAckFeeRequest) returns (QueryAckFeeResponse) { option (google.api.http).get = "/ibc/apps/fee/v1/ack_fee/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/" - "{packet_id.sequence}/relayer/{relayer_address}/height/{query_height}"; + "{packet_id.sequence}"; } // Gets the fee expected for submitting TimeoutPacket msg for the given packet rpc TimeoutFee(QueryTimeoutFeeRequest) returns (QueryTimeoutFeeResponse) { option (google.api.http).get = "/ibc/apps/fee/v1/timeout_fee/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/" - "{packet_id.sequence}/{relayer_address}/height/{query_height}"; + "{packet_id.sequence}"; } // Gets all incentivized packets rpc IncentivizedPackets(QueryIncentivizedPacketsRequest) returns (QueryIncentivizedPacketsResponse) { - option (google.api.http).get = "/ibc/apps/fee/v1/incentivized_packets/height/{query_height}"; + option (google.api.http).get = "/ibc/apps/fee/v1/incentivized_packets"; } // Gets the specified incentivized packet rpc IncentivizedPacket(QueryIncentivizedPacketRequest) returns (QueryIncentivizedPacketResponse) { option (google.api.http).get = "/ibc/apps/fee/v1/incentivized_packet/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/" - "{packet_id.sequence}/height/{query_height}"; + "{packet_id.sequence}"; } } diff --git a/proto/ibc/applications/fee/v1/tx.proto b/proto/ibc/applications/fee/v1/tx.proto index 65bc727f0eb..85ee09d0672 100644 --- a/proto/ibc/applications/fee/v1/tx.proto +++ b/proto/ibc/applications/fee/v1/tx.proto @@ -38,11 +38,9 @@ message MsgEscrowPacketFee { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.moretags) = "yaml:\"packet_id\""]; - ibc.applications.fee.v1.Fee receive_fee = 2 [(gogoproto.moretags) = "yaml:\"receive_fee\""]; - ibc.applications.fee.v1.Fee ack_fee = 3 [(gogoproto.moretags) = "yaml:\"ack_fee\""]; - ibc.applications.fee.v1.Fee timeout_fee = 4 [(gogoproto.moretags) = "yaml:\"timeout_fee\""]; - repeated string relayers = 5; + ibc.applications.fee.v1.IdentifiedPacketFee incentivized_packet = 1 + [(gogoproto.moretags) = "yaml:\"incentivized_packet\""]; + repeated string relayers = 2; } // MsgEscrowPacketFeeResponse defines the response type for Msg/EscrowPacketFee From e3704c683eb171a4c74658af631a1b7a6d035c4d Mon Sep 17 00:00:00 2001 From: Sean King Date: Wed, 8 Sep 2021 13:29:49 +0200 Subject: [PATCH 04/79] 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,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xa9, 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 05/79] 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 dd4f8c7fd2a333e43dd70ef902066a7f15c77c3b Mon Sep 17 00:00:00 2001 From: Aditya Date: Mon, 27 Sep 2021 14:36:37 +0200 Subject: [PATCH 06/79] feat: Add handshake logic to ics29 (#307) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * do handshake logic, create test file * do cap logic and fix build * open handshake implementation and tests * remove prints * Update modules/apps/29-fee/module.go Co-authored-by: Sean King * debugging progress * fee enabled flag * cleanup handshake logic * fix tests * much cleaner simapp * split module.go file * cleanup and docs * assert IBC interfaces are fulfilled in middleware * Update modules/apps/transfer/module.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * fix unnecessary crossing hello logic * fix version negotiation bugs and improve tests * cleanup tests * Apply suggestions from code review Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * address rest of colin comments Co-authored-by: Sean King Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> --- modules/apps/29-fee/fee_test.go | 41 +++ modules/apps/29-fee/ibc_module.go | 178 +++++++++++ modules/apps/29-fee/ibc_module_test.go | 302 ++++++++++++++++++ modules/apps/29-fee/keeper/keeper.go | 75 +++-- modules/apps/29-fee/module.go | 169 +++------- modules/apps/29-fee/types/errors.go | 6 +- modules/apps/29-fee/types/expected_keepers.go | 28 -- modules/apps/29-fee/types/keys.go | 13 +- modules/apps/transfer/module.go | 9 +- modules/apps/transfer/module_test.go | 16 +- modules/core/04-channel/keeper/handshake.go | 3 +- modules/core/04-channel/types/version.go | 27 ++ modules/core/04-channel/types/version_test.go | 77 +++++ testing/simapp/app.go | 32 +- 14 files changed, 768 insertions(+), 208 deletions(-) create mode 100644 modules/apps/29-fee/fee_test.go create mode 100644 modules/apps/29-fee/ibc_module.go create mode 100644 modules/apps/29-fee/ibc_module_test.go create mode 100644 modules/core/04-channel/types/version.go create mode 100644 modules/core/04-channel/types/version_test.go diff --git a/modules/apps/29-fee/fee_test.go b/modules/apps/29-fee/fee_test.go new file mode 100644 index 00000000000..9ecb400f710 --- /dev/null +++ b/modules/apps/29-fee/fee_test.go @@ -0,0 +1,41 @@ +package fee_test + +import ( + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" + ibctesting "github.com/cosmos/ibc-go/testing" +) + +type FeeTestSuite struct { + suite.Suite + + coordinator *ibctesting.Coordinator + + chainA *ibctesting.TestChain + chainB *ibctesting.TestChain + + path *ibctesting.Path +} + +func (suite *FeeTestSuite) SetupTest() { + suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) + suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(0)) + suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1)) + + path := ibctesting.NewPath(suite.chainA, suite.chainB) + feeTransferVersion := channeltypes.MergeChannelVersions(types.Version, transfertypes.Version) + path.EndpointA.ChannelConfig.Version = feeTransferVersion + path.EndpointB.ChannelConfig.Version = feeTransferVersion + path.EndpointA.ChannelConfig.PortID = transfertypes.PortID + path.EndpointB.ChannelConfig.PortID = transfertypes.PortID + suite.path = path +} + +func TestIBCFeeTestSuite(t *testing.T) { + suite.Run(t, new(FeeTestSuite)) +} diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go new file mode 100644 index 00000000000..0c22fb19d8d --- /dev/null +++ b/modules/apps/29-fee/ibc_module.go @@ -0,0 +1,178 @@ +package fee + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + + "github.com/cosmos/ibc-go/modules/apps/29-fee/keeper" + "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/modules/core/05-port/types" + ibcexported "github.com/cosmos/ibc-go/modules/core/exported" +) + +// IBCModule implements the ICS26 callbacks for the fee middleware given the fee keeper and the underlying application. +type IBCModule struct { + keeper keeper.Keeper + app porttypes.IBCModule +} + +// NewIBCModule creates a new IBCModule given the keeper and underlying application +func NewIBCModule(k keeper.Keeper, app porttypes.IBCModule) IBCModule { + return IBCModule{ + keeper: k, + app: app, + } +} + +// OnChanOpenInit implements the IBCModule interface +func (im IBCModule) OnChanOpenInit( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID string, + channelID string, + chanCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + version string, +) error { + mwVersion, appVersion := channeltypes.SplitChannelVersion(version) + // Since it is valid for fee version to not be specified, the above middleware version may be for a middleware + // lower down in the stack. Thus, if it is not a fee version we pass the entire version string onto the underlying + // application. + // If an invalid fee version was passed, we expect the underlying application to fail on its version negotiation. + if mwVersion == types.Version { + im.keeper.SetFeeEnabled(ctx, portID, channelID) + } else { + // middleware version is not the expected version for this midddleware. Pass the full version string along, + // if it not valid version for any other lower middleware, an error will be returned by base application. + appVersion = version + } + + // call underlying app's OnChanOpenInit callback with the appVersion + return im.app.OnChanOpenInit(ctx, order, connectionHops, portID, channelID, + chanCap, counterparty, appVersion) +} + +// OnChanOpenTry implements the IBCModule interface +func (im IBCModule) OnChanOpenTry( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID, + channelID string, + chanCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + version, + counterpartyVersion string, +) error { + mwVersion, appVersion := channeltypes.SplitChannelVersion(version) + cpMwVersion, cpAppVersion := channeltypes.SplitChannelVersion(counterpartyVersion) + + // Since it is valid for fee version to not be specified, the above middleware version may be for a middleware + // lower down in the stack. Thus, if it is not a fee version we pass the entire version string onto the underlying + // application. + // If an invalid fee version was passed, we expect the underlying application to fail on its version negotiation. + if mwVersion == types.Version || cpMwVersion == types.Version { + if cpMwVersion != mwVersion { + return sdkerrors.Wrapf(types.ErrInvalidVersion, "fee versions do not match. self version: %s, counterparty version: %s", mwVersion, cpMwVersion) + } + + im.keeper.SetFeeEnabled(ctx, portID, channelID) + } else { + // middleware versions are not the expected version for this midddleware. Pass the full version strings along, + // if it not valid version for any other lower middleware, an error will be returned by base application. + appVersion = version + cpAppVersion = counterpartyVersion + } + + // call underlying app's OnChanOpenTry callback with the app versions + return im.app.OnChanOpenTry(ctx, order, connectionHops, portID, channelID, + chanCap, counterparty, appVersion, cpAppVersion) +} + +// OnChanOpenAck implements the IBCModule interface +func (im IBCModule) OnChanOpenAck( + ctx sdk.Context, + portID, + channelID string, + counterpartyVersion string, +) error { + // If handshake was initialized with fee enabled it must complete with fee enabled. + // If handshake was initialized with fee disabled it must complete with fee disabled. + cpAppVersion := counterpartyVersion + if im.keeper.IsFeeEnabled(ctx, portID, channelID) { + var cpFeeVersion string + cpFeeVersion, cpAppVersion = channeltypes.SplitChannelVersion(counterpartyVersion) + + if cpFeeVersion != types.Version { + return sdkerrors.Wrapf(types.ErrInvalidVersion, "expected counterparty version: %s, got: %s", types.Version, cpFeeVersion) + } + } + // call underlying app's OnChanOpenAck callback with the counterparty app version. + return im.app.OnChanOpenAck(ctx, portID, channelID, cpAppVersion) +} + +// OnChanOpenConfirm implements the IBCModule interface +func (im IBCModule) OnChanOpenConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + // call underlying app's OnChanOpenConfirm callback. + return im.app.OnChanOpenConfirm(ctx, portID, channelID) +} + +// OnChanCloseInit implements the IBCModule interface +func (im IBCModule) OnChanCloseInit( + ctx sdk.Context, + portID, + channelID string, +) error { + // TODO: Unescrow all remaining funds for unprocessed packets + im.keeper.DeleteFeeEnabled(ctx, portID, channelID) + return im.app.OnChanCloseInit(ctx, portID, channelID) +} + +// OnChanCloseConfirm implements the IBCModule interface +func (im IBCModule) OnChanCloseConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + // TODO: Unescrow all remaining funds for unprocessed packets + im.keeper.DeleteFeeEnabled(ctx, portID, channelID) + return im.app.OnChanCloseConfirm(ctx, portID, channelID) +} + +// OnRecvPacket implements the IBCModule interface. +func (im IBCModule) OnRecvPacket( + ctx sdk.Context, + packet channeltypes.Packet, + relayer sdk.AccAddress, +) ibcexported.Acknowledgement { + // TODO: Implement fee specific logic if fee is enabled for the given channel + return im.app.OnRecvPacket(ctx, packet, relayer) +} + +// OnAcknowledgementPacket implements the IBCModule interface +func (im IBCModule) OnAcknowledgementPacket( + ctx sdk.Context, + packet channeltypes.Packet, + acknowledgement []byte, + relayer sdk.AccAddress, +) error { + // TODO: Implement fee specific logic if fee is enabled for the given channel + return im.app.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer) +} + +// OnTimeoutPacket implements the IBCModule interface +func (im IBCModule) OnTimeoutPacket( + ctx sdk.Context, + packet channeltypes.Packet, + relayer sdk.AccAddress, +) error { + // TODO: Implement fee specific logic if fee is enabled for the given channel + return im.app.OnTimeoutPacket(ctx, packet, relayer) +} diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go new file mode 100644 index 00000000000..915fdaebf79 --- /dev/null +++ b/modules/apps/29-fee/ibc_module_test.go @@ -0,0 +1,302 @@ +package fee_test + +import ( + "fmt" + + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + + "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/modules/core/24-host" + ibctesting "github.com/cosmos/ibc-go/testing" +) + +// Tests OnChanOpenInit on ChainA +func (suite *FeeTestSuite) TestOnChanOpenInit() { + testCases := []struct { + name string + version string + expPass bool + }{ + { + "valid fee middleware and transfer version", + channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + true, + }, + { + "fee version not included, only perform transfer logic", + transfertypes.Version, + true, + }, + { + "invalid fee middleware version", + channeltypes.MergeChannelVersions("otherfee28-1", transfertypes.Version), + false, + }, + { + "invalid transfer version", + channeltypes.MergeChannelVersions(types.Version, "wrongics20-1"), + false, + }, + { + "incorrect wrapping delimiter", + fmt.Sprintf("%s//%s", types.Version, transfertypes.Version), + false, + }, + { + "transfer version not wrapped", + types.Version, + false, + }, + { + "hanging delimiter", + fmt.Sprintf("%s:%s:", types.Version, transfertypes.Version), + false, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + // reset suite + suite.SetupTest() + suite.coordinator.SetupConnections(suite.path) + suite.path.EndpointA.ChannelID = ibctesting.FirstChannelID + + counterparty := channeltypes.NewCounterparty(suite.path.EndpointB.ChannelConfig.PortID, suite.path.EndpointB.ChannelID) + channel := &channeltypes.Channel{ + State: channeltypes.INIT, + Ordering: channeltypes.UNORDERED, + Counterparty: counterparty, + ConnectionHops: []string{suite.path.EndpointA.ConnectionID}, + Version: tc.version, + } + + module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort) + suite.Require().NoError(err) + + chanCap, err := suite.chainA.App.GetScopedIBCKeeper().NewCapability(suite.chainA.GetContext(), host.ChannelCapabilityPath(ibctesting.TransferPort, suite.path.EndpointA.ChannelID)) + suite.Require().NoError(err) + + cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + suite.Require().True(ok) + + err = cbs.OnChanOpenInit(suite.chainA.GetContext(), channel.Ordering, channel.GetConnectionHops(), + suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, chanCap, counterparty, channel.Version) + + if tc.expPass { + suite.Require().NoError(err, "unexpected error from version: %s", tc.version) + } else { + suite.Require().Error(err, "error not returned for version: %s", tc.version) + } + }) + } +} + +// Tests OnChanOpenTry on ChainA +func (suite *FeeTestSuite) TestOnChanOpenTry() { + testCases := []struct { + name string + version string + cpVersion string + crossing bool + expPass bool + }{ + { + "valid fee middleware and transfer version", + channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + false, + true, + }, + { + "valid transfer version on try and counterparty", + transfertypes.Version, + transfertypes.Version, + false, + true, + }, + { + "valid fee middleware and transfer version, crossing hellos", + channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + true, + true, + }, + { + "invalid fee middleware version", + channeltypes.MergeChannelVersions("otherfee28-1", transfertypes.Version), + channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + false, + false, + }, + { + "invalid counterparty fee middleware version", + channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + channeltypes.MergeChannelVersions("wrongfee29-1", transfertypes.Version), + false, + false, + }, + { + "invalid transfer version", + channeltypes.MergeChannelVersions(types.Version, "wrongics20-1"), + channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + false, + false, + }, + { + "invalid counterparty transfer version", + channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + channeltypes.MergeChannelVersions(types.Version, "wrongics20-1"), + false, + false, + }, + { + "transfer version not wrapped", + types.Version, + channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + false, + false, + }, + { + "counterparty transfer version not wrapped", + channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + types.Version, + false, + false, + }, + { + "fee version not included on try, but included in counterparty", + transfertypes.Version, + channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + false, + false, + }, + { + "fee version not included", + channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + transfertypes.Version, + false, + false, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + // reset suite + suite.SetupTest() + suite.coordinator.SetupConnections(suite.path) + suite.path.EndpointB.ChanOpenInit() + + var ( + chanCap *capabilitytypes.Capability + ok bool + err error + ) + if tc.crossing { + suite.path.EndpointA.ChanOpenInit() + chanCap, ok = suite.chainA.GetSimApp().ScopedTransferKeeper.GetCapability(suite.chainA.GetContext(), host.ChannelCapabilityPath(ibctesting.TransferPort, suite.path.EndpointA.ChannelID)) + suite.Require().True(ok) + } else { + chanCap, err = suite.chainA.App.GetScopedIBCKeeper().NewCapability(suite.chainA.GetContext(), host.ChannelCapabilityPath(ibctesting.TransferPort, suite.path.EndpointA.ChannelID)) + suite.Require().NoError(err) + } + + suite.path.EndpointA.ChannelID = ibctesting.FirstChannelID + + counterparty := channeltypes.NewCounterparty(suite.path.EndpointB.ChannelConfig.PortID, suite.path.EndpointB.ChannelID) + channel := &channeltypes.Channel{ + State: channeltypes.INIT, + Ordering: channeltypes.UNORDERED, + Counterparty: counterparty, + ConnectionHops: []string{suite.path.EndpointA.ConnectionID}, + Version: tc.version, + } + + module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort) + suite.Require().NoError(err) + + cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + suite.Require().True(ok) + + err = cbs.OnChanOpenTry(suite.chainA.GetContext(), channel.Ordering, channel.GetConnectionHops(), + suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, chanCap, counterparty, tc.version, tc.cpVersion) + + if tc.expPass { + suite.Require().NoError(err, "unexpected error from version: %s", tc.version) + } else { + suite.Require().Error(err, "error not returned for version: %s", tc.version) + } + }) + } +} + +// Tests OnChanOpenAck on ChainA +func (suite *FeeTestSuite) TestOnChanOpenAck() { + testCases := []struct { + name string + cpVersion string + malleate func(suite *FeeTestSuite) + expPass bool + }{ + { + "success", + channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + func(suite *FeeTestSuite) {}, + true, + }, + { + "invalid fee version", + channeltypes.MergeChannelVersions("fee29-A", transfertypes.Version), + func(suite *FeeTestSuite) {}, + false, + }, + { + "invalid transfer version", + channeltypes.MergeChannelVersions(types.Version, "ics20-4"), + func(suite *FeeTestSuite) {}, + false, + }, + { + "previous INIT set without fee, however counterparty set fee version", // note this can only happen with incompetent or malicious counterparty chain + channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + func(suite *FeeTestSuite) { + // do the first steps without fee version, then pass the fee version as counterparty version in ChanOpenACK + suite.path.EndpointA.ChannelConfig.Version = transfertypes.Version + suite.path.EndpointB.ChannelConfig.Version = transfertypes.Version + }, + false, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + suite.SetupTest() + suite.coordinator.SetupConnections(suite.path) + + // malleate test case + tc.malleate(suite) + + suite.path.EndpointA.ChanOpenInit() + suite.path.EndpointB.ChanOpenTry() + + module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort) + suite.Require().NoError(err) + + cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + suite.Require().True(ok) + + err = cbs.OnChanOpenAck(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, tc.cpVersion) + if tc.expPass { + suite.Require().NoError(err, "unexpected error for case: %s", tc.name) + } else { + suite.Require().Error(err, "%s expected error but returned none", tc.name) + } + }) + } +} diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index 8dd7ab03af2..eb14e1a3a1f 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -3,12 +3,22 @@ package keeper import ( "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/tendermint/tendermint/libs/log" "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/modules/core/24-host" + ibcexported "github.com/cosmos/ibc-go/modules/core/exported" +) + +// Middleware must implement types.ChannelKeeper and types.PortKeeper expected interfaces +// so that it can wrap IBC channel and port logic for underlying application. +var ( + _ types.ChannelKeeper = Keeper{} + _ types.PortKeeper = Keeper{} ) // Keeper defines the IBC fungible transfer keeper @@ -18,16 +28,12 @@ type Keeper struct { channelKeeper types.ChannelKeeper portKeeper types.PortKeeper - authKeeper types.AccountKeeper - bankKeeper types.BankKeeper - scopedKeeper capabilitykeeper.ScopedKeeper } // NewKeeper creates a new 29-fee Keeper instance func NewKeeper( cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace, channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper, - authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, scopedKeeper capabilitykeeper.ScopedKeeper, ) Keeper { return Keeper{ @@ -35,9 +41,6 @@ func NewKeeper( storeKey: key, channelKeeper: channelKeeper, portKeeper: portKeeper, - authKeeper: authKeeper, - bankKeeper: bankKeeper, - scopedKeeper: scopedKeeper, } } @@ -46,37 +49,51 @@ 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)) - return ok +// BindPort defines a wrapper function for the port Keeper's function in +// order to expose it to module's InitGenesis function +func (k Keeper) BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability { + return k.portKeeper.BindPort(ctx, portID) } -// BindPort defines a wrapper function for the ort Keeper's function in -// order to expose it to module's InitGenesis function -func (k Keeper) BindPort(ctx sdk.Context, portID string) error { - cap := k.portKeeper.BindPort(ctx, portID) - return k.ClaimCapability(ctx, cap, host.PortPath(portID)) +// ChanCloseInit wraps the channel keeper's function in order to expose it to underlying app. +func (k Keeper) ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capabilitytypes.Capability) error { + return k.channelKeeper.ChanCloseInit(ctx, portID, channelID, chanCap) +} + +// GetChannel wraps IBC ChannelKeeper's GetChannel function +func (k Keeper) GetChannel(ctx sdk.Context, portID, channelID string) (channeltypes.Channel, bool) { + return k.channelKeeper.GetChannel(ctx, portID, channelID) } -// SetPort sets the portID for the transfer module. Used in InitGenesis -func (k Keeper) SetPort(ctx sdk.Context, portID string) { +// GetNextSequenceSend wraps IBC ChannelKeeper's GetNextSequenceSend function +func (k Keeper) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) { + return k.channelKeeper.GetNextSequenceSend(ctx, portID, channelID) +} + +// SendPacket wraps IBC ChannelKeeper's SendPacket function +func (k Keeper) SendPacket(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI) error { + return k.channelKeeper.SendPacket(ctx, chanCap, packet) +} + +// SetFeeEnabled sets a flag to determine if fee handling logic should run for the given channel +// identified by channel and port identifiers. +func (k Keeper) SetFeeEnabled(ctx sdk.Context, portID, channelID string) { store := ctx.KVStore(k.storeKey) - store.Set(types.PortKey, []byte(portID)) + store.Set(types.FeeEnabledKey(portID, channelID), []byte{1}) } -// 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) +// DeleteFeeEnabled deletes the fee enabled flag for a given portID and channelID +func (k Keeper) DeleteFeeEnabled(ctx sdk.Context, portID, channelID string) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.FeeEnabledKey(portID, channelID)) } -// 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) +// IsFeeEnabled returns whether fee handling logic should be run for the given port. It will check the +// fee enabled flag for the given port and channel identifiers +func (k Keeper) IsFeeEnabled(ctx sdk.Context, portID, channelID string) bool { + store := ctx.KVStore(k.storeKey) + return store.Get(types.FeeEnabledKey(portID, channelID)) != nil } -*/ // 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/module.go b/modules/apps/29-fee/module.go index c0645e3db78..6e73a3b9b08 100644 --- a/modules/apps/29-fee/module.go +++ b/modules/apps/29-fee/module.go @@ -1,37 +1,34 @@ package fee -/* import ( "context" "encoding/json" - "fmt" "math/rand" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" - "github.com/cosmos/ibc-go/modules/apps/transfer/client/cli" - "github.com/cosmos/ibc-go/modules/apps/transfer/keeper" - "github.com/cosmos/ibc-go/modules/apps/transfer/simulation" - "github.com/cosmos/ibc-go/modules/apps/transfer/types" - channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" + "github.com/cosmos/ibc-go/modules/apps/29-fee/client/cli" + "github.com/cosmos/ibc-go/modules/apps/29-fee/keeper" + "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + + // "github.com/cosmos/ibc-go/modules/apps/29-fee/client/cli" + // "github.com/cosmos/ibc-go/modules/apps/29-fee/simulation" + porttypes "github.com/cosmos/ibc-go/modules/core/05-port/types" - ibcexported "github.com/cosmos/ibc-go/modules/core/exported" ) var ( _ module.AppModule = AppModule{} - _ porttypes.IBCModule = AppModule{} + _ porttypes.IBCModule = IBCModule{} _ module.AppModuleBasic = AppModuleBasic{} ) @@ -48,30 +45,32 @@ 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 -// transfer module. +// 29-fee module. func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { - return cdc.MustMarshalJSON(types.DefaultGenesisState()) + // return cdc.MustMarshalJSON(types.DefaultGenesisState()) + return nil } // ValidateGenesis performs genesis state validation for the 29-fee module. func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { - var gs types.GenesisState - if err := cdc.UnmarshalJSON(bz, &gs); err != nil { - return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) - } + // var gs types.GenesisState + // if err := cdc.UnmarshalJSON(bz, &gs); err != nil { + // return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + // } - return gs.Validate() + // return gs.Validate() + return nil } // RegisterRESTRoutes implements AppModuleBasic interface func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { } -// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the ibc-transfer module. +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for ics29 fee module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) } @@ -121,24 +120,25 @@ 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.RegisterQueryServer(cfg.QueryServer(), am.keeper) + // types.RegisterMsgServer(cfg.MsgServer(), am.keeper) + // types.RegisterQueryServer(cfg.QueryServer(), am.keeper) } -// InitGenesis performs genesis initialization for the ibc-transfer module. It returns +// InitGenesis performs genesis initialization for the ibc-29-fee module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { - var genesisState types.GenesisState - cdc.MustUnmarshalJSON(data, &genesisState) - am.keeper.InitGenesis(ctx, genesisState) + // var genesisState types.GenesisState + // cdc.MustUnmarshalJSON(data, &genesisState) + // am.keeper.InitGenesis(ctx, genesisState) return []abci.ValidatorUpdate{} } -// ExportGenesis returns the exported genesis state as raw bytes for the ibc-transfer +// ExportGenesis returns the exported genesis state as raw bytes for the ibc-29-fee // module. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { - gs := am.keeper.ExportGenesis(ctx) - return cdc.MustMarshalJSON(gs) + // gs := am.keeper.ExportGenesis(ctx) + // return cdc.MustMarshalJSON(gs) + return nil } // ConsensusVersion implements AppModule/ConsensusVersion. @@ -155,9 +155,9 @@ func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.V // AppModuleSimulation functions -// GenerateGenesisState creates a randomized GenState of the transfer module. +// GenerateGenesisState creates a randomized GenState of the 29-fee module. func (AppModule) GenerateGenesisState(simState *module.SimulationState) { - simulation.RandomizedGenState(simState) + // simulation.RandomizedGenState(simState) } // ProposalContents doesn't return any content functions for governance proposals. @@ -165,113 +165,18 @@ func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedP return nil } -// RandomizedParams creates randomized ibc-transfer param changes for the simulator. +// RandomizedParams creates randomized ibc-29-fee param changes for the simulator. func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { - return simulation.ParamChanges(r) + // return simulation.ParamChanges(r) + return nil } -// RegisterStoreDecoder registers a decoder for transfer module's types +// RegisterStoreDecoder registers a decoder for 29-fee module's types func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { - sdr[types.StoreKey] = simulation.NewDecodeStore(am.keeper) + // sdr[types.StoreKey] = simulation.NewDecodeStore(am.keeper) } -// WeightedOperations returns the all the transfer module operations with their respective weights. +// WeightedOperations returns the all the 29-fee module operations with their respective weights. func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation { return nil } - -// OnChanOpenInit implements the IBCModule interface -func (am AppModule) OnChanOpenInit( - ctx sdk.Context, - order channeltypes.Order, - connectionHops []string, - portID string, - channelID string, - chanCap *capabilitytypes.Capability, - counterparty channeltypes.Counterparty, - version string, -) error { - return nil -} - -// OnChanOpenTry implements the IBCModule interface -func (am AppModule) OnChanOpenTry( - ctx sdk.Context, - order channeltypes.Order, - connectionHops []string, - portID, - channelID string, - chanCap *capabilitytypes.Capability, - counterparty channeltypes.Counterparty, - version, - counterpartyVersion string, -) error { - return nil -} - -// OnChanOpenAck implements the IBCModule interface -func (am AppModule) OnChanOpenAck( - ctx sdk.Context, - portID, - channelID string, - counterpartyVersion string, -) error { - return nil -} - -// OnChanOpenConfirm implements the IBCModule interface -func (am AppModule) OnChanOpenConfirm( - ctx sdk.Context, - portID, - channelID string, -) error { - return nil -} - -// OnChanCloseInit implements the IBCModule interface -func (am AppModule) OnChanCloseInit( - ctx sdk.Context, - portID, - channelID string, -) error { - // Disallow user-initiated channel closing for 29-fee channels - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "user cannot close channel") -} - -// OnChanCloseConfirm implements the IBCModule interface -func (am AppModule) OnChanCloseConfirm( - ctx sdk.Context, - portID, - channelID string, -) error { - return nil -} - -// OnRecvPacket implements the IBCModule interface. -func (am AppModule) OnRecvPacket( - ctx sdk.Context, - packet channeltypes.Packet, - relayer sdk.AccAddress, -) ibcexported.Acknowledgement { - return nil -} - -// OnAcknowledgementPacket implements the IBCModule interface -func (am AppModule) OnAcknowledgementPacket( - ctx sdk.Context, - packet channeltypes.Packet, - acknowledgement []byte, - relayer sdk.AccAddress, -) error { - return nil -} - -// OnTimeoutPacket implements the IBCModule interface -func (am AppModule) OnTimeoutPacket( - ctx sdk.Context, - packet channeltypes.Packet, - relayer sdk.AccAddress, -) error { - return nil -} -*/ diff --git a/modules/apps/29-fee/types/errors.go b/modules/apps/29-fee/types/errors.go index 9ed5755a9a0..5536d326fc0 100644 --- a/modules/apps/29-fee/types/errors.go +++ b/modules/apps/29-fee/types/errors.go @@ -1,8 +1,10 @@ package types import ( -// sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) // 29-fee sentinel errors -var () +var ( + ErrInvalidVersion = sdkerrors.Register(ModuleName, 2, "invalid ICS29 middleware version") +) diff --git a/modules/apps/29-fee/types/expected_keepers.go b/modules/apps/29-fee/types/expected_keepers.go index 07f9bce4b8f..8e49bbe8ab0 100644 --- a/modules/apps/29-fee/types/expected_keepers.go +++ b/modules/apps/29-fee/types/expected_keepers.go @@ -2,29 +2,11 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - - 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" ) -// AccountKeeper defines the contract required for account APIs. -type AccountKeeper interface { - GetModuleAddress(name string) sdk.AccAddress - GetModuleAccount(ctx sdk.Context, name string) types.ModuleAccountI -} - -// BankKeeper defines the expected bank keeper -type BankKeeper interface { - SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error - MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error - BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error - SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error - SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error -} - // ChannelKeeper defines the expected IBC channel keeper type ChannelKeeper interface { GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channeltypes.Channel, found bool) @@ -33,16 +15,6 @@ type ChannelKeeper interface { ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capabilitytypes.Capability) error } -// ClientKeeper defines the expected IBC client keeper -type ClientKeeper interface { - GetClientConsensusState(ctx sdk.Context, clientID string) (connection ibcexported.ConsensusState, found bool) -} - -// ConnectionKeeper defines the expected IBC connection keeper -type ConnectionKeeper interface { - GetConnection(ctx sdk.Context, connectionID string) (connection connectiontypes.ConnectionEnd, found bool) -} - // PortKeeper defines the expected IBC port keeper 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 474f27fb87a..39bbfe5ff85 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -4,7 +4,7 @@ import "fmt" const ( // ModuleName defines the 29-fee name - ModuleName = "ibcfee" + ModuleName = "feeibc" // StoreKey is the store key string for IBC transfer StoreKey = ModuleName @@ -18,10 +18,21 @@ const ( // QuerierRoute is the querier route for IBC transfer QuerierRoute = ModuleName + Version = "fee29-1" + + // FeeEnabledPrefix is the key prefix for storing fee enabled flag + FeeEnabledKeyPrefix = "feeEnabled" + // RelayerAddressKeyPrefix is the key prefix for relayer address mapping RelayerAddressKeyPrefix = "relayerAddress" ) +// FeeEnabledKey returns the key that stores a flag to determine if fee logic should +// be enabled for the given port and channel identifiers. +func FeeEnabledKey(portID, channelID string) []byte { + return []byte(fmt.Sprintf("%s/%s/%s", FeeEnabledKeyPrefix, portID, channelID)) +} + // 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/transfer/module.go b/modules/apps/transfer/module.go index a9a1aa4f875..90e8456381a 100644 --- a/modules/apps/transfer/module.go +++ b/modules/apps/transfer/module.go @@ -190,6 +190,7 @@ func ValidateTransferChannelParams( ctx sdk.Context, keeper keeper.Keeper, order channeltypes.Order, + counterparty channeltypes.Counterparty, portID string, channelID string, version string, @@ -213,6 +214,10 @@ func ValidateTransferChannelParams( return sdkerrors.Wrapf(porttypes.ErrInvalidPort, "invalid port: %s, expected %s", portID, boundPort) } + if portID != counterparty.PortId { + return sdkerrors.Wrapf(porttypes.ErrInvalidPort, "portID: %s does not match counterparty portID: %s", portID, counterparty.PortId) + } + if version != types.Version { return sdkerrors.Wrapf(types.ErrInvalidVersion, "got %s, expected %s", version, types.Version) } @@ -230,7 +235,7 @@ func (am AppModule) OnChanOpenInit( counterparty channeltypes.Counterparty, version string, ) error { - if err := ValidateTransferChannelParams(ctx, am.keeper, order, portID, channelID, version); err != nil { + if err := ValidateTransferChannelParams(ctx, am.keeper, order, counterparty, portID, channelID, version); err != nil { return err } @@ -254,7 +259,7 @@ func (am AppModule) OnChanOpenTry( version, counterpartyVersion string, ) error { - if err := ValidateTransferChannelParams(ctx, am.keeper, order, portID, channelID, version); err != nil { + if err := ValidateTransferChannelParams(ctx, am.keeper, order, counterparty, portID, channelID, version); err != nil { return err } diff --git a/modules/apps/transfer/module_test.go b/modules/apps/transfer/module_test.go index 63d610de84a..954babec3f0 100644 --- a/modules/apps/transfer/module_test.go +++ b/modules/apps/transfer/module_test.go @@ -12,9 +12,10 @@ import ( func (suite *TransferTestSuite) TestOnChanOpenInit() { var ( - channel *channeltypes.Channel - path *ibctesting.Path - chanCap *capabilitytypes.Capability + channel *channeltypes.Channel + path *ibctesting.Path + chanCap *capabilitytypes.Capability + counterparty channeltypes.Counterparty ) testCases := []struct { @@ -63,7 +64,7 @@ func (suite *TransferTestSuite) TestOnChanOpenInit() { suite.coordinator.SetupConnections(path) path.EndpointA.ChannelID = ibctesting.FirstChannelID - counterparty := channeltypes.NewCounterparty(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) + counterparty = channeltypes.NewCounterparty(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) channel = &channeltypes.Channel{ State: channeltypes.INIT, Ordering: channeltypes.UNORDERED, @@ -84,7 +85,7 @@ func (suite *TransferTestSuite) TestOnChanOpenInit() { tc.malleate() // explicitly change fields in channel and testChannel err = cbs.OnChanOpenInit(suite.chainA.GetContext(), channel.Ordering, channel.GetConnectionHops(), - path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, chanCap, channel.Counterparty, channel.GetVersion(), + path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, chanCap, counterparty, channel.GetVersion(), ) if tc.expPass { @@ -102,6 +103,7 @@ func (suite *TransferTestSuite) TestOnChanOpenTry() { channel *channeltypes.Channel chanCap *capabilitytypes.Capability path *ibctesting.Path + counterparty channeltypes.Counterparty counterpartyVersion string ) @@ -157,7 +159,7 @@ func (suite *TransferTestSuite) TestOnChanOpenTry() { suite.coordinator.SetupConnections(path) path.EndpointA.ChannelID = ibctesting.FirstChannelID - counterparty := channeltypes.NewCounterparty(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) + counterparty = channeltypes.NewCounterparty(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) channel = &channeltypes.Channel{ State: channeltypes.TRYOPEN, Ordering: channeltypes.UNORDERED, @@ -179,7 +181,7 @@ func (suite *TransferTestSuite) TestOnChanOpenTry() { tc.malleate() // explicitly change fields in channel and testChannel err = cbs.OnChanOpenTry(suite.chainA.GetContext(), channel.Ordering, channel.GetConnectionHops(), - path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, chanCap, channel.Counterparty, channel.GetVersion(), counterpartyVersion, + path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, chanCap, counterparty, channel.GetVersion(), counterpartyVersion, ) if tc.expPass { diff --git a/modules/core/04-channel/keeper/handshake.go b/modules/core/04-channel/keeper/handshake.go index 5f9d70ad090..adad943b81c 100644 --- a/modules/core/04-channel/keeper/handshake.go +++ b/modules/core/04-channel/keeper/handshake.go @@ -127,7 +127,8 @@ func (k Keeper) ChanOpenTry( channelID := previousChannelID - // empty channel identifier indicates continuing a previous channel handshake + // non-empty channel identifier indicates continuing a previous channel handshake + // where ChanOpenINIT has already been called on the executing chain. if previousChannelID != "" { // channel identifier and connection hop length checked on msg.ValidateBasic() // ensure that the previous channel exists diff --git a/modules/core/04-channel/types/version.go b/modules/core/04-channel/types/version.go new file mode 100644 index 00000000000..a2696d291ed --- /dev/null +++ b/modules/core/04-channel/types/version.go @@ -0,0 +1,27 @@ +package types + +import "strings" + +const ChannelVersionDelimiter = ":" + +// SplitChannelVersion middleware version will split the channel version string +// into the outermost middleware version and the underlying app version. +// It will use the default delimiter `:` for middleware versions. +// In case there's no delimeter, this function returns an empty string for the middleware version (first return argument), +// and the full input as the second underlying app version. +func SplitChannelVersion(version string) (middlewareVersion, appVersion string) { + // only split out the first middleware version + splitVersions := strings.Split(version, ChannelVersionDelimiter) + if len(splitVersions) == 1 { + return "", version + } + middlewareVersion = splitVersions[0] + appVersion = strings.Join(splitVersions[1:], ChannelVersionDelimiter) + return +} + +// MergeChannelVersions merges the provided versions together with the channel version delimiter +// the versions should be passed in from the highest-level middleware to the base application +func MergeChannelVersions(versions ...string) string { + return strings.Join(versions, ChannelVersionDelimiter) +} diff --git a/modules/core/04-channel/types/version_test.go b/modules/core/04-channel/types/version_test.go new file mode 100644 index 00000000000..fda5a570f2f --- /dev/null +++ b/modules/core/04-channel/types/version_test.go @@ -0,0 +1,77 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/ibc-go/modules/core/04-channel/types" +) + +func TestSplitVersions(t *testing.T) { + testCases := []struct { + name string + version string + mwVersion string + appVersion string + }{ + { + "single wrapped middleware", + "fee29-1:ics20-1", + "fee29-1", + "ics20-1", + }, + { + "multiple wrapped middleware", + "fee29-1:whitelist:ics20-1", + "fee29-1", + "whitelist:ics20-1", + }, + { + "no middleware", + "ics20-1", + "", + "ics20-1", + }, + } + + for _, tc := range testCases { + mwVersion, appVersion := types.SplitChannelVersion(tc.version) + require.Equal(t, tc.mwVersion, mwVersion, "middleware version is unexpected for case: %s", tc.name) + require.Equal(t, tc.appVersion, appVersion, "app version is unexpected for case: %s", tc.name) + } +} + +func TestMergeVersions(t *testing.T) { + testCases := []struct { + name string + versions []string + merged string + }{ + { + "single version", + []string{"ics20-1"}, + "ics20-1", + }, + { + "empty version", + []string{}, + "", + }, + { + "two versions", + []string{"fee29-1", "ics20-1"}, + "fee29-1:ics20-1", + }, + { + "multiple versions", + []string{"fee29-1", "whitelist", "ics20-1"}, + "fee29-1:whitelist:ics20-1", + }, + } + + for _, tc := range testCases { + actual := types.MergeChannelVersions(tc.versions...) + require.Equal(t, tc.merged, actual, "merged versions string does not equal expected value") + } +} diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 230ad71ae24..83cdf6ff2a7 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -80,6 +80,9 @@ import ( upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + ibcfee "github.com/cosmos/ibc-go/modules/apps/29-fee" + ibcfeekeeper "github.com/cosmos/ibc-go/modules/apps/29-fee/keeper" + ibcfeetypes "github.com/cosmos/ibc-go/modules/apps/29-fee/types" transfer "github.com/cosmos/ibc-go/modules/apps/transfer" ibctransferkeeper "github.com/cosmos/ibc-go/modules/apps/transfer/keeper" ibctransfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" @@ -132,6 +135,7 @@ var ( ibcmock.AppModuleBasic{}, authzmodule.AppModuleBasic{}, vesting.AppModuleBasic{}, + ibcfee.AppModuleBasic{}, ) // module account permissions @@ -184,11 +188,13 @@ type SimApp struct { EvidenceKeeper evidencekeeper.Keeper TransferKeeper ibctransferkeeper.Keeper FeeGrantKeeper feegrantkeeper.Keeper + IBCFeeKeeper ibcfeekeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper ScopedTransferKeeper capabilitykeeper.ScopedKeeper ScopedIBCMockKeeper capabilitykeeper.ScopedKeeper + ScopedIBCFeeKeeper capabilitykeeper.ScopedKeeper // the module manager mm *module.Manager @@ -230,7 +236,7 @@ func NewSimApp( minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey, - authzkeeper.StoreKey, + authzkeeper.StoreKey, ibcfeetypes.StoreKey, ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) @@ -315,22 +321,35 @@ func NewSimApp( &stakingKeeper, govRouter, ) - // Create Transfer Keepers + app.IBCFeeKeeper = ibcfeekeeper.NewKeeper(appCodec, keys[ibcfeetypes.StoreKey], app.GetSubspace(ibcfeetypes.ModuleName), + app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, + ) + + // 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.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, + app.IBCFeeKeeper, &app.IBCFeeKeeper, app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, ) transferModule := transfer.NewAppModule(app.TransferKeeper) + // create fee-wrapped transfer module + feeTransferModule := ibcfee.NewIBCModule(app.IBCFeeKeeper, transferModule) + + feeModule := ibcfee.NewAppModule(app.IBCFeeKeeper) // NOTE: the IBC mock keeper and application module is used only for testing core IBC. Do // note replicate if you do not need to test core IBC or light clients. - mockModule := ibcmock.NewAppModule(scopedIBCMockKeeper, &app.IBCKeeper.PortKeeper) + // Pass IBCFeeKeeper for PortKeeper since fee middleware will wrap the IBCKeeper for underlying application. + mockModule := ibcmock.NewAppModule(scopedIBCMockKeeper, &app.IBCFeeKeeper) + // create fee wrapped mock module + feeMockModule := ibcfee.NewIBCModule(app.IBCFeeKeeper, mockModule) // Create static IBC router, add transfer route, then set and seal it + // pass in top-level (fully-wrapped) IBCModules to IBC Router ibcRouter := porttypes.NewRouter() - ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferModule) - ibcRouter.AddRoute(ibcmock.ModuleName, mockModule) + ibcRouter.AddRoute(ibctransfertypes.ModuleName, feeTransferModule) + ibcRouter.AddRoute(ibcmock.ModuleName, feeMockModule) app.IBCKeeper.SetRouter(ibcRouter) // create evidence keeper with router @@ -370,6 +389,7 @@ func NewSimApp( params.NewAppModule(app.ParamsKeeper), authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), transferModule, + feeModule, mockModule, ) From 67bd5948bae658364b6a829618aa362ca6d064f8 Mon Sep 17 00:00:00 2001 From: Sean King Date: Fri, 5 Nov 2021 17:01:48 +0100 Subject: [PATCH 07/79] Fee Middleware: Escrow logic (#465) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: adding second endpoint for async pay fee + renaming types * feat: adding escrow logic * feat: updating proto types & escrow logic * fix: stub fn & proto comment * feat: adding PayFee & PayFeeTimeout & escrow_test * test: adding happy path for EscrowPacketFee * fix: comments, error handling * fix: comments & grammar * test: adding unhappy path for escrow * tests(escrow): adding hasBalance check for module acc * test(PayFee): adding happy path for PayFee tests * tests(PayFee, PayFeeTimeout): adding tests * fix: adding relayers back to IdentifiedPacket * fix: removing refund acc from key * fix: storing IdentifiedPacketFee in state instead of Fee * feat: adding msg_server test for registerCPAddr, wiring for codec + stubs for sdk.Msg interface * test: adding msg_server test for PayPacketFee * test: adding PayPacketFeeAsync msg_server test * chore: updating PayFee -> DistributeFee & minor nits * nit: removing unnecessary nil check * refactor: add portId to store key & use packetId as param * fix: add DeleteFeeInEscrow & remove fee on successful distribution * tests: adding validation & signer tests for PayFee/Async & updating proto to use Signer sdk standard * chore: adding NewIdentifiedPacketFee fn * fix: getter/setter for counterparty address + fix NewIdentifiedPacketFee * fix: updating EscrowPacketFee with correct usage of coins api * test: adding balance check for refund acc after escrow * fix: remove unncessary errors * test: updating escrow tests + miscellaneous fixes * nit: updating var names * docs: godoc * refactor: IdentifiedPacketFee & Fee no longer pointers * fixes: small fixes * Update modules/apps/29-fee/keeper/escrow.go Co-authored-by: Aditya * Update modules/apps/29-fee/keeper/escrow.go Co-authored-by: Aditya * Update modules/apps/29-fee/keeper/keeper.go Co-authored-by: Aditya * Update modules/apps/29-fee/keeper/msg_server.go Co-authored-by: Aditya * Update modules/apps/29-fee/keeper/msg_server.go Co-authored-by: Aditya * Update modules/apps/29-fee/types/msgs.go Co-authored-by: Aditya * nit: proto doc & error fix * fix: escrow test * test: updating distribute fee tests * test: adding validation check for fee and updating tests * test: allow counterparty address to be arbitrary string * fix: message validation should pass if one fee is valid * Update modules/apps/29-fee/keeper/escrow.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * Update modules/apps/29-fee/keeper/escrow.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * fix: nits * Update modules/apps/29-fee/keeper/escrow.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * test: adding isZero check for msgs Co-authored-by: Aditya Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> --- docs/ibc/proto-docs.md | 68 +- modules/apps/29-fee/keeper/escrow.go | 106 +++ modules/apps/29-fee/keeper/escrow_test.go | 284 +++++++ modules/apps/29-fee/keeper/keeper.go | 69 +- modules/apps/29-fee/keeper/keeper_test.go | 37 +- modules/apps/29-fee/keeper/msg_server.go | 54 +- modules/apps/29-fee/keeper/msg_server_test.go | 131 +++ modules/apps/29-fee/module.go | 4 +- modules/apps/29-fee/types/codec.go | 34 +- modules/apps/29-fee/types/errors.go | 7 +- modules/apps/29-fee/types/expected_keepers.go | 14 + modules/apps/29-fee/types/fee.pb.go | 361 +++++---- modules/apps/29-fee/types/genesis.pb.go | 94 +-- modules/apps/29-fee/types/keys.go | 14 +- modules/apps/29-fee/types/msgs.go | 134 +++- modules/apps/29-fee/types/msgs_test.go | 322 +++++++- modules/apps/29-fee/types/tx.pb.go | 743 +++++++++++++++--- proto/ibc/applications/fee/v1/fee.proto | 26 +- proto/ibc/applications/fee/v1/genesis.proto | 4 +- proto/ibc/applications/fee/v1/tx.proto | 49 +- testing/simapp/app.go | 3 +- 21 files changed, 2111 insertions(+), 447 deletions(-) create mode 100644 modules/apps/29-fee/keeper/escrow.go create mode 100644 modules/apps/29-fee/keeper/escrow_test.go create mode 100644 modules/apps/29-fee/keeper/msg_server_test.go diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index ff79278b80a..52f2a145f8f 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -47,8 +47,10 @@ - [Query](#ibc.applications.fee.v1.Query) - [ibc/applications/fee/v1/tx.proto](#ibc/applications/fee/v1/tx.proto) - - [MsgEscrowPacketFee](#ibc.applications.fee.v1.MsgEscrowPacketFee) - - [MsgEscrowPacketFeeResponse](#ibc.applications.fee.v1.MsgEscrowPacketFeeResponse) + - [MsgPayPacketFee](#ibc.applications.fee.v1.MsgPayPacketFee) + - [MsgPayPacketFeeAsync](#ibc.applications.fee.v1.MsgPayPacketFeeAsync) + - [MsgPayPacketFeeAsyncResponse](#ibc.applications.fee.v1.MsgPayPacketFeeAsyncResponse) + - [MsgPayPacketFeeResponse](#ibc.applications.fee.v1.MsgPayPacketFeeResponse) - [MsgRegisterCounterpartyAddress](#ibc.applications.fee.v1.MsgRegisterCounterpartyAddress) - [MsgRegisterCounterpartyAddressResponse](#ibc.applications.fee.v1.MsgRegisterCounterpartyAddressResponse) @@ -628,7 +630,9 @@ https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middl | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `amount` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `receive_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `ack_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `timeout_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | @@ -644,9 +648,7 @@ Fee associated with a packet_id | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | | -| `receive_fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | -| `ack_fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | -| `timeout_fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | +| `fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | | `relayers` | [string](#string) | repeated | | @@ -676,11 +678,6 @@ Fee associated with a packet_id GenesisState defines the fee middleware genesis state -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `packets_fees` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | repeated | A mapping of packets -> escrowed fees | - - @@ -889,15 +886,20 @@ Query provides defines the gRPC querier service. - + -### MsgEscrowPacketFee -MsgEscrowPacketFee defines the request type EscrowPacketFee RPC +### MsgPayPacketFee +MsgPayPacketFee defines the request type PayPacketFee RPC +This Msg can be used to pay for a packet at the next sequence send & should be combined with the Msg that will be +paid for | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `incentivized_packet` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | | | +| `fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | +| `source_port_id` | [string](#string) | | source channel port identifier | +| `source_channel_id` | [string](#string) | | source channel unique identifier | +| `signer` | [string](#string) | | account address to refund fee if necessary | | `relayers` | [string](#string) | repeated | | @@ -905,10 +907,37 @@ MsgEscrowPacketFee defines the request type EscrowPacketFee RPC - + + +### MsgPayPacketFeeAsync +MsgPayPacketFeeAsync defines the request type PayPacketFeeAsync RPC +This Msg can be used to pay for a packet at a specified sequence (instead of the next sequence send) + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `identified_packet_fee` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | | packet to pay fee for | +| `signer` | [string](#string) | | account address to refund fee if necessary | + + + + + + + + +### MsgPayPacketFeeAsyncResponse +MsgPayPacketFeeAsyncResponse defines the response type for Msg/PayPacketFeeAsync + + + + + + + -### MsgEscrowPacketFeeResponse -MsgEscrowPacketFeeResponse defines the response type for Msg/EscrowPacketFee +### MsgPayPacketFeeResponse +MsgPayPacketFeeResponse defines the response type for Msg/PayPacketFee @@ -955,7 +984,8 @@ 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. | | -| `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. | | +| `PayPacketFee` | [MsgPayPacketFee](#ibc.applications.fee.v1.MsgPayPacketFee) | [MsgPayPacketFeeResponse](#ibc.applications.fee.v1.MsgPayPacketFeeResponse) | PayPacketFee defines a rpc handler method for MsgPayPacketFee PayPacketFee 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 packet at the next sequence | | +| `PayPacketFeeAsync` | [MsgPayPacketFeeAsync](#ibc.applications.fee.v1.MsgPayPacketFeeAsync) | [MsgPayPacketFeeAsyncResponse](#ibc.applications.fee.v1.MsgPayPacketFeeAsyncResponse) | PayPacketFeeAsync defines a rpc handler method for MsgPayPacketFeeAsync PayPacketFeeAsync is an open callback that may be called by any module/user that wishes to escrow funds in order to incentivize the relaying of a known packet | | diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go new file mode 100644 index 00000000000..cddb3be047a --- /dev/null +++ b/modules/apps/29-fee/keeper/escrow.go @@ -0,0 +1,106 @@ +package keeper + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" +) + +// EscrowPacketFee sends the packet fee to the 29-fee module account to hold in escrow +func (k Keeper) EscrowPacketFee(ctx sdk.Context, refundAcc sdk.AccAddress, identifiedFee *types.IdentifiedPacketFee) error { + // check if the refund account exists + hasRefundAcc := k.authKeeper.GetAccount(ctx, refundAcc) + if hasRefundAcc == nil { + return sdkerrors.Wrap(types.ErrRefundAccNotFound, fmt.Sprintf("Account with address: %s not found", refundAcc)) + } + + coins := identifiedFee.Fee.ReceiveFee + coins = coins.Add(identifiedFee.Fee.AckFee...) + coins = coins.Add(identifiedFee.Fee.TimeoutFee...) + + if err := k.bankKeeper.SendCoinsFromAccountToModule( + ctx, refundAcc, types.ModuleName, coins, + ); err != nil { + return err + } + + // Store fee in state for reference later + // feeInEscrow///packet// -> Fee (timeout, ack, onrecv) + k.SetFeeInEscrow(ctx, identifiedFee) + return nil +} + +// DistributeFee pays the acknowledgement fee & receive fee for a given packetId while refunding the timeout fee to the refund account associated with the Fee +func (k Keeper) DistributeFee(ctx sdk.Context, refundAcc, forwardRelayer, reverseRelayer sdk.AccAddress, packetID *channeltypes.PacketId) error { + // check if there is a Fee in escrow for the given packetId + feeInEscrow, found := k.GetFeeInEscrow(ctx, packetID) + if !found { + return sdkerrors.Wrapf(types.ErrFeeNotFound, "with channelID %s, sequence %d", packetID.ChannelId, packetID.Sequence) + } + + // get module accAddr + feeModuleAccAddr := k.authKeeper.GetModuleAddress(types.ModuleName) + + // send receive fee to forward relayer + err := k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, forwardRelayer, feeInEscrow.Fee.ReceiveFee) + if err != nil { + return sdkerrors.Wrap(err, "failed to send fee to forward relayer") + } + + // send ack fee to reverse relayer + err = k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, reverseRelayer, feeInEscrow.Fee.AckFee) + if err != nil { + return sdkerrors.Wrap(err, "error sending fee to reverse relayer") + } + + // refund timeout fee to refundAddr + err = k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, refundAcc, feeInEscrow.Fee.TimeoutFee) + if err != nil { + return sdkerrors.Wrap(err, "error refunding timeout fee") + } + + // removes the fee from the store as fee is now paid + k.DeleteFeeInEscrow(ctx, packetID) + + return nil +} + +// DistributeFeeTimeout pays the timeout fee for a given packetId while refunding the acknowledgement fee & receive fee to the refund account associated with the Fee +func (k Keeper) DistributeFeeTimeout(ctx sdk.Context, refundAcc, timeoutRelayer sdk.AccAddress, packetID *channeltypes.PacketId) error { + // check if there is a Fee in escrow for the given packetId + feeInEscrow, found := k.GetFeeInEscrow(ctx, packetID) + if !found { + return sdkerrors.Wrap(types.ErrFeeNotFound, refundAcc.String()) + } + + // get module accAddr + feeModuleAccAddr := k.authKeeper.GetModuleAddress(types.ModuleName) + + // refund the receive fee + err := k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, refundAcc, feeInEscrow.Fee.ReceiveFee) + if err != nil { + return sdkerrors.Wrap(err, "error refunding receive fee") + } + + // refund the ack fee + err = k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, refundAcc, feeInEscrow.Fee.AckFee) + if err != nil { + return sdkerrors.Wrap(err, "error refunding ack fee") + } + + // pay the timeout fee to the reverse relayer + err = k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, timeoutRelayer, feeInEscrow.Fee.TimeoutFee) + if err != nil { + return sdkerrors.Wrap(err, "error sending fee to timeout relayer") + } + + // removes the fee from the store as fee is now paid + k.DeleteFeeInEscrow(ctx, packetID) + + return nil +} diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go new file mode 100644 index 00000000000..d5600c964e3 --- /dev/null +++ b/modules/apps/29-fee/keeper/escrow_test.go @@ -0,0 +1,284 @@ +package keeper_test + +import ( + "github.com/tendermint/tendermint/crypto/secp256k1" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" +) + +var ( + validCoins = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}} + validCoins2 = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(200)}} + validCoins3 = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(300)}} + invalidCoins = sdk.Coins{sdk.Coin{Denom: "invalidDenom", Amount: sdk.NewInt(100)}} +) + +func (suite *KeeperTestSuite) TestEscrowPacketFee() { + var ( + err error + refundAcc sdk.AccAddress + ackFee sdk.Coins + receiveFee sdk.Coins + timeoutFee sdk.Coins + ) + + // refundAcc does not have balance for the following Coin + validChannelId := "channel-0" + + testCases := []struct { + name string + malleate func() + expPass bool + }{ + { + "success", func() {}, true, + }, + { + "refundAcc does not exist", func() { + // this acc does not exist on chainA + refundAcc = suite.chainB.SenderAccount.GetAddress() + }, false, + }, + { + "ackFee balance not found", func() { + ackFee = invalidCoins + }, false, + }, + { + "receive balance not found", func() { + receiveFee = invalidCoins + }, false, + }, + { + "timeout balance not found", func() { + timeoutFee = invalidCoins + }, false, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + // setup + refundAcc = suite.chainA.SenderAccount.GetAddress() + ackFee = validCoins + receiveFee = validCoins2 + timeoutFee = validCoins3 + packetId := &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortKey, Sequence: uint64(1)} + + tc.malleate() + fee := types.Fee{ackFee, receiveFee, timeoutFee} + identifiedPacketFee := &types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, Relayers: []string{}} + + // refundAcc balance before escrow + originalBal := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom) + + // escrow the packet fee + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), refundAcc, identifiedPacketFee) + + if tc.expPass { + feeInEscrow, _ := suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeInEscrow(suite.chainA.GetContext(), packetId) + // check if the escrowed fee is set in state + suite.Require().True(feeInEscrow.Fee.AckFee.IsEqual(fee.AckFee)) + suite.Require().True(feeInEscrow.Fee.ReceiveFee.IsEqual(fee.ReceiveFee)) + suite.Require().True(feeInEscrow.Fee.TimeoutFee.IsEqual(fee.TimeoutFee)) + // check if the fee is escrowed correctly + hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(600)}) + suite.Require().True(hasBalance) + expectedBal := originalBal.Amount.Sub(sdk.NewInt(600)) + // check if the refund acc has sent the fee + hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), refundAcc, sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: expectedBal}) + suite.Require().True(hasBalance) + suite.Require().NoError(err) + } else { + suite.Require().Error(err) + } + }) + } +} + +func (suite *KeeperTestSuite) TestDistributeFee() { + var ( + err error + ackFee sdk.Coins + receiveFee sdk.Coins + timeoutFee sdk.Coins + packetId *channeltypes.PacketId + reverseRelayer sdk.AccAddress + forwardRelayer sdk.AccAddress + refundAcc sdk.AccAddress + ) + + // refundAcc does not have balance for the following Coin + validChannelId := "channel-0" + validSeq := uint64(1) + + testCases := []struct { + name string + malleate func() + expPass bool + }{ + { + "success", func() {}, true, + }, + { + "fee not found for packet", func() { + // setting packetId with an invalid sequence of 2 + packetId = &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortKey, Sequence: uint64(2)} + }, false, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + // setup + refundAcc = suite.chainA.SenderAccount.GetAddress() + reverseRelayer = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + forwardRelayer = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + + ackFee = validCoins + receiveFee = validCoins2 + timeoutFee = validCoins3 + packetId = &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortKey, Sequence: validSeq} + fee := types.Fee{receiveFee, ackFee, timeoutFee} + + // escrow the packet fee & store the fee in state + identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, Relayers: []string{}} + + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), refundAcc, &identifiedPacketFee) + suite.Require().NoError(err) + + tc.malleate() + + // refundAcc balance after escrow + refundAccBal := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom) + + err = suite.chainA.GetSimApp().IBCFeeKeeper.DistributeFee(suite.chainA.GetContext(), refundAcc, forwardRelayer, reverseRelayer, packetId) + + if tc.expPass { + suite.Require().NoError(err) + hasFeeInEscrow := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), packetId) + // there should no longer be a fee in escrow for this packet + suite.Require().False(hasFeeInEscrow) + // check if the reverse relayer is paid + hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), reverseRelayer, ackFee[0]) + suite.Require().True(hasBalance) + // check if the forward relayer is paid + hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), forwardRelayer, receiveFee[0]) + suite.Require().True(hasBalance) + // check if the refund acc has been refunded the timeoutFee + expectedRefundAccBal := refundAccBal.Add(timeoutFee[0]) + hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), refundAcc, expectedRefundAccBal) + suite.Require().True(hasBalance) + // check the module acc wallet is now empty + hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(0)}) + suite.Require().True(hasBalance) + + suite.Require().NoError(err) + + } else { + suite.Require().Error(err) + invalidPacketID := &channeltypes.PacketId{PortId: types.PortKey, ChannelId: validChannelId, Sequence: 1} + hasFeeInEscrow := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), invalidPacketID) + // there should still be a fee in escrow for this packet + suite.Require().True(hasFeeInEscrow) + } + }) + } +} + +func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { + var ( + err error + ackFee sdk.Coins + receiveFee sdk.Coins + timeoutFee sdk.Coins + packetId *channeltypes.PacketId + refundAcc sdk.AccAddress + ) + + // refundAcc does not have balance for the following Coin + validChannelId := "channel-0" + validSeq := uint64(1) + + testCases := []struct { + name string + malleate func() + expPass bool + }{ + { + "success", func() {}, true, + }, + { + "fee not found for packet", func() { + // setting packetId with an invalid sequence of 2 + packetId = &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortKey, Sequence: uint64(2)} + }, false, + }, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + // setup + refundAcc = suite.chainA.SenderAccount.GetAddress() + timeoutRelayer := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + + ackFee = validCoins + receiveFee = validCoins2 + timeoutFee = validCoins3 + packetId = &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortKey, Sequence: validSeq} + fee := types.Fee{receiveFee, ackFee, timeoutFee} + + // escrow the packet fee & store the fee in state + identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, Relayers: []string{}} + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), refundAcc, &identifiedPacketFee) + suite.Require().NoError(err) + + tc.malleate() + + // refundAcc balance after escrow + refundAccBal := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom) + + err = suite.chainA.GetSimApp().IBCFeeKeeper.DistributeFeeTimeout(suite.chainA.GetContext(), refundAcc, timeoutRelayer, packetId) + + if tc.expPass { + suite.Require().NoError(err) + hasFeeInEscrow := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), packetId) + // there should no longer be a fee in escrow for this packet + suite.Require().False(hasFeeInEscrow) + // check if the timeoutRelayer has been paid + hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), timeoutRelayer, timeoutFee[0]) + suite.Require().True(hasBalance) + // check if the refund acc has been refunded the recv & ack fees + expectedRefundAccBal := refundAccBal.Add(ackFee[0]) + expectedRefundAccBal = refundAccBal.Add(receiveFee[0]) + hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), refundAcc, expectedRefundAccBal) + suite.Require().True(hasBalance) + // check the module acc wallet is now empty + hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(0)}) + suite.Require().True(hasBalance) + + } else { + suite.Require().Error(err) + invalidPacketID := &channeltypes.PacketId{PortId: types.PortKey, ChannelId: validChannelId, Sequence: 1} + hasFeeInEscrow := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), invalidPacketID) + // there should still be a fee in escrow for this packet + suite.Require().True(hasFeeInEscrow) + } + }) + } +} diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index eb14e1a3a1f..3691204d2a6 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -26,14 +26,16 @@ type Keeper struct { storeKey sdk.StoreKey cdc codec.BinaryCodec + authKeeper types.AccountKeeper channelKeeper types.ChannelKeeper portKeeper types.PortKeeper + bankKeeper types.BankKeeper } // NewKeeper creates a new 29-fee Keeper instance func NewKeeper( cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace, - channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper, + channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper, authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, ) Keeper { return Keeper{ @@ -41,6 +43,8 @@ func NewKeeper( storeKey: key, channelKeeper: channelKeeper, portKeeper: portKeeper, + authKeeper: authKeeper, + bankKeeper: bankKeeper, } } @@ -70,6 +74,11 @@ func (k Keeper) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) ( return k.channelKeeper.GetNextSequenceSend(ctx, portID, channelID) } +// GetFeeAccount returns the ICS29 Fee ModuleAccount address +func (k Keeper) GetFeeModuleAddress() sdk.AccAddress { + return k.authKeeper.GetModuleAddress(types.ModuleName) +} + // SendPacket wraps IBC ChannelKeeper's SendPacket function func (k Keeper) SendPacket(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI) error { return k.channelKeeper.SendPacket(ctx, chanCap, packet) @@ -103,13 +112,63 @@ func (k Keeper) SetCounterpartyAddress(ctx sdk.Context, address, counterpartyAdd } // GetCounterpartyAddress gets the relayer counterparty address given a destination relayer address -func (k Keeper) GetCounterpartyAddress(ctx sdk.Context, address sdk.AccAddress) (sdk.AccAddress, bool) { +func (k Keeper) GetCounterpartyAddress(ctx sdk.Context, address string) (string, bool) { store := ctx.KVStore(k.storeKey) - key := types.KeyRelayerAddress(address.String()) + key := types.KeyRelayerAddress(address) if !store.Has(key) { - return []byte{}, false + return "", false } - return store.Get(key), true + addr := string(store.Get(key)) + return addr, true +} + +// Stores a Fee for a given packet in state +func (k Keeper) SetFeeInEscrow(ctx sdk.Context, fee *types.IdentifiedPacketFee) { + store := ctx.KVStore(k.storeKey) + bz := k.MustMarshalFee(fee) + store.Set(types.KeyFeeInEscrow(fee.PacketId), bz) +} + +// Gets a Fee for a given packet +func (k Keeper) GetFeeInEscrow(ctx sdk.Context, packetId *channeltypes.PacketId) (types.IdentifiedPacketFee, bool) { + store := ctx.KVStore(k.storeKey) + key := types.KeyFeeInEscrow(packetId) + bz := store.Get(key) + if bz == nil { + return types.IdentifiedPacketFee{}, false + } + fee := k.MustUnmarshalFee(bz) + + return fee, true +} + +// Deletes the fee associated with the given packetId +func (k Keeper) DeleteFeeInEscrow(ctx sdk.Context, packetId *channeltypes.PacketId) { + store := ctx.KVStore(k.storeKey) + key := types.KeyFeeInEscrow(packetId) + store.Delete(key) +} + +// GetFeeInEscrow returns true if there is a Fee still to be escrowed for a given packet +func (k Keeper) HasFeeInEscrow(ctx sdk.Context, packetId *channeltypes.PacketId) bool { + store := ctx.KVStore(k.storeKey) + key := types.KeyFeeInEscrow(packetId) + + return store.Has(key) +} + +// MustMarshalFee attempts to encode a Fee object and returns the +// raw encoded bytes. It panics on error. +func (k Keeper) MustMarshalFee(fee *types.IdentifiedPacketFee) []byte { + return k.cdc.MustMarshal(fee) +} + +// MustUnmarshalFee attempts to decode and return a Fee object from +// raw encoded bytes. It panics on error. +func (k Keeper) MustUnmarshalFee(bz []byte) types.IdentifiedPacketFee { + var fee types.IdentifiedPacketFee + k.cdc.MustUnmarshal(bz, &fee) + return fee } diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index f227c98171c..ab4ce879a29 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -5,6 +5,9 @@ import ( "github.com/stretchr/testify/suite" + "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/testing" ) @@ -16,14 +19,42 @@ type KeeperTestSuite struct { // testing chains used for convenience and readability chainA *ibctesting.TestChain chainB *ibctesting.TestChain - chainC *ibctesting.TestChain + + path *ibctesting.Path } 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)) + + path := ibctesting.NewPath(suite.chainA, suite.chainB) + feeTransferVersion := channeltypes.MergeChannelVersions(types.Version, transfertypes.Version) + path.EndpointA.ChannelConfig.Version = feeTransferVersion + path.EndpointB.ChannelConfig.Version = feeTransferVersion + path.EndpointA.ChannelConfig.PortID = transfertypes.PortID + path.EndpointB.ChannelConfig.PortID = transfertypes.PortID + suite.path = path +} + +func SetupFeePath(path *ibctesting.Path) error { + if err := path.EndpointA.ChanOpenInit(); err != nil { + return err + } + + if err := path.EndpointB.ChanOpenTry(); err != nil { + return err + } + + if err := path.EndpointA.ChanOpenAck(); err != nil { + return err + } + + if err := path.EndpointB.ChanOpenConfirm(); err != nil { + return err + } + + return nil } func TestKeeperTestSuite(t *testing.T) { diff --git a/modules/apps/29-fee/keeper/msg_server.go b/modules/apps/29-fee/keeper/msg_server.go index 54b0dadbc37..4b81a870eea 100644 --- a/modules/apps/29-fee/keeper/msg_server.go +++ b/modules/apps/29-fee/keeper/msg_server.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" ) var _ types.MsgServer = Keeper{} @@ -25,9 +26,52 @@ func (k Keeper) RegisterCounterpartyAddress(goCtx context.Context, msg *types.Ms 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 +// PayPacketFee defines a rpc handler method for MsgPayPacketFee +// PayPacketFee is an open callback that may be called by any module/user that wishes to escrow funds in order to relay the packet with the next sequence +func (k Keeper) PayPacketFee(goCtx context.Context, msg *types.MsgPayPacketFee) (*types.MsgPayPacketFeeResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // get the next sequence + sequence, found := k.GetNextSequenceSend(ctx, msg.SourcePortId, msg.SourceChannelId) + if !found { + return nil, channeltypes.ErrSequenceSendNotFound + } + + packetId := &channeltypes.PacketId{ + PortId: msg.SourcePortId, + ChannelId: msg.SourceChannelId, + Sequence: sequence, + } + + refundAccAddr, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + return nil, err + } + + identifiedPacket := types.NewIdentifiedPacketFee(packetId, msg.Fee, msg.Relayers) + err = k.EscrowPacketFee(ctx, refundAccAddr, identifiedPacket) + if err != nil { + return nil, err + } + + return &types.MsgPayPacketFeeResponse{}, nil +} + +// PayPacketFee defines a rpc handler method for MsgPayPacketFee +// PayPacketFee is an open callback that may be called by any module/user that wishes to escrow funds in order to +// incentivize the relaying of a known packet +func (k Keeper) PayPacketFeeAsync(goCtx context.Context, msg *types.MsgPayPacketFeeAsync) (*types.MsgPayPacketFeeAsyncResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + refundAccAddr, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + return nil, err + } + + err = k.EscrowPacketFee(ctx, refundAccAddr, &msg.IdentifiedPacketFee) + if err != nil { + return nil, err + } + + return &types.MsgPayPacketFeeAsyncResponse{}, nil } 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..face4c4c905 --- /dev/null +++ b/modules/apps/29-fee/keeper/msg_server_test.go @@ -0,0 +1,131 @@ +package keeper_test + +import ( + "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" +) + +func (suite *KeeperTestSuite) TestRegisterCounterpartyAddress() { + var ( + sender string + counterparty string + ) + + testCases := []struct { + name string + expPass bool + malleate func() + }{ + { + "success", + true, + func() {}, + }, + { + "success", + true, + func() { counterparty = "arbitrary-string" }, + }, + } + + for _, tc := range testCases { + suite.SetupTest() + ctx := suite.chainA.GetContext() + + sender = suite.chainA.SenderAccount.GetAddress().String() + counterparty = suite.chainB.SenderAccount.GetAddress().String() + tc.malleate() + msg := types.NewMsgRegisterCounterpartyAddress(sender, counterparty) + + _, 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().String()) + suite.Require().Equal(counterparty, counterpartyAddress) + } else { + suite.Require().Error(err) + } + } +} + +func (suite *KeeperTestSuite) TestPayPacketFee() { + testCases := []struct { + name string + expPass bool + malleate func() + }{ + { + "success", + true, + func() {}, + }, + } + + for _, tc := range testCases { + suite.SetupTest() + suite.coordinator.SetupConnections(suite.path) + err := SetupFeePath(suite.path) + suite.Require().NoError(err) + + refundAcc := suite.chainA.SenderAccount.GetAddress() + channelID := suite.path.EndpointA.ChannelID + fee := types.Fee{validCoins, validCoins, validCoins} + msg := types.NewMsgPayPacketFee(fee, suite.path.EndpointA.ChannelConfig.PortID, channelID, refundAcc.String(), []string{}) + + tc.malleate() + _, err = suite.chainA.SendMsgs(msg) + + if tc.expPass { + suite.Require().NoError(err) // message committed + } else { + suite.Require().Error(err) + } + } +} + +func (suite *KeeperTestSuite) TestPayPacketFeeAsync() { + testCases := []struct { + name string + expPass bool + malleate func() + }{ + { + "success", + true, + func() {}, + }, + } + + for _, tc := range testCases { + suite.SetupTest() + suite.coordinator.SetupConnections(suite.path) + err := SetupFeePath(suite.path) + suite.Require().NoError(err) + + ctxA := suite.chainA.GetContext() + + refundAcc := suite.chainA.SenderAccount.GetAddress() + + // build packetId + channelID := suite.path.EndpointA.ChannelID + fee := types.Fee{validCoins, validCoins, validCoins} + seq, _ := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetNextSequenceSend(ctxA, suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) + + // build fee + packetId := &channeltypes.PacketId{ChannelId: channelID, PortId: suite.path.EndpointA.ChannelConfig.PortID, Sequence: seq} + identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, Relayers: []string{}} + + tc.malleate() + + msg := types.NewMsgPayPacketFeeAsync(identifiedPacketFee, refundAcc.String()) + _, err = suite.chainA.SendMsgs(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 6e73a3b9b08..61e39846584 100644 --- a/modules/apps/29-fee/module.go +++ b/modules/apps/29-fee/module.go @@ -45,7 +45,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 @@ -120,7 +120,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..846716d740f 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(&MsgPayPacketFee{}, "cosmos-sdk/MsgPayPacketFee", nil) + cdc.RegisterConcrete(&MsgPayPacketFeeAsync{}, "cosmos-sdk/MsgPayPacketFeeAsync", 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{}, &MsgPayPacketFee{}, &MsgPayPacketFeeAsync{}) 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/errors.go b/modules/apps/29-fee/types/errors.go index 5536d326fc0..b5e8203ec9f 100644 --- a/modules/apps/29-fee/types/errors.go +++ b/modules/apps/29-fee/types/errors.go @@ -6,5 +6,10 @@ import ( // 29-fee sentinel errors var ( - ErrInvalidVersion = sdkerrors.Register(ModuleName, 2, "invalid ICS29 middleware version") + ErrInvalidVersion = sdkerrors.Register(ModuleName, 2, "invalid ICS29 middleware version") + ErrRefundAccNotFound = sdkerrors.Register(ModuleName, 3, "no account found for given refund address") + ErrBalanceNotFound = sdkerrors.Register(ModuleName, 4, "balance not found for given account address") + ErrFeeNotFound = sdkerrors.Register(ModuleName, 5, "there is no fee escrowed for the given packetID") + ErrRelayersNotNil = sdkerrors.Register(ModuleName, 6, "relayers must be nil. This feature is not supported") + ErrCounterpartyAddressEmpty = sdkerrors.Register(ModuleName, 7, "counterparty address must not be empty") ) diff --git a/modules/apps/29-fee/types/expected_keepers.go b/modules/apps/29-fee/types/expected_keepers.go index 8e49bbe8ab0..33edb1c01ce 100644 --- a/modules/apps/29-fee/types/expected_keepers.go +++ b/modules/apps/29-fee/types/expected_keepers.go @@ -2,11 +2,18 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" ibcexported "github.com/cosmos/ibc-go/modules/core/exported" ) +// AccountKeeper defines the contract required for account APIs. +type AccountKeeper interface { + GetModuleAddress(name string) sdk.AccAddress + GetAccount(sdk.Context, sdk.AccAddress) types.AccountI +} + // ChannelKeeper defines the expected IBC channel keeper type ChannelKeeper interface { GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channeltypes.Channel, found bool) @@ -19,3 +26,10 @@ type ChannelKeeper interface { type PortKeeper interface { BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability } + +// BankKeeper defines the expected bank keeper +type BankKeeper interface { + HasBalance(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coin) bool + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error +} diff --git a/modules/apps/29-fee/types/fee.pb.go b/modules/apps/29-fee/types/fee.pb.go index d6597e1c0f8..23c7abecd4d 100644 --- a/modules/apps/29-fee/types/fee.pb.go +++ b/modules/apps/29-fee/types/fee.pb.go @@ -30,7 +30,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // See Fee Payment Middleware spec: // https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middleware-contract type Fee struct { - Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` + ReceiveFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=receive_fee,json=receiveFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"receive_fee" yaml:"receive_fee"` + AckFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=ack_fee,json=ackFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"ack_fee" yaml:"ack_fee"` + TimeoutFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=timeout_fee,json=timeoutFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"timeout_fee" yaml:"timeout_fee"` } func (m *Fee) Reset() { *m = Fee{} } @@ -66,20 +68,32 @@ func (m *Fee) XXX_DiscardUnknown() { var xxx_messageInfo_Fee proto.InternalMessageInfo -func (m *Fee) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { +func (m *Fee) GetReceiveFee() github_com_cosmos_cosmos_sdk_types.Coins { if m != nil { - return m.Amount + return m.ReceiveFee + } + return nil +} + +func (m *Fee) GetAckFee() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.AckFee + } + return nil +} + +func (m *Fee) GetTimeoutFee() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.TimeoutFee } return nil } // Fee associated with a packet_id type IdentifiedPacketFee struct { - PacketId *types1.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id,omitempty" yaml:"packet_id"` - ReceiveFee *Fee `protobuf:"bytes,2,opt,name=receive_fee,json=receiveFee,proto3" json:"receive_fee,omitempty" yaml:"receive_fee"` - AckFee *Fee `protobuf:"bytes,3,opt,name=ack_fee,json=ackFee,proto3" json:"ack_fee,omitempty" yaml:"ack_fee"` - TimeoutFee *Fee `protobuf:"bytes,4,opt,name=timeout_fee,json=timeoutFee,proto3" json:"timeout_fee,omitempty" yaml:"timeout_fee"` - Relayers []string `protobuf:"bytes,5,rep,name=relayers,proto3" json:"relayers,omitempty"` + PacketId *types1.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id,omitempty" yaml:"packet_id"` + Fee Fee `protobuf:"bytes,2,opt,name=fee,proto3" json:"fee"` + Relayers []string `protobuf:"bytes,3,rep,name=relayers,proto3" json:"relayers,omitempty"` } func (m *IdentifiedPacketFee) Reset() { *m = IdentifiedPacketFee{} } @@ -122,25 +136,11 @@ func (m *IdentifiedPacketFee) GetPacketId() *types1.PacketId { return nil } -func (m *IdentifiedPacketFee) GetReceiveFee() *Fee { +func (m *IdentifiedPacketFee) GetFee() Fee { if m != nil { - return m.ReceiveFee + return m.Fee } - return nil -} - -func (m *IdentifiedPacketFee) GetAckFee() *Fee { - if m != nil { - return m.AckFee - } - return nil -} - -func (m *IdentifiedPacketFee) GetTimeoutFee() *Fee { - if m != nil { - return m.TimeoutFee - } - return nil + return Fee{} } func (m *IdentifiedPacketFee) GetRelayers() []string { @@ -159,34 +159,34 @@ func init() { proto.RegisterFile("ibc/applications/fee/v1/fee.proto", fileDescri var fileDescriptor_cb3319f1af2a53e5 = []byte{ // 443 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0x3f, 0x8f, 0xd3, 0x30, - 0x18, 0xc6, 0x9b, 0x2b, 0x94, 0x3b, 0x57, 0x42, 0x28, 0x9c, 0xa0, 0x54, 0x90, 0x94, 0x4c, 0x5d, - 0x6a, 0xd3, 0x32, 0xc1, 0x18, 0xa4, 0x93, 0x2a, 0x31, 0x9c, 0x22, 0xdd, 0xc2, 0x72, 0x72, 0x9c, - 0xb7, 0x39, 0x93, 0x3f, 0x8e, 0x62, 0x27, 0x52, 0xbf, 0x05, 0x9f, 0x83, 0x4f, 0x72, 0xe3, 0x8d, - 0x4c, 0x01, 0xb5, 0xdf, 0xa0, 0x33, 0x03, 0xb2, 0x63, 0x4e, 0x95, 0x10, 0x12, 0x4c, 0x7e, 0x5f, - 0xdb, 0xcf, 0xef, 0x79, 0x64, 0xbf, 0xe8, 0x35, 0x8f, 0x19, 0xa1, 0x55, 0x95, 0x73, 0x46, 0x15, - 0x17, 0xa5, 0x24, 0x1b, 0x00, 0xd2, 0x2e, 0xf5, 0x82, 0xab, 0x5a, 0x28, 0xe1, 0x3e, 0xe7, 0x31, - 0xc3, 0xc7, 0x57, 0xb0, 0x3e, 0x6b, 0x97, 0x53, 0x8f, 0x09, 0x59, 0x08, 0x49, 0x62, 0x2a, 0xb5, - 0x24, 0x06, 0x45, 0x97, 0x84, 0x09, 0x5e, 0xf6, 0xc2, 0xe9, 0x79, 0x2a, 0x52, 0x61, 0x4a, 0xa2, - 0x2b, 0xbb, 0x6b, 0x1c, 0x99, 0xa8, 0x81, 0xb0, 0x1b, 0x5a, 0x96, 0x90, 0x6b, 0x37, 0x5b, 0xf6, - 0x57, 0x82, 0xcf, 0x68, 0x78, 0x01, 0xe0, 0x32, 0x34, 0xa2, 0x85, 0x68, 0x4a, 0x35, 0x71, 0x66, - 0xc3, 0xf9, 0x78, 0xf5, 0x02, 0xf7, 0x86, 0x58, 0x1b, 0x62, 0x6b, 0x88, 0x3f, 0x08, 0x5e, 0x86, - 0x6f, 0x6e, 0x3b, 0x7f, 0xf0, 0xf5, 0xbb, 0x3f, 0x4f, 0xb9, 0xba, 0x69, 0x62, 0xcc, 0x44, 0x41, - 0x6c, 0xba, 0x7e, 0x59, 0xc8, 0x24, 0x23, 0x6a, 0x5b, 0x81, 0x34, 0x02, 0x19, 0x59, 0x74, 0xf0, - 0xf3, 0x04, 0x3d, 0x5d, 0x27, 0x50, 0x2a, 0xbe, 0xe1, 0x90, 0x5c, 0x52, 0x96, 0x81, 0xd2, 0xe6, - 0x97, 0xe8, 0xac, 0x32, 0xcd, 0x35, 0x4f, 0x26, 0xce, 0xcc, 0x99, 0x8f, 0x57, 0xaf, 0xb0, 0x7e, - 0x09, 0x1d, 0x1d, 0xff, 0xce, 0xdb, 0x2e, 0x71, 0x2f, 0x59, 0x27, 0xe1, 0xf9, 0xa1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x65, 0x0b, 0x74, 0x92, 0x3e, 0xec, 0x93, 0x4f, 0x37, 0xdb, 0x08, 0xdd, 0x6e, + 0x23, 0xf4, 0x7b, 0x1b, 0xa1, 0x6f, 0xbb, 0x68, 0x70, 0xbb, 0x8b, 0x06, 0x3f, 0x77, 0xd1, 0xe0, + 0xf3, 0xfc, 0xef, 0x5a, 0x88, 0x8c, 0x4f, 0x0b, 0x49, 0x6b, 0x99, 0xaf, 0x2a, 0x50, 0x66, 0x22, + 0x14, 0x9d, 0xbf, 0x9f, 0x9a, 0x61, 0xb0, 0xb5, 0xc9, 0x8e, 0x6c, 0x6b, 0xbe, 0xfd, 0x13, 0x00, + 0x00, 0xff, 0xff, 0x80, 0x3a, 0xb6, 0x74, 0x31, 0x03, 0x00, 0x00, } func (m *Fee) Marshal() (dAtA []byte, err error) { @@ -209,10 +209,38 @@ func (m *Fee) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Amount) > 0 { - for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + if len(m.TimeoutFee) > 0 { + for iNdEx := len(m.TimeoutFee) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.Amount[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.TimeoutFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFee(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.AckFee) > 0 { + for iNdEx := len(m.AckFee) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AckFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFee(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.ReceiveFee) > 0 { + for iNdEx := len(m.ReceiveFee) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ReceiveFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -252,45 +280,19 @@ func (m *IdentifiedPacketFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Relayers[iNdEx]) i = encodeVarintFee(dAtA, i, uint64(len(m.Relayers[iNdEx]))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x1a } } - if m.TimeoutFee != nil { - { - size, err := m.TimeoutFee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintFee(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - if m.AckFee != nil { - { - size, err := m.AckFee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintFee(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.ReceiveFee != nil { - { - size, err := m.ReceiveFee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintFee(dAtA, i, uint64(size)) + { + size, err := m.Fee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0x12 + i -= size + i = encodeVarintFee(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 if m.PacketId != nil { { size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) @@ -323,8 +325,20 @@ func (m *Fee) Size() (n int) { } var l int _ = l - if len(m.Amount) > 0 { - for _, e := range m.Amount { + if len(m.ReceiveFee) > 0 { + for _, e := range m.ReceiveFee { + l = e.Size() + n += 1 + l + sovFee(uint64(l)) + } + } + if len(m.AckFee) > 0 { + for _, e := range m.AckFee { + l = e.Size() + n += 1 + l + sovFee(uint64(l)) + } + } + if len(m.TimeoutFee) > 0 { + for _, e := range m.TimeoutFee { l = e.Size() n += 1 + l + sovFee(uint64(l)) } @@ -342,18 +356,8 @@ func (m *IdentifiedPacketFee) Size() (n int) { l = m.PacketId.Size() n += 1 + l + sovFee(uint64(l)) } - if m.ReceiveFee != nil { - l = m.ReceiveFee.Size() - n += 1 + l + sovFee(uint64(l)) - } - if m.AckFee != nil { - l = m.AckFee.Size() - n += 1 + l + sovFee(uint64(l)) - } - if m.TimeoutFee != nil { - l = m.TimeoutFee.Size() - n += 1 + l + sovFee(uint64(l)) - } + l = m.Fee.Size() + n += 1 + l + sovFee(uint64(l)) if len(m.Relayers) > 0 { for _, s := range m.Relayers { l = len(s) @@ -400,7 +404,7 @@ func (m *Fee) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ReceiveFee", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -427,64 +431,14 @@ func (m *Fee) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Amount = append(m.Amount, types.Coin{}) - if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.ReceiveFee = append(m.ReceiveFee, types.Coin{}) + if err := m.ReceiveFee[len(m.ReceiveFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipFee(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthFee - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *IdentifiedPacketFee) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowFee - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: IdentifiedPacketFee: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: IdentifiedPacketFee: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AckFee", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -511,16 +465,14 @@ func (m *IdentifiedPacketFee) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.PacketId == nil { - m.PacketId = &types1.PacketId{} - } - if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.AckFee = append(m.AckFee, types.Coin{}) + if err := m.AckFee[len(m.AckFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 2: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ReceiveFee", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TimeoutFee", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -547,16 +499,64 @@ func (m *IdentifiedPacketFee) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.ReceiveFee == nil { - m.ReceiveFee = &Fee{} - } - if err := m.ReceiveFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.TimeoutFee = append(m.TimeoutFee, types.Coin{}) + if err := m.TimeoutFee[len(m.TimeoutFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 3: + default: + iNdEx = preIndex + skippy, err := skipFee(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFee + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *IdentifiedPacketFee) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFee + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: IdentifiedPacketFee: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IdentifiedPacketFee: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AckFee", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -583,16 +583,16 @@ func (m *IdentifiedPacketFee) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.AckFee == nil { - m.AckFee = &Fee{} + if m.PacketId == nil { + m.PacketId = &types1.PacketId{} } - if err := m.AckFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 4: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TimeoutFee", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -619,14 +619,11 @@ func (m *IdentifiedPacketFee) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.TimeoutFee == nil { - m.TimeoutFee = &Fee{} - } - if err := m.TimeoutFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Fee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 5: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Relayers", wireType) } diff --git a/modules/apps/29-fee/types/genesis.pb.go b/modules/apps/29-fee/types/genesis.pb.go index e108131adfc..b07a497011f 100644 --- a/modules/apps/29-fee/types/genesis.pb.go +++ b/modules/apps/29-fee/types/genesis.pb.go @@ -25,8 +25,6 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the fee middleware genesis state type GenesisState struct { - // A mapping of packets -> escrowed fees - PacketsFees []*IdentifiedPacketFee `protobuf:"bytes,1,rep,name=packets_fees,json=packetsFees,proto3" json:"packets_fees,omitempty" yaml:"packets_fees"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -62,13 +60,6 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetPacketsFees() []*IdentifiedPacketFee { - if m != nil { - return m.PacketsFees - } - return nil -} - func init() { proto.RegisterType((*GenesisState)(nil), "ibc.applications.fee.v1.GenesisState") } @@ -78,24 +69,19 @@ func init() { } var fileDescriptor_7191992e856dff95 = []byte{ - // 260 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x8f, 0xb1, 0x4a, 0xc3, 0x50, - 0x14, 0x86, 0x13, 0x04, 0x87, 0xb4, 0x53, 0x15, 0x2a, 0x1d, 0xae, 0x1a, 0x10, 0x1c, 0xec, 0xbd, - 0x34, 0x4e, 0x3a, 0x76, 0xa8, 0x08, 0x0e, 0xa2, 0x9b, 0x8b, 0xe4, 0xde, 0x9c, 0xdc, 0x1e, 0x4c, - 0x72, 0x2e, 0x9e, 0xdb, 0x62, 0xdf, 0xc2, 0xc7, 0x72, 0xec, 0xe8, 0x24, 0x92, 0xbc, 0x81, 0x4f, - 0x20, 0x49, 0x3b, 0x74, 0xe9, 0x76, 0x0e, 0x7c, 0xff, 0xff, 0xf3, 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xaa, - 0x49, 0x01, 0x00, 0x00, + // 192 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcd, 0x4c, 0x4a, 0xd6, + 0x4f, 0x2c, 0x28, 0xc8, 0xc9, 0x4c, 0x4e, 0x2c, 0xc9, 0xcc, 0xcf, 0x2b, 0xd6, 0x4f, 0x4b, 0x4d, + 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, + 0xc9, 0x17, 0x12, 0xcf, 0x4c, 0x4a, 0xd6, 0x43, 0x56, 0xa6, 0x97, 0x96, 0x9a, 0xaa, 0x57, 0x66, + 0x28, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xa3, 0x0f, 0x62, 0x41, 0x94, 0x4b, 0x29, 0xe2, + 0x32, 0x15, 0xa4, 0x0b, 0xac, 0x44, 0x89, 0x8f, 0x8b, 0xc7, 0x1d, 0x62, 0x45, 0x70, 0x49, 0x62, + 0x49, 0xaa, 0x93, 0xcf, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, + 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa5, + 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x27, 0xe7, 0x17, 0xe7, 0xe6, 0x17, + 0xeb, 0x67, 0x26, 0x25, 0xeb, 0xa6, 0xe7, 0xeb, 0xe7, 0xe6, 0xa7, 0x94, 0xe6, 0xa4, 0x16, 0x83, + 0x6c, 0x2a, 0xd6, 0x37, 0xb2, 0xd4, 0x05, 0x59, 0x52, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, + 0xb6, 0xc4, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x90, 0xf8, 0xaf, 0x33, 0xdf, 0x00, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -118,20 +104,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.PacketsFees) > 0 { - for iNdEx := len(m.PacketsFees) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.PacketsFees[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } return len(dAtA) - i, nil } @@ -152,12 +124,6 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l - if len(m.PacketsFees) > 0 { - for _, e := range m.PacketsFees { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } return n } @@ -196,40 +162,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PacketsFees", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PacketsFees = append(m.PacketsFees, &IdentifiedPacketFee{}) - if err := m.PacketsFees[len(m.PacketsFees)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index 39bbfe5ff85..174168a32b0 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -1,6 +1,10 @@ package types -import "fmt" +import ( + "fmt" + + channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" +) const ( // ModuleName defines the 29-fee name @@ -25,6 +29,9 @@ const ( // RelayerAddressKeyPrefix is the key prefix for relayer address mapping RelayerAddressKeyPrefix = "relayerAddress" + + // FeeInEscrowPrefix is the key prefix for fee in escrow mapping + FeeInEscrowPrefix = "feeInEscrow" ) // FeeEnabledKey returns the key that stores a flag to determine if fee logic should @@ -37,3 +44,8 @@ func FeeEnabledKey(portID, channelID string) []byte { func KeyRelayerAddress(address string) []byte { return []byte(fmt.Sprintf("%s/%s", RelayerAddressKeyPrefix, address)) } + +// KeyFeeInEscrow returns the key for escrowed fees +func KeyFeeInEscrow(packetID *channeltypes.PacketId) []byte { + return []byte(fmt.Sprintf("%s/%s/%s/packet/%d", FeeInEscrowPrefix, packetID.PortId, packetID.ChannelId, packetID.Sequence)) +} diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index 7e330d547bb..ef9e49901fd 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -3,6 +3,9 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/modules/core/24-host" ) // msg types @@ -25,9 +28,8 @@ func (msg MsgRegisterCounterpartyAddress) ValidateBasic() error { 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") + if msg.CounterpartyAddress == "" { + return ErrCounterpartyAddressEmpty } return nil @@ -41,3 +43,129 @@ func (msg MsgRegisterCounterpartyAddress) GetSigners() []sdk.AccAddress { } return []sdk.AccAddress{signer} } + +// NewMsgPayPacketFee creates a new instance of MsgPayPacketFee +func NewMsgPayPacketFee(fee Fee, sourcePortId, sourceChannelId, signer string, relayers []string) *MsgPayPacketFee { + return &MsgPayPacketFee{ + Fee: fee, + SourcePortId: sourcePortId, + SourceChannelId: sourceChannelId, + Signer: signer, + Relayers: relayers, + } +} + +// ValidateBasic performs a basic check of the MsgPayPacketFee fields +func (msg MsgPayPacketFee) ValidateBasic() error { + // validate channelId + err := host.ChannelIdentifierValidator(msg.SourceChannelId) + if err != nil { + return err + } + + // validate portId + err = host.PortIdentifierValidator(msg.SourcePortId) + if err != nil { + return err + } + + // signer check + _, err = sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + return sdkerrors.Wrap(err, "failed to convert msg.Signer into sdk.AccAddress") + } + + // enforce relayer is nil + if msg.Relayers != nil { + return ErrRelayersNotNil + } + + // if any of the fee's are invalid return an error + if !msg.Fee.AckFee.IsValid() || !msg.Fee.ReceiveFee.IsValid() || !msg.Fee.TimeoutFee.IsValid() { + return sdkerrors.ErrInvalidCoins + } + + // if all three fee's are zero or empty return an error + if msg.Fee.AckFee.IsZero() && msg.Fee.ReceiveFee.IsZero() && msg.Fee.TimeoutFee.IsZero() { + return sdkerrors.ErrInvalidCoins + } + + return nil +} + +// GetSigners implements sdk.Msg +func (msg MsgPayPacketFee) GetSigners() []sdk.AccAddress { + signer, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + panic(err) + } + return []sdk.AccAddress{signer} +} + +// NewMsgPayPacketAsync creates a new instance of MsgPayPacketFee +func NewMsgPayPacketFeeAsync(identifiedPacketFee IdentifiedPacketFee, signer string) *MsgPayPacketFeeAsync { + return &MsgPayPacketFeeAsync{ + IdentifiedPacketFee: identifiedPacketFee, + Signer: signer, + } +} + +// ValidateBasic performs a basic check of the MsgPayPacketFeeAsync fields +func (msg MsgPayPacketFeeAsync) ValidateBasic() error { + // validate channelId + err := host.ChannelIdentifierValidator(msg.IdentifiedPacketFee.PacketId.ChannelId) + if err != nil { + return err + } + + // validate portId + err = host.PortIdentifierValidator(msg.IdentifiedPacketFee.PacketId.PortId) + if err != nil { + return err + } + + // signer check + _, err = sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + return sdkerrors.Wrap(err, "failed to convert msg.Signer into sdk.AccAddress") + } + + // enforce relayer is nil + if msg.IdentifiedPacketFee.Relayers != nil { + return ErrRelayersNotNil + } + + // ensure sequence is not 0 + if msg.IdentifiedPacketFee.PacketId.Sequence == 0 { + return sdkerrors.ErrInvalidSequence + } + + // if any of the fee's are invalid return an error + if !msg.IdentifiedPacketFee.Fee.AckFee.IsValid() || !msg.IdentifiedPacketFee.Fee.ReceiveFee.IsValid() || !msg.IdentifiedPacketFee.Fee.TimeoutFee.IsValid() { + return sdkerrors.ErrInvalidCoins + } + + // if all three fee's are zero or empty return an error + if msg.IdentifiedPacketFee.Fee.AckFee.IsZero() && msg.IdentifiedPacketFee.Fee.ReceiveFee.IsZero() && msg.IdentifiedPacketFee.Fee.TimeoutFee.IsZero() { + return sdkerrors.ErrInvalidCoins + } + + return nil +} + +// GetSigners implements sdk.Msg +func (msg MsgPayPacketFeeAsync) GetSigners() []sdk.AccAddress { + signer, err := sdk.AccAddressFromBech32(msg.Signer) + if err != nil { + panic(err) + } + return []sdk.AccAddress{signer} +} + +func NewIdentifiedPacketFee(packetId *channeltypes.PacketId, fee Fee, relayers []string) *IdentifiedPacketFee { + return &IdentifiedPacketFee{ + PacketId: packetId, + Fee: fee, + Relayers: relayers, + } +} diff --git a/modules/apps/29-fee/types/msgs_test.go b/modules/apps/29-fee/types/msgs_test.go index d29073f75a7..480eedcc403 100644 --- a/modules/apps/29-fee/types/msgs_test.go +++ b/modules/apps/29-fee/types/msgs_test.go @@ -4,13 +4,19 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/secp256k1" ) var ( - validAddr = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() - invalidAddr = "invalid_address" + validChannelID = "channel-1" + validPortID = "validPortId" + invalidID = "this identifier is too long to be used as a valid identifier" + validCoins = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}} + invalidCoins = sdk.Coins{sdk.Coin{Denom: "invalid-denom", Amount: sdk.NewInt(-2)}} + validAddr = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() + invalidAddr = "invalid_address" ) // TestMsgTransferValidation tests ValidateBasic for MsgTransfer @@ -22,7 +28,7 @@ func TestMsgRegisterCountepartyAddressValidation(t *testing.T) { }{ {"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}, + {"invalid counterparty address", NewMsgRegisterCounterpartyAddress(validAddr, ""), false}, } for i, tc := range testCases { @@ -34,3 +40,313 @@ func TestMsgRegisterCountepartyAddressValidation(t *testing.T) { } } } + +// TestRegisterCounterpartyAddressGetSigners tests GetSigners +func TestRegisterCountepartyAddressGetSigners(t *testing.T) { + addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + // build message + msg := NewMsgRegisterCounterpartyAddress(addr.String(), "counterparty") + + // GetSigners + res := msg.GetSigners() + + require.Equal(t, []sdk.AccAddress{addr}, res) +} + +// TestMsgPayPacketFeeValidation tests ValidateBasic +func TestMsgPayPacketFeeValidation(t *testing.T) { + var ( + signer string + channelID string + portID string + fee Fee + relayers []string + ackFee sdk.Coins + receiveFee sdk.Coins + timeoutFee sdk.Coins + ) + + testCases := []struct { + name string + malleate func() + expPass bool + }{ + { + "success", + func() {}, + true, + }, + { + "invalid channelID", + func() { + channelID = invalidID + }, + false, + }, + { + "invalid portID", + func() { + portID = invalidID + }, + false, + }, + { + "relayers is not nil", + func() { + relayers = []string{validAddr} + }, + false, + }, + { + "invalid signer address", + func() { + signer = "invalid-addr" + }, + false, + }, + { + "should fail when all fees are invalid", + func() { + ackFee = invalidCoins + receiveFee = invalidCoins + timeoutFee = invalidCoins + }, + false, + }, + { + "should fail with single invalid fee", + func() { + ackFee = invalidCoins + }, + false, + }, + { + "should fail with two invalid fees", + func() { + timeoutFee = invalidCoins + ackFee = invalidCoins + }, + false, + }, + { + "should pass with two empty fees", + func() { + timeoutFee = sdk.Coins{} + ackFee = sdk.Coins{} + }, + true, + }, + { + "should pass with one empty fee", + func() { + timeoutFee = sdk.Coins{} + }, + true, + }, + { + "should fail if all fees are empty", + func() { + ackFee = sdk.Coins{} + receiveFee = sdk.Coins{} + timeoutFee = sdk.Coins{} + }, + false, + }, + } + + for _, tc := range testCases { + // build message + signer = validAddr + channelID = validChannelID + portID = validPortID + ackFee = validCoins + receiveFee = validCoins + timeoutFee = validCoins + relayers = nil + + // malleate + tc.malleate() + fee = Fee{receiveFee, ackFee, timeoutFee} + msg := NewMsgPayPacketFee(fee, portID, channelID, signer, relayers) + + err := msg.ValidateBasic() + + if tc.expPass { + require.NoError(t, err) + } else { + require.Error(t, err) + } + } +} + +// TestPayPacketFeeGetSigners tests GetSigners +func TestPayPacketFeeGetSigners(t *testing.T) { + addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + // build message + signer := addr.String() + channelID := validChannelID + portID := validPortID + fee := Fee{validCoins, validCoins, validCoins} + msg := NewMsgPayPacketFee(fee, portID, channelID, signer, nil) + + // GetSigners + res := msg.GetSigners() + + require.Equal(t, []sdk.AccAddress{addr}, res) +} + +// TestMsgPayPacketFeeAsyncValidation tests ValidateBasic +func TestMsgPayPacketFeeAsyncValidation(t *testing.T) { + var ( + signer string + channelID string + portID string + fee Fee + relayers []string + seq uint64 + ackFee sdk.Coins + receiveFee sdk.Coins + timeoutFee sdk.Coins + ) + + testCases := []struct { + name string + malleate func() + expPass bool + }{ + { + "success", + func() {}, + true, + }, + { + "invalid channelID", + func() { + channelID = invalidID + }, + false, + }, + { + "invalid portID", + func() { + portID = invalidID + }, + false, + }, + { + "relayers is not nil", + func() { + relayers = []string{validAddr} + }, + false, + }, + { + "invalid signer address", + func() { + signer = "invalid-addr" + }, + false, + }, + { + "invalid sequence", + func() { + seq = 0 + }, + false, + }, + { + "should fail when all fees are invalid", + func() { + ackFee = invalidCoins + receiveFee = invalidCoins + timeoutFee = invalidCoins + }, + false, + }, + { + "should fail with single invalid fee", + func() { + ackFee = invalidCoins + }, + false, + }, + { + "should fail with two invalid fees", + func() { + timeoutFee = invalidCoins + ackFee = invalidCoins + }, + false, + }, + { + "should pass with two empty fees", + func() { + timeoutFee = sdk.Coins{} + ackFee = sdk.Coins{} + }, + true, + }, + { + "should pass with one empty fee", + func() { + timeoutFee = sdk.Coins{} + }, + true, + }, + { + "should fail if all fees are empty", + func() { + ackFee = sdk.Coins{} + receiveFee = sdk.Coins{} + timeoutFee = sdk.Coins{} + }, + false, + }, + } + + for _, tc := range testCases { + // build message + signer = validAddr + channelID = validChannelID + portID = validPortID + ackFee = validCoins + receiveFee = validCoins + timeoutFee = validCoins + relayers = nil + seq = 1 + + // malleate + tc.malleate() + fee = Fee{receiveFee, ackFee, timeoutFee} + + packetId := &channeltypes.PacketId{ChannelId: channelID, PortId: portID, Sequence: seq} + identifiedPacketFee := IdentifiedPacketFee{PacketId: packetId, Fee: fee, Relayers: relayers} + msg := NewMsgPayPacketFeeAsync(identifiedPacketFee, signer) + + err := msg.ValidateBasic() + + if tc.expPass { + require.NoError(t, err) + } else { + require.Error(t, err) + } + } +} + +// TestRegisterCounterpartyAddressGetSigners tests GetSigners +func TestPayPacketFeeAsyncGetSigners(t *testing.T) { + addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + // build message + channelID := validChannelID + portID := validPortID + fee := Fee{validCoins, validCoins, validCoins} + seq := uint64(1) + packetId := &channeltypes.PacketId{ChannelId: channelID, PortId: portID, Sequence: seq} + identifiedPacketFee := IdentifiedPacketFee{PacketId: packetId, Fee: fee, Relayers: nil} + msg := NewMsgPayPacketFeeAsync(identifiedPacketFee, addr.String()) + + // GetSigners + res := msg.GetSigners() + + require.Equal(t, []sdk.AccAddress{addr}, res) +} diff --git a/modules/apps/29-fee/types/tx.pb.go b/modules/apps/29-fee/types/tx.pb.go index c9fb330d12b..7e27acc666a 100644 --- a/modules/apps/29-fee/types/tx.pb.go +++ b/modules/apps/29-fee/types/tx.pb.go @@ -107,24 +107,32 @@ func (m *MsgRegisterCounterpartyAddressResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRegisterCounterpartyAddressResponse proto.InternalMessageInfo -// MsgEscrowPacketFee defines the request type EscrowPacketFee RPC -type MsgEscrowPacketFee struct { - IncentivizedPacket *IdentifiedPacketFee `protobuf:"bytes,1,opt,name=incentivized_packet,json=incentivizedPacket,proto3" json:"incentivized_packet,omitempty" yaml:"incentivized_packet"` - Relayers []string `protobuf:"bytes,2,rep,name=relayers,proto3" json:"relayers,omitempty"` +// MsgPayPacketFee defines the request type PayPacketFee RPC +// This Msg can be used to pay for a packet at the next sequence send & should be combined with the Msg that will be +// paid for +type MsgPayPacketFee struct { + Fee Fee `protobuf:"bytes,1,opt,name=fee,proto3" json:"fee"` + // source channel port identifier + SourcePortId string `protobuf:"bytes,2,opt,name=source_port_id,json=sourcePortId,proto3" json:"source_port_id,omitempty" yaml:"source_port_id"` + // source channel unique identifier + SourceChannelId string `protobuf:"bytes,3,opt,name=source_channel_id,json=sourceChannelId,proto3" json:"source_channel_id,omitempty" yaml:"source_channel_id"` + // account address to refund fee if necessary + Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` + Relayers []string `protobuf:"bytes,5,rep,name=relayers,proto3" json:"relayers,omitempty"` } -func (m *MsgEscrowPacketFee) Reset() { *m = MsgEscrowPacketFee{} } -func (m *MsgEscrowPacketFee) String() string { return proto.CompactTextString(m) } -func (*MsgEscrowPacketFee) ProtoMessage() {} -func (*MsgEscrowPacketFee) Descriptor() ([]byte, []int) { +func (m *MsgPayPacketFee) Reset() { *m = MsgPayPacketFee{} } +func (m *MsgPayPacketFee) String() string { return proto.CompactTextString(m) } +func (*MsgPayPacketFee) ProtoMessage() {} +func (*MsgPayPacketFee) Descriptor() ([]byte, []int) { return fileDescriptor_05c93128649f1b96, []int{2} } -func (m *MsgEscrowPacketFee) XXX_Unmarshal(b []byte) error { +func (m *MsgPayPacketFee) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgEscrowPacketFee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgPayPacketFee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgEscrowPacketFee.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgPayPacketFee.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -134,34 +142,34 @@ func (m *MsgEscrowPacketFee) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *MsgEscrowPacketFee) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgEscrowPacketFee.Merge(m, src) +func (m *MsgPayPacketFee) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPayPacketFee.Merge(m, src) } -func (m *MsgEscrowPacketFee) XXX_Size() int { +func (m *MsgPayPacketFee) XXX_Size() int { return m.Size() } -func (m *MsgEscrowPacketFee) XXX_DiscardUnknown() { - xxx_messageInfo_MsgEscrowPacketFee.DiscardUnknown(m) +func (m *MsgPayPacketFee) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPayPacketFee.DiscardUnknown(m) } -var xxx_messageInfo_MsgEscrowPacketFee proto.InternalMessageInfo +var xxx_messageInfo_MsgPayPacketFee proto.InternalMessageInfo -// MsgEscrowPacketFeeResponse defines the response type for Msg/EscrowPacketFee -type MsgEscrowPacketFeeResponse struct { +// MsgPayPacketFeeResponse defines the response type for Msg/PayPacketFee +type MsgPayPacketFeeResponse struct { } -func (m *MsgEscrowPacketFeeResponse) Reset() { *m = MsgEscrowPacketFeeResponse{} } -func (m *MsgEscrowPacketFeeResponse) String() string { return proto.CompactTextString(m) } -func (*MsgEscrowPacketFeeResponse) ProtoMessage() {} -func (*MsgEscrowPacketFeeResponse) Descriptor() ([]byte, []int) { +func (m *MsgPayPacketFeeResponse) Reset() { *m = MsgPayPacketFeeResponse{} } +func (m *MsgPayPacketFeeResponse) String() string { return proto.CompactTextString(m) } +func (*MsgPayPacketFeeResponse) ProtoMessage() {} +func (*MsgPayPacketFeeResponse) Descriptor() ([]byte, []int) { return fileDescriptor_05c93128649f1b96, []int{3} } -func (m *MsgEscrowPacketFeeResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgPayPacketFeeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgEscrowPacketFeeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgPayPacketFeeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgEscrowPacketFeeResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgPayPacketFeeResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -171,58 +179,147 @@ func (m *MsgEscrowPacketFeeResponse) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } -func (m *MsgEscrowPacketFeeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgEscrowPacketFeeResponse.Merge(m, src) +func (m *MsgPayPacketFeeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPayPacketFeeResponse.Merge(m, src) } -func (m *MsgEscrowPacketFeeResponse) XXX_Size() int { +func (m *MsgPayPacketFeeResponse) XXX_Size() int { return m.Size() } -func (m *MsgEscrowPacketFeeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgEscrowPacketFeeResponse.DiscardUnknown(m) +func (m *MsgPayPacketFeeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPayPacketFeeResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgEscrowPacketFeeResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgPayPacketFeeResponse proto.InternalMessageInfo + +// MsgPayPacketFeeAsync defines the request type PayPacketFeeAsync RPC +// This Msg can be used to pay for a packet at a specified sequence (instead of the next sequence send) +type MsgPayPacketFeeAsync struct { + // packet to pay fee for + IdentifiedPacketFee IdentifiedPacketFee `protobuf:"bytes,1,opt,name=identified_packet_fee,json=identifiedPacketFee,proto3" json:"identified_packet_fee" yaml:"identified_packet_fee"` + // account address to refund fee if necessary + Signer string `protobuf:"bytes,2,opt,name=signer,proto3" json:"signer,omitempty"` +} + +func (m *MsgPayPacketFeeAsync) Reset() { *m = MsgPayPacketFeeAsync{} } +func (m *MsgPayPacketFeeAsync) String() string { return proto.CompactTextString(m) } +func (*MsgPayPacketFeeAsync) ProtoMessage() {} +func (*MsgPayPacketFeeAsync) Descriptor() ([]byte, []int) { + return fileDescriptor_05c93128649f1b96, []int{4} +} +func (m *MsgPayPacketFeeAsync) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPayPacketFeeAsync) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPayPacketFeeAsync.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgPayPacketFeeAsync) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPayPacketFeeAsync.Merge(m, src) +} +func (m *MsgPayPacketFeeAsync) XXX_Size() int { + return m.Size() +} +func (m *MsgPayPacketFeeAsync) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPayPacketFeeAsync.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPayPacketFeeAsync proto.InternalMessageInfo + +// MsgPayPacketFeeAsyncResponse defines the response type for Msg/PayPacketFeeAsync +type MsgPayPacketFeeAsyncResponse struct { +} + +func (m *MsgPayPacketFeeAsyncResponse) Reset() { *m = MsgPayPacketFeeAsyncResponse{} } +func (m *MsgPayPacketFeeAsyncResponse) String() string { return proto.CompactTextString(m) } +func (*MsgPayPacketFeeAsyncResponse) ProtoMessage() {} +func (*MsgPayPacketFeeAsyncResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_05c93128649f1b96, []int{5} +} +func (m *MsgPayPacketFeeAsyncResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgPayPacketFeeAsyncResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgPayPacketFeeAsyncResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgPayPacketFeeAsyncResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgPayPacketFeeAsyncResponse.Merge(m, src) +} +func (m *MsgPayPacketFeeAsyncResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgPayPacketFeeAsyncResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgPayPacketFeeAsyncResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgPayPacketFeeAsyncResponse proto.InternalMessageInfo func init() { proto.RegisterType((*MsgRegisterCounterpartyAddress)(nil), "ibc.applications.fee.v1.MsgRegisterCounterpartyAddress") 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") + proto.RegisterType((*MsgPayPacketFee)(nil), "ibc.applications.fee.v1.MsgPayPacketFee") + proto.RegisterType((*MsgPayPacketFeeResponse)(nil), "ibc.applications.fee.v1.MsgPayPacketFeeResponse") + proto.RegisterType((*MsgPayPacketFeeAsync)(nil), "ibc.applications.fee.v1.MsgPayPacketFeeAsync") + proto.RegisterType((*MsgPayPacketFeeAsyncResponse)(nil), "ibc.applications.fee.v1.MsgPayPacketFeeAsyncResponse") } func init() { proto.RegisterFile("ibc/applications/fee/v1/tx.proto", fileDescriptor_05c93128649f1b96) } var fileDescriptor_05c93128649f1b96 = []byte{ - // 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, 0x41, 0x72, 0xf4, 0x52, 0x26, 0x93, - 0xb7, 0xd3, 0xc1, 0x6c, 0x26, 0xcc, 0x9b, 0x5d, 0x5d, 0xc1, 0xbb, 0x47, 0x0f, 0x82, 0x1e, 0xfb, - 0x35, 0xfc, 0x06, 0x1e, 0x7b, 0xf4, 0x54, 0x64, 0xf7, 0xe2, 0xb9, 0x9f, 0x40, 0x66, 0x63, 0x4a, - 0x68, 0x77, 0x17, 0xf4, 0xf6, 0x26, 0xf3, 0xfb, 0xbf, 0x79, 0xff, 0x7f, 0x78, 0x64, 0x4f, 0x65, - 0x82, 0xf1, 0xaa, 0x2a, 0x94, 0xe0, 0x56, 0xe9, 0x12, 0xd9, 0x00, 0x80, 0x8d, 0x0f, 0x98, 0x7d, - 0x9f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 0xce, 0xa3, 0xa0, 0xf6, 0xb2, 0xa0, 0x65, 0x9c, 0xd2, - 0xf6, 0xd7, 0x5a, 0x46, 0x03, 0xb2, 0x61, 0xa0, 0xe0, 0x13, 0x30, 0x2e, 0x91, 0xf5, 0xce, 0x66, - 0x7a, 0x79, 0x6e, 0xb9, 0xbc, 0x4b, 0x82, 0xeb, 0xa3, 0x37, 0xce, 0xba, 0x5f, 0xd6, 0xc8, 0x7a, - 0x1f, 0x25, 0xfd, 0xea, 0x93, 0xdd, 0x55, 0xff, 0xe8, 0xd1, 0x52, 0x37, 0xab, 0x23, 0x0c, 0x9e, - 0xfc, 0xa7, 0xb0, 0x99, 0x90, 0x22, 0xb9, 0x7d, 0x35, 0xf7, 0x07, 0xab, 0x7a, 0x5e, 0x81, 0x83, - 0xc3, 0x7f, 0x80, 0x9b, 0x47, 0x7b, 0xaf, 0x7e, 0x4c, 0x43, 0xff, 0x6c, 0x1a, 0xfa, 0xbf, 0xa6, - 0xa1, 0xff, 0x79, 0x16, 0x7a, 0x67, 0xb3, 0xd0, 0xfb, 0x39, 0x0b, 0xbd, 0x37, 0x5d, 0xa9, 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, + // 589 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0x4f, 0x6f, 0xd3, 0x3e, + 0x18, 0xc7, 0x93, 0x75, 0xbf, 0xfd, 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 0xc2, 0x00, 0x78, 0x73, 0x2d, 0xfe, 0xb4, 0x5e, 0xfd, + 0x09, 0x00, 0x00, 0xff, 0xff, 0xa7, 0xcb, 0x98, 0x2b, 0x4d, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -243,10 +340,14 @@ type MsgClient interface { // 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) - // 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. - EscrowPacketFee(ctx context.Context, in *MsgEscrowPacketFee, opts ...grpc.CallOption) (*MsgEscrowPacketFeeResponse, error) + // PayPacketFee defines a rpc handler method for MsgPayPacketFee + // PayPacketFee 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 packet at the next sequence + PayPacketFee(ctx context.Context, in *MsgPayPacketFee, opts ...grpc.CallOption) (*MsgPayPacketFeeResponse, error) + // PayPacketFeeAsync defines a rpc handler method for MsgPayPacketFeeAsync + // PayPacketFeeAsync is an open callback that may be called by any module/user that wishes to escrow funds in order to + // incentivize the relaying of a known packet + PayPacketFeeAsync(ctx context.Context, in *MsgPayPacketFeeAsync, opts ...grpc.CallOption) (*MsgPayPacketFeeAsyncResponse, error) } type msgClient struct { @@ -266,9 +367,18 @@ func (c *msgClient) RegisterCounterpartyAddress(ctx context.Context, in *MsgRegi return out, nil } -func (c *msgClient) EscrowPacketFee(ctx context.Context, in *MsgEscrowPacketFee, opts ...grpc.CallOption) (*MsgEscrowPacketFeeResponse, error) { - out := new(MsgEscrowPacketFeeResponse) - err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Msg/EscrowPacketFee", in, out, opts...) +func (c *msgClient) PayPacketFee(ctx context.Context, in *MsgPayPacketFee, opts ...grpc.CallOption) (*MsgPayPacketFeeResponse, error) { + out := new(MsgPayPacketFeeResponse) + err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Msg/PayPacketFee", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) PayPacketFeeAsync(ctx context.Context, in *MsgPayPacketFeeAsync, opts ...grpc.CallOption) (*MsgPayPacketFeeAsyncResponse, error) { + out := new(MsgPayPacketFeeAsyncResponse) + err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Msg/PayPacketFeeAsync", in, out, opts...) if err != nil { return nil, err } @@ -283,10 +393,14 @@ type MsgServer interface { // 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) - // 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. - EscrowPacketFee(context.Context, *MsgEscrowPacketFee) (*MsgEscrowPacketFeeResponse, error) + // PayPacketFee defines a rpc handler method for MsgPayPacketFee + // PayPacketFee 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 packet at the next sequence + PayPacketFee(context.Context, *MsgPayPacketFee) (*MsgPayPacketFeeResponse, error) + // PayPacketFeeAsync defines a rpc handler method for MsgPayPacketFeeAsync + // PayPacketFeeAsync is an open callback that may be called by any module/user that wishes to escrow funds in order to + // incentivize the relaying of a known packet + PayPacketFeeAsync(context.Context, *MsgPayPacketFeeAsync) (*MsgPayPacketFeeAsyncResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -296,8 +410,11 @@ 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) EscrowPacketFee(ctx context.Context, req *MsgEscrowPacketFee) (*MsgEscrowPacketFeeResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method EscrowPacketFee not implemented") +func (*UnimplementedMsgServer) PayPacketFee(ctx context.Context, req *MsgPayPacketFee) (*MsgPayPacketFeeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PayPacketFee not implemented") +} +func (*UnimplementedMsgServer) PayPacketFeeAsync(ctx context.Context, req *MsgPayPacketFeeAsync) (*MsgPayPacketFeeAsyncResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method PayPacketFeeAsync not implemented") } func RegisterMsgServer(s grpc1.Server, srv MsgServer) { @@ -322,20 +439,38 @@ func _Msg_RegisterCounterpartyAddress_Handler(srv interface{}, ctx context.Conte return interceptor(ctx, in, info, handler) } -func _Msg_EscrowPacketFee_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgEscrowPacketFee) +func _Msg_PayPacketFee_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgPayPacketFee) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).EscrowPacketFee(ctx, in) + return srv.(MsgServer).PayPacketFee(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ibc.applications.fee.v1.Msg/EscrowPacketFee", + FullMethod: "/ibc.applications.fee.v1.Msg/PayPacketFee", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).EscrowPacketFee(ctx, req.(*MsgEscrowPacketFee)) + return srv.(MsgServer).PayPacketFee(ctx, req.(*MsgPayPacketFee)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_PayPacketFeeAsync_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgPayPacketFeeAsync) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).PayPacketFeeAsync(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.applications.fee.v1.Msg/PayPacketFeeAsync", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).PayPacketFeeAsync(ctx, req.(*MsgPayPacketFeeAsync)) } return interceptor(ctx, in, info, handler) } @@ -349,8 +484,12 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Handler: _Msg_RegisterCounterpartyAddress_Handler, }, { - MethodName: "EscrowPacketFee", - Handler: _Msg_EscrowPacketFee_Handler, + MethodName: "PayPacketFee", + Handler: _Msg_PayPacketFee_Handler, + }, + { + MethodName: "PayPacketFeeAsync", + Handler: _Msg_PayPacketFeeAsync_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -417,7 +556,7 @@ func (m *MsgRegisterCounterpartyAddressResponse) MarshalToSizedBuffer(dAtA []byt return len(dAtA) - i, nil } -func (m *MsgEscrowPacketFee) Marshal() (dAtA []byte, err error) { +func (m *MsgPayPacketFee) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -427,12 +566,12 @@ func (m *MsgEscrowPacketFee) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgEscrowPacketFee) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgPayPacketFee) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgEscrowPacketFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgPayPacketFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -443,25 +582,107 @@ func (m *MsgEscrowPacketFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Relayers[iNdEx]) i = encodeVarintTx(dAtA, i, uint64(len(m.Relayers[iNdEx]))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x2a } } - if m.IncentivizedPacket != nil { - { - size, err := m.IncentivizedPacket.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) + i-- + dAtA[i] = 0x22 + } + if len(m.SourceChannelId) > 0 { + i -= len(m.SourceChannelId) + copy(dAtA[i:], m.SourceChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.SourceChannelId))) + i-- + dAtA[i] = 0x1a + } + if len(m.SourcePortId) > 0 { + i -= len(m.SourcePortId) + copy(dAtA[i:], m.SourcePortId) + i = encodeVarintTx(dAtA, i, uint64(len(m.SourcePortId))) + i-- + dAtA[i] = 0x12 + } + { + size, err := m.Fee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *MsgPayPacketFeeResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgPayPacketFeeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPayPacketFeeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgPayPacketFeeAsync) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgPayPacketFeeAsync) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgPayPacketFeeAsync) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signer) > 0 { + i -= len(m.Signer) + copy(dAtA[i:], m.Signer) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 } + { + size, err := m.IdentifiedPacketFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } -func (m *MsgEscrowPacketFeeResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgPayPacketFeeAsyncResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -471,12 +692,12 @@ func (m *MsgEscrowPacketFeeResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgEscrowPacketFeeResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgPayPacketFeeAsyncResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgEscrowPacketFeeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgPayPacketFeeAsyncResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -521,14 +742,24 @@ func (m *MsgRegisterCounterpartyAddressResponse) Size() (n int) { return n } -func (m *MsgEscrowPacketFee) Size() (n int) { +func (m *MsgPayPacketFee) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.IncentivizedPacket != nil { - l = m.IncentivizedPacket.Size() + l = m.Fee.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.SourcePortId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.SourceChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Signer) + if l > 0 { n += 1 + l + sovTx(uint64(l)) } if len(m.Relayers) > 0 { @@ -540,7 +771,31 @@ func (m *MsgEscrowPacketFee) Size() (n int) { return n } -func (m *MsgEscrowPacketFeeResponse) Size() (n int) { +func (m *MsgPayPacketFeeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgPayPacketFeeAsync) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.IdentifiedPacketFee.Size() + n += 1 + l + sovTx(uint64(l)) + l = len(m.Signer) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgPayPacketFeeAsyncResponse) Size() (n int) { if m == nil { return 0 } @@ -719,7 +974,7 @@ func (m *MsgRegisterCounterpartyAddressResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgEscrowPacketFee) Unmarshal(dAtA []byte) error { +func (m *MsgPayPacketFee) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -742,15 +997,15 @@ func (m *MsgEscrowPacketFee) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgEscrowPacketFee: wiretype end group for non-group") + return fmt.Errorf("proto: MsgPayPacketFee: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgEscrowPacketFee: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgPayPacketFee: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field IncentivizedPacket", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -777,14 +1032,107 @@ func (m *MsgEscrowPacketFee) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.IncentivizedPacket == nil { - m.IncentivizedPacket = &IdentifiedPacketFee{} - } - if err := m.IncentivizedPacket.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Fee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourcePortId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SourcePortId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SourceChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SourceChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Relayers", wireType) } @@ -837,7 +1185,172 @@ func (m *MsgEscrowPacketFee) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgEscrowPacketFeeResponse) Unmarshal(dAtA []byte) error { +func (m *MsgPayPacketFeeResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgPayPacketFeeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPayPacketFeeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgPayPacketFeeAsync) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgPayPacketFeeAsync: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgPayPacketFeeAsync: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IdentifiedPacketFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.IdentifiedPacketFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgPayPacketFeeAsyncResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -860,10 +1373,10 @@ func (m *MsgEscrowPacketFeeResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgEscrowPacketFeeResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgPayPacketFeeAsyncResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgEscrowPacketFeeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgPayPacketFeeAsyncResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: diff --git a/proto/ibc/applications/fee/v1/fee.proto b/proto/ibc/applications/fee/v1/fee.proto index 888ade35acb..121eae2dca4 100644 --- a/proto/ibc/applications/fee/v1/fee.proto +++ b/proto/ibc/applications/fee/v1/fee.proto @@ -10,15 +10,25 @@ option go_package = "github.com/cosmos/ibc-go/modules/apps/29-fee/types"; // See Fee Payment Middleware spec: // https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middleware-contract message Fee { - repeated cosmos.base.v1beta1.Coin amount = 1 - [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + repeated cosmos.base.v1beta1.Coin receive_fee = 1 [ + (gogoproto.moretags) = "yaml:\"receive_fee\"", + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + repeated cosmos.base.v1beta1.Coin ack_fee = 2 [ + (gogoproto.moretags) = "yaml:\"ack_fee\"", + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + repeated cosmos.base.v1beta1.Coin timeout_fee = 3 [ + (gogoproto.moretags) = "yaml:\"timeout_fee\"", + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; } - // Fee associated with a packet_id message IdentifiedPacketFee { - ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.moretags) = "yaml:\"packet_id\""]; - Fee receive_fee = 2 [(gogoproto.moretags) = "yaml:\"receive_fee\""]; - Fee ack_fee = 3 [(gogoproto.moretags) = "yaml:\"ack_fee\""]; - Fee timeout_fee = 4 [(gogoproto.moretags) = "yaml:\"timeout_fee\""]; - repeated string relayers = 5; + ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.moretags) = "yaml:\"packet_id\""]; + Fee fee = 2 [(gogoproto.nullable) = false]; + repeated string relayers = 3; } diff --git a/proto/ibc/applications/fee/v1/genesis.proto b/proto/ibc/applications/fee/v1/genesis.proto index 373fd7786c4..4006b5fdc9d 100644 --- a/proto/ibc/applications/fee/v1/genesis.proto +++ b/proto/ibc/applications/fee/v1/genesis.proto @@ -7,7 +7,5 @@ option go_package = "github.com/cosmos/ibc-go/modules/apps/29-fee/types"; // GenesisState defines the fee middleware genesis state message GenesisState { - // A mapping of packets -> escrowed fees - repeated ibc.applications.fee.v1.IdentifiedPacketFee packets_fees = 1 - [(gogoproto.moretags) = "yaml:\"packets_fees\""]; + // TODO } diff --git a/proto/ibc/applications/fee/v1/tx.proto b/proto/ibc/applications/fee/v1/tx.proto index f9b56cf5011..31163483d4d 100644 --- a/proto/ibc/applications/fee/v1/tx.proto +++ b/proto/ibc/applications/fee/v1/tx.proto @@ -15,10 +15,14 @@ service Msg { // 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); - // 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. - rpc EscrowPacketFee(MsgEscrowPacketFee) returns (MsgEscrowPacketFeeResponse); + // PayPacketFee defines a rpc handler method for MsgPayPacketFee + // PayPacketFee 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 packet at the next sequence + rpc PayPacketFee(MsgPayPacketFee) returns (MsgPayPacketFeeResponse); + // PayPacketFeeAsync defines a rpc handler method for MsgPayPacketFeeAsync + // PayPacketFeeAsync is an open callback that may be called by any module/user that wishes to escrow funds in order to + // incentivize the relaying of a known packet + rpc PayPacketFeeAsync(MsgPayPacketFeeAsync) returns (MsgPayPacketFeeAsyncResponse); } // MsgRegisterCounterpartyAddress is the request type for registering the counter party address @@ -33,15 +37,38 @@ message MsgRegisterCounterpartyAddress { // MsgRegisterCounterpartyAddressResponse defines the Msg/RegisterCounterypartyAddress response type message MsgRegisterCounterpartyAddressResponse {} -// MsgEscrowPacketFee defines the request type EscrowPacketFee RPC -message MsgEscrowPacketFee { +// MsgPayPacketFee defines the request type PayPacketFee RPC +// This Msg can be used to pay for a packet at the next sequence send & should be combined with the Msg that will be +// paid for +message MsgPayPacketFee { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - ibc.applications.fee.v1.IdentifiedPacketFee incentivized_packet = 1 - [(gogoproto.moretags) = "yaml:\"incentivized_packet\""]; - repeated string relayers = 2; + ibc.applications.fee.v1.Fee fee = 1 [(gogoproto.nullable) = false]; + // source channel port identifier + string source_port_id = 2 [(gogoproto.moretags) = "yaml:\"source_port_id\""]; + // source channel unique identifier + string source_channel_id = 3 [(gogoproto.moretags) = "yaml:\"source_channel_id\""]; + // account address to refund fee if necessary + string signer = 4; + repeated string relayers = 5; } -// MsgEscrowPacketFeeResponse defines the response type for Msg/EscrowPacketFee -message MsgEscrowPacketFeeResponse {} +// MsgPayPacketFeeResponse defines the response type for Msg/PayPacketFee +message MsgPayPacketFeeResponse {} + +// MsgPayPacketFeeAsync defines the request type PayPacketFeeAsync RPC +// This Msg can be used to pay for a packet at a specified sequence (instead of the next sequence send) +message MsgPayPacketFeeAsync { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // packet to pay fee for + ibc.applications.fee.v1.IdentifiedPacketFee identified_packet_fee = 1 + [(gogoproto.moretags) = "yaml:\"identified_packet_fee\"", (gogoproto.nullable) = false]; + // account address to refund fee if necessary + string signer = 2; +} + +// MsgPayPacketFeeAsyncResponse defines the response type for Msg/PayPacketFeeAsync +message MsgPayPacketFeeAsyncResponse {} diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 83cdf6ff2a7..58b2a79006d 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -147,6 +147,7 @@ var ( stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, govtypes.ModuleName: {authtypes.Burner}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + ibcfeetypes.ModuleName: nil, } ) @@ -322,7 +323,7 @@ func NewSimApp( ) app.IBCFeeKeeper = ibcfeekeeper.NewKeeper(appCodec, keys[ibcfeetypes.StoreKey], app.GetSubspace(ibcfeetypes.ModuleName), - app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, + app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper, ) // Create Transfer Keeper and pass IBCFeeKeeper as expected Channel and PortKeeper From 405f193d356db8a4d3ac29263a29a5787c1a0614 Mon Sep 17 00:00:00 2001 From: Charly Date: Wed, 10 Nov 2021 16:44:32 +0100 Subject: [PATCH 08/79] feat: update protos, grpc queries (#488) --- docs/ibc/proto-docs.md | 102 +- modules/apps/29-fee/keeper/grpc_query.go | 64 +- modules/apps/29-fee/keeper/grpc_query_test.go | 151 ++ modules/apps/29-fee/keeper/keeper_test.go | 8 +- modules/apps/29-fee/types/keys.go | 6 +- modules/apps/29-fee/types/msgs.go | 4 + modules/apps/29-fee/types/query.pb.go | 1598 +---------------- modules/apps/29-fee/types/query.pb.gw.go | 480 ----- proto/ibc/applications/fee/v1/query.proto | 69 +- 9 files changed, 323 insertions(+), 2159 deletions(-) create mode 100644 modules/apps/29-fee/keeper/grpc_query_test.go diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 52f2a145f8f..562bb7f718d 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -33,16 +33,10 @@ - [GenesisState](#ibc.applications.fee.v1.GenesisState) - [ibc/applications/fee/v1/query.proto](#ibc/applications/fee/v1/query.proto) - - [QueryAckFeeRequest](#ibc.applications.fee.v1.QueryAckFeeRequest) - - [QueryAckFeeResponse](#ibc.applications.fee.v1.QueryAckFeeResponse) - [QueryIncentivizedPacketRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketRequest) - [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) - [QueryIncentivizedPacketsRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsRequest) - [QueryIncentivizedPacketsResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsResponse) - - [QueryReceiveFeeRequest](#ibc.applications.fee.v1.QueryReceiveFeeRequest) - - [QueryReceiveFeeResponse](#ibc.applications.fee.v1.QueryReceiveFeeResponse) - - [QueryTimeoutFeeRequest](#ibc.applications.fee.v1.QueryTimeoutFeeRequest) - - [QueryTimeoutFeeResponse](#ibc.applications.fee.v1.QueryTimeoutFeeResponse) - [Query](#ibc.applications.fee.v1.Query) @@ -698,38 +692,6 @@ GenesisState defines the fee middleware genesis state - - -### QueryAckFeeRequest -QueryAckFeeRequest is the request type for querying the acknowledgement fee - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | PacketID | -| `relayer_address` | [string](#string) | | Caller should provide the intended relayer address in case the fee is dependent on specific relayer(s). | -| `query_height` | [uint64](#uint64) | | Height to query at | - - - - - - - - -### QueryAckFeeResponse -QueryAckFeeResponse is the response type for the AckFee RPC - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | - - - - - - ### QueryIncentivizedPacketRequest @@ -791,75 +753,73 @@ QueryIncentivizedPacketsResponse is the response type for the incentivized packe + - - -### QueryReceiveFeeRequest -QueryReceiveFeeRequest is the request type for querying the receive fee - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | PacketID | -| `relayer_address` | [string](#string) | | Caller should provide the intended relayer address in case the fee is dependent on specific relayer(s). | -| `query_height` | [uint64](#uint64) | | Height to query at | - - + + + - +### Query +Query provides defines the gRPC querier service. -### QueryReceiveFeeResponse -QueryReceiveFeeResponse is the response type for the ReceiveFee RPC +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `IncentivizedPackets` | [QueryIncentivizedPacketsRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsRequest) | [QueryIncentivizedPacketsResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsResponse) | Gets all incentivized packets | GET|/ibc/apps/fee/v1/incentivized_packets| +| `IncentivizedPacket` | [QueryIncentivizedPacketRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketRequest) | [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) | Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the given packet | GET|/ibc/apps/fee/v1/incentivized_packet/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | + +

Top

+## ibc/applications/fee/v1/tx.proto - + -### QueryTimeoutFeeRequest -QueryTimeoutFeeRequest is the request type for querying the timeout fee +### MsgPayPacketFee +MsgPayPacketFee defines the request type EscrowPacketFee RPC +This Msg can be used to pay for a packet at the next sequence send & should be combined with the Msg that will be +paid for | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | PacketID | -| `relayer_address` | [string](#string) | | Caller should provide the intended relayer address in case the fee is dependent on specific relayer(s). | -| `query_height` | [uint64](#uint64) | | Height to query at | +| `fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | +| `source_port_id` | [string](#string) | | source channel port identifier | +| `source_channel_id` | [string](#string) | | source channel unique identifier | +| `signer` | [string](#string) | | account address to refund fee if necessary | +| `relayers` | [string](#string) | repeated | | - + -### QueryTimeoutFeeResponse -QueryTimeoutFeeResponse is the response type for the timeout RPC +### MsgPayPacketFeeAsync +MsgPayPacketFeeAsync defines the request type PayPacketFeeAsync RPC +This Msg can be used to pay for a packet at a specified sequence (instead of the next sequence send) | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | +| `identified_packet_fee` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | | packet to pay fee for | +| `signer` | [string](#string) | | account address to refund fee if necessary | - - - - + diff --git a/modules/apps/29-fee/keeper/grpc_query.go b/modules/apps/29-fee/keeper/grpc_query.go index 185ad775c93..5c9a8037ab7 100644 --- a/modules/apps/29-fee/keeper/grpc_query.go +++ b/modules/apps/29-fee/keeper/grpc_query.go @@ -1,5 +1,65 @@ package keeper -// TODO +import ( + "context" -//var _ types.QueryServer = Keeper{} + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/query" + + "github.com/cosmos/ibc-go/modules/apps/29-fee/types" +) + +var _ types.QueryServer = Keeper{} + +// IncentivizedPackets implements the IncentivizedPackets gRPC method +func (k Keeper) IncentivizedPackets(c context.Context, req *types.QueryIncentivizedPacketsRequest) (*types.QueryIncentivizedPacketsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(c).WithBlockHeight(int64(req.QueryHeight)) + + var packets []*types.IdentifiedPacketFee + store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.FeeInEscrowPrefix)) + _, err := query.Paginate(store, req.Pagination, func(_, value []byte) error { + result := k.MustUnmarshalFee(value) + packets = append(packets, &result) + return nil + }) + + if err != nil { + return nil, status.Error( + codes.NotFound, err.Error(), + ) + } + + return &types.QueryIncentivizedPacketsResponse{ + IncentivizedPackets: packets, + }, nil +} + +// IncentivizedPacket implements the IncentivizedPacket gRPC method +func (k Keeper) IncentivizedPacket(c context.Context, req *types.QueryIncentivizedPacketRequest) (*types.QueryIncentivizedPacketResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(c).WithBlockHeight(int64(req.QueryHeight)) + + fee, exists := k.GetFeeInEscrow(ctx, req.PacketId) + if !exists { + return nil, status.Error( + codes.NotFound, + sdkerrors.Wrap(types.ErrFeeNotFound, req.PacketId.String()).Error(), + ) + } + + return &types.QueryIncentivizedPacketResponse{ + IncentivizedPacket: &fee, + }, nil +} diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go new file mode 100644 index 00000000000..c1eb27f2fcc --- /dev/null +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -0,0 +1,151 @@ +package keeper_test + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + + "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + ibctesting "github.com/cosmos/ibc-go/testing" +) + +func (suite *KeeperTestSuite) TestQueryIncentivizedPacket() { + + var ( + req *types.QueryIncentivizedPacketRequest + ) + + // setup + validPacketId := types.NewPacketId(ibctesting.FirstChannelID, 1) + invalidPacketId := types.NewPacketId(ibctesting.FirstChannelID, 2) + identifiedPacketFee := types.NewIdentifiedPacketFee( + validPacketId, + types.Fee{ + AckFee: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + ReceiveFee: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + TimeoutFee: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + }, + []string(nil), + ) + + testCases := []struct { + name string + malleate func() + expPass bool + }{ + { + "success", + func() { + req = &types.QueryIncentivizedPacketRequest{ + PacketId: validPacketId, + QueryHeight: 0, + } + }, + true, + }, + { + "packetId not found", + func() { + req = &types.QueryIncentivizedPacketRequest{ + PacketId: invalidPacketId, + QueryHeight: 0, + } + }, + false, + }, + } + + for _, tc := range testCases { + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + refundAcc := suite.chainA.SenderAccount.GetAddress() + + tc.malleate() + ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) + suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), refundAcc, identifiedPacketFee) + res, err := suite.queryClient.IncentivizedPacket(ctx, req) + + if tc.expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(identifiedPacketFee, res.IncentivizedPacket) + } else { + suite.Require().Error(err) + } + }) + } +} + +func (suite *KeeperTestSuite) TestQueryIncentivizedPackets() { + var ( + req *types.QueryIncentivizedPacketsRequest + expPackets []*types.IdentifiedPacketFee + ) + + fee := types.Fee{ + AckFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}}, + ReceiveFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}}, + TimeoutFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}}, + } + + testCases := []struct { + msg string + malleate func() + expPass bool + }{ + { + "empty pagination", + func() { + req = &types.QueryIncentivizedPacketsRequest{} + }, + true, + }, + { + "success", + func() { + refundAcc := suite.chainA.SenderAccount.GetAddress() + + fee1 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, 1), fee, []string(nil)) + fee2 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, 2), fee, []string(nil)) + fee3 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, 3), fee, []string(nil)) + + expPackets = []*types.IdentifiedPacketFee{} + expPackets = append(expPackets, fee1, fee2, fee3) + + for _, p := range expPackets { + suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), refundAcc, p) + } + + req = &types.QueryIncentivizedPacketsRequest{ + Pagination: &query.PageRequest{ + Limit: 5, + CountTotal: false, + }, + QueryHeight: 0, + } + }, + true, + }, + } + + for _, tc := range testCases { + suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { + suite.SetupTest() // reset + tc.malleate() + ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) + + res, err := suite.queryClient.IncentivizedPackets(ctx, req) + + if tc.expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + fmt.Println(expPackets) + suite.Require().Equal(expPackets, res.IncentivizedPackets) + } else { + suite.Require().Error(err) + } + }) + } +} diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index ab4ce879a29..476a14698b0 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/suite" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/ibc-go/modules/apps/29-fee/types" transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" @@ -20,7 +21,8 @@ type KeeperTestSuite struct { chainA *ibctesting.TestChain chainB *ibctesting.TestChain - path *ibctesting.Path + path *ibctesting.Path + queryClient types.QueryClient } func (suite *KeeperTestSuite) SetupTest() { @@ -35,6 +37,10 @@ func (suite *KeeperTestSuite) SetupTest() { path.EndpointA.ChannelConfig.PortID = transfertypes.PortID path.EndpointB.ChannelConfig.PortID = transfertypes.PortID suite.path = path + + queryHelper := baseapp.NewQueryServerTestHelper(suite.chainA.GetContext(), suite.chainA.GetSimApp().InterfaceRegistry()) + types.RegisterQueryServer(queryHelper, suite.chainA.GetSimApp().IBCFeeKeeper) + suite.queryClient = types.NewQueryClient(queryHelper) } func SetupFeePath(path *ibctesting.Path) error { diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index 174168a32b0..3df1f637a6c 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -10,16 +10,16 @@ const ( // ModuleName defines the 29-fee name ModuleName = "feeibc" - // StoreKey is the store key string for IBC transfer + // StoreKey is the store key string for IBC fee module StoreKey = ModuleName // PortKey is the port id that is wrapped by fee middleware PortKey = "feetransfer" - // RouterKey is the message route for IBC transfer + // RouterKey is the message route for IBC fee module RouterKey = ModuleName - // QuerierRoute is the querier route for IBC transfer + // QuerierRoute is the querier route for IBC fee module QuerierRoute = ModuleName Version = "fee29-1" diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index ef9e49901fd..2c212da21bc 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -169,3 +169,7 @@ func NewIdentifiedPacketFee(packetId *channeltypes.PacketId, fee Fee, relayers [ Relayers: relayers, } } + +func NewPacketId(channelId string, id uint64) *channeltypes.PacketId { + return &channeltypes.PacketId{ChannelId: channelId, PortId: PortKey, Sequence: id} +} diff --git a/modules/apps/29-fee/types/query.pb.go b/modules/apps/29-fee/types/query.pb.go index dfc07f81fee..99f961652a4 100644 --- a/modules/apps/29-fee/types/query.pb.go +++ b/modules/apps/29-fee/types/query.pb.go @@ -31,333 +31,6 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// QueryReceiveFeeRequest is the request type for querying the receive fee -type QueryReceiveFeeRequest struct { - // PacketID - PacketId *types.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id,omitempty"` - // Caller should provide the intended relayer address in case the fee is dependent on specific relayer(s). - RelayerAddress string `protobuf:"bytes,2,opt,name=relayer_address,json=relayerAddress,proto3" json:"relayer_address,omitempty"` - // Height to query at - QueryHeight uint64 `protobuf:"varint,3,opt,name=query_height,json=queryHeight,proto3" json:"query_height,omitempty"` -} - -func (m *QueryReceiveFeeRequest) Reset() { *m = QueryReceiveFeeRequest{} } -func (m *QueryReceiveFeeRequest) String() string { return proto.CompactTextString(m) } -func (*QueryReceiveFeeRequest) ProtoMessage() {} -func (*QueryReceiveFeeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_0638a8a78ca2503c, []int{0} -} -func (m *QueryReceiveFeeRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryReceiveFeeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryReceiveFeeRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryReceiveFeeRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryReceiveFeeRequest.Merge(m, src) -} -func (m *QueryReceiveFeeRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryReceiveFeeRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryReceiveFeeRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryReceiveFeeRequest proto.InternalMessageInfo - -func (m *QueryReceiveFeeRequest) GetPacketId() *types.PacketId { - if m != nil { - return m.PacketId - } - return nil -} - -func (m *QueryReceiveFeeRequest) GetRelayerAddress() string { - if m != nil { - return m.RelayerAddress - } - return "" -} - -func (m *QueryReceiveFeeRequest) GetQueryHeight() uint64 { - if m != nil { - return m.QueryHeight - } - return 0 -} - -// QueryReceiveFeeResponse is the response type for the ReceiveFee RPC -type QueryReceiveFeeResponse struct { - Fee *Fee `protobuf:"bytes,1,opt,name=fee,proto3" json:"fee,omitempty"` -} - -func (m *QueryReceiveFeeResponse) Reset() { *m = QueryReceiveFeeResponse{} } -func (m *QueryReceiveFeeResponse) String() string { return proto.CompactTextString(m) } -func (*QueryReceiveFeeResponse) ProtoMessage() {} -func (*QueryReceiveFeeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_0638a8a78ca2503c, []int{1} -} -func (m *QueryReceiveFeeResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryReceiveFeeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryReceiveFeeResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryReceiveFeeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryReceiveFeeResponse.Merge(m, src) -} -func (m *QueryReceiveFeeResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryReceiveFeeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryReceiveFeeResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryReceiveFeeResponse proto.InternalMessageInfo - -func (m *QueryReceiveFeeResponse) GetFee() *Fee { - if m != nil { - return m.Fee - } - return nil -} - -// QueryAckFeeRequest is the request type for querying the acknowledgement fee -type QueryAckFeeRequest struct { - // PacketID - PacketId *types.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id,omitempty"` - // Caller should provide the intended relayer address in case the fee is dependent on specific relayer(s). - RelayerAddress string `protobuf:"bytes,2,opt,name=relayer_address,json=relayerAddress,proto3" json:"relayer_address,omitempty"` - // Height to query at - QueryHeight uint64 `protobuf:"varint,3,opt,name=query_height,json=queryHeight,proto3" json:"query_height,omitempty"` -} - -func (m *QueryAckFeeRequest) Reset() { *m = QueryAckFeeRequest{} } -func (m *QueryAckFeeRequest) String() string { return proto.CompactTextString(m) } -func (*QueryAckFeeRequest) ProtoMessage() {} -func (*QueryAckFeeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_0638a8a78ca2503c, []int{2} -} -func (m *QueryAckFeeRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAckFeeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAckFeeRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryAckFeeRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAckFeeRequest.Merge(m, src) -} -func (m *QueryAckFeeRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryAckFeeRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAckFeeRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryAckFeeRequest proto.InternalMessageInfo - -func (m *QueryAckFeeRequest) GetPacketId() *types.PacketId { - if m != nil { - return m.PacketId - } - return nil -} - -func (m *QueryAckFeeRequest) GetRelayerAddress() string { - if m != nil { - return m.RelayerAddress - } - return "" -} - -func (m *QueryAckFeeRequest) GetQueryHeight() uint64 { - if m != nil { - return m.QueryHeight - } - return 0 -} - -// QueryAckFeeResponse is the response type for the AckFee RPC -type QueryAckFeeResponse struct { - Fee *Fee `protobuf:"bytes,1,opt,name=fee,proto3" json:"fee,omitempty"` -} - -func (m *QueryAckFeeResponse) Reset() { *m = QueryAckFeeResponse{} } -func (m *QueryAckFeeResponse) String() string { return proto.CompactTextString(m) } -func (*QueryAckFeeResponse) ProtoMessage() {} -func (*QueryAckFeeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_0638a8a78ca2503c, []int{3} -} -func (m *QueryAckFeeResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryAckFeeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryAckFeeResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryAckFeeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryAckFeeResponse.Merge(m, src) -} -func (m *QueryAckFeeResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryAckFeeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryAckFeeResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryAckFeeResponse proto.InternalMessageInfo - -func (m *QueryAckFeeResponse) GetFee() *Fee { - if m != nil { - return m.Fee - } - return nil -} - -// QueryTimeoutFeeRequest is the request type for querying the timeout fee -type QueryTimeoutFeeRequest struct { - // PacketID - PacketId *types.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id,omitempty"` - // Caller should provide the intended relayer address in case the fee is dependent on specific relayer(s). - RelayerAddress string `protobuf:"bytes,2,opt,name=relayer_address,json=relayerAddress,proto3" json:"relayer_address,omitempty"` - // Height to query at - QueryHeight uint64 `protobuf:"varint,3,opt,name=query_height,json=queryHeight,proto3" json:"query_height,omitempty"` -} - -func (m *QueryTimeoutFeeRequest) Reset() { *m = QueryTimeoutFeeRequest{} } -func (m *QueryTimeoutFeeRequest) String() string { return proto.CompactTextString(m) } -func (*QueryTimeoutFeeRequest) ProtoMessage() {} -func (*QueryTimeoutFeeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_0638a8a78ca2503c, []int{4} -} -func (m *QueryTimeoutFeeRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryTimeoutFeeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryTimeoutFeeRequest.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryTimeoutFeeRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryTimeoutFeeRequest.Merge(m, src) -} -func (m *QueryTimeoutFeeRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryTimeoutFeeRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryTimeoutFeeRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryTimeoutFeeRequest proto.InternalMessageInfo - -func (m *QueryTimeoutFeeRequest) GetPacketId() *types.PacketId { - if m != nil { - return m.PacketId - } - return nil -} - -func (m *QueryTimeoutFeeRequest) GetRelayerAddress() string { - if m != nil { - return m.RelayerAddress - } - return "" -} - -func (m *QueryTimeoutFeeRequest) GetQueryHeight() uint64 { - if m != nil { - return m.QueryHeight - } - return 0 -} - -// QueryTimeoutFeeResponse is the response type for the timeout RPC -type QueryTimeoutFeeResponse struct { - Fee *Fee `protobuf:"bytes,1,opt,name=fee,proto3" json:"fee,omitempty"` -} - -func (m *QueryTimeoutFeeResponse) Reset() { *m = QueryTimeoutFeeResponse{} } -func (m *QueryTimeoutFeeResponse) String() string { return proto.CompactTextString(m) } -func (*QueryTimeoutFeeResponse) ProtoMessage() {} -func (*QueryTimeoutFeeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_0638a8a78ca2503c, []int{5} -} -func (m *QueryTimeoutFeeResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryTimeoutFeeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryTimeoutFeeResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *QueryTimeoutFeeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryTimeoutFeeResponse.Merge(m, src) -} -func (m *QueryTimeoutFeeResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryTimeoutFeeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryTimeoutFeeResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryTimeoutFeeResponse proto.InternalMessageInfo - -func (m *QueryTimeoutFeeResponse) GetFee() *Fee { - if m != nil { - return m.Fee - } - return nil -} - // QueryIncentivizedPacketsRequest is the request type for querying for all incentivized packets type QueryIncentivizedPacketsRequest struct { // pagination defines an optional pagination for the request. @@ -370,7 +43,7 @@ func (m *QueryIncentivizedPacketsRequest) Reset() { *m = QueryIncentiviz func (m *QueryIncentivizedPacketsRequest) String() string { return proto.CompactTextString(m) } func (*QueryIncentivizedPacketsRequest) ProtoMessage() {} func (*QueryIncentivizedPacketsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_0638a8a78ca2503c, []int{6} + return fileDescriptor_0638a8a78ca2503c, []int{0} } func (m *QueryIncentivizedPacketsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -423,7 +96,7 @@ func (m *QueryIncentivizedPacketsResponse) Reset() { *m = QueryIncentivi func (m *QueryIncentivizedPacketsResponse) String() string { return proto.CompactTextString(m) } func (*QueryIncentivizedPacketsResponse) ProtoMessage() {} func (*QueryIncentivizedPacketsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_0638a8a78ca2503c, []int{7} + return fileDescriptor_0638a8a78ca2503c, []int{1} } func (m *QueryIncentivizedPacketsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -471,7 +144,7 @@ func (m *QueryIncentivizedPacketRequest) Reset() { *m = QueryIncentivize func (m *QueryIncentivizedPacketRequest) String() string { return proto.CompactTextString(m) } func (*QueryIncentivizedPacketRequest) ProtoMessage() {} func (*QueryIncentivizedPacketRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_0638a8a78ca2503c, []int{8} + return fileDescriptor_0638a8a78ca2503c, []int{2} } func (m *QueryIncentivizedPacketRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -524,7 +197,7 @@ func (m *QueryIncentivizedPacketResponse) Reset() { *m = QueryIncentiviz func (m *QueryIncentivizedPacketResponse) String() string { return proto.CompactTextString(m) } func (*QueryIncentivizedPacketResponse) ProtoMessage() {} func (*QueryIncentivizedPacketResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_0638a8a78ca2503c, []int{9} + return fileDescriptor_0638a8a78ca2503c, []int{3} } func (m *QueryIncentivizedPacketResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -561,12 +234,6 @@ func (m *QueryIncentivizedPacketResponse) GetIncentivizedPacket() *IdentifiedPac } func init() { - proto.RegisterType((*QueryReceiveFeeRequest)(nil), "ibc.applications.fee.v1.QueryReceiveFeeRequest") - proto.RegisterType((*QueryReceiveFeeResponse)(nil), "ibc.applications.fee.v1.QueryReceiveFeeResponse") - proto.RegisterType((*QueryAckFeeRequest)(nil), "ibc.applications.fee.v1.QueryAckFeeRequest") - proto.RegisterType((*QueryAckFeeResponse)(nil), "ibc.applications.fee.v1.QueryAckFeeResponse") - proto.RegisterType((*QueryTimeoutFeeRequest)(nil), "ibc.applications.fee.v1.QueryTimeoutFeeRequest") - proto.RegisterType((*QueryTimeoutFeeResponse)(nil), "ibc.applications.fee.v1.QueryTimeoutFeeResponse") proto.RegisterType((*QueryIncentivizedPacketsRequest)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketsRequest") proto.RegisterType((*QueryIncentivizedPacketsResponse)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketsResponse") proto.RegisterType((*QueryIncentivizedPacketRequest)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketRequest") @@ -578,54 +245,41 @@ func init() { } var fileDescriptor_0638a8a78ca2503c = []byte{ - // 746 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0xc1, 0x6b, 0x13, 0x4f, - 0x18, 0xed, 0xa4, 0xbf, 0x5f, 0xb1, 0x53, 0x51, 0x98, 0x14, 0x1b, 0x42, 0x8d, 0x69, 0x44, 0x1b, - 0xb4, 0x9d, 0x31, 0xf1, 0x60, 0xeb, 0xad, 0x82, 0xc5, 0x80, 0x87, 0x1a, 0x3c, 0x09, 0x12, 0x36, - 0xbb, 0x5f, 0x36, 0x43, 0x93, 0x9d, 0xed, 0xee, 0x24, 0xd0, 0x6a, 0x51, 0xea, 0xb5, 0x07, 0xc1, - 0xab, 0x07, 0xff, 0x0d, 0xff, 0x03, 0x8f, 0x05, 0x2f, 0x82, 0x17, 0x69, 0xbd, 0xf9, 0x4f, 0xc8, - 0xcc, 0x4e, 0xd2, 0x94, 0xcd, 0xb6, 0x49, 0xb1, 0xd0, 0xdb, 0xee, 0xcc, 0xfb, 0xbe, 0x79, 0xef, - 0x7d, 0x3b, 0x8f, 0xc5, 0xb7, 0x79, 0xdd, 0x66, 0x96, 0xef, 0xb7, 0xb8, 0x6d, 0x49, 0x2e, 0xbc, - 0x90, 0x35, 0x00, 0x58, 0xb7, 0xc4, 0xb6, 0x3a, 0x10, 0x6c, 0x53, 0x3f, 0x10, 0x52, 0x90, 0x39, - 0x5e, 0xb7, 0xe9, 0x20, 0x88, 0x36, 0x00, 0x68, 0xb7, 0x94, 0x9d, 0x75, 0x85, 0x2b, 0x34, 0x86, - 0xa9, 0xa7, 0x08, 0x9e, 0xbd, 0x67, 0x8b, 0xb0, 0x2d, 0x42, 0x56, 0xb7, 0x42, 0x88, 0xfa,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0x1b, 0xaf, 0xdb, 0xcb, 0xae, 0x60, 0x6d, 0xe1, 0x74, 0x5a, 0x10, 0x46, 0x8c, 0xcb, 0xab, - 0xcb, 0x8a, 0xb4, 0xdc, 0xf6, 0x21, 0xac, 0x4f, 0xe9, 0xdf, 0xb7, 0x87, 0x7f, 0x03, 0x00, 0x00, - 0xff, 0xff, 0x4c, 0x6f, 0x7f, 0x1d, 0xd0, 0x0a, 0x00, 0x00, + // 542 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x41, 0x6f, 0x12, 0x41, + 0x14, 0xee, 0x50, 0x35, 0x3a, 0x78, 0x1a, 0x9a, 0x48, 0x88, 0xae, 0x14, 0xa3, 0x12, 0x23, 0x33, + 0x01, 0x0f, 0xb6, 0x1e, 0x3d, 0x34, 0x92, 0x78, 0xa8, 0x1c, 0x4d, 0x0c, 0xd9, 0x9d, 0x7d, 0x2c, + 0x13, 0x61, 0x67, 0xcb, 0x0c, 0x24, 0xad, 0x36, 0x9a, 0x7a, 0xed, 0xc1, 0xc4, 0x5f, 0xe3, 0x3f, + 0xf0, 0xd8, 0xe8, 0xc5, 0xa3, 0x01, 0x7f, 0x88, 0x99, 0xd9, 0x59, 0xdc, 0x04, 0x36, 0x16, 0x6f, + 0xc3, 0x7b, 0xdf, 0xf7, 0xbe, 0x8f, 0xef, 0xcd, 0x2c, 0xbe, 0x27, 0x02, 0xce, 0xfc, 0x24, 0x19, + 0x09, 0xee, 0x6b, 0x21, 0x63, 0xc5, 0x06, 0x00, 0x6c, 0xd6, 0x66, 0x47, 0x53, 0x98, 0x1c, 0xd3, + 0x64, 0x22, 0xb5, 0x24, 0xb7, 0x44, 0xc0, 0x69, 0x1e, 0x44, 0x07, 0x00, 0x74, 0xd6, 0xae, 0xed, + 0x44, 0x32, 0x92, 0x16, 0xc3, 0xcc, 0x29, 0x85, 0xd7, 0x1e, 0x71, 0x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 0x11, 0xf0, 0x56, 0x24, 0xd9, 0x58, 0x86, 0xd3, 0x11, + 0xa8, 0xd4, 0x71, 0x67, 0xbf, 0x65, 0x4c, 0xeb, 0xe3, 0x04, 0x54, 0x70, 0xcd, 0x7e, 0x42, 0x9e, + 0xfc, 0x09, 0x00, 0x00, 0xff, 0xff, 0x6a, 0x6c, 0x98, 0x87, 0x54, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -640,15 +294,10 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { - // Gets the fee expected for submitting ReceivePacket msg for the given packet - ReceiveFee(ctx context.Context, in *QueryReceiveFeeRequest, opts ...grpc.CallOption) (*QueryReceiveFeeResponse, error) - // Gets the fee expected for submitting AcknowledgePacket msg for the given packet - AckFee(ctx context.Context, in *QueryAckFeeRequest, opts ...grpc.CallOption) (*QueryAckFeeResponse, error) - // Gets the fee expected for submitting TimeoutPacket msg for the given packet - TimeoutFee(ctx context.Context, in *QueryTimeoutFeeRequest, opts ...grpc.CallOption) (*QueryTimeoutFeeResponse, error) // Gets all incentivized packets IncentivizedPackets(ctx context.Context, in *QueryIncentivizedPacketsRequest, opts ...grpc.CallOption) (*QueryIncentivizedPacketsResponse, error) - // Gets the specified incentivized packet + // Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the + // given packet IncentivizedPacket(ctx context.Context, in *QueryIncentivizedPacketRequest, opts ...grpc.CallOption) (*QueryIncentivizedPacketResponse, error) } @@ -660,33 +309,6 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } -func (c *queryClient) ReceiveFee(ctx context.Context, in *QueryReceiveFeeRequest, opts ...grpc.CallOption) (*QueryReceiveFeeResponse, error) { - out := new(QueryReceiveFeeResponse) - err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Query/ReceiveFee", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) AckFee(ctx context.Context, in *QueryAckFeeRequest, opts ...grpc.CallOption) (*QueryAckFeeResponse, error) { - out := new(QueryAckFeeResponse) - err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Query/AckFee", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) TimeoutFee(ctx context.Context, in *QueryTimeoutFeeRequest, opts ...grpc.CallOption) (*QueryTimeoutFeeResponse, error) { - out := new(QueryTimeoutFeeResponse) - err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Query/TimeoutFee", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *queryClient) IncentivizedPackets(ctx context.Context, in *QueryIncentivizedPacketsRequest, opts ...grpc.CallOption) (*QueryIncentivizedPacketsResponse, error) { out := new(QueryIncentivizedPacketsResponse) err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Query/IncentivizedPackets", in, out, opts...) @@ -707,15 +329,10 @@ func (c *queryClient) IncentivizedPacket(ctx context.Context, in *QueryIncentivi // QueryServer is the server API for Query service. type QueryServer interface { - // Gets the fee expected for submitting ReceivePacket msg for the given packet - ReceiveFee(context.Context, *QueryReceiveFeeRequest) (*QueryReceiveFeeResponse, error) - // Gets the fee expected for submitting AcknowledgePacket msg for the given packet - AckFee(context.Context, *QueryAckFeeRequest) (*QueryAckFeeResponse, error) - // Gets the fee expected for submitting TimeoutPacket msg for the given packet - TimeoutFee(context.Context, *QueryTimeoutFeeRequest) (*QueryTimeoutFeeResponse, error) // Gets all incentivized packets IncentivizedPackets(context.Context, *QueryIncentivizedPacketsRequest) (*QueryIncentivizedPacketsResponse, error) - // Gets the specified incentivized packet + // Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the + // given packet IncentivizedPacket(context.Context, *QueryIncentivizedPacketRequest) (*QueryIncentivizedPacketResponse, error) } @@ -723,15 +340,6 @@ type QueryServer interface { type UnimplementedQueryServer struct { } -func (*UnimplementedQueryServer) ReceiveFee(ctx context.Context, req *QueryReceiveFeeRequest) (*QueryReceiveFeeResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ReceiveFee not implemented") -} -func (*UnimplementedQueryServer) AckFee(ctx context.Context, req *QueryAckFeeRequest) (*QueryAckFeeResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method AckFee not implemented") -} -func (*UnimplementedQueryServer) TimeoutFee(ctx context.Context, req *QueryTimeoutFeeRequest) (*QueryTimeoutFeeResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method TimeoutFee not implemented") -} func (*UnimplementedQueryServer) IncentivizedPackets(ctx context.Context, req *QueryIncentivizedPacketsRequest) (*QueryIncentivizedPacketsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method IncentivizedPackets not implemented") } @@ -743,92 +351,38 @@ func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } -func _Query_ReceiveFee_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryReceiveFeeRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).ReceiveFee(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.applications.fee.v1.Query/ReceiveFee", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).ReceiveFee(ctx, req.(*QueryReceiveFeeRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_AckFee_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryAckFeeRequest) +func _Query_IncentivizedPackets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryIncentivizedPacketsRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).AckFee(ctx, in) + return srv.(QueryServer).IncentivizedPackets(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ibc.applications.fee.v1.Query/AckFee", + FullMethod: "/ibc.applications.fee.v1.Query/IncentivizedPackets", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).AckFee(ctx, req.(*QueryAckFeeRequest)) + return srv.(QueryServer).IncentivizedPackets(ctx, req.(*QueryIncentivizedPacketsRequest)) } return interceptor(ctx, in, info, handler) } -func _Query_TimeoutFee_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryTimeoutFeeRequest) +func _Query_IncentivizedPacket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryIncentivizedPacketRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).TimeoutFee(ctx, in) + return srv.(QueryServer).IncentivizedPacket(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/ibc.applications.fee.v1.Query/TimeoutFee", + FullMethod: "/ibc.applications.fee.v1.Query/IncentivizedPacket", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).TimeoutFee(ctx, req.(*QueryTimeoutFeeRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_IncentivizedPackets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryIncentivizedPacketsRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).IncentivizedPackets(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.applications.fee.v1.Query/IncentivizedPackets", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).IncentivizedPackets(ctx, req.(*QueryIncentivizedPacketsRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_IncentivizedPacket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryIncentivizedPacketRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).IncentivizedPacket(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/ibc.applications.fee.v1.Query/IncentivizedPacket", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).IncentivizedPacket(ctx, req.(*QueryIncentivizedPacketRequest)) + return srv.(QueryServer).IncentivizedPacket(ctx, req.(*QueryIncentivizedPacketRequest)) } return interceptor(ctx, in, info, handler) } @@ -837,18 +391,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.applications.fee.v1.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ - { - MethodName: "ReceiveFee", - Handler: _Query_ReceiveFee_Handler, - }, - { - MethodName: "AckFee", - Handler: _Query_AckFee_Handler, - }, - { - MethodName: "TimeoutFee", - Handler: _Query_TimeoutFee_Handler, - }, { MethodName: "IncentivizedPackets", Handler: _Query_IncentivizedPackets_Handler, @@ -862,252 +404,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Metadata: "ibc/applications/fee/v1/query.proto", } -func (m *QueryReceiveFeeRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryReceiveFeeRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryReceiveFeeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.QueryHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.QueryHeight)) - i-- - dAtA[i] = 0x18 - } - if len(m.RelayerAddress) > 0 { - i -= len(m.RelayerAddress) - copy(dAtA[i:], m.RelayerAddress) - i = encodeVarintQuery(dAtA, i, uint64(len(m.RelayerAddress))) - i-- - dAtA[i] = 0x12 - } - if m.PacketId != nil { - { - size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryReceiveFeeResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryReceiveFeeResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryReceiveFeeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Fee != nil { - { - size, err := m.Fee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryAckFeeRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryAckFeeRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAckFeeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.QueryHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.QueryHeight)) - i-- - dAtA[i] = 0x18 - } - if len(m.RelayerAddress) > 0 { - i -= len(m.RelayerAddress) - copy(dAtA[i:], m.RelayerAddress) - i = encodeVarintQuery(dAtA, i, uint64(len(m.RelayerAddress))) - i-- - dAtA[i] = 0x12 - } - if m.PacketId != nil { - { - size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryAckFeeResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryAckFeeResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryAckFeeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Fee != nil { - { - size, err := m.Fee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryTimeoutFeeRequest) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryTimeoutFeeRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryTimeoutFeeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.QueryHeight != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.QueryHeight)) - i-- - dAtA[i] = 0x18 - } - if len(m.RelayerAddress) > 0 { - i -= len(m.RelayerAddress) - copy(dAtA[i:], m.RelayerAddress) - i = encodeVarintQuery(dAtA, i, uint64(len(m.RelayerAddress))) - i-- - dAtA[i] = 0x12 - } - if m.PacketId != nil { - { - size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QueryTimeoutFeeResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *QueryTimeoutFeeResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryTimeoutFeeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Fee != nil { - { - size, err := m.Fee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *QueryIncentivizedPacketsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1271,18 +567,14 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *QueryReceiveFeeRequest) Size() (n int) { +func (m *QueryIncentivizedPacketsRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.PacketId != nil { - l = m.PacketId.Size() - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.RelayerAddress) - if l > 0 { + if m.Pagination != nil { + l = m.Pagination.Size() n += 1 + l + sovQuery(uint64(l)) } if m.QueryHeight != 0 { @@ -1291,117 +583,22 @@ func (m *QueryReceiveFeeRequest) Size() (n int) { return n } -func (m *QueryReceiveFeeResponse) Size() (n int) { +func (m *QueryIncentivizedPacketsResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Fee != nil { - l = m.Fee.Size() - n += 1 + l + sovQuery(uint64(l)) + if len(m.IncentivizedPackets) > 0 { + for _, e := range m.IncentivizedPackets { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } } return n } -func (m *QueryAckFeeRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PacketId != nil { - l = m.PacketId.Size() - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.RelayerAddress) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.QueryHeight != 0 { - n += 1 + sovQuery(uint64(m.QueryHeight)) - } - return n -} - -func (m *QueryAckFeeResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Fee != nil { - l = m.Fee.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryTimeoutFeeRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PacketId != nil { - l = m.PacketId.Size() - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.RelayerAddress) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.QueryHeight != 0 { - n += 1 + sovQuery(uint64(m.QueryHeight)) - } - return n -} - -func (m *QueryTimeoutFeeResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Fee != nil { - l = m.Fee.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryIncentivizedPacketsRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - if m.QueryHeight != 0 { - n += 1 + sovQuery(uint64(m.QueryHeight)) - } - return n -} - -func (m *QueryIncentivizedPacketsResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.IncentivizedPackets) > 0 { - for _, e := range m.IncentivizedPackets { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func (m *QueryIncentivizedPacketRequest) Size() (n int) { +func (m *QueryIncentivizedPacketRequest) Size() (n int) { if m == nil { return 0 } @@ -1436,675 +633,6 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *QueryReceiveFeeRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryReceiveFeeRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryReceiveFeeRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.PacketId == nil { - m.PacketId = &types.PacketId{} - } - if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RelayerAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RelayerAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field QueryHeight", wireType) - } - m.QueryHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.QueryHeight |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryReceiveFeeResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryReceiveFeeResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryReceiveFeeResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Fee == nil { - m.Fee = &Fee{} - } - if err := m.Fee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryAckFeeRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryAckFeeRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAckFeeRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.PacketId == nil { - m.PacketId = &types.PacketId{} - } - if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RelayerAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RelayerAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field QueryHeight", wireType) - } - m.QueryHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.QueryHeight |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryAckFeeResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryAckFeeResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAckFeeResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Fee == nil { - m.Fee = &Fee{} - } - if err := m.Fee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryTimeoutFeeRequest) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryTimeoutFeeRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryTimeoutFeeRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.PacketId == nil { - m.PacketId = &types.PacketId{} - } - if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RelayerAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RelayerAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field QueryHeight", wireType) - } - m.QueryHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.QueryHeight |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryTimeoutFeeResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: QueryTimeoutFeeResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryTimeoutFeeResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Fee == nil { - m.Fee = &Fee{} - } - if err := m.Fee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *QueryIncentivizedPacketsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/modules/apps/29-fee/types/query.pb.gw.go b/modules/apps/29-fee/types/query.pb.gw.go index 884d410092d..3a9b3d581b2 100644 --- a/modules/apps/29-fee/types/query.pb.gw.go +++ b/modules/apps/29-fee/types/query.pb.gw.go @@ -31,354 +31,6 @@ var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage -var ( - filter_Query_ReceiveFee_0 = &utilities.DoubleArray{Encoding: map[string]int{"packet_id": 0, "port_id": 1, "channel_id": 2, "sequence": 3}, Base: []int{1, 1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 2, 2, 2, 3, 4, 5}} -) - -func request_Query_ReceiveFee_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryReceiveFeeRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["packet_id.port_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") - } - - err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) - } - - val, ok = pathParams["packet_id.channel_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") - } - - err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) - } - - val, ok = pathParams["packet_id.sequence"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") - } - - err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ReceiveFee_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.ReceiveFee(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_ReceiveFee_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryReceiveFeeRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["packet_id.port_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") - } - - err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) - } - - val, ok = pathParams["packet_id.channel_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") - } - - err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) - } - - val, ok = pathParams["packet_id.sequence"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") - } - - err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_ReceiveFee_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.ReceiveFee(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_AckFee_0 = &utilities.DoubleArray{Encoding: map[string]int{"packet_id": 0, "port_id": 1, "channel_id": 2, "sequence": 3}, Base: []int{1, 1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 2, 2, 2, 3, 4, 5}} -) - -func request_Query_AckFee_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAckFeeRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["packet_id.port_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") - } - - err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) - } - - val, ok = pathParams["packet_id.channel_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") - } - - err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) - } - - val, ok = pathParams["packet_id.sequence"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") - } - - err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AckFee_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.AckFee(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_AckFee_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryAckFeeRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["packet_id.port_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") - } - - err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) - } - - val, ok = pathParams["packet_id.channel_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") - } - - err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) - } - - val, ok = pathParams["packet_id.sequence"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") - } - - err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AckFee_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.AckFee(ctx, &protoReq) - return msg, metadata, err - -} - -var ( - filter_Query_TimeoutFee_0 = &utilities.DoubleArray{Encoding: map[string]int{"packet_id": 0, "port_id": 1, "channel_id": 2, "sequence": 3}, Base: []int{1, 1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 2, 2, 2, 3, 4, 5}} -) - -func request_Query_TimeoutFee_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryTimeoutFeeRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["packet_id.port_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") - } - - err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) - } - - val, ok = pathParams["packet_id.channel_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") - } - - err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) - } - - val, ok = pathParams["packet_id.sequence"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") - } - - err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TimeoutFee_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.TimeoutFee(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_TimeoutFee_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryTimeoutFeeRequest - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["packet_id.port_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") - } - - err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) - } - - val, ok = pathParams["packet_id.channel_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") - } - - err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) - } - - val, ok = pathParams["packet_id.sequence"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") - } - - err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) - } - - if err := req.ParseForm(); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TimeoutFee_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.TimeoutFee(ctx, &protoReq) - return msg, metadata, err - -} - var ( filter_Query_IncentivizedPackets_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) @@ -537,66 +189,6 @@ func local_request_Query_IncentivizedPacket_0(ctx context.Context, marshaler run // Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_ReceiveFee_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_ReceiveFee_0(rctx, inboundMarshaler, server, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_ReceiveFee_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_AckFee_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_AckFee_0(rctx, inboundMarshaler, server, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_AckFee_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_TimeoutFee_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := local_request_Query_TimeoutFee_0(rctx, inboundMarshaler, server, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_TimeoutFee_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_IncentivizedPackets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -678,66 +270,6 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_ReceiveFee_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_ReceiveFee_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_ReceiveFee_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_AckFee_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_AckFee_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_AckFee_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_TimeoutFee_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_TimeoutFee_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_TimeoutFee_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_IncentivizedPackets_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -782,24 +314,12 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_ReceiveFee_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "receive_fee", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) - - pattern_Query_AckFee_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "ack_fee", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) - - pattern_Query_TimeoutFee_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "timeout_fee", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_IncentivizedPackets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"ibc", "apps", "fee", "v1", "incentivized_packets"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_IncentivizedPacket_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "incentivized_packet", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( - forward_Query_ReceiveFee_0 = runtime.ForwardResponseMessage - - forward_Query_AckFee_0 = runtime.ForwardResponseMessage - - forward_Query_TimeoutFee_0 = runtime.ForwardResponseMessage - forward_Query_IncentivizedPackets_0 = runtime.ForwardResponseMessage forward_Query_IncentivizedPacket_0 = runtime.ForwardResponseMessage diff --git a/proto/ibc/applications/fee/v1/query.proto b/proto/ibc/applications/fee/v1/query.proto index e2fd5c141fd..d8b258359ae 100644 --- a/proto/ibc/applications/fee/v1/query.proto +++ b/proto/ibc/applications/fee/v1/query.proto @@ -13,33 +13,13 @@ option go_package = "github.com/cosmos/ibc-go/modules/apps/29-fee/types"; // Query provides defines the gRPC querier service. service Query { - // Gets the fee expected for submitting ReceivePacket msg for the given packet - rpc ReceiveFee(QueryReceiveFeeRequest) returns (QueryReceiveFeeResponse) { - option (google.api.http).get = - "/ibc/apps/fee/v1/receive_fee/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/" - "{packet_id.sequence}"; - } - - // Gets the fee expected for submitting AcknowledgePacket msg for the given packet - rpc AckFee(QueryAckFeeRequest) returns (QueryAckFeeResponse) { - option (google.api.http).get = - "/ibc/apps/fee/v1/ack_fee/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/" - "{packet_id.sequence}"; - } - - // Gets the fee expected for submitting TimeoutPacket msg for the given packet - rpc TimeoutFee(QueryTimeoutFeeRequest) returns (QueryTimeoutFeeResponse) { - option (google.api.http).get = - "/ibc/apps/fee/v1/timeout_fee/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/" - "{packet_id.sequence}"; - } - // Gets all incentivized packets rpc IncentivizedPackets(QueryIncentivizedPacketsRequest) returns (QueryIncentivizedPacketsResponse) { option (google.api.http).get = "/ibc/apps/fee/v1/incentivized_packets"; } - // Gets the specified incentivized packet + // Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the + // given packet rpc IncentivizedPacket(QueryIncentivizedPacketRequest) returns (QueryIncentivizedPacketResponse) { option (google.api.http).get = "/ibc/apps/fee/v1/incentivized_packet/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/" @@ -47,51 +27,6 @@ service Query { } } -// QueryReceiveFeeRequest is the request type for querying the receive fee -message QueryReceiveFeeRequest { - // PacketID - ibc.core.channel.v1.PacketId packet_id = 1; - // Caller should provide the intended relayer address in case the fee is dependent on specific relayer(s). - string relayer_address = 2; - // Height to query at - uint64 query_height = 3; -} - -// QueryReceiveFeeResponse is the response type for the ReceiveFee RPC -message QueryReceiveFeeResponse { - ibc.applications.fee.v1.Fee fee = 1; -} - -// QueryAckFeeRequest is the request type for querying the acknowledgement fee -message QueryAckFeeRequest { - // PacketID - ibc.core.channel.v1.PacketId packet_id = 1; - // Caller should provide the intended relayer address in case the fee is dependent on specific relayer(s). - string relayer_address = 2; - // Height to query at - uint64 query_height = 3; -} - -// QueryAckFeeResponse is the response type for the AckFee RPC -message QueryAckFeeResponse { - ibc.applications.fee.v1.Fee fee = 1; -} - -// QueryTimeoutFeeRequest is the request type for querying the timeout fee -message QueryTimeoutFeeRequest { - // PacketID - ibc.core.channel.v1.PacketId packet_id = 1; - // Caller should provide the intended relayer address in case the fee is dependent on specific relayer(s). - string relayer_address = 2; - // Height to query at - uint64 query_height = 3; -} - -// QueryTimeoutFeeResponse is the response type for the timeout RPC -message QueryTimeoutFeeResponse { - ibc.applications.fee.v1.Fee fee = 1; -} - // QueryIncentivizedPacketsRequest is the request type for querying for all incentivized packets message QueryIncentivizedPacketsRequest { // pagination defines an optional pagination for the request. From 8ebbe187e590631e4b0f3891eb8a37a4d0f40979 Mon Sep 17 00:00:00 2001 From: Aditya Date: Thu, 18 Nov 2021 11:55:20 +0100 Subject: [PATCH 09/79] store refund address in IdentifiedPacketFee (#546) --- docs/ibc/proto-docs.md | 76 +---------- modules/apps/29-fee/keeper/escrow.go | 6 +- modules/apps/29-fee/keeper/escrow_test.go | 12 +- modules/apps/29-fee/keeper/grpc_query_test.go | 14 +- modules/apps/29-fee/keeper/msg_server.go | 16 +-- modules/apps/29-fee/keeper/msg_server_test.go | 4 +- modules/apps/29-fee/types/fee.pb.go | 126 +++++++++++++----- modules/apps/29-fee/types/msgs.go | 17 +-- modules/apps/29-fee/types/msgs_test.go | 8 +- modules/apps/29-fee/types/tx.pb.go | 124 ++++++----------- proto/ibc/applications/fee/v1/fee.proto | 15 ++- proto/ibc/applications/fee/v1/tx.proto | 5 +- 12 files changed, 187 insertions(+), 236 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 562bb7f718d..11f3ab0479b 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -617,7 +617,7 @@ CLOSED, INIT, TRYOPEN, OPEN or UNINITIALIZED. ### Fee -Fee interface +Fee implements the ics29 Fee interface See Fee Payment Middleware spec: https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middleware-contract @@ -636,13 +636,17 @@ https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middl ### IdentifiedPacketFee -Fee associated with a packet_id +IdentifiedPacketFee contains the relayer fee along with the associated metadata needed to process it. +This includes the PacketId identifying the packet the fee is paying for, +the refund address to which any unused funds are refunded, +and an optional list of relayers that are permitted to receive the fee. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | | | `fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | +| `refund_address` | [string](#string) | | | | `relayers` | [string](#string) | repeated | | @@ -781,71 +785,6 @@ Query provides defines the gRPC querier service. - - -### MsgPayPacketFee -MsgPayPacketFee defines the request type EscrowPacketFee RPC -This Msg can be used to pay for a packet at the next sequence send & should be combined with the Msg that will be -paid for - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | -| `source_port_id` | [string](#string) | | source channel port identifier | -| `source_channel_id` | [string](#string) | | source channel unique identifier | -| `signer` | [string](#string) | | account address to refund fee if necessary | -| `relayers` | [string](#string) | repeated | | - - - - - - - - -### MsgPayPacketFeeAsync -MsgPayPacketFeeAsync defines the request type PayPacketFeeAsync RPC -This Msg can be used to pay for a packet at a specified sequence (instead of the next sequence send) - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `identified_packet_fee` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | | packet to pay fee for | -| `signer` | [string](#string) | | account address to refund fee if necessary | - - - - - - - - - - - -### Query -Query provides defines the gRPC querier service. - -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `ReceiveFee` | [QueryReceiveFeeRequest](#ibc.applications.fee.v1.QueryReceiveFeeRequest) | [QueryReceiveFeeResponse](#ibc.applications.fee.v1.QueryReceiveFeeResponse) | Gets the fee expected for submitting ReceivePacket msg for the given packet | GET|/ibc/apps/fee/v1/receive_fee/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| -| `AckFee` | [QueryAckFeeRequest](#ibc.applications.fee.v1.QueryAckFeeRequest) | [QueryAckFeeResponse](#ibc.applications.fee.v1.QueryAckFeeResponse) | Gets the fee expected for submitting AcknowledgePacket msg for the given packet | GET|/ibc/apps/fee/v1/ack_fee/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| -| `TimeoutFee` | [QueryTimeoutFeeRequest](#ibc.applications.fee.v1.QueryTimeoutFeeRequest) | [QueryTimeoutFeeResponse](#ibc.applications.fee.v1.QueryTimeoutFeeResponse) | Gets the fee expected for submitting TimeoutPacket msg for the given packet | GET|/ibc/apps/fee/v1/timeout_fee/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| -| `IncentivizedPackets` | [QueryIncentivizedPacketsRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsRequest) | [QueryIncentivizedPacketsResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsResponse) | Gets all incentivized packets | GET|/ibc/apps/fee/v1/incentivized_packets| -| `IncentivizedPacket` | [QueryIncentivizedPacketRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketRequest) | [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) | Gets the specified incentivized packet | GET|/ibc/apps/fee/v1/incentivized_packet/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| - - - - - - -

Top

- -## ibc/applications/fee/v1/tx.proto - - - ### MsgPayPacketFee @@ -876,8 +815,7 @@ This Msg can be used to pay for a packet at a specified sequence (instead of the | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `identified_packet_fee` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | | packet to pay fee for | -| `signer` | [string](#string) | | account address to refund fee if necessary | +| `identified_packet_fee` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | | identified packet to pay fee for identified fee must contain the refund address which is also signer of this message | diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index cddb3be047a..1f46d16bbf9 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -12,8 +12,12 @@ import ( ) // EscrowPacketFee sends the packet fee to the 29-fee module account to hold in escrow -func (k Keeper) EscrowPacketFee(ctx sdk.Context, refundAcc sdk.AccAddress, identifiedFee *types.IdentifiedPacketFee) error { +func (k Keeper) EscrowPacketFee(ctx sdk.Context, identifiedFee *types.IdentifiedPacketFee) error { // check if the refund account exists + refundAcc, err := sdk.AccAddressFromBech32(identifiedFee.RefundAddress) + if err != nil { + return err + } hasRefundAcc := k.authKeeper.GetAccount(ctx, refundAcc) if hasRefundAcc == nil { return sdkerrors.Wrap(types.ErrRefundAccNotFound, fmt.Sprintf("Account with address: %s not found", refundAcc)) diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go index d5600c964e3..91cd66a2a14 100644 --- a/modules/apps/29-fee/keeper/escrow_test.go +++ b/modules/apps/29-fee/keeper/escrow_test.go @@ -74,13 +74,13 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { tc.malleate() fee := types.Fee{ackFee, receiveFee, timeoutFee} - identifiedPacketFee := &types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, Relayers: []string{}} + identifiedPacketFee := &types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} // refundAcc balance before escrow originalBal := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom) // escrow the packet fee - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), refundAcc, identifiedPacketFee) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) if tc.expPass { feeInEscrow, _ := suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeInEscrow(suite.chainA.GetContext(), packetId) @@ -153,9 +153,9 @@ func (suite *KeeperTestSuite) TestDistributeFee() { fee := types.Fee{receiveFee, ackFee, timeoutFee} // escrow the packet fee & store the fee in state - identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, Relayers: []string{}} + identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), refundAcc, &identifiedPacketFee) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), &identifiedPacketFee) suite.Require().NoError(err) tc.malleate() @@ -244,8 +244,8 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { fee := types.Fee{receiveFee, ackFee, timeoutFee} // escrow the packet fee & store the fee in state - identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, Relayers: []string{}} - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), refundAcc, &identifiedPacketFee) + identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), &identifiedPacketFee) suite.Require().NoError(err) tc.malleate() diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index c1eb27f2fcc..899df77d5bd 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -26,6 +26,7 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacket() { ReceiveFee: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), TimeoutFee: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), }, + "", // leave empty here and then populate on each testcase since suite resets []string(nil), ) @@ -61,10 +62,12 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacket() { suite.SetupTest() // reset refundAcc := suite.chainA.SenderAccount.GetAddress() + // populate RefundAddress field + identifiedPacketFee.RefundAddress = refundAcc.String() tc.malleate() ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) - suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), refundAcc, identifiedPacketFee) + suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) res, err := suite.queryClient.IncentivizedPacket(ctx, req) if tc.expPass { @@ -107,15 +110,15 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPackets() { func() { refundAcc := suite.chainA.SenderAccount.GetAddress() - fee1 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, 1), fee, []string(nil)) - fee2 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, 2), fee, []string(nil)) - fee3 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, 3), fee, []string(nil)) + fee1 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, 1), fee, refundAcc.String(), []string(nil)) + fee2 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, 2), fee, refundAcc.String(), []string(nil)) + fee3 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, 3), fee, refundAcc.String(), []string(nil)) expPackets = []*types.IdentifiedPacketFee{} expPackets = append(expPackets, fee1, fee2, fee3) for _, p := range expPackets { - suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), refundAcc, p) + suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), p) } req = &types.QueryIncentivizedPacketsRequest{ @@ -141,7 +144,6 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPackets() { if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) - fmt.Println(expPackets) suite.Require().Equal(expPackets, res.IncentivizedPackets) } else { suite.Require().Error(err) diff --git a/modules/apps/29-fee/keeper/msg_server.go b/modules/apps/29-fee/keeper/msg_server.go index 4b81a870eea..e3687b9d215 100644 --- a/modules/apps/29-fee/keeper/msg_server.go +++ b/modules/apps/29-fee/keeper/msg_server.go @@ -43,13 +43,8 @@ func (k Keeper) PayPacketFee(goCtx context.Context, msg *types.MsgPayPacketFee) Sequence: sequence, } - refundAccAddr, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - return nil, err - } - - identifiedPacket := types.NewIdentifiedPacketFee(packetId, msg.Fee, msg.Relayers) - err = k.EscrowPacketFee(ctx, refundAccAddr, identifiedPacket) + identifiedPacket := types.NewIdentifiedPacketFee(packetId, msg.Fee, msg.Signer, msg.Relayers) + err := k.EscrowPacketFee(ctx, identifiedPacket) if err != nil { return nil, err } @@ -63,12 +58,7 @@ func (k Keeper) PayPacketFee(goCtx context.Context, msg *types.MsgPayPacketFee) func (k Keeper) PayPacketFeeAsync(goCtx context.Context, msg *types.MsgPayPacketFeeAsync) (*types.MsgPayPacketFeeAsyncResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - refundAccAddr, err := sdk.AccAddressFromBech32(msg.Signer) - if err != nil { - return nil, err - } - - err = k.EscrowPacketFee(ctx, refundAccAddr, &msg.IdentifiedPacketFee) + err := k.EscrowPacketFee(ctx, &msg.IdentifiedPacketFee) if err != nil { return nil, err } diff --git a/modules/apps/29-fee/keeper/msg_server_test.go b/modules/apps/29-fee/keeper/msg_server_test.go index face4c4c905..c93f02bd97c 100644 --- a/modules/apps/29-fee/keeper/msg_server_test.go +++ b/modules/apps/29-fee/keeper/msg_server_test.go @@ -115,11 +115,11 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() { // build fee packetId := &channeltypes.PacketId{ChannelId: channelID, PortId: suite.path.EndpointA.ChannelConfig.PortID, Sequence: seq} - identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, Relayers: []string{}} + identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} tc.malleate() - msg := types.NewMsgPayPacketFeeAsync(identifiedPacketFee, refundAcc.String()) + msg := types.NewMsgPayPacketFeeAsync(identifiedPacketFee) _, err = suite.chainA.SendMsgs(msg) if tc.expPass { diff --git a/modules/apps/29-fee/types/fee.pb.go b/modules/apps/29-fee/types/fee.pb.go index 23c7abecd4d..038368c7ce8 100644 --- a/modules/apps/29-fee/types/fee.pb.go +++ b/modules/apps/29-fee/types/fee.pb.go @@ -26,7 +26,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// Fee interface +// Fee implements the ics29 Fee interface // See Fee Payment Middleware spec: // https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middleware-contract type Fee struct { @@ -89,11 +89,15 @@ func (m *Fee) GetTimeoutFee() github_com_cosmos_cosmos_sdk_types.Coins { return nil } -// Fee associated with a packet_id +// IdentifiedPacketFee contains the relayer fee along with the associated metadata needed to process it. +// This includes the PacketId identifying the packet the fee is paying for, +// the refund address to which any unused funds are refunded, +// and an optional list of relayers that are permitted to receive the fee. type IdentifiedPacketFee struct { - PacketId *types1.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id,omitempty" yaml:"packet_id"` - Fee Fee `protobuf:"bytes,2,opt,name=fee,proto3" json:"fee"` - Relayers []string `protobuf:"bytes,3,rep,name=relayers,proto3" json:"relayers,omitempty"` + PacketId *types1.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id,omitempty" yaml:"packet_id"` + Fee Fee `protobuf:"bytes,2,opt,name=fee,proto3" json:"fee"` + RefundAddress string `protobuf:"bytes,3,opt,name=refund_address,json=refundAddress,proto3" json:"refund_address,omitempty" yaml:"refund_address"` + Relayers []string `protobuf:"bytes,4,rep,name=relayers,proto3" json:"relayers,omitempty"` } func (m *IdentifiedPacketFee) Reset() { *m = IdentifiedPacketFee{} } @@ -143,6 +147,13 @@ func (m *IdentifiedPacketFee) GetFee() Fee { return Fee{} } +func (m *IdentifiedPacketFee) GetRefundAddress() string { + if m != nil { + return m.RefundAddress + } + return "" +} + func (m *IdentifiedPacketFee) GetRelayers() []string { if m != nil { return m.Relayers @@ -158,35 +169,37 @@ func init() { func init() { proto.RegisterFile("ibc/applications/fee/v1/fee.proto", fileDescriptor_cb3319f1af2a53e5) } var fileDescriptor_cb3319f1af2a53e5 = []byte{ - // 443 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xcd, 0x6e, 0x13, 0x31, - 0x10, 0xc7, 0x63, 0x16, 0x95, 0xd6, 0x91, 0x10, 0x5a, 0x2a, 0x51, 0x22, 0xd8, 0x94, 0x3d, 0xe5, - 0x12, 0x5b, 0x09, 0x5c, 0xe0, 0xb8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0, - 0xf3, 0xfc, 0xef, 0x5a, 0x88, 0x8c, 0x4f, 0x0b, 0x49, 0x6b, 0x99, 0xaf, 0x2a, 0x50, 0x66, 0x22, - 0x14, 0x9d, 0xbf, 0x9f, 0x9a, 0x61, 0xb0, 0xb5, 0xc9, 0x8e, 0x6c, 0x6b, 0xbe, 0xfd, 0x13, 0x00, - 0x00, 0xff, 0xff, 0x80, 0x3a, 0xb6, 0x74, 0x31, 0x03, 0x00, 0x00, + // 480 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x31, 0x8f, 0xd3, 0x30, + 0x14, 0xc7, 0x1b, 0x72, 0x3a, 0xae, 0xae, 0x38, 0xa1, 0x70, 0x88, 0x5e, 0x05, 0x69, 0xc9, 0x94, + 0xa5, 0xb6, 0x5a, 0x58, 0x60, 0x82, 0x20, 0x55, 0x3a, 0x89, 0xe1, 0x94, 0x91, 0xa5, 0x72, 0xec, + 0xd7, 0x9e, 0xd5, 0x24, 0x8e, 0xe2, 0x34, 0x52, 0x57, 0x16, 0x56, 0x3e, 0x07, 0x9f, 0xe4, 0xc6, + 0x1b, 0x99, 0x0a, 0x6a, 0xbf, 0x41, 0x57, 0x16, 0xe4, 0xd8, 0x3d, 0x55, 0x42, 0xe8, 0xd4, 0xc9, + 0xf6, 0x7b, 0xef, 0xef, 0xdf, 0x7b, 0xcf, 0xcf, 0xe8, 0xb5, 0x48, 0x18, 0xa1, 0x45, 0x91, 0x0a, + 0x46, 0x2b, 0x21, 0x73, 0x45, 0x66, 0x00, 0xa4, 0x1e, 0xe9, 0x05, 0x17, 0xa5, 0xac, 0xa4, 0xf7, + 0x42, 0x24, 0x0c, 0x1f, 0x86, 0x60, 0xed, 0xab, 0x47, 0x3d, 0x9f, 0x49, 0x95, 0x49, 0x45, 0x12, + 0xaa, 0xb4, 0x24, 0x81, 0x8a, 0x8e, 0x08, 0x93, 0x22, 0x37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ef, 0x5f, 0xb3, 0x1e, 0x61, 0x23, 0xb9, 0xe2, 0xd1, 0xc5, 0x6e, 0xdd, 0x7f, 0x6a, 0x32, 0xbb, + 0x57, 0x06, 0xf1, 0x59, 0x61, 0xfd, 0xde, 0x5b, 0xe4, 0x9a, 0x16, 0xeb, 0xbb, 0x5e, 0xe2, 0xff, + 0xcc, 0x1c, 0x9e, 0x00, 0x44, 0x27, 0xba, 0xd0, 0x58, 0x87, 0x7b, 0x1f, 0xd0, 0x79, 0x09, 0xb3, + 0x65, 0xce, 0xa7, 0x94, 0xf3, 0x12, 0x94, 0xea, 0xba, 0x03, 0x27, 0x6c, 0x47, 0x97, 0xbb, 0x75, + 0xff, 0xf9, 0x7e, 0x08, 0x0e, 0xfd, 0x41, 0xfc, 0xc4, 0x18, 0x3e, 0x9a, 0xb3, 0xd7, 0x43, 0x67, + 0x25, 0xa4, 0x74, 0x05, 0xa5, 0xea, 0x9e, 0x0c, 0xdc, 0xb0, 0x1d, 0xdf, 0x9f, 0xa3, 0xcf, 0xb7, + 0x1b, 0xdf, 0xb9, 0xdb, 0xf8, 0xce, 0xef, 0x8d, 0xef, 0x7c, 0xdf, 0xfa, 0xad, 0xbb, 0xad, 0xdf, + 0xfa, 0xb9, 0xf5, 0x5b, 0x5f, 0xc6, 0xff, 0x76, 0x53, 0x24, 0x6c, 0x38, 0x97, 0x24, 0x93, 0x7c, + 0x99, 0x82, 0xd2, 0x7f, 0x4a, 0x91, 0xf1, 0xbb, 0xa1, 0xfe, 0x4e, 0x4d, 0x77, 0x93, 0xd3, 0x66, + 0xb8, 0xdf, 0xfc, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xbf, 0x7c, 0x4e, 0x14, 0x73, 0x03, 0x00, 0x00, } func (m *Fee) Marshal() (dAtA []byte, err error) { @@ -280,9 +293,16 @@ func (m *IdentifiedPacketFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.Relayers[iNdEx]) i = encodeVarintFee(dAtA, i, uint64(len(m.Relayers[iNdEx]))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 } } + if len(m.RefundAddress) > 0 { + i -= len(m.RefundAddress) + copy(dAtA[i:], m.RefundAddress) + i = encodeVarintFee(dAtA, i, uint64(len(m.RefundAddress))) + i-- + dAtA[i] = 0x1a + } { size, err := m.Fee.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -358,6 +378,10 @@ func (m *IdentifiedPacketFee) Size() (n int) { } l = m.Fee.Size() n += 1 + l + sovFee(uint64(l)) + l = len(m.RefundAddress) + if l > 0 { + n += 1 + l + sovFee(uint64(l)) + } if len(m.Relayers) > 0 { for _, s := range m.Relayers { l = len(s) @@ -624,6 +648,38 @@ func (m *IdentifiedPacketFee) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RefundAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFee + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFee + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFee + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RefundAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Relayers", wireType) } diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index 2c212da21bc..53bcc0b5b74 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -103,10 +103,9 @@ func (msg MsgPayPacketFee) GetSigners() []sdk.AccAddress { } // NewMsgPayPacketAsync creates a new instance of MsgPayPacketFee -func NewMsgPayPacketFeeAsync(identifiedPacketFee IdentifiedPacketFee, signer string) *MsgPayPacketFeeAsync { +func NewMsgPayPacketFeeAsync(identifiedPacketFee IdentifiedPacketFee) *MsgPayPacketFeeAsync { return &MsgPayPacketFeeAsync{ IdentifiedPacketFee: identifiedPacketFee, - Signer: signer, } } @@ -125,7 +124,7 @@ func (msg MsgPayPacketFeeAsync) ValidateBasic() error { } // signer check - _, err = sdk.AccAddressFromBech32(msg.Signer) + _, err = sdk.AccAddressFromBech32(msg.IdentifiedPacketFee.RefundAddress) if err != nil { return sdkerrors.Wrap(err, "failed to convert msg.Signer into sdk.AccAddress") } @@ -154,19 +153,21 @@ func (msg MsgPayPacketFeeAsync) ValidateBasic() error { } // GetSigners implements sdk.Msg +// The signer of the fee message must be the refund address func (msg MsgPayPacketFeeAsync) GetSigners() []sdk.AccAddress { - signer, err := sdk.AccAddressFromBech32(msg.Signer) + signer, err := sdk.AccAddressFromBech32(msg.IdentifiedPacketFee.RefundAddress) if err != nil { panic(err) } return []sdk.AccAddress{signer} } -func NewIdentifiedPacketFee(packetId *channeltypes.PacketId, fee Fee, relayers []string) *IdentifiedPacketFee { +func NewIdentifiedPacketFee(packetId *channeltypes.PacketId, fee Fee, refundAddr string, relayers []string) *IdentifiedPacketFee { return &IdentifiedPacketFee{ - PacketId: packetId, - Fee: fee, - Relayers: relayers, + PacketId: packetId, + Fee: fee, + RefundAddress: refundAddr, + Relayers: relayers, } } diff --git a/modules/apps/29-fee/types/msgs_test.go b/modules/apps/29-fee/types/msgs_test.go index 480eedcc403..16172969776 100644 --- a/modules/apps/29-fee/types/msgs_test.go +++ b/modules/apps/29-fee/types/msgs_test.go @@ -320,8 +320,8 @@ func TestMsgPayPacketFeeAsyncValidation(t *testing.T) { fee = Fee{receiveFee, ackFee, timeoutFee} packetId := &channeltypes.PacketId{ChannelId: channelID, PortId: portID, Sequence: seq} - identifiedPacketFee := IdentifiedPacketFee{PacketId: packetId, Fee: fee, Relayers: relayers} - msg := NewMsgPayPacketFeeAsync(identifiedPacketFee, signer) + identifiedPacketFee := IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: signer, Relayers: relayers} + msg := NewMsgPayPacketFeeAsync(identifiedPacketFee) err := msg.ValidateBasic() @@ -342,8 +342,8 @@ func TestPayPacketFeeAsyncGetSigners(t *testing.T) { fee := Fee{validCoins, validCoins, validCoins} seq := uint64(1) packetId := &channeltypes.PacketId{ChannelId: channelID, PortId: portID, Sequence: seq} - identifiedPacketFee := IdentifiedPacketFee{PacketId: packetId, Fee: fee, Relayers: nil} - msg := NewMsgPayPacketFeeAsync(identifiedPacketFee, addr.String()) + identifiedPacketFee := IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: addr.String(), Relayers: nil} + msg := NewMsgPayPacketFeeAsync(identifiedPacketFee) // GetSigners res := msg.GetSigners() diff --git a/modules/apps/29-fee/types/tx.pb.go b/modules/apps/29-fee/types/tx.pb.go index 7e27acc666a..8602f2996c8 100644 --- a/modules/apps/29-fee/types/tx.pb.go +++ b/modules/apps/29-fee/types/tx.pb.go @@ -194,10 +194,9 @@ var xxx_messageInfo_MsgPayPacketFeeResponse proto.InternalMessageInfo // MsgPayPacketFeeAsync defines the request type PayPacketFeeAsync RPC // This Msg can be used to pay for a packet at a specified sequence (instead of the next sequence send) type MsgPayPacketFeeAsync struct { - // packet to pay fee for + // identified packet to pay fee for + // identified fee must contain the refund address which is also signer of this message IdentifiedPacketFee IdentifiedPacketFee `protobuf:"bytes,1,opt,name=identified_packet_fee,json=identifiedPacketFee,proto3" json:"identified_packet_fee" yaml:"identified_packet_fee"` - // account address to refund fee if necessary - Signer string `protobuf:"bytes,2,opt,name=signer,proto3" json:"signer,omitempty"` } func (m *MsgPayPacketFeeAsync) Reset() { *m = MsgPayPacketFeeAsync{} } @@ -282,44 +281,44 @@ func init() { func init() { proto.RegisterFile("ibc/applications/fee/v1/tx.proto", fileDescriptor_05c93128649f1b96) } var fileDescriptor_05c93128649f1b96 = []byte{ - // 589 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0x4f, 0x6f, 0xd3, 0x3e, - 0x18, 0xc7, 0x93, 0x75, 0xbf, 0xfd, 0x36, 0x33, 0x31, 0x2d, 0xeb, 0x58, 0x97, 0x55, 0x49, 0x89, - 0x10, 0xea, 0x81, 0x26, 0xac, 0x80, 0x10, 0xbb, 0x4c, 0xeb, 0xa4, 0x89, 0x4a, 0x54, 0xaa, 0x72, - 0xe4, 0x52, 0xa5, 0xce, 0xd3, 0xcc, 0xd0, 0xc6, 0x91, 0xed, 0x4e, 0xe4, 0x0d, 0x4c, 0x1c, 0x77, - 0x83, 0xe3, 0xde, 0x0a, 0xb7, 0x1d, 0x77, 0xe4, 0x54, 0xa1, 0xf6, 0xc2, 0xb9, 0xaf, 0x00, 0x25, - 0x69, 0xbb, 0x74, 0xfd, 0xa3, 0xc1, 0xcd, 0xf6, 0xf3, 0x79, 0xbe, 0xf6, 0xf7, 0x6b, 0xcb, 0xa8, - 0x40, 0x9a, 0xd8, 0x72, 0x82, 0xa0, 0x4d, 0xb0, 0x23, 0x08, 0xf5, 0xb9, 0xd5, 0x02, 0xb0, 0x2e, - 0x0e, 0x2d, 0xf1, 0xc5, 0x0c, 0x18, 0x15, 0x54, 0xd9, 0x23, 0x4d, 0x6c, 0xa6, 0x09, 0xb3, 0x05, - 0x60, 0x5e, 0x1c, 0xaa, 0x59, 0x8f, 0x7a, 0x34, 0x66, 0xac, 0x68, 0x94, 0xe0, 0xea, 0xd3, 0x45, - 0x82, 0x51, 0x57, 0x0a, 0xc1, 0x94, 0x81, 0x85, 0xcf, 0x1d, 0xdf, 0x87, 0x76, 0x54, 0x1e, 0x0d, - 0x13, 0xc4, 0xf8, 0x2e, 0x23, 0xad, 0xc6, 0x3d, 0x1b, 0x3c, 0xc2, 0x05, 0xb0, 0x53, 0xda, 0xf5, - 0x05, 0xb0, 0xc0, 0x61, 0x22, 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 0x3b, 0x94, 0x5b, 0xa4, 0x89, 0x4b, 0x1e, 0xb5, 0x3a, 0xd4, 0xed, 0xb6, 0x81, 0x47, 0x9f, 0x1b, - 0xb7, 0xca, 0xef, 0x4a, 0xd1, 0xbf, 0x26, 0xc2, 0x00, 0x78, 0x73, 0x2d, 0xfe, 0xb4, 0x5e, 0xfd, - 0x09, 0x00, 0x00, 0xff, 0xff, 0xa7, 0xcb, 0x98, 0x2b, 0x4d, 0x05, 0x00, 0x00, + // 585 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0x4f, 0x6f, 0xd3, 0x4c, + 0x10, 0xc6, 0xed, 0xa6, 0x6f, 0xdf, 0x76, 0xa9, 0xa8, 0xea, 0xa6, 0x34, 0x75, 0x23, 0x3b, 0x58, + 0x08, 0xe5, 0x40, 0x6c, 0x1a, 0x40, 0x88, 0x5e, 0xaa, 0xa6, 0x52, 0x45, 0x24, 0x22, 0x45, 0x3e, + 0x72, 0x89, 0x9c, 0xf5, 0xc4, 0x5d, 0x48, 0xbc, 0xd6, 0xee, 0xa6, 0xc2, 0x5f, 0xa0, 0xe2, 0xd8, + 0x1b, 0x1c, 0x7b, 0xe5, 0x9b, 0xf4, 0xd8, 0x23, 0xa7, 0x08, 0x25, 0x17, 0xce, 0xf9, 0x04, 0xc8, + 0x76, 0x92, 0x3a, 0xcd, 0x1f, 0x15, 0x6e, 0xbb, 0x3b, 0xbf, 0x79, 0x76, 0xe6, 0xd9, 0xd5, 0xa0, + 0x02, 0x69, 0x62, 0xcb, 0x09, 0x82, 0x36, 0xc1, 0x8e, 0x20, 0xd4, 0xe7, 0x56, 0x0b, 0xc0, 0xba, + 0x38, 0xb4, 0xc4, 0x17, 0x33, 0x60, 0x54, 0x50, 0x65, 0x8f, 0x34, 0xb1, 0x99, 0x26, 0xcc, 0x16, + 0x80, 0x79, 0x71, 0xa8, 0x66, 0x3d, 0xea, 0xd1, 0x98, 0xb1, 0xa2, 0x55, 0x82, 0xab, 0x4f, 0x17, + 0x09, 0x46, 0x59, 0x29, 0x04, 0x53, 0x06, 0x16, 0x3e, 0x77, 0x7c, 0x1f, 0xda, 0x51, 0x78, 0xb4, + 0x4c, 0x10, 0xe3, 0xbb, 0x8c, 0xb4, 0x1a, 0xf7, 0x6c, 0xf0, 0x08, 0x17, 0xc0, 0x4e, 0x69, 0xd7, + 0x17, 0xc0, 0x02, 0x87, 0x89, 0xf0, 0xc4, 0x75, 0x19, 0x70, 0xae, 0xe4, 0xd0, 0xff, 0x4e, 0xb2, + 0xcc, 0xc9, 0x05, 0xb9, 0xb8, 0x61, 0x8f, 0xb7, 0x8a, 0x8d, 0xb2, 0x38, 0x95, 0xd0, 0x18, 0x63, + 0x2b, 0x11, 0x56, 0xd1, 0x87, 0x3d, 0xfd, 0x20, 0x74, 0x3a, 0xed, 0x23, 0x63, 0x1e, 0x65, 0xd8, + 0x3b, 0x78, 0xf6, 0xb6, 0xa3, 0xf5, 0xaf, 0xd7, 0xba, 0xf4, 0xfb, 0x5a, 0x97, 0x8c, 0x22, 0x7a, + 0xbe, 0xbc, 0x32, 0x1b, 0x78, 0x40, 0x7d, 0x0e, 0xc6, 0xd5, 0x0a, 0xda, 0xaa, 0x71, 0xaf, 0xee, + 0x84, 0x75, 0x07, 0x7f, 0x06, 0x71, 0x06, 0xa0, 0xbc, 0x46, 0x99, 0x16, 0x40, 0x5c, 0xf1, 0xa3, + 0x72, 0xde, 0x5c, 0xe0, 0xad, 0x79, 0x06, 0x50, 0x59, 0xbd, 0xe9, 0xe9, 0x92, 0x1d, 0xe1, 0xca, + 0x31, 0x7a, 0xcc, 0x69, 0x97, 0x61, 0x68, 0x04, 0x94, 0x89, 0x06, 0x71, 0x47, 0xbd, 0xec, 0x0f, + 0x7b, 0xfa, 0x6e, 0xd2, 0xcb, 0x74, 0xdc, 0xb0, 0x37, 0x93, 0x83, 0x3a, 0x65, 0xa2, 0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0xcd, 0x5f, 0xe1, 0xe3, 0xab, 0x2b, 0x1f, 0x6e, 0xfa, 0x9a, 0x7c, 0xdb, + 0xd7, 0xe4, 0x5f, 0x7d, 0x4d, 0xbe, 0x1a, 0x68, 0xd2, 0xed, 0x40, 0x93, 0x7e, 0x0e, 0x34, 0xe9, + 0x63, 0xd9, 0x23, 0xe2, 0xbc, 0xdb, 0x34, 0x31, 0xed, 0x58, 0x98, 0xf2, 0x0e, 0xe5, 0x16, 0x69, + 0xe2, 0x92, 0x47, 0xad, 0x0e, 0x75, 0xbb, 0x6d, 0xe0, 0xd1, 0x10, 0xe3, 0x56, 0xf9, 0x5d, 0x29, + 0x9a, 0x5f, 0x22, 0x0c, 0x80, 0x37, 0xd7, 0xe2, 0xe1, 0xf4, 0xea, 0x4f, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x20, 0xf7, 0x8a, 0xce, 0x35, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -662,13 +661,6 @@ func (m *MsgPayPacketFeeAsync) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Signer) > 0 { - i -= len(m.Signer) - copy(dAtA[i:], m.Signer) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signer))) - i-- - dAtA[i] = 0x12 - } { size, err := m.IdentifiedPacketFee.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -788,10 +780,6 @@ func (m *MsgPayPacketFeeAsync) Size() (n int) { _ = l l = m.IdentifiedPacketFee.Size() n += 1 + l + sovTx(uint64(l)) - l = len(m.Signer) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } return n } @@ -1297,38 +1285,6 @@ func (m *MsgPayPacketFeeAsync) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signer", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signer = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/proto/ibc/applications/fee/v1/fee.proto b/proto/ibc/applications/fee/v1/fee.proto index 121eae2dca4..eb21f44caec 100644 --- a/proto/ibc/applications/fee/v1/fee.proto +++ b/proto/ibc/applications/fee/v1/fee.proto @@ -6,7 +6,7 @@ import "gogoproto/gogo.proto"; import "ibc/core/channel/v1/channel.proto"; option go_package = "github.com/cosmos/ibc-go/modules/apps/29-fee/types"; -// Fee interface +// Fee implements the ics29 Fee interface // See Fee Payment Middleware spec: // https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middleware-contract message Fee { @@ -26,9 +26,14 @@ message Fee { (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; } -// Fee associated with a packet_id + +// IdentifiedPacketFee contains the relayer fee along with the associated metadata needed to process it. +// This includes the PacketId identifying the packet the fee is paying for, +// the refund address to which any unused funds are refunded, +// and an optional list of relayers that are permitted to receive the fee. message IdentifiedPacketFee { - ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.moretags) = "yaml:\"packet_id\""]; - Fee fee = 2 [(gogoproto.nullable) = false]; - repeated string relayers = 3; + ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.moretags) = "yaml:\"packet_id\""]; + Fee fee = 2 [(gogoproto.nullable) = false]; + string refund_address = 3 [(gogoproto.moretags) = "yaml:\"refund_address\""]; + repeated string relayers = 4; } diff --git a/proto/ibc/applications/fee/v1/tx.proto b/proto/ibc/applications/fee/v1/tx.proto index 31163483d4d..6313e94d0ef 100644 --- a/proto/ibc/applications/fee/v1/tx.proto +++ b/proto/ibc/applications/fee/v1/tx.proto @@ -63,11 +63,10 @@ message MsgPayPacketFeeAsync { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - // packet to pay fee for + // identified packet to pay fee for + // identified fee must contain the refund address which is also signer of this message ibc.applications.fee.v1.IdentifiedPacketFee identified_packet_fee = 1 [(gogoproto.moretags) = "yaml:\"identified_packet_fee\"", (gogoproto.nullable) = false]; - // account address to refund fee if necessary - string signer = 2; } // MsgPayPacketFeeAsyncResponse defines the response type for Msg/PayPacketFeeAsync From d419972852e1fa056704e53e78f100a40c6626f4 Mon Sep 17 00:00:00 2001 From: Sean King Date: Wed, 24 Nov 2021 15:13:21 +0100 Subject: [PATCH 10/79] 29-Fee: Genesis (#557) * proto: adding genesis state * feat: add GetAllIdentifiedPacketFees * feat: adding genesis.go & updating proto + app.go * fix: removing PortId from genesis * feat: adding GetAll for relayer addr/fee enabled chan + update genesis * test: TestExportGenesis * feat: update type + hook up to module.go * fix: remove PortKey * fix: imports + remove scoped keeper * nit: using NewPacketId helper and updating helper def to have correct params --- docs/ibc/proto-docs.md | 41 ++ modules/apps/29-fee/keeper/escrow.go | 1 - modules/apps/29-fee/keeper/escrow_test.go | 14 +- modules/apps/29-fee/keeper/genesis.go | 21 +- modules/apps/29-fee/keeper/genesis_test.go | 112 +++ modules/apps/29-fee/keeper/grpc_query_test.go | 10 +- modules/apps/29-fee/keeper/keeper.go | 69 +- modules/apps/29-fee/keeper/keeper_test.go | 72 ++ modules/apps/29-fee/module.go | 25 +- modules/apps/29-fee/types/genesis.go | 18 +- modules/apps/29-fee/types/genesis.pb.go | 674 +++++++++++++++++- modules/apps/29-fee/types/keys.go | 4 +- modules/apps/29-fee/types/msgs.go | 6 +- proto/ibc/applications/fee/v1/genesis.proto | 16 +- 14 files changed, 1019 insertions(+), 64 deletions(-) create mode 100644 modules/apps/29-fee/keeper/genesis_test.go diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 11f3ab0479b..4b05a167c58 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -30,7 +30,9 @@ - [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) - [ibc/applications/fee/v1/genesis.proto](#ibc/applications/fee/v1/genesis.proto) + - [FeeEnabledChannel](#ibc.applications.fee.v1.FeeEnabledChannel) - [GenesisState](#ibc.applications.fee.v1.GenesisState) + - [RegisteredRelayerAddress](#ibc.applications.fee.v1.RegisteredRelayerAddress) - [ibc/applications/fee/v1/query.proto](#ibc/applications/fee/v1/query.proto) - [QueryIncentivizedPacketRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketRequest) @@ -670,12 +672,51 @@ and an optional list of relayers that are permitted to receive the fee. + + +### FeeEnabledChannel +Contains the PortID & ChannelID for a fee enabled channel + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `port_id` | [string](#string) | | | +| `channel_id` | [string](#string) | | | + + + + + + ### GenesisState GenesisState defines the fee middleware genesis state +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `identified_fees` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | repeated | | +| `fee_enabled_channels` | [FeeEnabledChannel](#ibc.applications.fee.v1.FeeEnabledChannel) | repeated | | +| `registered_relayers` | [RegisteredRelayerAddress](#ibc.applications.fee.v1.RegisteredRelayerAddress) | repeated | | + + + + + + + + +### RegisteredRelayerAddress +Contains the address and counterparty address for a specific relayer (for distributing fees) + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [string](#string) | | | +| `counterparty_address` | [string](#string) | | | + + diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index 1f46d16bbf9..ce7c73db8ce 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -4,7 +4,6 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/ibc-go/modules/apps/29-fee/types" diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go index 91cd66a2a14..f9622bc3259 100644 --- a/modules/apps/29-fee/keeper/escrow_test.go +++ b/modules/apps/29-fee/keeper/escrow_test.go @@ -70,7 +70,7 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { ackFee = validCoins receiveFee = validCoins2 timeoutFee = validCoins3 - packetId := &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortKey, Sequence: uint64(1)} + packetId := &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortID, Sequence: uint64(1)} tc.malleate() fee := types.Fee{ackFee, receiveFee, timeoutFee} @@ -130,7 +130,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() { { "fee not found for packet", func() { // setting packetId with an invalid sequence of 2 - packetId = &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortKey, Sequence: uint64(2)} + packetId = &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortID, Sequence: uint64(2)} }, false, }, } @@ -149,7 +149,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() { ackFee = validCoins receiveFee = validCoins2 timeoutFee = validCoins3 - packetId = &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortKey, Sequence: validSeq} + packetId = &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortID, Sequence: validSeq} fee := types.Fee{receiveFee, ackFee, timeoutFee} // escrow the packet fee & store the fee in state @@ -188,7 +188,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() { } else { suite.Require().Error(err) - invalidPacketID := &channeltypes.PacketId{PortId: types.PortKey, ChannelId: validChannelId, Sequence: 1} + invalidPacketID := &channeltypes.PacketId{PortId: types.PortID, ChannelId: validChannelId, Sequence: 1} hasFeeInEscrow := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), invalidPacketID) // there should still be a fee in escrow for this packet suite.Require().True(hasFeeInEscrow) @@ -222,7 +222,7 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { { "fee not found for packet", func() { // setting packetId with an invalid sequence of 2 - packetId = &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortKey, Sequence: uint64(2)} + packetId = &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortID, Sequence: uint64(2)} }, false, }, } @@ -240,7 +240,7 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { ackFee = validCoins receiveFee = validCoins2 timeoutFee = validCoins3 - packetId = &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortKey, Sequence: validSeq} + packetId = &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortID, Sequence: validSeq} fee := types.Fee{receiveFee, ackFee, timeoutFee} // escrow the packet fee & store the fee in state @@ -274,7 +274,7 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { } else { suite.Require().Error(err) - invalidPacketID := &channeltypes.PacketId{PortId: types.PortKey, ChannelId: validChannelId, Sequence: 1} + invalidPacketID := &channeltypes.PacketId{PortId: types.PortID, ChannelId: validChannelId, Sequence: 1} hasFeeInEscrow := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), invalidPacketID) // there should still be a fee in escrow for this packet suite.Require().True(hasFeeInEscrow) diff --git a/modules/apps/29-fee/keeper/genesis.go b/modules/apps/29-fee/keeper/genesis.go index cb500443231..7ce7f11970f 100644 --- a/modules/apps/29-fee/keeper/genesis.go +++ b/modules/apps/29-fee/keeper/genesis.go @@ -1,16 +1,31 @@ package keeper -/* import ( sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/ibc-go/modules/apps/29-fee/types" ) // InitGenesis func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) { + for _, fee := range state.IdentifiedFees { + k.SetFeeInEscrow(ctx, fee) + } + + for _, addr := range state.RegisteredRelayers { + k.SetCounterpartyAddress(ctx, addr.Address, addr.CounterpartyAddress) + } + + for _, enabledChan := range state.FeeEnabledChannels { + k.SetFeeEnabled(ctx, enabledChan.PortId, enabledChan.ChannelId) + } } // ExportGenesis func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - return &types.GenesisState{} + return &types.GenesisState{ + IdentifiedFees: k.GetAllIdentifiedPacketFees(ctx), + FeeEnabledChannels: k.GetAllFeeEnabledChannels(ctx), + RegisteredRelayers: k.GetAllRelayerAddresses(ctx), + } } -*/ diff --git a/modules/apps/29-fee/keeper/genesis_test.go b/modules/apps/29-fee/keeper/genesis_test.go new file mode 100644 index 00000000000..4119891d380 --- /dev/null +++ b/modules/apps/29-fee/keeper/genesis_test.go @@ -0,0 +1,112 @@ +package keeper_test + +import ( + "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" + ibctesting "github.com/cosmos/ibc-go/testing" +) + +func (suite *KeeperTestSuite) TestInitGenesis() { + suite.SetupTest() + + // build PacketId & Fee + refundAcc := suite.chainA.SenderAccount.GetAddress() + packetId := types.NewPacketId( + ibctesting.FirstChannelID, + types.PortID, + uint64(1), + ) + fee := types.Fee{ + validCoins, + validCoins2, + validCoins3, + } + + // relayer addresses + sender := suite.chainA.SenderAccount.GetAddress().String() + counterparty := suite.chainB.SenderAccount.GetAddress().String() + + genesisState := types.GenesisState{ + IdentifiedFees: []*types.IdentifiedPacketFee{ + { + PacketId: packetId, + Fee: fee, + RefundAddress: refundAcc.String(), + Relayers: nil, + }, + }, + FeeEnabledChannels: []*types.FeeEnabledChannel{ + { + PortId: transfertypes.PortID, + ChannelId: ibctesting.FirstChannelID, + }, + }, + RegisteredRelayers: []*types.RegisteredRelayerAddress{ + { + Address: sender, + CounterpartyAddress: counterparty, + }, + }, + } + + suite.chainA.GetSimApp().IBCFeeKeeper.InitGenesis(suite.chainA.GetContext(), genesisState) + + // check fee + identifiedFee, found := suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeInEscrow(suite.chainA.GetContext(), packetId) + suite.Require().True(found) + suite.Require().Equal(genesisState.IdentifiedFees[0], &identifiedFee) + + // check fee is enabled + isEnabled := suite.chainA.GetSimApp().IBCFeeKeeper.IsFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, ibctesting.FirstChannelID) + suite.Require().True(isEnabled) + + // check relayers + addr, found := suite.chainA.GetSimApp().IBCFeeKeeper.GetCounterpartyAddress(suite.chainA.GetContext(), sender) + suite.Require().True(found) + suite.Require().Equal(genesisState.RegisteredRelayers[0].CounterpartyAddress, addr) +} + +func (suite *KeeperTestSuite) TestExportGenesis() { + suite.SetupTest() + // set fee enabled + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, ibctesting.FirstChannelID) + + // setup & escrow the packet fee + refundAcc := suite.chainA.SenderAccount.GetAddress() + packetId := types.NewPacketId( + ibctesting.FirstChannelID, + types.PortID, + uint64(1), + ) + fee := types.Fee{ + validCoins, + validCoins2, + validCoins3, + } + identifiedPacketFee := &types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + suite.Require().NoError(err) + + // relayer addresses + sender := suite.chainA.SenderAccount.GetAddress().String() + counterparty := suite.chainB.SenderAccount.GetAddress().String() + // set counterparty address + suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainA.GetContext(), sender, counterparty) + + // export genesis + genesisState := suite.chainA.GetSimApp().IBCFeeKeeper.ExportGenesis(suite.chainA.GetContext()) + + // check fee enabled + suite.Require().Equal(ibctesting.FirstChannelID, genesisState.FeeEnabledChannels[0].ChannelId) + suite.Require().Equal(transfertypes.PortID, genesisState.FeeEnabledChannels[0].PortId) + + // check fee + suite.Require().Equal(packetId, genesisState.IdentifiedFees[0].PacketId) + suite.Require().Equal(fee, genesisState.IdentifiedFees[0].Fee) + suite.Require().Equal(refundAcc.String(), genesisState.IdentifiedFees[0].RefundAddress) + suite.Require().Equal([]string(nil), genesisState.IdentifiedFees[0].Relayers) + + // check registered relayer addresses + suite.Require().Equal(sender, genesisState.RegisteredRelayers[0].Address) + suite.Require().Equal(counterparty, genesisState.RegisteredRelayers[0].CounterpartyAddress) +} diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index 899df77d5bd..1403326837a 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -17,8 +17,8 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacket() { ) // setup - validPacketId := types.NewPacketId(ibctesting.FirstChannelID, 1) - invalidPacketId := types.NewPacketId(ibctesting.FirstChannelID, 2) + validPacketId := types.NewPacketId(ibctesting.FirstChannelID, types.PortID, 1) + invalidPacketId := types.NewPacketId(ibctesting.FirstChannelID, types.PortID, 2) identifiedPacketFee := types.NewIdentifiedPacketFee( validPacketId, types.Fee{ @@ -110,9 +110,9 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPackets() { func() { refundAcc := suite.chainA.SenderAccount.GetAddress() - fee1 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, 1), fee, refundAcc.String(), []string(nil)) - fee2 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, 2), fee, refundAcc.String(), []string(nil)) - fee3 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, 3), fee, refundAcc.String(), []string(nil)) + fee1 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, types.PortID, 1), fee, refundAcc.String(), []string(nil)) + fee2 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, types.PortID, 2), fee, refundAcc.String(), []string(nil)) + fee3 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, types.PortID, 3), fee, refundAcc.String(), []string(nil)) expPackets = []*types.IdentifiedPacketFee{} expPackets = append(expPackets, fee1, fee2, fee3) diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index 3691204d2a6..1fda4910bc2 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -1,11 +1,12 @@ package keeper import ( + "strings" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/ibc-go/modules/apps/29-fee/types" @@ -53,17 +54,17 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+host.ModuleName+"-"+types.ModuleName) } +// ChanCloseInit wraps the channel keeper's function in order to expose it to underlying app. +func (k Keeper) ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capabilitytypes.Capability) error { + return k.channelKeeper.ChanCloseInit(ctx, portID, channelID, chanCap) +} + // BindPort defines a wrapper function for the port Keeper's function in // order to expose it to module's InitGenesis function func (k Keeper) BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability { return k.portKeeper.BindPort(ctx, portID) } -// ChanCloseInit wraps the channel keeper's function in order to expose it to underlying app. -func (k Keeper) ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capabilitytypes.Capability) error { - return k.channelKeeper.ChanCloseInit(ctx, portID, channelID, chanCap) -} - // GetChannel wraps IBC ChannelKeeper's GetChannel function func (k Keeper) GetChannel(ctx sdk.Context, portID, channelID string) (channeltypes.Channel, bool) { return k.channelKeeper.GetChannel(ctx, portID, channelID) @@ -104,6 +105,27 @@ func (k Keeper) IsFeeEnabled(ctx sdk.Context, portID, channelID string) bool { return store.Get(types.FeeEnabledKey(portID, channelID)) != nil } +// GetAllFeeEnabledChannels returns a list of all ics29 enabled channels containing portID & channelID that are stored in state +func (k Keeper) GetAllFeeEnabledChannels(ctx sdk.Context) []*types.FeeEnabledChannel { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, []byte(types.FeeEnabledKeyPrefix)) + defer iterator.Close() + + var enabledChArr []*types.FeeEnabledChannel + for ; iterator.Valid(); iterator.Next() { + keySplit := strings.Split(string(iterator.Key()), "/") + + ch := &types.FeeEnabledChannel{ + PortId: keySplit[1], + ChannelId: keySplit[2], + } + + enabledChArr = append(enabledChArr, ch) + } + + return enabledChArr +} + // 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) { @@ -124,6 +146,26 @@ func (k Keeper) GetCounterpartyAddress(ctx sdk.Context, address string) (string, return addr, true } +func (k Keeper) GetAllRelayerAddresses(ctx sdk.Context) []*types.RegisteredRelayerAddress { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, []byte(types.RelayerAddressKeyPrefix)) + defer iterator.Close() + + var registeredAddrArr []*types.RegisteredRelayerAddress + for ; iterator.Valid(); iterator.Next() { + keySplit := strings.Split(string(iterator.Key()), "/") + + addr := &types.RegisteredRelayerAddress{ + Address: keySplit[1], + CounterpartyAddress: string(iterator.Value()), + } + + registeredAddrArr = append(registeredAddrArr, addr) + } + + return registeredAddrArr +} + // Stores a Fee for a given packet in state func (k Keeper) SetFeeInEscrow(ctx sdk.Context, fee *types.IdentifiedPacketFee) { store := ctx.KVStore(k.storeKey) @@ -159,6 +201,21 @@ func (k Keeper) HasFeeInEscrow(ctx sdk.Context, packetId *channeltypes.PacketId) return store.Has(key) } +// GetAllIdentifiedPacketFees returns a list of all IdentifiedPacketFees that are stored in state +func (k Keeper) GetAllIdentifiedPacketFees(ctx sdk.Context) []*types.IdentifiedPacketFee { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, []byte(types.FeeInEscrowPrefix)) + defer iterator.Close() + + var identifiedFees []*types.IdentifiedPacketFee + for ; iterator.Valid(); iterator.Next() { + fee := k.MustUnmarshalFee(iterator.Value()) + identifiedFees = append(identifiedFees, &fee) + } + + return identifiedFees +} + // MustMarshalFee attempts to encode a Fee object and returns the // raw encoded bytes. It panics on error. func (k Keeper) MustMarshalFee(fee *types.IdentifiedPacketFee) []byte { diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index 476a14698b0..f4315baa3b6 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -66,3 +66,75 @@ func SetupFeePath(path *ibctesting.Path) error { func TestKeeperTestSuite(t *testing.T) { suite.Run(t, new(KeeperTestSuite)) } + +func (suite *KeeperTestSuite) TestGetAllIdentifiedPacketFees() { + // escrow a fee + refundAcc := suite.chainA.SenderAccount.GetAddress() + ackFee := validCoins + receiveFee := validCoins2 + timeoutFee := validCoins3 + packetId := &channeltypes.PacketId{ChannelId: ibctesting.FirstChannelID, PortId: types.PortID, Sequence: uint64(1)} + fee := types.Fee{ackFee, receiveFee, timeoutFee} + identifiedPacketFee := &types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} + + // escrow the packet fee + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + suite.Require().NoError(err) + + expectedFees := []*types.IdentifiedPacketFee{ + { + PacketId: packetId, + Fee: fee, + RefundAddress: refundAcc.String(), + Relayers: nil, + }, + } + + fees := suite.chainA.GetSimApp().IBCFeeKeeper.GetAllIdentifiedPacketFees(suite.chainA.GetContext()) + suite.Require().Len(fees, len(expectedFees)) + suite.Require().Equal(fees, expectedFees) +} + +func (suite *KeeperTestSuite) TestGetAllFeeEnabledChannels() { + suite.SetupTest() // reset + + validPortId := "ibcmoduleport" + // set two channels enabled + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, ibctesting.FirstChannelID) + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), validPortId, ibctesting.FirstChannelID) + + expectedCh := []*types.FeeEnabledChannel{ + { + PortId: validPortId, + ChannelId: ibctesting.FirstChannelID, + }, + { + PortId: transfertypes.PortID, + ChannelId: ibctesting.FirstChannelID, + }, + } + + ch := suite.chainA.GetSimApp().IBCFeeKeeper.GetAllFeeEnabledChannels(suite.chainA.GetContext()) + suite.Require().Len(ch, len(expectedCh)) + suite.Require().Equal(ch, expectedCh) +} + +func (suite *KeeperTestSuite) TestGetAllRelayerAddresses() { + suite.SetupTest() // reset + + sender := suite.chainA.SenderAccount.GetAddress().String() + counterparty := suite.chainB.SenderAccount.GetAddress().String() + + suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainA.GetContext(), sender, counterparty) + + expectedAddr := []*types.RegisteredRelayerAddress{ + { + Address: sender, + CounterpartyAddress: counterparty, + }, + } + + addr := suite.chainA.GetSimApp().IBCFeeKeeper.GetAllRelayerAddresses(suite.chainA.GetContext()) + suite.Require().Len(addr, len(expectedAddr)) + suite.Require().Equal(addr, expectedAddr) +} diff --git a/modules/apps/29-fee/module.go b/modules/apps/29-fee/module.go index 61e39846584..78b9dc6d091 100644 --- a/modules/apps/29-fee/module.go +++ b/modules/apps/29-fee/module.go @@ -3,6 +3,7 @@ package fee import ( "context" "encoding/json" + "fmt" "math/rand" "github.com/cosmos/cosmos-sdk/client" @@ -51,19 +52,18 @@ func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) // DefaultGenesis returns default genesis state as raw bytes for the ibc // 29-fee module. func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { - // return cdc.MustMarshalJSON(types.DefaultGenesisState()) + return cdc.MustMarshalJSON(types.DefaultGenesisState()) return nil } // ValidateGenesis performs genesis state validation for the 29-fee module. func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { - // var gs types.GenesisState - // if err := cdc.UnmarshalJSON(bz, &gs); err != nil { - // return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) - // } + var gs types.GenesisState + if err := cdc.UnmarshalJSON(bz, &gs); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } - // return gs.Validate() - return nil + return gs.Validate() } // RegisterRESTRoutes implements AppModuleBasic interface @@ -127,18 +127,17 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { // InitGenesis performs genesis initialization for the ibc-29-fee module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { - // var genesisState types.GenesisState - // cdc.MustUnmarshalJSON(data, &genesisState) - // am.keeper.InitGenesis(ctx, genesisState) + var genesisState types.GenesisState + cdc.MustUnmarshalJSON(data, &genesisState) + am.keeper.InitGenesis(ctx, genesisState) return []abci.ValidatorUpdate{} } // ExportGenesis returns the exported genesis state as raw bytes for the ibc-29-fee // module. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { - // gs := am.keeper.ExportGenesis(ctx) - // return cdc.MustMarshalJSON(gs) - return nil + gs := am.keeper.ExportGenesis(ctx) + return cdc.MustMarshalJSON(gs) } // ConsensusVersion implements AppModule/ConsensusVersion. diff --git a/modules/apps/29-fee/types/genesis.go b/modules/apps/29-fee/types/genesis.go index 4086325bebb..3f85192d930 100644 --- a/modules/apps/29-fee/types/genesis.go +++ b/modules/apps/29-fee/types/genesis.go @@ -1,29 +1,25 @@ package types -/* -import ( - host "github.com/cosmos/ibc-go/modules/core/24-host" -) - // NewGenesisState creates a 29-fee GenesisState instance. -func NewGenesisState(portID string, denomTraces Traces, params Params) *GenesisState { +func NewGenesisState(identifiedFees []*IdentifiedPacketFee, feeEnabledChannels []*FeeEnabledChannel, registeredRelayers []*RegisteredRelayerAddress) *GenesisState { return &GenesisState{ - Params: params, + IdentifiedFees: identifiedFees, + FeeEnabledChannels: feeEnabledChannels, + RegisteredRelayers: registeredRelayers, } } // DefaultGenesisState returns a GenesisState with "transfer" as the default PortID. func DefaultGenesisState() *GenesisState { return &GenesisState{ + IdentifiedFees: []*IdentifiedPacketFee{}, + FeeEnabledChannels: []*FeeEnabledChannel{}, + RegisteredRelayers: []*RegisteredRelayerAddress{}, } } // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { - if err := host.PortIdentifierValidator(gs.PortId); err != nil { - return err - } return nil } -*/ diff --git a/modules/apps/29-fee/types/genesis.pb.go b/modules/apps/29-fee/types/genesis.pb.go index b07a497011f..80a2e44d3df 100644 --- a/modules/apps/29-fee/types/genesis.pb.go +++ b/modules/apps/29-fee/types/genesis.pb.go @@ -25,6 +25,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the fee middleware genesis state type GenesisState struct { + IdentifiedFees []*IdentifiedPacketFee `protobuf:"bytes,1,rep,name=identified_fees,json=identifiedFees,proto3" json:"identified_fees,omitempty" yaml:"identified_fees"` + FeeEnabledChannels []*FeeEnabledChannel `protobuf:"bytes,2,rep,name=fee_enabled_channels,json=feeEnabledChannels,proto3" json:"fee_enabled_channels,omitempty" yaml:"fee_enabled_channels"` + RegisteredRelayers []*RegisteredRelayerAddress `protobuf:"bytes,3,rep,name=registered_relayers,json=registeredRelayers,proto3" json:"registered_relayers,omitempty" yaml:"registered_relayers"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -60,8 +63,137 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo +func (m *GenesisState) GetIdentifiedFees() []*IdentifiedPacketFee { + if m != nil { + return m.IdentifiedFees + } + return nil +} + +func (m *GenesisState) GetFeeEnabledChannels() []*FeeEnabledChannel { + if m != nil { + return m.FeeEnabledChannels + } + return nil +} + +func (m *GenesisState) GetRegisteredRelayers() []*RegisteredRelayerAddress { + if m != nil { + return m.RegisteredRelayers + } + return nil +} + +// Contains the PortID & ChannelID for a fee enabled channel +type FeeEnabledChannel struct { + PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty" yaml:"port_id"` + ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` +} + +func (m *FeeEnabledChannel) Reset() { *m = FeeEnabledChannel{} } +func (m *FeeEnabledChannel) String() string { return proto.CompactTextString(m) } +func (*FeeEnabledChannel) ProtoMessage() {} +func (*FeeEnabledChannel) Descriptor() ([]byte, []int) { + return fileDescriptor_7191992e856dff95, []int{1} +} +func (m *FeeEnabledChannel) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FeeEnabledChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FeeEnabledChannel.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *FeeEnabledChannel) XXX_Merge(src proto.Message) { + xxx_messageInfo_FeeEnabledChannel.Merge(m, src) +} +func (m *FeeEnabledChannel) XXX_Size() int { + return m.Size() +} +func (m *FeeEnabledChannel) XXX_DiscardUnknown() { + xxx_messageInfo_FeeEnabledChannel.DiscardUnknown(m) +} + +var xxx_messageInfo_FeeEnabledChannel proto.InternalMessageInfo + +func (m *FeeEnabledChannel) GetPortId() string { + if m != nil { + return m.PortId + } + return "" +} + +func (m *FeeEnabledChannel) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +// Contains the address and counterparty address for a specific relayer (for distributing fees) +type RegisteredRelayerAddress struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + CounterpartyAddress string `protobuf:"bytes,2,opt,name=counterparty_address,json=counterpartyAddress,proto3" json:"counterparty_address,omitempty" yaml:"counterparty_address"` +} + +func (m *RegisteredRelayerAddress) Reset() { *m = RegisteredRelayerAddress{} } +func (m *RegisteredRelayerAddress) String() string { return proto.CompactTextString(m) } +func (*RegisteredRelayerAddress) ProtoMessage() {} +func (*RegisteredRelayerAddress) Descriptor() ([]byte, []int) { + return fileDescriptor_7191992e856dff95, []int{2} +} +func (m *RegisteredRelayerAddress) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RegisteredRelayerAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RegisteredRelayerAddress.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *RegisteredRelayerAddress) XXX_Merge(src proto.Message) { + xxx_messageInfo_RegisteredRelayerAddress.Merge(m, src) +} +func (m *RegisteredRelayerAddress) XXX_Size() int { + return m.Size() +} +func (m *RegisteredRelayerAddress) XXX_DiscardUnknown() { + xxx_messageInfo_RegisteredRelayerAddress.DiscardUnknown(m) +} + +var xxx_messageInfo_RegisteredRelayerAddress proto.InternalMessageInfo + +func (m *RegisteredRelayerAddress) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *RegisteredRelayerAddress) GetCounterpartyAddress() string { + if m != nil { + return m.CounterpartyAddress + } + return "" +} + func init() { proto.RegisterType((*GenesisState)(nil), "ibc.applications.fee.v1.GenesisState") + proto.RegisterType((*FeeEnabledChannel)(nil), "ibc.applications.fee.v1.FeeEnabledChannel") + proto.RegisterType((*RegisteredRelayerAddress)(nil), "ibc.applications.fee.v1.RegisteredRelayerAddress") } func init() { @@ -69,19 +201,37 @@ func init() { } var fileDescriptor_7191992e856dff95 = []byte{ - // 192 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcd, 0x4c, 0x4a, 0xd6, - 0x4f, 0x2c, 0x28, 0xc8, 0xc9, 0x4c, 0x4e, 0x2c, 0xc9, 0xcc, 0xcf, 0x2b, 0xd6, 0x4f, 0x4b, 0x4d, - 0xd5, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, - 0xc9, 0x17, 0x12, 0xcf, 0x4c, 0x4a, 0xd6, 0x43, 0x56, 0xa6, 0x97, 0x96, 0x9a, 0xaa, 0x57, 0x66, - 0x28, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xa3, 0x0f, 0x62, 0x41, 0x94, 0x4b, 0x29, 0xe2, - 0x32, 0x15, 0xa4, 0x0b, 0xac, 0x44, 0x89, 0x8f, 0x8b, 0xc7, 0x1d, 0x62, 0x45, 0x70, 0x49, 0x62, - 0x49, 0xaa, 0x93, 0xcf, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, - 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x19, 0xa5, - 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x27, 0xe7, 0x17, 0xe7, 0xe6, 0x17, - 0xeb, 0x67, 0x26, 0x25, 0xeb, 0xa6, 0xe7, 0xeb, 0xe7, 0xe6, 0xa7, 0x94, 0xe6, 0xa4, 0x16, 0x83, - 0x6c, 0x2a, 0xd6, 0x37, 0xb2, 0xd4, 0x05, 0x59, 0x52, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, - 0xb6, 0xc4, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x90, 0xf8, 0xaf, 0x33, 0xdf, 0x00, 0x00, 0x00, + // 470 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x41, 0x8b, 0xd3, 0x40, + 0x14, 0xc7, 0x9b, 0x2d, 0xec, 0xb2, 0xa3, 0xac, 0xec, 0x6c, 0xd5, 0x50, 0x21, 0x59, 0x07, 0x84, + 0x45, 0xdd, 0x84, 0x56, 0x2f, 0x7a, 0xb3, 0x62, 0xa5, 0xe0, 0x41, 0xc6, 0x9b, 0x97, 0x30, 0xc9, + 0xbc, 0x64, 0x07, 0xd3, 0x4c, 0x9c, 0x99, 0x16, 0x7a, 0xf0, 0x22, 0x08, 0x1e, 0xfd, 0x58, 0x1e, + 0xf7, 0xe8, 0xa9, 0x48, 0xfb, 0x0d, 0xfa, 0x09, 0x24, 0x99, 0x76, 0xb7, 0xd4, 0xe6, 0xf6, 0x66, + 0xde, 0xef, 0xff, 0xff, 0xe7, 0x65, 0x1e, 0x7a, 0x22, 0xe2, 0x24, 0x64, 0x65, 0x99, 0x8b, 0x84, + 0x19, 0x21, 0x0b, 0x1d, 0xa6, 0x00, 0xe1, 0xb4, 0x17, 0x66, 0x50, 0x80, 0x16, 0x3a, 0x28, 0x95, + 0x34, 0x12, 0x3f, 0x14, 0x71, 0x12, 0x6c, 0x63, 0x41, 0x0a, 0x10, 0x4c, 0x7b, 0xdd, 0x4e, 0x26, + 0x33, 0x59, 0x33, 0x61, 0x55, 0x59, 0xbc, 0xfb, 0xb8, 0xc9, 0xb5, 0x52, 0xd5, 0x08, 0xf9, 0xd1, + 0x46, 0x77, 0xdf, 0xdb, 0x8c, 0x4f, 0x86, 0x19, 0xc0, 0x5f, 0xd1, 0x3d, 0xc1, 0xa1, 0x30, 0x22, + 0x15, 0xc0, 0xa3, 0x14, 0x40, 0xbb, 0xce, 0x79, 0xfb, 0xe2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xe4, 0xa7, + 0x83, 0xdc, 0xa6, 0x41, 0xb0, 0x8b, 0x8e, 0x98, 0x2d, 0x6d, 0x3e, 0xdd, 0x1c, 0x31, 0x45, 0x9d, + 0x44, 0x4e, 0x0a, 0x03, 0xaa, 0x64, 0xca, 0xcc, 0xa2, 0x0d, 0x66, 0x63, 0xb7, 0x9e, 0x61, 0x1f, + 0x45, 0xe8, 0xd9, 0xf6, 0xf5, 0xe6, 0xb7, 0x7d, 0xf8, 0xbd, 0xf0, 0x9c, 0xeb, 0x85, 0xe7, 0xfc, + 0x5d, 0x78, 0xce, 0xaf, 0xa5, 0xd7, 0xba, 0x5e, 0x7a, 0xad, 0x3f, 0x4b, 0xaf, 0xf5, 0xb9, 0x9f, + 0x09, 0x73, 0x35, 0x89, 0x83, 0x44, 0x8e, 0xc3, 0x44, 0xea, 0xb1, 0xd4, 0xa1, 0x88, 0x93, 0xcb, + 0x4c, 0x86, 0x63, 0xc9, 0x27, 0x39, 0xe8, 0x6a, 0xc9, 0x75, 0xd8, 0x7f, 0x75, 0x59, 0xed, 0xb7, + 0x99, 0x95, 0xa0, 0xe3, 0xc3, 0x7a, 0xbf, 0x5f, 0xfc, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x14, 0xf8, + 0xcc, 0x98, 0x5a, 0x03, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -104,6 +254,122 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.RegisteredRelayers) > 0 { + for iNdEx := len(m.RegisteredRelayers) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RegisteredRelayers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.FeeEnabledChannels) > 0 { + for iNdEx := len(m.FeeEnabledChannels) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.FeeEnabledChannels[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.IdentifiedFees) > 0 { + for iNdEx := len(m.IdentifiedFees) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.IdentifiedFees[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *FeeEnabledChannel) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *FeeEnabledChannel) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FeeEnabledChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x12 + } + if len(m.PortId) > 0 { + i -= len(m.PortId) + copy(dAtA[i:], m.PortId) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.PortId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RegisteredRelayerAddress) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RegisteredRelayerAddress) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RegisteredRelayerAddress) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CounterpartyAddress) > 0 { + i -= len(m.CounterpartyAddress) + copy(dAtA[i:], m.CounterpartyAddress) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.CounterpartyAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } return len(dAtA) - i, nil } @@ -124,6 +390,58 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l + if len(m.IdentifiedFees) > 0 { + for _, e := range m.IdentifiedFees { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.FeeEnabledChannels) > 0 { + for _, e := range m.FeeEnabledChannels { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.RegisteredRelayers) > 0 { + for _, e := range m.RegisteredRelayers { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func (m *FeeEnabledChannel) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PortId) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + +func (m *RegisteredRelayerAddress) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + l = len(m.CounterpartyAddress) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } return n } @@ -162,6 +480,336 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IdentifiedFees", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.IdentifiedFees = append(m.IdentifiedFees, &IdentifiedPacketFee{}) + if err := m.IdentifiedFees[len(m.IdentifiedFees)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeEnabledChannels", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FeeEnabledChannels = append(m.FeeEnabledChannels, &FeeEnabledChannel{}) + if err := m.FeeEnabledChannels[len(m.FeeEnabledChannels)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RegisteredRelayers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RegisteredRelayers = append(m.RegisteredRelayers, &RegisteredRelayerAddress{}) + if err := m.RegisteredRelayers[len(m.RegisteredRelayers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *FeeEnabledChannel) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: FeeEnabledChannel: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FeeEnabledChannel: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RegisteredRelayerAddress) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RegisteredRelayerAddress: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RegisteredRelayerAddress: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CounterpartyAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index 3df1f637a6c..522177c9aff 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -13,8 +13,8 @@ const ( // StoreKey is the store key string for IBC fee module StoreKey = ModuleName - // PortKey is the port id that is wrapped by fee middleware - PortKey = "feetransfer" + // PortID is the port id that is wrapped by fee middleware + PortID = "feetransfer" // RouterKey is the message route for IBC fee module RouterKey = ModuleName diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index 53bcc0b5b74..bd04c041bb5 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -171,6 +171,8 @@ func NewIdentifiedPacketFee(packetId *channeltypes.PacketId, fee Fee, refundAddr } } -func NewPacketId(channelId string, id uint64) *channeltypes.PacketId { - return &channeltypes.PacketId{ChannelId: channelId, PortId: PortKey, Sequence: id} +// NewPacketId returns a new instance of PacketId +// TODO: move to channeltypes +func NewPacketId(channelId, portId string, seq uint64) *channeltypes.PacketId { + return &channeltypes.PacketId{ChannelId: channelId, PortId: portId, Sequence: seq} } diff --git a/proto/ibc/applications/fee/v1/genesis.proto b/proto/ibc/applications/fee/v1/genesis.proto index 4006b5fdc9d..cef33b501a0 100644 --- a/proto/ibc/applications/fee/v1/genesis.proto +++ b/proto/ibc/applications/fee/v1/genesis.proto @@ -7,5 +7,19 @@ option go_package = "github.com/cosmos/ibc-go/modules/apps/29-fee/types"; // GenesisState defines the fee middleware genesis state message GenesisState { - // TODO + repeated IdentifiedPacketFee identified_fees = 1 [(gogoproto.moretags) = "yaml:\"identified_fees\""]; + repeated FeeEnabledChannel fee_enabled_channels = 2 [(gogoproto.moretags) = "yaml:\"fee_enabled_channels\""]; + repeated RegisteredRelayerAddress registered_relayers = 3 [(gogoproto.moretags) = "yaml:\"registered_relayers\""]; +} + +// Contains the PortID & ChannelID for a fee enabled channel +message FeeEnabledChannel { + string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; + string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""]; +} + +// Contains the address and counterparty address for a specific relayer (for distributing fees) +message RegisteredRelayerAddress { + string address = 1; + string counterparty_address = 2 [(gogoproto.moretags) = "yaml:\"counterparty_address\""]; } From 4dbc83eb5bfcb60ebda325cec0dd4e52134b7c91 Mon Sep 17 00:00:00 2001 From: Sean King Date: Wed, 24 Nov 2021 18:21:42 +0100 Subject: [PATCH 11/79] feat: adding genesis validation + tests (#561) * feat: adding genesis validation + tests * fix: imports * Update modules/apps/29-fee/types/genesis.go * fix: nit * Update modules/apps/29-fee/types/genesis_test.go Co-authored-by: Aditya * nit: imporve default gen val test * chore: move packetId + val to channeltypes and use validate fn Co-authored-by: Aditya --- modules/apps/29-fee/keeper/genesis_test.go | 5 +- modules/apps/29-fee/keeper/grpc_query_test.go | 11 +- modules/apps/29-fee/types/genesis.go | 37 ++++ modules/apps/29-fee/types/genesis_test.go | 169 ++++++++++++++++-- modules/apps/29-fee/types/msgs.go | 67 ++++--- modules/core/04-channel/types/packet.go | 22 +++ 6 files changed, 253 insertions(+), 58 deletions(-) diff --git a/modules/apps/29-fee/keeper/genesis_test.go b/modules/apps/29-fee/keeper/genesis_test.go index 4119891d380..7c5939c7b2f 100644 --- a/modules/apps/29-fee/keeper/genesis_test.go +++ b/modules/apps/29-fee/keeper/genesis_test.go @@ -3,6 +3,7 @@ package keeper_test import ( "github.com/cosmos/ibc-go/modules/apps/29-fee/types" transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/testing" ) @@ -11,7 +12,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() { // build PacketId & Fee refundAcc := suite.chainA.SenderAccount.GetAddress() - packetId := types.NewPacketId( + packetId := channeltypes.NewPacketId( ibctesting.FirstChannelID, types.PortID, uint64(1), @@ -73,7 +74,7 @@ func (suite *KeeperTestSuite) TestExportGenesis() { // setup & escrow the packet fee refundAcc := suite.chainA.SenderAccount.GetAddress() - packetId := types.NewPacketId( + packetId := channeltypes.NewPacketId( ibctesting.FirstChannelID, types.PortID, uint64(1), diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index 1403326837a..560ccb6ffa3 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/testing" ) @@ -17,8 +18,8 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacket() { ) // setup - validPacketId := types.NewPacketId(ibctesting.FirstChannelID, types.PortID, 1) - invalidPacketId := types.NewPacketId(ibctesting.FirstChannelID, types.PortID, 2) + validPacketId := channeltypes.NewPacketId(ibctesting.FirstChannelID, types.PortID, 1) + invalidPacketId := channeltypes.NewPacketId(ibctesting.FirstChannelID, types.PortID, 2) identifiedPacketFee := types.NewIdentifiedPacketFee( validPacketId, types.Fee{ @@ -110,9 +111,9 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPackets() { func() { refundAcc := suite.chainA.SenderAccount.GetAddress() - fee1 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, types.PortID, 1), fee, refundAcc.String(), []string(nil)) - fee2 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, types.PortID, 2), fee, refundAcc.String(), []string(nil)) - fee3 := types.NewIdentifiedPacketFee(types.NewPacketId(ibctesting.FirstChannelID, types.PortID, 3), fee, refundAcc.String(), []string(nil)) + fee1 := types.NewIdentifiedPacketFee(channeltypes.NewPacketId(ibctesting.FirstChannelID, types.PortID, 1), fee, refundAcc.String(), []string(nil)) + fee2 := types.NewIdentifiedPacketFee(channeltypes.NewPacketId(ibctesting.FirstChannelID, types.PortID, 2), fee, refundAcc.String(), []string(nil)) + fee3 := types.NewIdentifiedPacketFee(channeltypes.NewPacketId(ibctesting.FirstChannelID, types.PortID, 3), fee, refundAcc.String(), []string(nil)) expPackets = []*types.IdentifiedPacketFee{} expPackets = append(expPackets, fee1, fee2, fee3) diff --git a/modules/apps/29-fee/types/genesis.go b/modules/apps/29-fee/types/genesis.go index 3f85192d930..5a0ebdeb9d2 100644 --- a/modules/apps/29-fee/types/genesis.go +++ b/modules/apps/29-fee/types/genesis.go @@ -1,5 +1,12 @@ package types +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + host "github.com/cosmos/ibc-go/modules/core/24-host" +) + // NewGenesisState creates a 29-fee GenesisState instance. func NewGenesisState(identifiedFees []*IdentifiedPacketFee, feeEnabledChannels []*FeeEnabledChannel, registeredRelayers []*RegisteredRelayerAddress) *GenesisState { return &GenesisState{ @@ -21,5 +28,35 @@ func DefaultGenesisState() *GenesisState { // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { + // Validate IdentifiedPacketFees + for _, fee := range gs.IdentifiedFees { + err := fee.Validate() + if err != nil { + return err + } + } + + // Validate FeeEnabledChannels + for _, feeCh := range gs.FeeEnabledChannels { + if err := host.PortIdentifierValidator(feeCh.PortId); err != nil { + return sdkerrors.Wrap(err, "invalid source port ID") + } + if err := host.ChannelIdentifierValidator(feeCh.ChannelId); err != nil { + return sdkerrors.Wrap(err, "invalid source channel ID") + } + } + + // Validate RegisteredRelayers + for _, rel := range gs.RegisteredRelayers { + _, err := sdk.AccAddressFromBech32(rel.Address) + if err != nil { + return sdkerrors.Wrap(err, "failed to convert source relayer address into sdk.AccAddress") + } + + if rel.CounterpartyAddress == "" { + return ErrCounterpartyAddressEmpty + } + } + return nil } diff --git a/modules/apps/29-fee/types/genesis_test.go b/modules/apps/29-fee/types/genesis_test.go index 30516612cce..1a98142a870 100644 --- a/modules/apps/29-fee/types/genesis_test.go +++ b/modules/apps/29-fee/types/genesis_test.go @@ -1,44 +1,177 @@ package types_test -/* import ( "testing" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/secp256k1" - "github.com/cosmos/ibc-go/modules/apps/transfer/types" + "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" + ibctesting "github.com/cosmos/ibc-go/testing" +) + +var ( + addr1 = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() + addr2 = sdk.AccAddress("testaddr2").String() + validCoins = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}} + validCoins2 = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(200)}} + validCoins3 = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(300)}} ) func TestValidateGenesis(t *testing.T) { + var ( + packetId *channeltypes.PacketId + fee types.Fee + refundAcc string + sender string + counterparty string + portID string + channelID string + seq uint64 + ) + testCases := []struct { name string - genState *types.GenesisState + malleate func() expPass bool }{ { - name: "default", - genState: types.DefaultGenesisState(), - expPass: true, + "valid genesis", + func() {}, + true, }, { - "valid genesis", - &types.GenesisState{ - PortId: "portidone", + "invalid packetId: invalid channel", + func() { + packetId = channeltypes.NewPacketId( + "", + portID, + seq, + ) }, - true, + false, + }, + { + "invalid packetId: invalid port", + func() { + packetId = channeltypes.NewPacketId( + channelID, + "", + seq, + ) + }, + false, }, { - "invalid client", - &types.GenesisState{ - PortId: "(INVALIDPORT)", + "invalid packetId: invalid sequence", + func() { + packetId = channeltypes.NewPacketId( + channelID, + portID, + 0, + ) + }, + false, + }, + { + "invalid packetId: invalid fee", + func() { + fee = types.Fee{ + sdk.Coins{}, + sdk.Coins{}, + sdk.Coins{}, + } + }, + false, + }, + { + "invalid packetId: invalid refundAcc", + func() { + refundAcc = "" + }, + false, + }, + { + "invalid FeeEnabledChannel: invalid ChannelID", + func() { + channelID = "" + }, + false, + }, + { + "invalid FeeEnabledChannel: invalid PortID", + func() { + portID = "" + }, + false, + }, + { + "invalid RegisteredRelayers: invalid sender", + func() { + sender = "" + }, + false, + }, + { + "invalid RegisteredRelayers: invalid counterparty", + func() { + counterparty = "" }, false, }, } for _, tc := range testCases { - tc := tc - err := tc.genState.Validate() + portID = types.PortID + channelID = ibctesting.FirstChannelID + seq = uint64(1) + + // build PacketId & Fee + packetId = channeltypes.NewPacketId( + portID, + channelID, + seq, + ) + fee = types.Fee{ + validCoins, + validCoins2, + validCoins3, + } + + refundAcc = addr1 + + // relayer addresses + sender = addr1 + counterparty = addr2 + + tc.malleate() + + genState := types.GenesisState{ + IdentifiedFees: []*types.IdentifiedPacketFee{ + { + PacketId: packetId, + Fee: fee, + RefundAddress: refundAcc, + Relayers: nil, + }, + }, + FeeEnabledChannels: []*types.FeeEnabledChannel{ + { + PortId: portID, + ChannelId: channelID, + }, + }, + RegisteredRelayers: []*types.RegisteredRelayerAddress{ + { + Address: sender, + CounterpartyAddress: counterparty, + }, + }, + } + + err := genState.Validate() if tc.expPass { require.NoError(t, err, tc.name) } else { @@ -46,4 +179,8 @@ func TestValidateGenesis(t *testing.T) { } } } -*/ + +func TestValidateDefaultGenesis(t *testing.T) { + err := types.DefaultGenesisState().Validate() + require.NoError(t, err) +} diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index bd04c041bb5..4653b69ce18 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -111,42 +111,15 @@ func NewMsgPayPacketFeeAsync(identifiedPacketFee IdentifiedPacketFee) *MsgPayPac // ValidateBasic performs a basic check of the MsgPayPacketFeeAsync fields func (msg MsgPayPacketFeeAsync) ValidateBasic() error { - // validate channelId - err := host.ChannelIdentifierValidator(msg.IdentifiedPacketFee.PacketId.ChannelId) - if err != nil { - return err - } - - // validate portId - err = host.PortIdentifierValidator(msg.IdentifiedPacketFee.PacketId.PortId) - if err != nil { - return err - } - // signer check - _, err = sdk.AccAddressFromBech32(msg.IdentifiedPacketFee.RefundAddress) + _, err := sdk.AccAddressFromBech32(msg.IdentifiedPacketFee.RefundAddress) if err != nil { return sdkerrors.Wrap(err, "failed to convert msg.Signer into sdk.AccAddress") } - // enforce relayer is nil - if msg.IdentifiedPacketFee.Relayers != nil { - return ErrRelayersNotNil - } - - // ensure sequence is not 0 - if msg.IdentifiedPacketFee.PacketId.Sequence == 0 { - return sdkerrors.ErrInvalidSequence - } - - // if any of the fee's are invalid return an error - if !msg.IdentifiedPacketFee.Fee.AckFee.IsValid() || !msg.IdentifiedPacketFee.Fee.ReceiveFee.IsValid() || !msg.IdentifiedPacketFee.Fee.TimeoutFee.IsValid() { - return sdkerrors.ErrInvalidCoins - } - - // if all three fee's are zero or empty return an error - if msg.IdentifiedPacketFee.Fee.AckFee.IsZero() && msg.IdentifiedPacketFee.Fee.ReceiveFee.IsZero() && msg.IdentifiedPacketFee.Fee.TimeoutFee.IsZero() { - return sdkerrors.ErrInvalidCoins + err = msg.IdentifiedPacketFee.Validate() + if err != nil { + return sdkerrors.Wrap(err, "Invalid IdentifiedPacketFee") } return nil @@ -171,8 +144,32 @@ func NewIdentifiedPacketFee(packetId *channeltypes.PacketId, fee Fee, refundAddr } } -// NewPacketId returns a new instance of PacketId -// TODO: move to channeltypes -func NewPacketId(channelId, portId string, seq uint64) *channeltypes.PacketId { - return &channeltypes.PacketId{ChannelId: channelId, PortId: portId, Sequence: seq} +func (fee IdentifiedPacketFee) Validate() error { + // validate PacketId + err := fee.PacketId.Validate() + if err != nil { + return sdkerrors.Wrap(err, "Invalid PacketId") + } + + _, err = sdk.AccAddressFromBech32(fee.RefundAddress) + if err != nil { + return sdkerrors.Wrap(err, "failed to convert RefundAddress into sdk.AccAddress") + } + + // if any of the fee's are invalid return an error + if !fee.Fee.AckFee.IsValid() || !fee.Fee.ReceiveFee.IsValid() || !fee.Fee.TimeoutFee.IsValid() { + return sdkerrors.ErrInvalidCoins + } + + // if all three fee's are zero or empty return an error + if fee.Fee.AckFee.IsZero() && fee.Fee.ReceiveFee.IsZero() && fee.Fee.TimeoutFee.IsZero() { + return sdkerrors.ErrInvalidCoins + } + + // enforce relayer is nil + if fee.Relayers != nil { + return ErrRelayersNotNil + } + + return nil } diff --git a/modules/core/04-channel/types/packet.go b/modules/core/04-channel/types/packet.go index 5e9c56e62d8..962ab94ffc9 100644 --- a/modules/core/04-channel/types/packet.go +++ b/modules/core/04-channel/types/packet.go @@ -110,3 +110,25 @@ func (p Packet) ValidateBasic() error { } return nil } + +// NewPacketId returns a new instance of PacketId +func NewPacketId(channelId, portId string, seq uint64) *PacketId { + return &PacketId{ChannelId: channelId, PortId: portId, Sequence: seq} +} + +// Validates a PacketId +func (p PacketId) Validate() error { + if err := host.PortIdentifierValidator(p.PortId); err != nil { + return sdkerrors.Wrap(err, "invalid source port ID") + } + + if err := host.ChannelIdentifierValidator(p.ChannelId); err != nil { + return sdkerrors.Wrap(err, "invalid source channel ID") + } + + if p.Sequence == 0 { + return sdkerrors.Wrap(ErrInvalidPacket, "packet sequence cannot be 0") + } + + return nil +} From c4dff6ce862431351437aff78b7c79797987f26d Mon Sep 17 00:00:00 2001 From: Charly Date: Mon, 29 Nov 2021 15:00:13 +0100 Subject: [PATCH 12/79] feat: add incentivised ack proto (#564) * proto file * incentivized ack proto --- docs/ibc/proto-docs.md | 36 +++ modules/apps/29-fee/types/ack.pb.go | 378 ++++++++++++++++++++++++ proto/ibc/applications/fee/v1/ack.proto | 12 + 3 files changed, 426 insertions(+) create mode 100644 modules/apps/29-fee/types/ack.pb.go create mode 100644 proto/ibc/applications/fee/v1/ack.proto diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 4b05a167c58..fd858751bf9 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -4,6 +4,9 @@ ## Table of Contents +- [ibc/applications/fee/v1/ack.proto](#ibc/applications/fee/v1/ack.proto) + - [IncentivizedAcknowledgement](#ibc.applications.fee.v1.IncentivizedAcknowledgement) + - [ibc/core/client/v1/client.proto](#ibc/core/client/v1/client.proto) - [ClientConsensusStates](#ibc.core.client.v1.ClientConsensusStates) - [ClientUpdateProposal](#ibc.core.client.v1.ClientUpdateProposal) @@ -274,6 +277,39 @@ + +

Top

+ +## ibc/applications/fee/v1/ack.proto + + + + + +### IncentivizedAcknowledgement +IncentivizedAcknowledgement is the acknowledgement format to be used by applications wrapped in the fee middleware +It contains the raw acknowledgement bytes, as well as the forward relayer address + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `result` | [bytes](#bytes) | | | +| `forward_relayer_address` | [string](#string) | | | + + + + + + + + + + + + + + +

Top

diff --git a/modules/apps/29-fee/types/ack.pb.go b/modules/apps/29-fee/types/ack.pb.go new file mode 100644 index 00000000000..0b970a8f918 --- /dev/null +++ b/modules/apps/29-fee/types/ack.pb.go @@ -0,0 +1,378 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/applications/fee/v1/ack.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// IncentivizedAcknowledgement is the acknowledgement format to be used by applications wrapped in the fee middleware +// It contains the raw acknowledgement bytes, as well as the forward relayer address +type IncentivizedAcknowledgement struct { + Result []byte `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` + ForwardRelayerAddress string `protobuf:"bytes,2,opt,name=forward_relayer_address,json=forwardRelayerAddress,proto3" json:"forward_relayer_address,omitempty" yaml:"forward_relayer_address"` +} + +func (m *IncentivizedAcknowledgement) Reset() { *m = IncentivizedAcknowledgement{} } +func (m *IncentivizedAcknowledgement) String() string { return proto.CompactTextString(m) } +func (*IncentivizedAcknowledgement) ProtoMessage() {} +func (*IncentivizedAcknowledgement) Descriptor() ([]byte, []int) { + return fileDescriptor_ab2834946fb65ea4, []int{0} +} +func (m *IncentivizedAcknowledgement) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IncentivizedAcknowledgement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IncentivizedAcknowledgement.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *IncentivizedAcknowledgement) XXX_Merge(src proto.Message) { + xxx_messageInfo_IncentivizedAcknowledgement.Merge(m, src) +} +func (m *IncentivizedAcknowledgement) XXX_Size() int { + return m.Size() +} +func (m *IncentivizedAcknowledgement) XXX_DiscardUnknown() { + xxx_messageInfo_IncentivizedAcknowledgement.DiscardUnknown(m) +} + +var xxx_messageInfo_IncentivizedAcknowledgement proto.InternalMessageInfo + +func (m *IncentivizedAcknowledgement) GetResult() []byte { + if m != nil { + return m.Result + } + return nil +} + +func (m *IncentivizedAcknowledgement) GetForwardRelayerAddress() string { + if m != nil { + return m.ForwardRelayerAddress + } + return "" +} + +func init() { + proto.RegisterType((*IncentivizedAcknowledgement)(nil), "ibc.applications.fee.v1.IncentivizedAcknowledgement") +} + +func init() { proto.RegisterFile("ibc/applications/fee/v1/ack.proto", fileDescriptor_ab2834946fb65ea4) } + +var fileDescriptor_ab2834946fb65ea4 = []byte{ + // 273 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0xd0, 0xb1, 0x4e, 0xf3, 0x30, + 0x10, 0x07, 0xf0, 0xf8, 0x1b, 0x2a, 0x7d, 0x11, 0x53, 0x04, 0xb4, 0x02, 0xc9, 0x94, 0x4c, 0x5d, + 0x1a, 0xab, 0x65, 0x82, 0xad, 0xdd, 0x90, 0x98, 0x32, 0x76, 0xa9, 0x1c, 0xfb, 0x12, 0xac, 0x3a, + 0xb9, 0xc8, 0x76, 0x52, 0x85, 0xa7, 0x80, 0xb7, 0x62, 0xec, 0xc8, 0x84, 0x50, 0xf2, 0x06, 0x3c, + 0x01, 0x4a, 0xd3, 0x81, 0x85, 0xed, 0xee, 0xfe, 0xbf, 0xe5, 0xfe, 0xfe, 0xad, 0x4a, 0x04, 0xe3, + 0x65, 0xa9, 0x95, 0xe0, 0x4e, 0x61, 0x61,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0x01, 0x00, + 0x00, +} + +func (m *IncentivizedAcknowledgement) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *IncentivizedAcknowledgement) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IncentivizedAcknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ForwardRelayerAddress) > 0 { + i -= len(m.ForwardRelayerAddress) + copy(dAtA[i:], m.ForwardRelayerAddress) + i = encodeVarintAck(dAtA, i, uint64(len(m.ForwardRelayerAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.Result) > 0 { + i -= len(m.Result) + copy(dAtA[i:], m.Result) + i = encodeVarintAck(dAtA, i, uint64(len(m.Result))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintAck(dAtA []byte, offset int, v uint64) int { + offset -= sovAck(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *IncentivizedAcknowledgement) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Result) + if l > 0 { + n += 1 + l + sovAck(uint64(l)) + } + l = len(m.ForwardRelayerAddress) + if l > 0 { + n += 1 + l + sovAck(uint64(l)) + } + return n +} + +func sovAck(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozAck(x uint64) (n int) { + return sovAck(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *IncentivizedAcknowledgement) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAck + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: IncentivizedAcknowledgement: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IncentivizedAcknowledgement: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAck + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAck + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAck + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Result = append(m.Result[:0], dAtA[iNdEx:postIndex]...) + if m.Result == nil { + m.Result = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ForwardRelayerAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAck + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAck + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAck + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ForwardRelayerAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAck(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAck + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipAck(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAck + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAck + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowAck + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthAck + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupAck + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthAck + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthAck = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAck = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupAck = fmt.Errorf("proto: unexpected end of group") +) diff --git a/proto/ibc/applications/fee/v1/ack.proto b/proto/ibc/applications/fee/v1/ack.proto new file mode 100644 index 00000000000..bfc76e38385 --- /dev/null +++ b/proto/ibc/applications/fee/v1/ack.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package ibc.applications.fee.v1; +import "gogoproto/gogo.proto"; +option go_package = "github.com/cosmos/ibc-go/modules/apps/29-fee/types"; + +// IncentivizedAcknowledgement is the acknowledgement format to be used by applications wrapped in the fee middleware +// It contains the raw acknowledgement bytes, as well as the forward relayer address +message IncentivizedAcknowledgement { + bytes result = 1; + string forward_relayer_address = 2 [(gogoproto.moretags) = "yaml:\"forward_relayer_address\""]; +} \ No newline at end of file From edd11c6912c703d9af2058f168910325bcc9e99f Mon Sep 17 00:00:00 2001 From: Aditya Date: Mon, 29 Nov 2021 17:14:20 +0100 Subject: [PATCH 13/79] Fee Closing Handshake (#551) * add iterate logic * add closing logic with tests * add comments for panic * change invariant breaking recovery to disabling middleware rather than panicing * docs, tests, minor refactor --- modules/apps/29-fee/ibc_module.go | 28 ++- modules/apps/29-fee/ibc_module_test.go | 168 ++++++++++++++++++ modules/apps/29-fee/keeper/escrow.go | 41 +++++ modules/apps/29-fee/keeper/escrow_test.go | 96 +++++++--- modules/apps/29-fee/keeper/genesis_test.go | 4 +- modules/apps/29-fee/keeper/grpc_query_test.go | 19 +- modules/apps/29-fee/keeper/keeper.go | 32 +++- modules/apps/29-fee/keeper/keeper_test.go | 68 +++++-- modules/apps/29-fee/keeper/msg_server_test.go | 12 +- modules/apps/29-fee/types/errors.go | 1 + modules/apps/29-fee/types/expected_keepers.go | 1 + modules/apps/29-fee/types/genesis_test.go | 3 +- modules/apps/29-fee/types/keys.go | 10 +- modules/core/04-channel/types/packet.go | 10 +- 14 files changed, 422 insertions(+), 71 deletions(-) diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go index 0c22fb19d8d..4bb6680b6d1 100644 --- a/modules/apps/29-fee/ibc_module.go +++ b/modules/apps/29-fee/ibc_module.go @@ -130,8 +130,20 @@ func (im IBCModule) OnChanCloseInit( portID, channelID string, ) error { - // TODO: Unescrow all remaining funds for unprocessed packets + // delete fee enabled on channel + // and refund any remaining fees escrowed on channel im.keeper.DeleteFeeEnabled(ctx, portID, channelID) + err := im.keeper.RefundFeesOnChannel(ctx, portID, channelID) + // error should only be non-nil if there is a bug in the code + // that causes module account to have insufficient funds to refund + // all escrowed fees on the channel. + // Disable all channels to allow for coordinated fix to the issue + // and mitigate/reverse damage. + // NOTE: Underlying application's packets will still go through, but + // fee module will be disabled for all channels + if err != nil { + im.keeper.DisableAllChannels(ctx) + } return im.app.OnChanCloseInit(ctx, portID, channelID) } @@ -141,8 +153,20 @@ func (im IBCModule) OnChanCloseConfirm( portID, channelID string, ) error { - // TODO: Unescrow all remaining funds for unprocessed packets + // delete fee enabled on channel + // and refund any remaining fees escrowed on channel im.keeper.DeleteFeeEnabled(ctx, portID, channelID) + err := im.keeper.RefundFeesOnChannel(ctx, portID, channelID) + // error should only be non-nil if there is a bug in the code + // that causes module account to have insufficient funds to refund + // all escrowed fees on the channel. + // Disable all channels to allow for coordinated fix to the issue + // and mitigate/reverse damage. + // NOTE: Underlying application's packets will still go through, but + // fee module will be disabled for all channels + if err != nil { + im.keeper.DisableAllChannels(ctx) + } return im.app.OnChanCloseConfirm(ctx, portID, channelID) } diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index 915fdaebf79..598b3af6b14 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -3,6 +3,7 @@ package fee_test import ( "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/cosmos/ibc-go/modules/apps/29-fee/types" @@ -12,6 +13,13 @@ import ( ibctesting "github.com/cosmos/ibc-go/testing" ) +var ( + validCoins = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}} + validCoins2 = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(200)}} + validCoins3 = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(300)}} + invalidCoins = sdk.Coins{sdk.Coin{Denom: "invalidDenom", Amount: sdk.NewInt(100)}} +) + // Tests OnChanOpenInit on ChainA func (suite *FeeTestSuite) TestOnChanOpenInit() { testCases := []struct { @@ -300,3 +308,163 @@ func (suite *FeeTestSuite) TestOnChanOpenAck() { }) } } + +// Tests OnChanCloseInit on chainA +func (suite *FeeTestSuite) TestOnChanCloseInit() { + testCases := []struct { + name string + setup func(suite *FeeTestSuite) + disabled bool + }{ + { + "success", + func(suite *FeeTestSuite) { + packetId := channeltypes.PacketId{ + PortId: suite.path.EndpointA.ChannelConfig.PortID, + ChannelId: suite.path.EndpointA.ChannelID, + Sequence: 1, + } + refundAcc := suite.chainA.SenderAccount.GetAddress() + identifiedFee := types.NewIdentifiedPacketFee(&packetId, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) + suite.Require().NoError(err) + }, + false, + }, + { + "module account balance insufficient", + func(suite *FeeTestSuite) { + packetId := channeltypes.PacketId{ + PortId: suite.path.EndpointA.ChannelConfig.PortID, + ChannelId: suite.path.EndpointA.ChannelID, + Sequence: 1, + } + refundAcc := suite.chainA.SenderAccount.GetAddress() + identifiedFee := types.NewIdentifiedPacketFee(&packetId, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) + suite.Require().NoError(err) + + suite.chainA.GetSimApp().BankKeeper.SendCoinsFromModuleToAccount(suite.chainA.GetContext(), types.ModuleName, refundAcc, validCoins3) + + // set fee enabled on different channel + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), "portID7", "channel-7") + }, + true, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + suite.SetupTest() + suite.coordinator.Setup(suite.path) // setup channel + + origBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress()) + + tc.setup(suite) + + module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort) + suite.Require().NoError(err) + + cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + suite.Require().True(ok) + + if tc.disabled { + suite.Require().True( + suite.chainA.GetSimApp().IBCFeeKeeper.IsFeeEnabled(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID), + + "fee is not disabled on original channel: %s", suite.path.EndpointA.ChannelID, + ) + suite.Require().True( + suite.chainA.GetSimApp().IBCFeeKeeper.IsFeeEnabled(suite.chainA.GetContext(), "portID7", "channel-7"), + + "fee is not disabled on other channel: %s", "channel-7", + ) + } else { + cbs.OnChanCloseInit(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) + afterBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress()) + suite.Require().Equal(origBal, afterBal, "balances of refund account not equal after all fees refunded") + } + }) + } +} + +// Tests OnChanCloseConfirm on chainA +func (suite *FeeTestSuite) TestOnChanCloseConfirm() { + testCases := []struct { + name string + setup func(suite *FeeTestSuite) + disabled bool + }{ + { + "success", + func(suite *FeeTestSuite) { + packetId := channeltypes.PacketId{ + PortId: suite.path.EndpointA.ChannelConfig.PortID, + ChannelId: suite.path.EndpointA.ChannelID, + Sequence: 1, + } + refundAcc := suite.chainA.SenderAccount.GetAddress() + identifiedFee := types.NewIdentifiedPacketFee(&packetId, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) + suite.Require().NoError(err) + }, + false, + }, + { + "module account balance insufficient", + func(suite *FeeTestSuite) { + packetId := channeltypes.PacketId{ + PortId: suite.path.EndpointA.ChannelConfig.PortID, + ChannelId: suite.path.EndpointA.ChannelID, + Sequence: 1, + } + refundAcc := suite.chainA.SenderAccount.GetAddress() + identifiedFee := types.NewIdentifiedPacketFee(&packetId, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) + suite.Require().NoError(err) + + suite.chainA.GetSimApp().BankKeeper.SendCoinsFromModuleToAccount(suite.chainA.GetContext(), types.ModuleName, refundAcc, validCoins3) + + // set fee enabled on different channel + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), "portID7", "channel-7") + }, + true, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + suite.SetupTest() + suite.coordinator.Setup(suite.path) // setup channel + + origBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress()) + + tc.setup(suite) + + module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort) + suite.Require().NoError(err) + + cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + suite.Require().True(ok) + + if tc.disabled { + suite.Require().True( + suite.chainA.GetSimApp().IBCFeeKeeper.IsFeeEnabled(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID), + + "fee is not disabled on original channel: %s", suite.path.EndpointA.ChannelID, + ) + suite.Require().True( + suite.chainA.GetSimApp().IBCFeeKeeper.IsFeeEnabled(suite.chainA.GetContext(), "portID7", "channel-7"), + + "fee is not disabled on other channel: %s", "channel-7", + ) + } else { + cbs.OnChanCloseConfirm(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) + afterBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress()) + suite.Require().Equal(origBal, afterBal, "balances of refund account not equal after all fees refunded") + } + }) + } +} diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index ce7c73db8ce..fe52439590e 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -12,6 +12,10 @@ import ( // EscrowPacketFee sends the packet fee to the 29-fee module account to hold in escrow func (k Keeper) EscrowPacketFee(ctx sdk.Context, identifiedFee *types.IdentifiedPacketFee) error { + if !k.IsFeeEnabled(ctx, identifiedFee.PacketId.PortId, identifiedFee.PacketId.ChannelId) { + // users may not escrow fees on this channel. Must send packets without a fee message + return sdkerrors.Wrap(types.ErrFeeNotEnabled, "cannot escrow fee for packet") + } // check if the refund account exists refundAcc, err := sdk.AccAddressFromBech32(identifiedFee.RefundAddress) if err != nil { @@ -107,3 +111,40 @@ func (k Keeper) DistributeFeeTimeout(ctx sdk.Context, refundAcc, timeoutRelayer return nil } + +func (k Keeper) RefundFeesOnChannel(ctx sdk.Context, portID, channelID string) error { + // get module accAddr + feeModuleAccAddr := k.authKeeper.GetModuleAddress(types.ModuleName) + + var refundErr error + + k.IterateChannelFeesInEscrow(ctx, portID, channelID, func(identifiedFee types.IdentifiedPacketFee) (stop bool) { + refundAccAddr, err := sdk.AccAddressFromBech32(identifiedFee.RefundAddress) + if err != nil { + refundErr = err + return true + } + + // refund all fees to refund address + // Use SendCoins rather than the module account send functions since refund address may be a user account or module address. + // if any `SendCoins` call returns an error, we return error and stop iteration + err = k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, refundAccAddr, identifiedFee.Fee.ReceiveFee) + if err != nil { + refundErr = err + return true + } + err = k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, refundAccAddr, identifiedFee.Fee.AckFee) + if err != nil { + refundErr = err + return true + } + err = k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, refundAccAddr, identifiedFee.Fee.TimeoutFee) + if err != nil { + refundErr = err + return true + } + return false + }) + + return refundErr +} diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go index f9622bc3259..8eed26d52a4 100644 --- a/modules/apps/29-fee/keeper/escrow_test.go +++ b/modules/apps/29-fee/keeper/escrow_test.go @@ -6,16 +6,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" ) -var ( - validCoins = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}} - validCoins2 = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(200)}} - validCoins3 = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(300)}} - invalidCoins = sdk.Coins{sdk.Coin{Denom: "invalidDenom", Amount: sdk.NewInt(100)}} -) - func (suite *KeeperTestSuite) TestEscrowPacketFee() { var ( err error @@ -23,11 +17,9 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { ackFee sdk.Coins receiveFee sdk.Coins timeoutFee sdk.Coins + packetId *channeltypes.PacketId ) - // refundAcc does not have balance for the following Coin - validChannelId := "channel-0" - testCases := []struct { name string malleate func() @@ -36,6 +28,11 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { { "success", func() {}, true, }, + { + "fee not enabled on this channel", func() { + packetId.ChannelId = "disabled_channel" + }, false, + }, { "refundAcc does not exist", func() { // this acc does not exist on chainA @@ -63,14 +60,15 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { tc := tc suite.Run(tc.name, func() { - suite.SetupTest() // reset + suite.SetupTest() // reset + suite.coordinator.Setup(suite.path) // setup channel // setup refundAcc = suite.chainA.SenderAccount.GetAddress() ackFee = validCoins receiveFee = validCoins2 timeoutFee = validCoins3 - packetId := &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortID, Sequence: uint64(1)} + packetId = &channeltypes.PacketId{ChannelId: suite.path.EndpointA.ChannelID, PortId: transfertypes.PortID, Sequence: uint64(1)} tc.malleate() fee := types.Fee{ackFee, receiveFee, timeoutFee} @@ -115,8 +113,6 @@ func (suite *KeeperTestSuite) TestDistributeFee() { refundAcc sdk.AccAddress ) - // refundAcc does not have balance for the following Coin - validChannelId := "channel-0" validSeq := uint64(1) testCases := []struct { @@ -130,7 +126,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() { { "fee not found for packet", func() { // setting packetId with an invalid sequence of 2 - packetId = &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortID, Sequence: uint64(2)} + packetId = &channeltypes.PacketId{ChannelId: suite.path.EndpointA.ChannelID, PortId: transfertypes.PortID, Sequence: uint64(2)} }, false, }, } @@ -139,7 +135,8 @@ func (suite *KeeperTestSuite) TestDistributeFee() { tc := tc suite.Run(tc.name, func() { - suite.SetupTest() // reset + suite.SetupTest() // reset + suite.coordinator.Setup(suite.path) // setup channel // setup refundAcc = suite.chainA.SenderAccount.GetAddress() @@ -149,7 +146,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() { ackFee = validCoins receiveFee = validCoins2 timeoutFee = validCoins3 - packetId = &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortID, Sequence: validSeq} + packetId = &channeltypes.PacketId{ChannelId: suite.path.EndpointA.ChannelID, PortId: transfertypes.PortID, Sequence: validSeq} fee := types.Fee{receiveFee, ackFee, timeoutFee} // escrow the packet fee & store the fee in state @@ -188,7 +185,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() { } else { suite.Require().Error(err) - invalidPacketID := &channeltypes.PacketId{PortId: types.PortID, ChannelId: validChannelId, Sequence: 1} + invalidPacketID := &channeltypes.PacketId{PortId: transfertypes.PortID, ChannelId: suite.path.EndpointA.ChannelID, Sequence: 1} hasFeeInEscrow := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), invalidPacketID) // there should still be a fee in escrow for this packet suite.Require().True(hasFeeInEscrow) @@ -207,8 +204,6 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { refundAcc sdk.AccAddress ) - // refundAcc does not have balance for the following Coin - validChannelId := "channel-0" validSeq := uint64(1) testCases := []struct { @@ -222,7 +217,7 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { { "fee not found for packet", func() { // setting packetId with an invalid sequence of 2 - packetId = &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortID, Sequence: uint64(2)} + packetId = &channeltypes.PacketId{ChannelId: suite.path.EndpointA.ChannelID, PortId: transfertypes.PortID, Sequence: uint64(2)} }, false, }, } @@ -231,7 +226,8 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { tc := tc suite.Run(tc.name, func() { - suite.SetupTest() // reset + suite.SetupTest() // reset + suite.coordinator.Setup(suite.path) // setup channel // setup refundAcc = suite.chainA.SenderAccount.GetAddress() @@ -240,7 +236,7 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { ackFee = validCoins receiveFee = validCoins2 timeoutFee = validCoins3 - packetId = &channeltypes.PacketId{ChannelId: validChannelId, PortId: types.PortID, Sequence: validSeq} + packetId = &channeltypes.PacketId{ChannelId: suite.path.EndpointA.ChannelID, PortId: transfertypes.PortID, Sequence: validSeq} fee := types.Fee{receiveFee, ackFee, timeoutFee} // escrow the packet fee & store the fee in state @@ -274,7 +270,7 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { } else { suite.Require().Error(err) - invalidPacketID := &channeltypes.PacketId{PortId: types.PortID, ChannelId: validChannelId, Sequence: 1} + invalidPacketID := &channeltypes.PacketId{PortId: transfertypes.PortID, ChannelId: suite.path.EndpointA.ChannelID, Sequence: 1} hasFeeInEscrow := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), invalidPacketID) // there should still be a fee in escrow for this packet suite.Require().True(hasFeeInEscrow) @@ -282,3 +278,55 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { }) } } + +func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { + // setup + refundAcc := suite.chainA.SenderAccount.GetAddress() + + // refundAcc balance before escrow + prevBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), refundAcc) + + ackFee := validCoins + receiveFee := validCoins2 + timeoutFee := validCoins3 + + for i := 0; i < 5; i++ { + packetId := &channeltypes.PacketId{ChannelId: "channel-0", PortId: transfertypes.PortID, Sequence: uint64(i)} + fee := types.Fee{receiveFee, ackFee, timeoutFee} + + identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, "channel-0") + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), &identifiedPacketFee) + suite.Require().NoError(err) + } + + // send a packet over a different channel to ensure this fee is not refunded + packetId := &channeltypes.PacketId{ChannelId: "channel-1", PortId: transfertypes.PortID, Sequence: 1} + fee := types.Fee{receiveFee, ackFee, timeoutFee} + + identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, "channel-1") + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), &identifiedPacketFee) + suite.Require().NoError(err) + + // check that refunding all fees on channel-0 refunds all fees except for fee on channel-1 + err = suite.chainA.GetSimApp().IBCFeeKeeper.RefundFeesOnChannel(suite.chainA.GetContext(), transfertypes.PortID, "channel-0") + suite.Require().NoError(err, "refund fees returned unexpected error") + + // add fee sent to channel-1 to after balance to recover original balance + afterBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), refundAcc) + suite.Require().Equal(prevBal, afterBal.Add(validCoins...).Add(validCoins2...).Add(validCoins3...), "refund account not back to original balance after refunding all tokens") + + // create escrow and then change module account balance to cause error on refund + packetId = &channeltypes.PacketId{ChannelId: "channel-0", PortId: transfertypes.PortID, Sequence: uint64(6)} + fee = types.Fee{receiveFee, ackFee, timeoutFee} + + identifiedPacketFee = types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), &identifiedPacketFee) + suite.Require().NoError(err) + + suite.chainA.GetSimApp().BankKeeper.SendCoinsFromModuleToAccount(suite.chainA.GetContext(), types.ModuleName, refundAcc, validCoins3) + + err = suite.chainA.GetSimApp().IBCFeeKeeper.RefundFeesOnChannel(suite.chainA.GetContext(), transfertypes.PortID, "channel-0") + suite.Require().Error(err, "refund fees returned no error with insufficient balance on module account") +} diff --git a/modules/apps/29-fee/keeper/genesis_test.go b/modules/apps/29-fee/keeper/genesis_test.go index 7c5939c7b2f..3fe9a3db38d 100644 --- a/modules/apps/29-fee/keeper/genesis_test.go +++ b/modules/apps/29-fee/keeper/genesis_test.go @@ -14,7 +14,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() { refundAcc := suite.chainA.SenderAccount.GetAddress() packetId := channeltypes.NewPacketId( ibctesting.FirstChannelID, - types.PortID, + transfertypes.PortID, uint64(1), ) fee := types.Fee{ @@ -76,7 +76,7 @@ func (suite *KeeperTestSuite) TestExportGenesis() { refundAcc := suite.chainA.SenderAccount.GetAddress() packetId := channeltypes.NewPacketId( ibctesting.FirstChannelID, - types.PortID, + transfertypes.PortID, uint64(1), ) fee := types.Fee{ diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index 560ccb6ffa3..b8b13f36242 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -7,19 +7,21 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/testing" ) -func (suite *KeeperTestSuite) TestQueryIncentivizedPacket() { +func (suite *KeeperTestSuite) TestQueryIncentivizedPacketI() { var ( req *types.QueryIncentivizedPacketRequest ) // setup - validPacketId := channeltypes.NewPacketId(ibctesting.FirstChannelID, types.PortID, 1) - invalidPacketId := channeltypes.NewPacketId(ibctesting.FirstChannelID, types.PortID, 2) + suite.coordinator.Setup(suite.path) // setup channel + validPacketId := channeltypes.NewPacketId(ibctesting.FirstChannelID, transfertypes.PortID, 1) + invalidPacketId := channeltypes.NewPacketId(ibctesting.FirstChannelID, transfertypes.PortID, 2) identifiedPacketFee := types.NewIdentifiedPacketFee( validPacketId, types.Fee{ @@ -67,8 +69,10 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacket() { identifiedPacketFee.RefundAddress = refundAcc.String() tc.malleate() + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, ibctesting.FirstChannelID) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + suite.Require().NoError(err) ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) - suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) res, err := suite.queryClient.IncentivizedPacket(ctx, req) if tc.expPass { @@ -111,13 +115,14 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPackets() { func() { refundAcc := suite.chainA.SenderAccount.GetAddress() - fee1 := types.NewIdentifiedPacketFee(channeltypes.NewPacketId(ibctesting.FirstChannelID, types.PortID, 1), fee, refundAcc.String(), []string(nil)) - fee2 := types.NewIdentifiedPacketFee(channeltypes.NewPacketId(ibctesting.FirstChannelID, types.PortID, 2), fee, refundAcc.String(), []string(nil)) - fee3 := types.NewIdentifiedPacketFee(channeltypes.NewPacketId(ibctesting.FirstChannelID, types.PortID, 3), fee, refundAcc.String(), []string(nil)) + fee1 := types.NewIdentifiedPacketFee(channeltypes.NewPacketId(ibctesting.FirstChannelID, transfertypes.PortID, 1), fee, refundAcc.String(), []string(nil)) + fee2 := types.NewIdentifiedPacketFee(channeltypes.NewPacketId(ibctesting.FirstChannelID, transfertypes.PortID, 2), fee, refundAcc.String(), []string(nil)) + fee3 := types.NewIdentifiedPacketFee(channeltypes.NewPacketId(ibctesting.FirstChannelID, transfertypes.PortID, 3), fee, refundAcc.String(), []string(nil)) expPackets = []*types.IdentifiedPacketFee{} expPackets = append(expPackets, fee1, fee2, fee3) + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, ibctesting.FirstChannelID) for _, p := range expPackets { suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), p) } diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index 1fda4910bc2..efe69f7aa5b 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -126,6 +126,21 @@ func (k Keeper) GetAllFeeEnabledChannels(ctx sdk.Context) []*types.FeeEnabledCha return enabledChArr } +// DisableAllChannels will disable the fee module for all channels. +// Only called if the module enters into an invalid state +// e.g. ModuleAccount has insufficient balance to refund users. +// In this case, chain developers should investigate the issue, fix it, +// and then re-enable the fee module in a coordinated upgrade. +func (k Keeper) DisableAllChannels(ctx sdk.Context) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, []byte(types.FeeEnabledKeyPrefix)) + + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + store.Delete(iterator.Key()) + } +} + // 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) { @@ -186,6 +201,21 @@ func (k Keeper) GetFeeInEscrow(ctx sdk.Context, packetId *channeltypes.PacketId) return fee, true } +// IterateChannelFeesInEscrow iterates over all the fees on the given channel currently escrowed and calls the provided callback +// if the callback returns true, then iteration is stopped. +func (k Keeper) IterateChannelFeesInEscrow(ctx sdk.Context, portID, channelID string, cb func(identifiedFee types.IdentifiedPacketFee) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.KeyFeeInEscrowChannelPrefix(portID, channelID)) + + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + identifiedFee := k.MustUnmarshalFee(iterator.Value()) + if cb(identifiedFee) { + break + } + } +} + // Deletes the fee associated with the given packetId func (k Keeper) DeleteFeeInEscrow(ctx sdk.Context, packetId *channeltypes.PacketId) { store := ctx.KVStore(k.storeKey) @@ -193,7 +223,7 @@ func (k Keeper) DeleteFeeInEscrow(ctx sdk.Context, packetId *channeltypes.Packet store.Delete(key) } -// GetFeeInEscrow returns true if there is a Fee still to be escrowed for a given packet +// HasFeeInEscrow returns true if there is a Fee still to be escrowed for a given packet func (k Keeper) HasFeeInEscrow(ctx sdk.Context, packetId *channeltypes.PacketId) bool { store := ctx.KVStore(k.storeKey) key := types.KeyFeeInEscrow(packetId) diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index f4315baa3b6..7675bb127e3 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -1,17 +1,26 @@ package keeper_test import ( + "fmt" "testing" "github.com/stretchr/testify/suite" "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/ibc-go/modules/apps/29-fee/types" transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/testing" ) +var ( + validCoins = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}} + validCoins2 = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(200)}} + validCoins3 = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(300)}} + invalidCoins = sdk.Coins{sdk.Coin{Denom: "invalidDenom", Amount: sdk.NewInt(100)}} +) + type KeeperTestSuite struct { suite.Suite @@ -43,37 +52,62 @@ func (suite *KeeperTestSuite) SetupTest() { suite.queryClient = types.NewQueryClient(queryHelper) } -func SetupFeePath(path *ibctesting.Path) error { - if err := path.EndpointA.ChanOpenInit(); err != nil { - return err - } - - if err := path.EndpointB.ChanOpenTry(); err != nil { - return err - } +func TestKeeperTestSuite(t *testing.T) { + suite.Run(t, new(KeeperTestSuite)) +} - if err := path.EndpointA.ChanOpenAck(); err != nil { - return err - } +func (suite *KeeperTestSuite) TestFeeInEscrow() { + ackFee := validCoins + receiveFee := validCoins2 + timeoutFee := validCoins3 + fee := types.Fee{ReceiveFee: receiveFee, AckFee: ackFee, TimeoutFee: timeoutFee} - if err := path.EndpointB.ChanOpenConfirm(); err != nil { - return err + // set some fees + for i := 1; i < 6; i++ { + packetId := channeltypes.NewPacketId(fmt.Sprintf("channel-1"), transfertypes.PortID, uint64(i)) + fee := types.NewIdentifiedPacketFee(packetId, fee, suite.chainA.SenderAccount.GetAddress().String(), []string{}) + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeInEscrow(suite.chainA.GetContext(), fee) } - return nil + // delete 1 fee + packetId := channeltypes.NewPacketId("channel-1", transfertypes.PortID, 3) + suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeeInEscrow(suite.chainA.GetContext(), packetId) + + // iterate over remaining fees + arr := []int64{} + expectedArr := []int64{1, 2, 4, 5} + suite.chainA.GetSimApp().IBCFeeKeeper.IterateChannelFeesInEscrow(suite.chainA.GetContext(), transfertypes.PortID, "channel-1", func(identifiedFee types.IdentifiedPacketFee) (stop bool) { + arr = append(arr, int64(identifiedFee.PacketId.Sequence)) + return false + }) + suite.Require().Equal(expectedArr, arr, "did not retrieve expected fees during iteration") } -func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(KeeperTestSuite)) +func (suite *KeeperTestSuite) TestDisableAllChannels() { + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), "port1", "channel1") + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), "port2", "channel2") + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), "port3", "channel3") + + suite.chainA.GetSimApp().IBCFeeKeeper.DisableAllChannels(suite.chainA.GetContext()) + + suite.Require().False(suite.chainA.GetSimApp().IBCFeeKeeper.IsFeeEnabled(suite.chainA.GetContext(), "port1", "channel1"), + "fee is still enabled on channel-1 after DisableAllChannels call") + suite.Require().False(suite.chainA.GetSimApp().IBCFeeKeeper.IsFeeEnabled(suite.chainA.GetContext(), "port2", "channel2"), + "fee is still enabled on channel-2 after DisableAllChannels call") + suite.Require().False(suite.chainA.GetSimApp().IBCFeeKeeper.IsFeeEnabled(suite.chainA.GetContext(), "port3", "channel3"), + "fee is still enabled on channel-3 after DisableAllChannels call") } func (suite *KeeperTestSuite) TestGetAllIdentifiedPacketFees() { + // setup channel + suite.coordinator.Setup(suite.path) + // escrow a fee refundAcc := suite.chainA.SenderAccount.GetAddress() ackFee := validCoins receiveFee := validCoins2 timeoutFee := validCoins3 - packetId := &channeltypes.PacketId{ChannelId: ibctesting.FirstChannelID, PortId: types.PortID, Sequence: uint64(1)} + packetId := &channeltypes.PacketId{ChannelId: suite.path.EndpointA.ChannelID, PortId: transfertypes.PortID, Sequence: uint64(1)} fee := types.Fee{ackFee, receiveFee, timeoutFee} identifiedPacketFee := &types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} diff --git a/modules/apps/29-fee/keeper/msg_server_test.go b/modules/apps/29-fee/keeper/msg_server_test.go index c93f02bd97c..ec7f830bd4d 100644 --- a/modules/apps/29-fee/keeper/msg_server_test.go +++ b/modules/apps/29-fee/keeper/msg_server_test.go @@ -65,9 +65,7 @@ func (suite *KeeperTestSuite) TestPayPacketFee() { for _, tc := range testCases { suite.SetupTest() - suite.coordinator.SetupConnections(suite.path) - err := SetupFeePath(suite.path) - suite.Require().NoError(err) + suite.coordinator.Setup(suite.path) // setup channel refundAcc := suite.chainA.SenderAccount.GetAddress() channelID := suite.path.EndpointA.ChannelID @@ -75,7 +73,7 @@ func (suite *KeeperTestSuite) TestPayPacketFee() { msg := types.NewMsgPayPacketFee(fee, suite.path.EndpointA.ChannelConfig.PortID, channelID, refundAcc.String(), []string{}) tc.malleate() - _, err = suite.chainA.SendMsgs(msg) + _, err := suite.chainA.SendMsgs(msg) if tc.expPass { suite.Require().NoError(err) // message committed @@ -100,9 +98,7 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() { for _, tc := range testCases { suite.SetupTest() - suite.coordinator.SetupConnections(suite.path) - err := SetupFeePath(suite.path) - suite.Require().NoError(err) + suite.coordinator.Setup(suite.path) // setup channel ctxA := suite.chainA.GetContext() @@ -120,7 +116,7 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() { tc.malleate() msg := types.NewMsgPayPacketFeeAsync(identifiedPacketFee) - _, err = suite.chainA.SendMsgs(msg) + _, err := suite.chainA.SendMsgs(msg) if tc.expPass { suite.Require().NoError(err) // message committed diff --git a/modules/apps/29-fee/types/errors.go b/modules/apps/29-fee/types/errors.go index b5e8203ec9f..7891d6e18b8 100644 --- a/modules/apps/29-fee/types/errors.go +++ b/modules/apps/29-fee/types/errors.go @@ -12,4 +12,5 @@ var ( ErrFeeNotFound = sdkerrors.Register(ModuleName, 5, "there is no fee escrowed for the given packetID") ErrRelayersNotNil = sdkerrors.Register(ModuleName, 6, "relayers must be nil. This feature is not supported") ErrCounterpartyAddressEmpty = sdkerrors.Register(ModuleName, 7, "counterparty address must not be empty") + ErrFeeNotEnabled = sdkerrors.Register(ModuleName, 8, "fee module is not enabled for this channel. If this error occurs after channel setup, fee module may not be enabled") ) diff --git a/modules/apps/29-fee/types/expected_keepers.go b/modules/apps/29-fee/types/expected_keepers.go index 33edb1c01ce..d5aad9621c0 100644 --- a/modules/apps/29-fee/types/expected_keepers.go +++ b/modules/apps/29-fee/types/expected_keepers.go @@ -31,5 +31,6 @@ type PortKeeper interface { type BankKeeper interface { HasBalance(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coin) bool SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error } diff --git a/modules/apps/29-fee/types/genesis_test.go b/modules/apps/29-fee/types/genesis_test.go index 1a98142a870..54af51e61fa 100644 --- a/modules/apps/29-fee/types/genesis_test.go +++ b/modules/apps/29-fee/types/genesis_test.go @@ -8,6 +8,7 @@ import ( "github.com/tendermint/tendermint/crypto/secp256k1" "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/testing" ) @@ -124,7 +125,7 @@ func TestValidateGenesis(t *testing.T) { } for _, tc := range testCases { - portID = types.PortID + portID = transfertypes.PortID channelID = ibctesting.FirstChannelID seq = uint64(1) diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index 522177c9aff..17e22df8530 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -13,9 +13,6 @@ const ( // StoreKey is the store key string for IBC fee module StoreKey = ModuleName - // PortID is the port id that is wrapped by fee middleware - PortID = "feetransfer" - // RouterKey is the message route for IBC fee module RouterKey = ModuleName @@ -47,5 +44,10 @@ func KeyRelayerAddress(address string) []byte { // KeyFeeInEscrow returns the key for escrowed fees func KeyFeeInEscrow(packetID *channeltypes.PacketId) []byte { - return []byte(fmt.Sprintf("%s/%s/%s/packet/%d", FeeInEscrowPrefix, packetID.PortId, packetID.ChannelId, packetID.Sequence)) + return []byte(fmt.Sprintf("%s/%d", KeyFeeInEscrowChannelPrefix(packetID.PortId, packetID.ChannelId), packetID.Sequence)) +} + +// KeyFeeInEscrowChannelPrefix returns the key prefix for escrowed fees on the given channel +func KeyFeeInEscrowChannelPrefix(portID, channelID string) []byte { + return []byte(fmt.Sprintf("%s/%s/%s/packet", FeeInEscrowPrefix, portID, channelID)) } diff --git a/modules/core/04-channel/types/packet.go b/modules/core/04-channel/types/packet.go index 962ab94ffc9..390da12c95f 100644 --- a/modules/core/04-channel/types/packet.go +++ b/modules/core/04-channel/types/packet.go @@ -11,6 +11,11 @@ import ( "github.com/cosmos/ibc-go/modules/core/exported" ) +// NewPacketId returns a new instance of PacketId +func NewPacketId(channelId, portId string, seq uint64) *PacketId { + return &PacketId{ChannelId: channelId, PortId: portId, Sequence: seq} +} + // CommitPacket returns the packet commitment bytes. The commitment consists of: // sha256_hash(timeout_timestamp + timeout_height.RevisionNumber + timeout_height.RevisionHeight + sha256_hash(data)) // from a given packet. This results in a fixed length preimage. @@ -111,11 +116,6 @@ func (p Packet) ValidateBasic() error { return nil } -// NewPacketId returns a new instance of PacketId -func NewPacketId(channelId, portId string, seq uint64) *PacketId { - return &PacketId{ChannelId: channelId, PortId: portId, Sequence: seq} -} - // Validates a PacketId func (p PacketId) Validate() error { if err := host.PortIdentifierValidator(p.PortId); err != nil { From 885fb9ad3292dc608bab70fa879c3b4b4392a3b7 Mon Sep 17 00:00:00 2001 From: Sean King Date: Wed, 1 Dec 2021 12:57:39 +0100 Subject: [PATCH 14/79] Fee Middleware: Add ICS4 wrapper (#562) * chore: add ICS4 wrapper * fix: remove channelKeeper sender packet * chore: add WriteAck --- modules/apps/29-fee/keeper/escrow.go | 1 + modules/apps/29-fee/keeper/keeper.go | 11 ++++------- modules/apps/29-fee/types/expected_keepers.go | 8 ++++++-- testing/simapp/app.go | 3 +-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index fe52439590e..ddc2cb9f727 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -21,6 +21,7 @@ func (k Keeper) EscrowPacketFee(ctx sdk.Context, identifiedFee *types.Identified if err != nil { return err } + hasRefundAcc := k.authKeeper.GetAccount(ctx, refundAcc) if hasRefundAcc == nil { return sdkerrors.Wrap(types.ErrRefundAccNotFound, fmt.Sprintf("Account with address: %s not found", refundAcc)) diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index efe69f7aa5b..580472953ea 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -28,6 +28,7 @@ type Keeper struct { cdc codec.BinaryCodec authKeeper types.AccountKeeper + ics4Wrapper types.ICS4Wrapper channelKeeper types.ChannelKeeper portKeeper types.PortKeeper bankKeeper types.BankKeeper @@ -36,12 +37,13 @@ type Keeper struct { // NewKeeper creates a new 29-fee Keeper instance func NewKeeper( cdc codec.BinaryCodec, key sdk.StoreKey, paramSpace paramtypes.Subspace, - channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper, authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, + ics4Wrapper types.ICS4Wrapper, channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper, authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, ) Keeper { return Keeper{ cdc: cdc, storeKey: key, + ics4Wrapper: ics4Wrapper, channelKeeper: channelKeeper, portKeeper: portKeeper, authKeeper: authKeeper, @@ -54,11 +56,6 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+host.ModuleName+"-"+types.ModuleName) } -// ChanCloseInit wraps the channel keeper's function in order to expose it to underlying app. -func (k Keeper) ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capabilitytypes.Capability) error { - return k.channelKeeper.ChanCloseInit(ctx, portID, channelID, chanCap) -} - // BindPort defines a wrapper function for the port Keeper's function in // order to expose it to module's InitGenesis function func (k Keeper) BindPort(ctx sdk.Context, portID string) *capabilitytypes.Capability { @@ -82,7 +79,7 @@ func (k Keeper) GetFeeModuleAddress() sdk.AccAddress { // SendPacket wraps IBC ChannelKeeper's SendPacket function func (k Keeper) SendPacket(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI) error { - return k.channelKeeper.SendPacket(ctx, chanCap, packet) + return k.ics4Wrapper.SendPacket(ctx, chanCap, packet) } // SetFeeEnabled sets a flag to determine if fee handling logic should run for the given channel diff --git a/modules/apps/29-fee/types/expected_keepers.go b/modules/apps/29-fee/types/expected_keepers.go index d5aad9621c0..e7d5b60088e 100644 --- a/modules/apps/29-fee/types/expected_keepers.go +++ b/modules/apps/29-fee/types/expected_keepers.go @@ -14,12 +14,16 @@ type AccountKeeper interface { GetAccount(sdk.Context, sdk.AccAddress) types.AccountI } +// ICS4Wrapper defines the expected ICS4Wrapper for middleware +type ICS4Wrapper interface { + WriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, acknowledgement []byte) error + SendPacket(ctx sdk.Context, channelCap *capabilitytypes.Capability, packet ibcexported.PacketI) error +} + // ChannelKeeper defines the expected IBC channel keeper type ChannelKeeper interface { GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channeltypes.Channel, found bool) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) - SendPacket(ctx sdk.Context, channelCap *capabilitytypes.Capability, packet ibcexported.PacketI) error - ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capabilitytypes.Capability) error } // PortKeeper defines the expected IBC port keeper diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 58b2a79006d..a926bdd9f9f 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -222,7 +222,6 @@ func NewSimApp( homePath string, invCheckPeriod uint, encodingConfig simappparams.EncodingConfig, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), ) *SimApp { - appCodec := encodingConfig.Marshaler legacyAmino := encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry @@ -323,7 +322,7 @@ func NewSimApp( ) app.IBCFeeKeeper = ibcfeekeeper.NewKeeper(appCodec, keys[ibcfeetypes.StoreKey], app.GetSubspace(ibcfeetypes.ModuleName), - app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper, + app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, app.AccountKeeper, app.BankKeeper, ) // Create Transfer Keeper and pass IBCFeeKeeper as expected Channel and PortKeeper From a737132d530a1e6c84e7225ebe5ccfb4071105f8 Mon Sep 17 00:00:00 2001 From: Charly Date: Tue, 21 Dec 2021 15:11:39 +0100 Subject: [PATCH 15/79] feat: ics 29 packet callbacks (#357) --- modules/apps/29-fee/fee_test.go | 24 ++ modules/apps/29-fee/ibc_module.go | 87 ++++- modules/apps/29-fee/ibc_module_test.go | 319 +++++++++++++++++- modules/apps/29-fee/keeper/escrow.go | 30 +- modules/apps/29-fee/keeper/escrow_test.go | 3 +- modules/apps/29-fee/keeper/keeper.go | 11 + modules/apps/29-fee/keeper/msg_server_test.go | 12 +- modules/apps/29-fee/module.go | 1 - modules/apps/29-fee/types/ack.go | 18 + .../apps/transfer/types/expected_keepers.go | 6 +- modules/core/05-port/types/module.go | 2 +- 11 files changed, 474 insertions(+), 39 deletions(-) create mode 100644 modules/apps/29-fee/types/ack.go diff --git a/modules/apps/29-fee/fee_test.go b/modules/apps/29-fee/fee_test.go index 9ecb400f710..87ebf4c758a 100644 --- a/modules/apps/29-fee/fee_test.go +++ b/modules/apps/29-fee/fee_test.go @@ -5,8 +5,11 @@ import ( "github.com/stretchr/testify/suite" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/ibc-go/modules/apps/29-fee/types" transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" + clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/testing" ) @@ -39,3 +42,24 @@ func (suite *FeeTestSuite) SetupTest() { func TestIBCFeeTestSuite(t *testing.T) { suite.Run(t, new(FeeTestSuite)) } + +func (suite *FeeTestSuite) CreateICS20Packet(coin sdk.Coin) channeltypes.Packet { + + fungibleTokenPacket := transfertypes.NewFungibleTokenPacketData( + coin.Denom, + sdk.NewInt(100).Uint64(), + suite.chainA.SenderAccount.GetAddress().String(), + suite.chainB.SenderAccount.GetAddress().String(), + ) + + return channeltypes.NewPacket( + fungibleTokenPacket.GetBytes(), + suite.chainA.SenderAccount.GetSequence(), + suite.path.EndpointA.ChannelConfig.PortID, + suite.path.EndpointA.ChannelID, + suite.path.EndpointB.ChannelConfig.PortID, + suite.path.EndpointB.ChannelID, + clienttypes.NewHeight(0, 100), + 0, + ) +} diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go index 4bb6680b6d1..22af7709cde 100644 --- a/modules/apps/29-fee/ibc_module.go +++ b/modules/apps/29-fee/ibc_module.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/ibc-go/modules/apps/29-fee/types" channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" porttypes "github.com/cosmos/ibc-go/modules/core/05-port/types" - ibcexported "github.com/cosmos/ibc-go/modules/core/exported" + "github.com/cosmos/ibc-go/modules/core/exported" ) // IBCModule implements the ICS26 callbacks for the fee middleware given the fee keeper and the underlying application. @@ -171,32 +171,105 @@ func (im IBCModule) OnChanCloseConfirm( } // OnRecvPacket implements the IBCModule interface. +// If fees are not enabled, this callback will default to the ibc-core packet callback func (im IBCModule) OnRecvPacket( ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress, -) ibcexported.Acknowledgement { - // TODO: Implement fee specific logic if fee is enabled for the given channel - return im.app.OnRecvPacket(ctx, packet, relayer) +) exported.Acknowledgement { + if !im.keeper.IsFeeEnabled(ctx, packet.DestinationPort, packet.DestinationChannel) { + return im.app.OnRecvPacket(ctx, packet, relayer) + } + + ack := im.app.OnRecvPacket(ctx, packet, relayer) + + forwardRelayer, found := im.keeper.GetCounterpartyAddress(ctx, relayer.String()) + if !found { + forwardRelayer = "" + } + + return types.IncentivizedAcknowledgement{ + Result: ack.Acknowledgement(), + ForwardRelayerAddress: forwardRelayer, + } } // OnAcknowledgementPacket implements the IBCModule interface +// If fees are not enabled, this callback will default to the ibc-core packet callback func (im IBCModule) OnAcknowledgementPacket( ctx sdk.Context, packet channeltypes.Packet, acknowledgement []byte, relayer sdk.AccAddress, ) error { - // TODO: Implement fee specific logic if fee is enabled for the given channel - return im.app.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer) + if !im.keeper.IsFeeEnabled(ctx, packet.SourcePort, packet.SourceChannel) { + return im.app.OnAcknowledgementPacket(ctx, packet, acknowledgement, relayer) + } + + ack := new(types.IncentivizedAcknowledgement) + if err := types.ModuleCdc.UnmarshalJSON(acknowledgement, ack); err != nil { + return sdkerrors.Wrapf(err, "cannot unmarshal ICS-29 incentivized packet acknowledgement: %v", ack) + } + + packetId := channeltypes.NewPacketId(packet.SourceChannel, packet.SourcePort, packet.Sequence) + identifiedPacketFee, found := im.keeper.GetFeeInEscrow(ctx, packetId) + + if !found { + // return underlying callback if no fee found for given packetID + return im.app.OnAcknowledgementPacket(ctx, packet, ack.Result, relayer) + } + + // cache context before trying to distribute the fee + cacheCtx, writeFn := ctx.CacheContext() + + forwardRelayer, _ := sdk.AccAddressFromBech32(ack.ForwardRelayerAddress) + refundAcc, _ := sdk.AccAddressFromBech32(identifiedPacketFee.RefundAddress) + + err := im.keeper.DistributeFee(cacheCtx, refundAcc, forwardRelayer, relayer, packetId) + + if err == nil { + // write the cache and then call underlying callback + writeFn() + // NOTE: The context returned by CacheContext() refers to a new EventManager, so it needs to explicitly set events to the original context. + ctx.EventManager().EmitEvents(cacheCtx.EventManager().Events()) + } + // otherwise discard cache and call underlying callback + return im.app.OnAcknowledgementPacket(ctx, packet, ack.Result, relayer) } // OnTimeoutPacket implements the IBCModule interface +// If fees are not enabled, this callback will default to the ibc-core packet callback func (im IBCModule) OnTimeoutPacket( ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress, ) error { - // TODO: Implement fee specific logic if fee is enabled for the given channel + if !im.keeper.IsFeeEnabled(ctx, packet.SourcePort, packet.SourceChannel) { + return im.app.OnTimeoutPacket(ctx, packet, relayer) + } + + packetId := channeltypes.NewPacketId(packet.SourceChannel, packet.SourcePort, packet.Sequence) + + identifiedPacketFee, found := im.keeper.GetFeeInEscrow(ctx, packetId) + + if !found { + // return underlying callback if fee not found for given packetID + return im.app.OnTimeoutPacket(ctx, packet, relayer) + } + + // cache context before trying to distribute the fee + cacheCtx, writeFn := ctx.CacheContext() + + refundAcc, _ := sdk.AccAddressFromBech32(identifiedPacketFee.RefundAddress) + err := im.keeper.DistributeFeeTimeout(cacheCtx, refundAcc, relayer, packetId) + + if err == nil { + // write the cache and then call underlying callback + writeFn() + // NOTE: The context returned by CacheContext() refers to a new EventManager, so it needs to explicitly set events to the original context. + ctx.EventManager().EmitEvents(cacheCtx.EventManager().Events()) + } + + // otherwise discard cache and call underlying callback return im.app.OnTimeoutPacket(ctx, packet, relayer) } diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index 598b3af6b14..f95617a3dd0 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -11,13 +11,13 @@ import ( channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/modules/core/24-host" ibctesting "github.com/cosmos/ibc-go/testing" + "github.com/cosmos/ibc-go/testing/simapp" ) var ( - validCoins = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}} - validCoins2 = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(200)}} - validCoins3 = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(300)}} - invalidCoins = sdk.Coins{sdk.Coin{Denom: "invalidDenom", Amount: sdk.NewInt(100)}} + validCoins = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}} + validCoins2 = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(200)}} + validCoins3 = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(300)}} ) // Tests OnChanOpenInit on ChainA @@ -468,3 +468,314 @@ func (suite *FeeTestSuite) TestOnChanCloseConfirm() { }) } } + +func (suite *FeeTestSuite) TestOnRecvPacket() { + testCases := []struct { + name string + malleate func() + // forwardRelayer bool indicates if there is a forwardRelayer address set + forwardRelayer bool + feeEnabled bool + }{ + { + "success", + func() {}, + true, + true, + }, + { + "source relayer is empty string", + func() { + suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), "") + }, + false, + true, + }, + { + "fee not enabled", + func() { + suite.chainB.GetSimApp().IBCFeeKeeper.DeleteFeeEnabled(suite.chainB.GetContext(), suite.path.EndpointB.ChannelConfig.PortID, suite.path.EndpointB.ChannelID) + }, + true, + false, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + suite.SetupTest() + suite.coordinator.Setup(suite.path) + + // set up coin & ics20 packet + coin := ibctesting.TestCoin + + // set up a different channel to make sure that the test will error if the destination channel of the packet is not fee enabled + suite.path.EndpointB.ChannelID = "channel-1" + suite.chainB.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainB.GetContext(), suite.path.EndpointB.ChannelConfig.PortID, suite.path.EndpointB.ChannelID) + suite.chainB.GetSimApp().IBCFeeKeeper.DeleteFeeEnabled(suite.chainB.GetContext(), suite.path.EndpointB.ChannelConfig.PortID, "channel-0") + + packet := suite.CreateICS20Packet(coin) + + // set up module and callbacks + module, _, err := suite.chainB.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainB.GetContext(), ibctesting.TransferPort) + suite.Require().NoError(err) + + cbs, ok := suite.chainB.App.GetIBCKeeper().Router.GetRoute(module) + suite.Require().True(ok) + + suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String()) + + // malleate test case + tc.malleate() + + result := cbs.OnRecvPacket(suite.chainB.GetContext(), packet, suite.chainA.SenderAccount.GetAddress()) + + switch { + case !tc.feeEnabled: + ack := channeltypes.NewResultAcknowledgement([]byte{1}) + suite.Require().Equal(ack, result) + + case tc.forwardRelayer: + ack := types.IncentivizedAcknowledgement{ + Result: channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement(), + ForwardRelayerAddress: suite.chainB.SenderAccount.GetAddress().String(), + } + suite.Require().Equal(ack, result) + + case !tc.forwardRelayer: + ack := types.IncentivizedAcknowledgement{ + Result: channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement(), + ForwardRelayerAddress: "", + } + suite.Require().Equal(ack, result) + } + }) + } +} + +// different channel than sending chain +func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { + var ack []byte + testCases := []struct { + name string + malleate func() + expPass bool + }{ + { + "success", + func() {}, + true, + }, + { + "no op success without a packet fee", + func() { + packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) + suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeeInEscrow(suite.chainA.GetContext(), packetId) + + ack = types.IncentivizedAcknowledgement{ + Result: channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement(), + ForwardRelayerAddress: suite.chainA.SenderAccount.GetAddress().String(), + }.Acknowledgement() + }, + false, + }, + { + "ack wrong format", + func() { + ack = []byte("unsupported acknowledgement format") + }, + false, + }, + { + "channel is not fee not enabled, success", + func() { + suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeeEnabled(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) + ack = channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement() + }, + false, + }, + { + "error on distribute fee (blocked address)", + func() { + blockedAddr := suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), types.ModuleName).GetAddress() + + ack = types.IncentivizedAcknowledgement{ + Result: channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement(), + ForwardRelayerAddress: blockedAddr.String(), + }.Acknowledgement() + }, + false, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + suite.SetupTest() + + // open incentivized channel + suite.coordinator.Setup(suite.path) + + // set up coin & ics20 packet + coin := ibctesting.TestCoin + packet := suite.CreateICS20Packet(coin) + + // set up module and callbacks + module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort) + suite.Require().NoError(err) + + cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + suite.Require().True(ok) + + // escrow the packet fee + packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) + identifiedFee := types.NewIdentifiedPacketFee( + packetId, + types.Fee{ + ReceiveFee: validCoins, + AckFee: validCoins2, + TimeoutFee: validCoins3, + }, + suite.chainA.SenderAccount.GetAddress().String(), + []string{}, + ) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) + suite.Require().NoError(err) + + // must be changed explicitly + ack = types.IncentivizedAcknowledgement{ + Result: channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement(), + ForwardRelayerAddress: suite.chainA.SenderAccount.GetAddress().String(), + }.Acknowledgement() + + // malleate test case + tc.malleate() + + err = cbs.OnAcknowledgementPacket(suite.chainA.GetContext(), packet, ack, suite.chainA.SenderAccount.GetAddress()) + + if tc.expPass { + suite.Require().NoError(err, "unexpected error for case: %s", tc.name) + suite.Require().Equal( + sdk.Coin{ + Denom: ibctesting.TestCoin.Denom, + Amount: sdk.NewInt(100000000000000), + }, + suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)) + } else { + suite.Require().Equal( + sdk.Coin{ + Denom: ibctesting.TestCoin.Denom, + Amount: sdk.NewInt(99999999999400), + }, + suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)) + } + }) + } +} + +func (suite *FeeTestSuite) TestOnTimeoutPacket() { + var ( + relayerAddr sdk.AccAddress + ) + testCases := []struct { + name string + malleate func() + expPass bool + }{ + { + "success", + func() {}, + true, + }, + { + "no op if identified packet fee doesn't exist", + func() { + // delete packet fee + packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) + suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeeInEscrow(suite.chainA.GetContext(), packetId) + }, + false, + }, + { + "error on distribute fee (blocked address)", + func() { + relayerAddr = suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), types.ModuleName).GetAddress() + }, + false, + }, + { + "fee not enabled", + func() { + suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeeEnabled(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) + }, + false, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + suite.SetupTest() + + // open incentivized channel + suite.coordinator.Setup(suite.path) + + // set up coin & create ics20 packet + coin := ibctesting.TestCoin + packet := suite.CreateICS20Packet(coin) + + // setup for ics20: fund chain A's escrow path so that tokens can be unescrowed upon timeout + escrow := transfertypes.GetEscrowAddress(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) + suite.Require().NoError(simapp.FundAccount(suite.chainA.GetSimApp(), suite.chainA.GetContext(), escrow, sdk.NewCoins(coin))) + + // set up module and callbacks + module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort) + suite.Require().NoError(err) + + cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) + suite.Require().True(ok) + + packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) + + // must be explicitly changed + relayerAddr = suite.chainA.SenderAccount.GetAddress() + + identifiedFee := types.NewIdentifiedPacketFee( + packetId, + types.Fee{ + ReceiveFee: validCoins, + AckFee: validCoins2, + TimeoutFee: validCoins3, + }, + suite.chainA.SenderAccount.GetAddress().String(), + []string{}, + ) + + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) + suite.Require().NoError(err) + + // malleate test case + tc.malleate() + + err = cbs.OnTimeoutPacket(suite.chainA.GetContext(), packet, relayerAddr) + + if tc.expPass { + suite.Require().NoError(err, "unexpected error for case: %s", tc.name) + suite.Require().Equal( + sdk.Coin{ + Denom: ibctesting.TestCoin.Denom, + Amount: sdk.NewInt(100000000000100), + }, + suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)) + } else { + suite.Require().Equal( + sdk.Coin{ + Denom: ibctesting.TestCoin.Denom, + Amount: sdk.NewInt(99999999999500), + }, + suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)) + } + }) + } +} diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index ddc2cb9f727..096d1f0ce3b 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -51,23 +51,20 @@ func (k Keeper) DistributeFee(ctx sdk.Context, refundAcc, forwardRelayer, revers return sdkerrors.Wrapf(types.ErrFeeNotFound, "with channelID %s, sequence %d", packetID.ChannelId, packetID.Sequence) } - // get module accAddr - feeModuleAccAddr := k.authKeeper.GetModuleAddress(types.ModuleName) - // send receive fee to forward relayer - err := k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, forwardRelayer, feeInEscrow.Fee.ReceiveFee) + err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, forwardRelayer, feeInEscrow.Fee.ReceiveFee) if err != nil { return sdkerrors.Wrap(err, "failed to send fee to forward relayer") } // send ack fee to reverse relayer - err = k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, reverseRelayer, feeInEscrow.Fee.AckFee) + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, reverseRelayer, feeInEscrow.Fee.AckFee) if err != nil { return sdkerrors.Wrap(err, "error sending fee to reverse relayer") } // refund timeout fee to refundAddr - err = k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, refundAcc, feeInEscrow.Fee.TimeoutFee) + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAcc, feeInEscrow.Fee.TimeoutFee) if err != nil { return sdkerrors.Wrap(err, "error refunding timeout fee") } @@ -83,26 +80,23 @@ func (k Keeper) DistributeFeeTimeout(ctx sdk.Context, refundAcc, timeoutRelayer // check if there is a Fee in escrow for the given packetId feeInEscrow, found := k.GetFeeInEscrow(ctx, packetID) if !found { - return sdkerrors.Wrap(types.ErrFeeNotFound, refundAcc.String()) + return sdkerrors.Wrapf(types.ErrFeeNotFound, "for packetID %s", packetID) } - // get module accAddr - feeModuleAccAddr := k.authKeeper.GetModuleAddress(types.ModuleName) - // refund the receive fee - err := k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, refundAcc, feeInEscrow.Fee.ReceiveFee) + err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAcc, feeInEscrow.Fee.ReceiveFee) if err != nil { return sdkerrors.Wrap(err, "error refunding receive fee") } // refund the ack fee - err = k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, refundAcc, feeInEscrow.Fee.AckFee) + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAcc, feeInEscrow.Fee.AckFee) if err != nil { return sdkerrors.Wrap(err, "error refunding ack fee") } - // pay the timeout fee to the reverse relayer - err = k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, timeoutRelayer, feeInEscrow.Fee.TimeoutFee) + // pay the timeout fee to the timeout relayer + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, timeoutRelayer, feeInEscrow.Fee.TimeoutFee) if err != nil { return sdkerrors.Wrap(err, "error sending fee to timeout relayer") } @@ -114,8 +108,6 @@ func (k Keeper) DistributeFeeTimeout(ctx sdk.Context, refundAcc, timeoutRelayer } func (k Keeper) RefundFeesOnChannel(ctx sdk.Context, portID, channelID string) error { - // get module accAddr - feeModuleAccAddr := k.authKeeper.GetModuleAddress(types.ModuleName) var refundErr error @@ -129,17 +121,17 @@ func (k Keeper) RefundFeesOnChannel(ctx sdk.Context, portID, channelID string) e // refund all fees to refund address // Use SendCoins rather than the module account send functions since refund address may be a user account or module address. // if any `SendCoins` call returns an error, we return error and stop iteration - err = k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, refundAccAddr, identifiedFee.Fee.ReceiveFee) + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.ReceiveFee) if err != nil { refundErr = err return true } - err = k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, refundAccAddr, identifiedFee.Fee.AckFee) + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.AckFee) if err != nil { refundErr = err return true } - err = k.bankKeeper.SendCoins(ctx, feeModuleAccAddr, refundAccAddr, identifiedFee.Fee.TimeoutFee) + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.TimeoutFee) if err != nil { refundErr = err return true diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go index 8eed26d52a4..103e3904f24 100644 --- a/modules/apps/29-fee/keeper/escrow_test.go +++ b/modules/apps/29-fee/keeper/escrow_test.go @@ -1,9 +1,8 @@ package keeper_test import ( - "github.com/tendermint/tendermint/crypto/secp256k1" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tendermint/tendermint/crypto/secp256k1" "github.com/cosmos/ibc-go/modules/apps/29-fee/types" transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index 580472953ea..028841e8f2d 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -82,6 +82,17 @@ func (k Keeper) SendPacket(ctx sdk.Context, chanCap *capabilitytypes.Capability, return k.ics4Wrapper.SendPacket(ctx, chanCap, packet) } +// WriteAcknowledgement wraps IBC ChannelKeeper's WriteAcknowledgement function +func (k Keeper) WriteAcknowledgement( + ctx sdk.Context, + chanCap *capabilitytypes.Capability, + packet ibcexported.PacketI, + acknowledgement []byte, +) error { + return nil + // return k.channelKeeper.WriteAcknowledgement(ctx, chanCap, packet, acknowledgement) +} + // SetFeeEnabled sets a flag to determine if fee handling logic should run for the given channel // identified by channel and port identifiers. func (k Keeper) SetFeeEnabled(ctx sdk.Context, portID, channelID string) { diff --git a/modules/apps/29-fee/keeper/msg_server_test.go b/modules/apps/29-fee/keeper/msg_server_test.go index ec7f830bd4d..f7d5d8f8c59 100644 --- a/modules/apps/29-fee/keeper/msg_server_test.go +++ b/modules/apps/29-fee/keeper/msg_server_test.go @@ -69,7 +69,11 @@ func (suite *KeeperTestSuite) TestPayPacketFee() { refundAcc := suite.chainA.SenderAccount.GetAddress() channelID := suite.path.EndpointA.ChannelID - fee := types.Fee{validCoins, validCoins, validCoins} + fee := types.Fee{ + ReceiveFee: validCoins, + AckFee: validCoins, + TimeoutFee: validCoins, + } msg := types.NewMsgPayPacketFee(fee, suite.path.EndpointA.ChannelConfig.PortID, channelID, refundAcc.String(), []string{}) tc.malleate() @@ -106,7 +110,11 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() { // build packetId channelID := suite.path.EndpointA.ChannelID - fee := types.Fee{validCoins, validCoins, validCoins} + fee := types.Fee{ + ReceiveFee: validCoins, + AckFee: validCoins, + TimeoutFee: validCoins, + } seq, _ := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetNextSequenceSend(ctxA, suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) // build fee diff --git a/modules/apps/29-fee/module.go b/modules/apps/29-fee/module.go index 78b9dc6d091..ea370790dbc 100644 --- a/modules/apps/29-fee/module.go +++ b/modules/apps/29-fee/module.go @@ -53,7 +53,6 @@ func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) // 29-fee module. func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { return cdc.MustMarshalJSON(types.DefaultGenesisState()) - return nil } // ValidateGenesis performs genesis state validation for the 29-fee module. diff --git a/modules/apps/29-fee/types/ack.go b/modules/apps/29-fee/types/ack.go new file mode 100644 index 00000000000..05908ce7b01 --- /dev/null +++ b/modules/apps/29-fee/types/ack.go @@ -0,0 +1,18 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// Success implements the Acknowledgement interface. The acknowledgement is +// considered successful if the forward relayer address is empty. Otherwise it is +// considered a failed acknowledgement. +func (ack IncentivizedAcknowledgement) Success() bool { + return ack.ForwardRelayerAddress != "" +} + +// Acknowledgement implements the Acknowledgement interface. It returns the +// acknowledgement serialised using JSON. +func (ack IncentivizedAcknowledgement) Acknowledgement() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&ack)) +} diff --git a/modules/apps/transfer/types/expected_keepers.go b/modules/apps/transfer/types/expected_keepers.go index d7881642c12..7bf24777bc4 100644 --- a/modules/apps/transfer/types/expected_keepers.go +++ b/modules/apps/transfer/types/expected_keepers.go @@ -6,7 +6,7 @@ import ( capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" 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" + "github.com/cosmos/ibc-go/modules/core/exported" ) // AccountKeeper defines the contract required for account APIs. @@ -28,12 +28,12 @@ type BankKeeper interface { type ChannelKeeper interface { GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channeltypes.Channel, found bool) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) - SendPacket(ctx sdk.Context, channelCap *capabilitytypes.Capability, packet ibcexported.PacketI) error + SendPacket(ctx sdk.Context, channelCap *capabilitytypes.Capability, packet exported.PacketI) error } // ClientKeeper defines the expected IBC client keeper type ClientKeeper interface { - GetClientConsensusState(ctx sdk.Context, clientID string) (connection ibcexported.ConsensusState, found bool) + GetClientConsensusState(ctx sdk.Context, clientID string) (connection exported.ConsensusState, found bool) } // ConnectionKeeper defines the expected IBC connection keeper diff --git a/modules/core/05-port/types/module.go b/modules/core/05-port/types/module.go index 9c0885c0cf1..886d9ba57c7 100644 --- a/modules/core/05-port/types/module.go +++ b/modules/core/05-port/types/module.go @@ -2,8 +2,8 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" "github.com/cosmos/ibc-go/modules/core/exported" ) From e0cc81a21280e381c538fd4791d80c0eb4c68092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Wed, 12 Jan 2022 12:20:32 +0100 Subject: [PATCH 16/79] update imports to v3 --- modules/apps/29-fee/fee_test.go | 8 ++++---- modules/apps/29-fee/ibc_module.go | 10 +++++----- modules/apps/29-fee/ibc_module_test.go | 8 ++++---- modules/apps/29-fee/keeper/escrow.go | 4 ++-- modules/apps/29-fee/keeper/escrow_test.go | 6 +++--- modules/apps/29-fee/keeper/genesis.go | 2 +- modules/apps/29-fee/keeper/genesis_test.go | 6 +++--- modules/apps/29-fee/keeper/grpc_query.go | 2 +- modules/apps/29-fee/keeper/grpc_query_test.go | 6 +++--- modules/apps/29-fee/keeper/keeper.go | 8 ++++---- modules/apps/29-fee/keeper/keeper_test.go | 6 +++--- modules/apps/29-fee/keeper/msg_server.go | 4 ++-- modules/apps/29-fee/keeper/msg_server_test.go | 4 ++-- modules/apps/29-fee/module.go | 12 ++++++------ modules/apps/29-fee/types/expected_keepers.go | 4 ++-- modules/apps/29-fee/types/fee.pb.go | 2 +- modules/apps/29-fee/types/genesis.go | 2 +- modules/apps/29-fee/types/genesis_test.go | 6 +++--- modules/apps/29-fee/types/keys.go | 2 +- modules/apps/29-fee/types/keys_test.go | 2 +- modules/apps/29-fee/types/msgs.go | 4 ++-- modules/apps/29-fee/types/msgs_test.go | 2 +- modules/apps/29-fee/types/query.pb.go | 2 +- modules/apps/29-fee/types/tx.pb.go | 2 +- 24 files changed, 57 insertions(+), 57 deletions(-) diff --git a/modules/apps/29-fee/fee_test.go b/modules/apps/29-fee/fee_test.go index 87ebf4c758a..1b930db6456 100644 --- a/modules/apps/29-fee/fee_test.go +++ b/modules/apps/29-fee/fee_test.go @@ -7,10 +7,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/ibc-go/modules/apps/29-fee/types" - transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" - clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" + transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" + clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/testing" ) diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go index 22af7709cde..230c7da2cd0 100644 --- a/modules/apps/29-fee/ibc_module.go +++ b/modules/apps/29-fee/ibc_module.go @@ -5,11 +5,11 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - "github.com/cosmos/ibc-go/modules/apps/29-fee/keeper" - "github.com/cosmos/ibc-go/modules/apps/29-fee/types" - channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" - porttypes "github.com/cosmos/ibc-go/modules/core/05-port/types" - "github.com/cosmos/ibc-go/modules/core/exported" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/keeper" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types" + "github.com/cosmos/ibc-go/v3/modules/core/exported" ) // IBCModule implements the ICS26 callbacks for the fee middleware given the fee keeper and the underlying application. diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index f95617a3dd0..bee6b693661 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -6,10 +6,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - "github.com/cosmos/ibc-go/modules/apps/29-fee/types" - transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" - channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" - host "github.com/cosmos/ibc-go/modules/core/24-host" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" + transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v3/modules/core/24-host" ibctesting "github.com/cosmos/ibc-go/testing" "github.com/cosmos/ibc-go/testing/simapp" ) diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index 096d1f0ce3b..0dae91cea93 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -6,8 +6,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/ibc-go/modules/apps/29-fee/types" - channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ) // EscrowPacketFee sends the packet fee to the 29-fee module account to hold in escrow diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go index 103e3904f24..fb71461913d 100644 --- a/modules/apps/29-fee/keeper/escrow_test.go +++ b/modules/apps/29-fee/keeper/escrow_test.go @@ -4,9 +4,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/tendermint/tendermint/crypto/secp256k1" - "github.com/cosmos/ibc-go/modules/apps/29-fee/types" - transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" - channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" + transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ) func (suite *KeeperTestSuite) TestEscrowPacketFee() { diff --git a/modules/apps/29-fee/keeper/genesis.go b/modules/apps/29-fee/keeper/genesis.go index 7ce7f11970f..b817b33c9a4 100644 --- a/modules/apps/29-fee/keeper/genesis.go +++ b/modules/apps/29-fee/keeper/genesis.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" ) // InitGenesis diff --git a/modules/apps/29-fee/keeper/genesis_test.go b/modules/apps/29-fee/keeper/genesis_test.go index 3fe9a3db38d..8332658cecd 100644 --- a/modules/apps/29-fee/keeper/genesis_test.go +++ b/modules/apps/29-fee/keeper/genesis_test.go @@ -1,9 +1,9 @@ package keeper_test import ( - "github.com/cosmos/ibc-go/modules/apps/29-fee/types" - transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" - channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" + transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/testing" ) diff --git a/modules/apps/29-fee/keeper/grpc_query.go b/modules/apps/29-fee/keeper/grpc_query.go index 5c9a8037ab7..1dae09d9265 100644 --- a/modules/apps/29-fee/keeper/grpc_query.go +++ b/modules/apps/29-fee/keeper/grpc_query.go @@ -11,7 +11,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" ) var _ types.QueryServer = Keeper{} diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index b8b13f36242..a2904234871 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -6,9 +6,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/cosmos/ibc-go/modules/apps/29-fee/types" - transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" - channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" + transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/testing" ) diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index 028841e8f2d..26d0d62f5e9 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -9,10 +9,10 @@ import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/tendermint/tendermint/libs/log" - "github.com/cosmos/ibc-go/modules/apps/29-fee/types" - channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" - host "github.com/cosmos/ibc-go/modules/core/24-host" - ibcexported "github.com/cosmos/ibc-go/modules/core/exported" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v3/modules/core/24-host" + ibcexported "github.com/cosmos/ibc-go/v3/modules/core/exported" ) // Middleware must implement types.ChannelKeeper and types.PortKeeper expected interfaces diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index 7675bb127e3..40623262158 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -8,9 +8,9 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/ibc-go/modules/apps/29-fee/types" - transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" - channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" + transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/testing" ) diff --git a/modules/apps/29-fee/keeper/msg_server.go b/modules/apps/29-fee/keeper/msg_server.go index e3687b9d215..dec2f27e928 100644 --- a/modules/apps/29-fee/keeper/msg_server.go +++ b/modules/apps/29-fee/keeper/msg_server.go @@ -5,8 +5,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/ibc-go/modules/apps/29-fee/types" - channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ) var _ types.MsgServer = Keeper{} diff --git a/modules/apps/29-fee/keeper/msg_server_test.go b/modules/apps/29-fee/keeper/msg_server_test.go index f7d5d8f8c59..9b6e0596b94 100644 --- a/modules/apps/29-fee/keeper/msg_server_test.go +++ b/modules/apps/29-fee/keeper/msg_server_test.go @@ -1,8 +1,8 @@ package keeper_test import ( - "github.com/cosmos/ibc-go/modules/apps/29-fee/types" - channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ) func (suite *KeeperTestSuite) TestRegisterCounterpartyAddress() { diff --git a/modules/apps/29-fee/module.go b/modules/apps/29-fee/module.go index ea370790dbc..c603bcf51ec 100644 --- a/modules/apps/29-fee/module.go +++ b/modules/apps/29-fee/module.go @@ -17,14 +17,14 @@ import ( "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" - "github.com/cosmos/ibc-go/modules/apps/29-fee/client/cli" - "github.com/cosmos/ibc-go/modules/apps/29-fee/keeper" - "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/client/cli" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/keeper" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" - // "github.com/cosmos/ibc-go/modules/apps/29-fee/client/cli" - // "github.com/cosmos/ibc-go/modules/apps/29-fee/simulation" + // "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/client/cli" + // "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/simulation" - porttypes "github.com/cosmos/ibc-go/modules/core/05-port/types" + porttypes "github.com/cosmos/ibc-go/v3/modules/core/05-port/types" ) var ( diff --git a/modules/apps/29-fee/types/expected_keepers.go b/modules/apps/29-fee/types/expected_keepers.go index e7d5b60088e..b5bdc1fd87c 100644 --- a/modules/apps/29-fee/types/expected_keepers.go +++ b/modules/apps/29-fee/types/expected_keepers.go @@ -4,8 +4,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" - ibcexported "github.com/cosmos/ibc-go/modules/core/exported" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + ibcexported "github.com/cosmos/ibc-go/v3/modules/core/exported" ) // AccountKeeper defines the contract required for account APIs. diff --git a/modules/apps/29-fee/types/fee.pb.go b/modules/apps/29-fee/types/fee.pb.go index 038368c7ce8..d3c55514660 100644 --- a/modules/apps/29-fee/types/fee.pb.go +++ b/modules/apps/29-fee/types/fee.pb.go @@ -7,7 +7,7 @@ import ( fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" - types1 "github.com/cosmos/ibc-go/modules/core/04-channel/types" + types1 "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" diff --git a/modules/apps/29-fee/types/genesis.go b/modules/apps/29-fee/types/genesis.go index 5a0ebdeb9d2..e1eea3b7fac 100644 --- a/modules/apps/29-fee/types/genesis.go +++ b/modules/apps/29-fee/types/genesis.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - host "github.com/cosmos/ibc-go/modules/core/24-host" + host "github.com/cosmos/ibc-go/v3/modules/core/24-host" ) // NewGenesisState creates a 29-fee GenesisState instance. diff --git a/modules/apps/29-fee/types/genesis_test.go b/modules/apps/29-fee/types/genesis_test.go index 54af51e61fa..72382501442 100644 --- a/modules/apps/29-fee/types/genesis_test.go +++ b/modules/apps/29-fee/types/genesis_test.go @@ -7,9 +7,9 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/secp256k1" - "github.com/cosmos/ibc-go/modules/apps/29-fee/types" - transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types" - channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" + transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/testing" ) diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index 17e22df8530..c017af5d32f 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -3,7 +3,7 @@ package types import ( "fmt" - channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ) const ( diff --git a/modules/apps/29-fee/types/keys_test.go b/modules/apps/29-fee/types/keys_test.go index 312188c5e21..b8329ecb206 100644 --- a/modules/apps/29-fee/types/keys_test.go +++ b/modules/apps/29-fee/types/keys_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/cosmos/ibc-go/modules/apps/29-fee/types" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" ) func TestKeyRelayerAddress(t *testing.T) { diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index 4653b69ce18..926da90de4e 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -4,8 +4,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" - host "github.com/cosmos/ibc-go/modules/core/24-host" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v3/modules/core/24-host" ) // msg types diff --git a/modules/apps/29-fee/types/msgs_test.go b/modules/apps/29-fee/types/msgs_test.go index 16172969776..e6386dc91d4 100644 --- a/modules/apps/29-fee/types/msgs_test.go +++ b/modules/apps/29-fee/types/msgs_test.go @@ -4,7 +4,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - channeltypes "github.com/cosmos/ibc-go/modules/core/04-channel/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/secp256k1" ) diff --git a/modules/apps/29-fee/types/query.pb.go b/modules/apps/29-fee/types/query.pb.go index 99f961652a4..6361527729d 100644 --- a/modules/apps/29-fee/types/query.pb.go +++ b/modules/apps/29-fee/types/query.pb.go @@ -7,7 +7,7 @@ import ( context "context" fmt "fmt" query "github.com/cosmos/cosmos-sdk/types/query" - types "github.com/cosmos/ibc-go/modules/core/04-channel/types" + types "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" diff --git a/modules/apps/29-fee/types/tx.pb.go b/modules/apps/29-fee/types/tx.pb.go index 8602f2996c8..382779cc86e 100644 --- a/modules/apps/29-fee/types/tx.pb.go +++ b/modules/apps/29-fee/types/tx.pb.go @@ -6,7 +6,7 @@ package types import ( context "context" fmt "fmt" - _ "github.com/cosmos/ibc-go/modules/core/04-channel/types" + _ "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" From 120fd767743583023ebb7528b14726d45cd04e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Wed, 12 Jan 2022 12:20:59 +0100 Subject: [PATCH 17/79] regenerate proto files --- docs/ibc/proto-docs.md | 742 +++++++++++--------- go.mod | 10 +- go.sum | 4 + modules/core/04-channel/types/channel.pb.go | 117 +-- 4 files changed, 489 insertions(+), 384 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 7025ed11cef..6510b6b75f3 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -54,6 +54,25 @@ - [MsgRegisterCounterpartyAddressResponse](#ibc.applications.fee.v1.MsgRegisterCounterpartyAddressResponse) - [Msg](#ibc.applications.fee.v1.Msg) + +- [ibc/applications/interchain_accounts/controller/v1/controller.proto](#ibc/applications/interchain_accounts/controller/v1/controller.proto) + - [Params](#ibc.applications.interchain_accounts.controller.v1.Params) + +- [ibc/applications/interchain_accounts/controller/v1/query.proto](#ibc/applications/interchain_accounts/controller/v1/query.proto) + - [QueryParamsRequest](#ibc.applications.interchain_accounts.controller.v1.QueryParamsRequest) + - [QueryParamsResponse](#ibc.applications.interchain_accounts.controller.v1.QueryParamsResponse) + + - [Query](#ibc.applications.interchain_accounts.controller.v1.Query) + +- [ibc/applications/interchain_accounts/host/v1/host.proto](#ibc/applications/interchain_accounts/host/v1/host.proto) + - [Params](#ibc.applications.interchain_accounts.host.v1.Params) + +- [ibc/applications/interchain_accounts/host/v1/query.proto](#ibc/applications/interchain_accounts/host/v1/query.proto) + - [QueryParamsRequest](#ibc.applications.interchain_accounts.host.v1.QueryParamsRequest) + - [QueryParamsResponse](#ibc.applications.interchain_accounts.host.v1.QueryParamsResponse) + + - [Query](#ibc.applications.interchain_accounts.host.v1.Query) + - [ibc/applications/interchain_accounts/v1/account.proto](#ibc/applications/interchain_accounts/v1/account.proto) - [InterchainAccount](#ibc.applications.interchain_accounts.v1.InterchainAccount) @@ -98,17 +117,6 @@ - [ibc/applications/transfer/v2/packet.proto](#ibc/applications/transfer/v2/packet.proto) - [FungibleTokenPacketData](#ibc.applications.transfer.v2.FungibleTokenPacketData) -- [ibc/core/channel/v1/channel.proto](#ibc/core/channel/v1/channel.proto) - - [Acknowledgement](#ibc.core.channel.v1.Acknowledgement) - - [Channel](#ibc.core.channel.v1.Channel) - - [Counterparty](#ibc.core.channel.v1.Counterparty) - - [IdentifiedChannel](#ibc.core.channel.v1.IdentifiedChannel) - - [Packet](#ibc.core.channel.v1.Packet) - - [PacketState](#ibc.core.channel.v1.PacketState) - - - [Order](#ibc.core.channel.v1.Order) - - [State](#ibc.core.channel.v1.State) - - [ibc/core/channel/v1/genesis.proto](#ibc/core/channel/v1/genesis.proto) - [GenesisState](#ibc.core.channel.v1.GenesisState) - [PacketSequence](#ibc.core.channel.v1.PacketSequence) @@ -319,25 +327,12 @@ ### IncentivizedAcknowledgement IncentivizedAcknowledgement is the acknowledgement format to be used by applications wrapped in the fee middleware It contains the raw acknowledgement bytes, as well as the forward relayer address - -

Top

- -## ibc/applications/interchain_accounts/v1/account.proto - - - - - -### InterchainAccount -An InterchainAccount is defined as a BaseAccount & the address of the account owner on the controller chain | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `result` | [bytes](#bytes) | | | | `forward_relayer_address` | [string](#string) | | | -| `base_account` | [cosmos.auth.v1beta1.BaseAccount](#cosmos.auth.v1beta1.BaseAccount) | | | -| `account_owner` | [string](#string) | | | @@ -516,7 +511,7 @@ NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental conflicts with other protobuf message formats used for acknowledgements. The first byte of any message with this format will be the non-ASCII values `0xaa` (result) or `0xb2` (error). Implemented as defined by ICS: -https://github.com/cosmos/ics/tree/master/spec/ics-004-channel-and-packet-semantics#acknowledgement-envelope +https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#acknowledgement-envelope | Field | Type | Label | Description | @@ -755,17 +750,6 @@ and an optional list of relayers that are permitted to receive the fee. ### FeeEnabledChannel Contains the PortID & ChannelID for a fee enabled channel - -

Top

- -## ibc/applications/interchain_accounts/v1/genesis.proto - - - - - -### ActiveChannel -ActiveChannel contains a pairing of port ID and channel ID for an active interchain accounts channel | Field | Type | Label | Description | @@ -782,28 +766,6 @@ ActiveChannel contains a pairing of port ID and channel ID for an active interch ### GenesisState GenesisState defines the fee middleware genesis state - - -### ControllerGenesisState -ControllerGenesisState defines the interchain accounts controller genesis state - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `active_channels` | [ActiveChannel](#ibc.applications.interchain_accounts.v1.ActiveChannel) | repeated | | -| `interchain_accounts` | [RegisteredInterchainAccount](#ibc.applications.interchain_accounts.v1.RegisteredInterchainAccount) | repeated | | -| `ports` | [string](#string) | repeated | | -| `params` | [ibc.applications.interchain_accounts.controller.v1.Params](#ibc.applications.interchain_accounts.controller.v1.Params) | | | - - - - - - - - -### GenesisState -GenesisState defines the interchain accounts genesis state | Field | Type | Label | Description | @@ -811,8 +773,6 @@ GenesisState defines the interchain accounts genesis state | `identified_fees` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | repeated | | | `fee_enabled_channels` | [FeeEnabledChannel](#ibc.applications.fee.v1.FeeEnabledChannel) | repeated | | | `registered_relayers` | [RegisteredRelayerAddress](#ibc.applications.fee.v1.RegisteredRelayerAddress) | repeated | | -| `controller_genesis_state` | [ControllerGenesisState](#ibc.applications.interchain_accounts.v1.ControllerGenesisState) | | | -| `host_genesis_state` | [HostGenesisState](#ibc.applications.interchain_accounts.v1.HostGenesisState) | | | @@ -823,36 +783,12 @@ GenesisState defines the interchain accounts genesis state ### RegisteredRelayerAddress Contains the address and counterparty address for a specific relayer (for distributing fees) - - -### HostGenesisState -HostGenesisState defines the interchain accounts host genesis state | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `address` | [string](#string) | | | | `counterparty_address` | [string](#string) | | | -| `active_channels` | [ActiveChannel](#ibc.applications.interchain_accounts.v1.ActiveChannel) | repeated | | -| `interchain_accounts` | [RegisteredInterchainAccount](#ibc.applications.interchain_accounts.v1.RegisteredInterchainAccount) | repeated | | -| `port` | [string](#string) | | | -| `params` | [ibc.applications.interchain_accounts.host.v1.Params](#ibc.applications.interchain_accounts.host.v1.Params) | | | - - - - - - - - -### RegisteredInterchainAccount -RegisteredInterchainAccount contains a pairing of controller port ID and associated interchain account address - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | | -| `account_address` | [string](#string) | | | @@ -879,24 +815,12 @@ RegisteredInterchainAccount contains a pairing of controller port ID and associa ### QueryIncentivizedPacketRequest QueryIncentivizedPacketRequest is the request type for querying for all incentivized packets - -

Top

- -## ibc/applications/interchain_accounts/v1/packet.proto - - - - - -### CosmosTx -CosmosTx contains a list of sdk.Msg's. It should be used when sending transactions to an SDK host chain. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | PacketID | | `query_height` | [uint64](#uint64) | | Height to query at | -| `messages` | [google.protobuf.Any](#google.protobuf.Any) | repeated | | @@ -907,10 +831,6 @@ CosmosTx contains a list of sdk.Msg's. It should be used when sending transactio ### QueryIncentivizedPacketResponse QueryIncentivizedPacketsResponse is the response type for the incentivized packet RPC - - -### InterchainAccountPacketData -InterchainAccountPacketData is comprised of a raw transaction, type of transaction and optional memo field. | Field | Type | Label | Description | @@ -947,9 +867,6 @@ QueryIncentivizedPacketsResponse is the response type for the incentivized packe | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `incentivized_packets` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | repeated | Map of all incentivized_packets | -| `type` | [Type](#ibc.applications.interchain_accounts.v1.Type) | | | -| `data` | [bytes](#bytes) | | | -| `memo` | [string](#string) | | | @@ -1067,18 +984,6 @@ MsgRegisterCounterpartyAddressResponse defines the Msg/RegisterCounterypartyAddr - - -### Type -Type defines a classification of message issued from a controller chain to its associated interchain accounts -host - -| Name | Number | Description | -| ---- | ------ | ----------- | -| TYPE_UNSPECIFIED | 0 | Default zero value enumeration | -| TYPE_EXECUTE_TX | 1 | Execute a transaction on an interchain accounts host chain | - - @@ -1099,76 +1004,64 @@ Msg defines the ibc/fee Msg service. - +

Top

-## ibc/applications/transfer/v1/transfer.proto +## ibc/applications/interchain_accounts/controller/v1/controller.proto - + -### DenomTrace -DenomTrace contains the base denomination for ICS20 fungible tokens and the -source tracing information path. +### Params +Params defines the set of on-chain interchain accounts parameters. +The following parameters may be used to disable the controller submodule. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `path` | [string](#string) | | path defines the chain of port/channel identifiers used for tracing the source of the fungible token. | -| `base_denom` | [string](#string) | | base denomination of the relayed fungible token. | - +| `controller_enabled` | [bool](#bool) | | controller_enabled enables or disables the controller submodule. | - - -### Params -Params defines the set of IBC transfer parameters. -NOTE: To prevent a single token from being transferred, set the -TransfersEnabled parameter to true and then set the bank module's SendEnabled -parameter for the denomination to false. + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `send_enabled` | [bool](#bool) | | send_enabled enables or disables all cross-chain token transfers from this chain. | -| `receive_enabled` | [bool](#bool) | | receive_enabled enables or disables all cross-chain token transfers to this chain. | + + + +

Top

- +## ibc/applications/interchain_accounts/controller/v1/query.proto - - - + +### QueryParamsRequest +QueryParamsRequest is the request type for the Query/Params RPC method. - -

Top

-## ibc/applications/transfer/v1/genesis.proto - + -### GenesisState -GenesisState defines the ibc-transfer genesis state +### QueryParamsResponse +QueryParamsResponse is the response type for the Query/Params RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | | -| `denom_traces` | [DenomTrace](#ibc.applications.transfer.v1.DenomTrace) | repeated | | -| `params` | [Params](#ibc.applications.transfer.v1.Params) | | | +| `params` | [Params](#ibc.applications.interchain_accounts.controller.v1.Params) | | params defines the parameters of the module. | @@ -1180,195 +1073,269 @@ GenesisState defines the ibc-transfer genesis state + + + +### Query +Query provides defines the gRPC querier service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Params` | [QueryParamsRequest](#ibc.applications.interchain_accounts.controller.v1.QueryParamsRequest) | [QueryParamsResponse](#ibc.applications.interchain_accounts.controller.v1.QueryParamsResponse) | Params queries all parameters of the ICA controller submodule. | GET|/ibc/apps/interchain_accounts/controller/v1/params| + - +

Top

-## ibc/applications/transfer/v1/query.proto +## ibc/applications/interchain_accounts/host/v1/host.proto - + -### QueryDenomHashRequest -QueryDenomHashRequest is the request type for the Query/DenomHash RPC -method +### Params +Params defines the set of on-chain interchain accounts parameters. +The following parameters may be used to disable the host submodule. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `trace` | [string](#string) | | The denomination trace ([port_id]/[channel_id])+/[denom] | - +| `host_enabled` | [bool](#bool) | | host_enabled enables or disables the host submodule. | +| `allow_messages` | [string](#string) | repeated | allow_messages defines a list of sdk message typeURLs allowed to be executed on a host chain. | - - -### QueryDenomHashResponse -QueryDenomHashResponse is the response type for the Query/DenomHash RPC -method. + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `hash` | [string](#string) | | hash (in hex format) of the denomination trace information. | + + + +

Top

+## ibc/applications/interchain_accounts/host/v1/query.proto - -### QueryDenomTraceRequest -QueryDenomTraceRequest is the request type for the Query/DenomTrace RPC -method + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `hash` | [string](#string) | | hash (in hex format) of the denomination trace information. | +### QueryParamsRequest +QueryParamsRequest is the request type for the Query/Params RPC method. - + -### QueryDenomTraceResponse -QueryDenomTraceResponse is the response type for the Query/DenomTrace RPC -method. +### QueryParamsResponse +QueryParamsResponse is the response type for the Query/Params RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `denom_trace` | [DenomTrace](#ibc.applications.transfer.v1.DenomTrace) | | denom_trace returns the requested denomination trace information. | +| `params` | [Params](#ibc.applications.interchain_accounts.host.v1.Params) | | params defines the parameters of the module. | + - + -### QueryDenomTracesRequest -QueryConnectionsRequest is the request type for the Query/DenomTraces RPC -method + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | + +### Query +Query provides defines the gRPC querier service. +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Params` | [QueryParamsRequest](#ibc.applications.interchain_accounts.host.v1.QueryParamsRequest) | [QueryParamsResponse](#ibc.applications.interchain_accounts.host.v1.QueryParamsResponse) | Params queries all parameters of the ICA host submodule. | GET|/ibc/apps/interchain_accounts/host/v1/params| + - + +

Top

-### QueryDenomTracesResponse -QueryConnectionsResponse is the response type for the Query/DenomTraces RPC -method. +## ibc/applications/interchain_accounts/v1/account.proto -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `denom_traces` | [DenomTrace](#ibc.applications.transfer.v1.DenomTrace) | repeated | denom_traces returns all denominations trace information. | -| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | + +### InterchainAccount +An InterchainAccount is defined as a BaseAccount & the address of the account owner on the controller chain +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `base_account` | [cosmos.auth.v1beta1.BaseAccount](#cosmos.auth.v1beta1.BaseAccount) | | | +| `account_owner` | [string](#string) | | | - -### QueryParamsRequest -QueryParamsRequest is the request type for the Query/Params RPC method. + + + + - -### QueryParamsResponse -QueryParamsResponse is the response type for the Query/Params RPC method. + + +

Top

+ +## ibc/applications/interchain_accounts/v1/genesis.proto + + + + + +### ActiveChannel +ActiveChannel contains a pairing of port ID and channel ID for an active interchain accounts channel | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#ibc.applications.transfer.v1.Params) | | params defines the parameters of the module. | +| `port_id` | [string](#string) | | | +| `channel_id` | [string](#string) | | | - - + - +### ControllerGenesisState +ControllerGenesisState defines the interchain accounts controller genesis state - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `active_channels` | [ActiveChannel](#ibc.applications.interchain_accounts.v1.ActiveChannel) | repeated | | +| `interchain_accounts` | [RegisteredInterchainAccount](#ibc.applications.interchain_accounts.v1.RegisteredInterchainAccount) | repeated | | +| `ports` | [string](#string) | repeated | | +| `params` | [ibc.applications.interchain_accounts.controller.v1.Params](#ibc.applications.interchain_accounts.controller.v1.Params) | | | + + + + + + + + +### GenesisState +GenesisState defines the interchain accounts genesis state + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `controller_genesis_state` | [ControllerGenesisState](#ibc.applications.interchain_accounts.v1.ControllerGenesisState) | | | +| `host_genesis_state` | [HostGenesisState](#ibc.applications.interchain_accounts.v1.HostGenesisState) | | | + + + + + + + + +### HostGenesisState +HostGenesisState defines the interchain accounts host genesis state + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `active_channels` | [ActiveChannel](#ibc.applications.interchain_accounts.v1.ActiveChannel) | repeated | | +| `interchain_accounts` | [RegisteredInterchainAccount](#ibc.applications.interchain_accounts.v1.RegisteredInterchainAccount) | repeated | | +| `port` | [string](#string) | | | +| `params` | [ibc.applications.interchain_accounts.host.v1.Params](#ibc.applications.interchain_accounts.host.v1.Params) | | | + + + + + + + + +### RegisteredInterchainAccount +RegisteredInterchainAccount contains a pairing of controller port ID and associated interchain account address + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `port_id` | [string](#string) | | | +| `account_address` | [string](#string) | | | -### Query -Query provides defines the gRPC querier service. -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `DenomTrace` | [QueryDenomTraceRequest](#ibc.applications.transfer.v1.QueryDenomTraceRequest) | [QueryDenomTraceResponse](#ibc.applications.transfer.v1.QueryDenomTraceResponse) | DenomTrace queries a denomination trace information. | GET|/ibc/apps/transfer/v1/denom_traces/{hash}| -| `DenomTraces` | [QueryDenomTracesRequest](#ibc.applications.transfer.v1.QueryDenomTracesRequest) | [QueryDenomTracesResponse](#ibc.applications.transfer.v1.QueryDenomTracesResponse) | DenomTraces queries all denomination traces. | GET|/ibc/apps/transfer/v1/denom_traces| -| `Params` | [QueryParamsRequest](#ibc.applications.transfer.v1.QueryParamsRequest) | [QueryParamsResponse](#ibc.applications.transfer.v1.QueryParamsResponse) | Params queries all parameters of the ibc-transfer module. | GET|/ibc/apps/transfer/v1/params| -| `DenomHash` | [QueryDenomHashRequest](#ibc.applications.transfer.v1.QueryDenomHashRequest) | [QueryDenomHashResponse](#ibc.applications.transfer.v1.QueryDenomHashResponse) | DenomHash queries a denomination hash information. | GET|/ibc/apps/transfer/v1/denom_hashes/{trace}| + + + + + + + + - +

Top

-## ibc/applications/transfer/v1/tx.proto +## ibc/applications/interchain_accounts/v1/packet.proto - + -### MsgTransfer -MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) between -ICS20 enabled chains. See ICS Spec here: -https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transfer#data-structures +### CosmosTx +CosmosTx contains a list of sdk.Msg's. It should be used when sending transactions to an SDK host chain. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `source_port` | [string](#string) | | the port on which the packet will be sent | -| `source_channel` | [string](#string) | | the channel by which the packet will be sent | -| `token` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | the tokens to be transferred | -| `sender` | [string](#string) | | the sender address | -| `receiver` | [string](#string) | | the recipient address on the destination chain | -| `timeout_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | Timeout height relative to the current block height. The timeout is disabled when set to 0. | -| `timeout_timestamp` | [uint64](#uint64) | | Timeout timestamp (in nanoseconds) relative to the current block timestamp. The timeout is disabled when set to 0. | +| `messages` | [google.protobuf.Any](#google.protobuf.Any) | repeated | | - + + +### InterchainAccountPacketData +InterchainAccountPacketData is comprised of a raw transaction, type of transaction and optional memo field. -### MsgTransferResponse -MsgTransferResponse defines the Msg/Transfer response type. + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `type` | [Type](#ibc.applications.interchain_accounts.v1.Type) | | | +| `data` | [bytes](#bytes) | | | +| `memo` | [string](#string) | | | @@ -1376,45 +1343,97 @@ MsgTransferResponse defines the Msg/Transfer response type. + + + +### Type +Type defines a classification of message issued from a controller chain to its associated interchain accounts +host + +| Name | Number | Description | +| ---- | ------ | ----------- | +| TYPE_UNSPECIFIED | 0 | Default zero value enumeration | +| TYPE_EXECUTE_TX | 1 | Execute a transaction on an interchain accounts host chain | + + + + + + + +

Top

+ +## ibc/applications/transfer/v1/transfer.proto + + + + + +### DenomTrace +DenomTrace contains the base denomination for ICS20 fungible tokens and the +source tracing information path. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `path` | [string](#string) | | path defines the chain of port/channel identifiers used for tracing the source of the fungible token. | +| `base_denom` | [string](#string) | | base denomination of the relayed fungible token. | + + - -### Msg -Msg defines the ibc/transfer Msg service. -| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | -| ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Transfer` | [MsgTransfer](#ibc.applications.transfer.v1.MsgTransfer) | [MsgTransferResponse](#ibc.applications.transfer.v1.MsgTransferResponse) | Transfer defines a rpc handler method for MsgTransfer. | | + + + +### Params +Params defines the set of IBC transfer parameters. +NOTE: To prevent a single token from being transferred, set the +TransfersEnabled parameter to true and then set the bank module's SendEnabled +parameter for the denomination to false. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `send_enabled` | [bool](#bool) | | send_enabled enables or disables all cross-chain token transfers from this chain. | +| `receive_enabled` | [bool](#bool) | | receive_enabled enables or disables all cross-chain token transfers to this chain. | + + + + + + + + + + - +

Top

-## ibc/applications/transfer/v2/packet.proto +## ibc/applications/transfer/v1/genesis.proto - + -### FungibleTokenPacketData -FungibleTokenPacketData defines a struct for the packet payload -See FungibleTokenPacketData spec: -https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transfer#data-structures +### GenesisState +GenesisState defines the ibc-transfer genesis state | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `denom` | [string](#string) | | the token denomination to be transferred | -| `amount` | [string](#string) | | the token amount to be transferred | -| `sender` | [string](#string) | | the sender address | -| `receiver` | [string](#string) | | the recipient address on the destination chain | +| `port_id` | [string](#string) | | | +| `denom_traces` | [DenomTrace](#ibc.applications.transfer.v1.DenomTrace) | repeated | | +| `params` | [Params](#ibc.applications.transfer.v1.Params) | | | @@ -1430,131 +1449,129 @@ https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transf - +

Top

-## ibc/core/channel/v1/channel.proto +## ibc/applications/transfer/v1/query.proto - + -### Acknowledgement -Acknowledgement is the recommended acknowledgement format to be used by -app-specific protocols. -NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental -conflicts with other protobuf message formats used for acknowledgements. -The first byte of any message with this format will be the non-ASCII values -`0xaa` (result) or `0xb2` (error). Implemented as defined by ICS: -https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#acknowledgement-envelope +### QueryDenomHashRequest +QueryDenomHashRequest is the request type for the Query/DenomHash RPC +method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `result` | [bytes](#bytes) | | | -| `error` | [string](#string) | | | +| `trace` | [string](#string) | | The denomination trace ([port_id]/[channel_id])+/[denom] | - + -### Channel -Channel defines pipeline for exactly-once packet delivery between specific -modules on separate blockchains, which has at least one end capable of -sending packets and one end capable of receiving packets. +### QueryDenomHashResponse +QueryDenomHashResponse is the response type for the Query/DenomHash RPC +method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `state` | [State](#ibc.core.channel.v1.State) | | current state of the channel end | -| `ordering` | [Order](#ibc.core.channel.v1.Order) | | whether the channel is ordered or unordered | -| `counterparty` | [Counterparty](#ibc.core.channel.v1.Counterparty) | | counterparty channel end | -| `connection_hops` | [string](#string) | repeated | list of connection identifiers, in order, along which packets sent on this channel will travel | -| `version` | [string](#string) | | opaque channel version, which is agreed upon during the handshake | +| `hash` | [string](#string) | | hash (in hex format) of the denomination trace information. | - + -### Counterparty -Counterparty defines a channel end counterparty +### QueryDenomTraceRequest +QueryDenomTraceRequest is the request type for the Query/DenomTrace RPC +method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | port on the counterparty chain which owns the other end of the channel. | -| `channel_id` | [string](#string) | | channel end on the counterparty chain | +| `hash` | [string](#string) | | hash (in hex format) of the denomination trace information. | - + -### IdentifiedChannel -IdentifiedChannel defines a channel with additional port and channel -identifier fields. +### QueryDenomTraceResponse +QueryDenomTraceResponse is the response type for the Query/DenomTrace RPC +method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `state` | [State](#ibc.core.channel.v1.State) | | current state of the channel end | -| `ordering` | [Order](#ibc.core.channel.v1.Order) | | whether the channel is ordered or unordered | -| `counterparty` | [Counterparty](#ibc.core.channel.v1.Counterparty) | | counterparty channel end | -| `connection_hops` | [string](#string) | repeated | list of connection identifiers, in order, along which packets sent on this channel will travel | -| `version` | [string](#string) | | opaque channel version, which is agreed upon during the handshake | -| `port_id` | [string](#string) | | port identifier | -| `channel_id` | [string](#string) | | channel identifier | +| `denom_trace` | [DenomTrace](#ibc.applications.transfer.v1.DenomTrace) | | denom_trace returns the requested denomination trace information. | - + -### Packet -Packet defines a type that carries data across different chains through IBC +### QueryDenomTracesRequest +QueryConnectionsRequest is the request type for the Query/DenomTraces RPC +method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `sequence` | [uint64](#uint64) | | number corresponds to the order of sends and receives, where a Packet with an earlier sequence number must be sent and received before a Packet with a later sequence number. | -| `source_port` | [string](#string) | | identifies the port on the sending chain. | -| `source_channel` | [string](#string) | | identifies the channel end on the sending chain. | -| `destination_port` | [string](#string) | | identifies the port on the receiving chain. | -| `destination_channel` | [string](#string) | | identifies the channel end on the receiving chain. | -| `data` | [bytes](#bytes) | | actual opaque bytes transferred directly to the application module | -| `timeout_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | block height after which the packet times out | -| `timeout_timestamp` | [uint64](#uint64) | | block timestamp (in nanoseconds) after which the packet times out | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | - + -### PacketState -PacketState defines the generic type necessary to retrieve and store -packet commitments, acknowledgements, and receipts. -Caller is responsible for knowing the context necessary to interpret this -state as a commitment, acknowledgement, or a receipt. +### QueryDenomTracesResponse +QueryConnectionsResponse is the response type for the Query/DenomTraces RPC +method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | channel port identifier. | -| `channel_id` | [string](#string) | | channel unique identifier. | -| `sequence` | [uint64](#uint64) | | packet sequence. | -| `data` | [bytes](#bytes) | | embedded data that represents packet state. | +| `denom_traces` | [DenomTrace](#ibc.applications.transfer.v1.DenomTrace) | repeated | denom_traces returns all denominations trace information. | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | + + + + + + + + +### QueryParamsRequest +QueryParamsRequest is the request type for the Query/Params RPC method. + + + + + + + + +### QueryParamsResponse +QueryParamsResponse is the response type for the Query/Params RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `params` | [Params](#ibc.applications.transfer.v1.Params) | | params defines the parameters of the module. | @@ -1562,34 +1579,113 @@ state as a commitment, acknowledgement, or a receipt. + - + -### Order -Order defines if a channel is ORDERED or UNORDERED -| Name | Number | Description | -| ---- | ------ | ----------- | -| ORDER_NONE_UNSPECIFIED | 0 | zero-value for channel ordering | -| ORDER_UNORDERED | 1 | packets can be delivered in any order, which may differ from the order in which they were sent. | -| ORDER_ORDERED | 2 | packets are delivered exactly in the order which they were sent | + +### Query +Query provides defines the gRPC querier service. +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `DenomTrace` | [QueryDenomTraceRequest](#ibc.applications.transfer.v1.QueryDenomTraceRequest) | [QueryDenomTraceResponse](#ibc.applications.transfer.v1.QueryDenomTraceResponse) | DenomTrace queries a denomination trace information. | GET|/ibc/apps/transfer/v1/denom_traces/{hash}| +| `DenomTraces` | [QueryDenomTracesRequest](#ibc.applications.transfer.v1.QueryDenomTracesRequest) | [QueryDenomTracesResponse](#ibc.applications.transfer.v1.QueryDenomTracesResponse) | DenomTraces queries all denomination traces. | GET|/ibc/apps/transfer/v1/denom_traces| +| `Params` | [QueryParamsRequest](#ibc.applications.transfer.v1.QueryParamsRequest) | [QueryParamsResponse](#ibc.applications.transfer.v1.QueryParamsResponse) | Params queries all parameters of the ibc-transfer module. | GET|/ibc/apps/transfer/v1/params| +| `DenomHash` | [QueryDenomHashRequest](#ibc.applications.transfer.v1.QueryDenomHashRequest) | [QueryDenomHashResponse](#ibc.applications.transfer.v1.QueryDenomHashResponse) | DenomHash queries a denomination hash information. | GET|/ibc/apps/transfer/v1/denom_hashes/{trace}| - + -### State -State defines if a channel is in one of the following states: -CLOSED, INIT, TRYOPEN, OPEN or UNINITIALIZED. -| Name | Number | Description | -| ---- | ------ | ----------- | -| STATE_UNINITIALIZED_UNSPECIFIED | 0 | Default State | -| STATE_INIT | 1 | A channel has just started the opening handshake. | -| STATE_TRYOPEN | 2 | A channel has acknowledged the handshake step on the counterparty chain. | -| STATE_OPEN | 3 | A channel has completed the handshake. Open channels are ready to send and receive packets. | -| STATE_CLOSED | 4 | A channel has been closed and can no longer be used to send or receive packets. | + +

Top

+ +## ibc/applications/transfer/v1/tx.proto + + + + + +### MsgTransfer +MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) between +ICS20 enabled chains. See ICS Spec here: +https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transfer#data-structures + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `source_port` | [string](#string) | | the port on which the packet will be sent | +| `source_channel` | [string](#string) | | the channel by which the packet will be sent | +| `token` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | the tokens to be transferred | +| `sender` | [string](#string) | | the sender address | +| `receiver` | [string](#string) | | the recipient address on the destination chain | +| `timeout_height` | [ibc.core.client.v1.Height](#ibc.core.client.v1.Height) | | Timeout height relative to the current block height. The timeout is disabled when set to 0. | +| `timeout_timestamp` | [uint64](#uint64) | | Timeout timestamp (in nanoseconds) relative to the current block timestamp. The timeout is disabled when set to 0. | + + + + + + + + +### MsgTransferResponse +MsgTransferResponse defines the Msg/Transfer response type. + + + + + + + + + + + + + + +### Msg +Msg defines the ibc/transfer Msg service. + +| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | +| ----------- | ------------ | ------------- | ------------| ------- | -------- | +| `Transfer` | [MsgTransfer](#ibc.applications.transfer.v1.MsgTransfer) | [MsgTransferResponse](#ibc.applications.transfer.v1.MsgTransferResponse) | Transfer defines a rpc handler method for MsgTransfer. | | + + + + + + +

Top

+ +## ibc/applications/transfer/v2/packet.proto + + + + + +### FungibleTokenPacketData +FungibleTokenPacketData defines a struct for the packet payload +See FungibleTokenPacketData spec: +https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transfer#data-structures + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `denom` | [string](#string) | | the token denomination to be transferred | +| `amount` | [string](#string) | | the token amount to be transferred | +| `sender` | [string](#string) | | the sender address | +| `receiver` | [string](#string) | | the recipient address on the destination chain | + + + + + + diff --git a/go.mod b/go.mod index 3e5f606755d..2cfda348a7d 100644 --- a/go.mod +++ b/go.mod @@ -54,7 +54,6 @@ require ( github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect github.com/felixge/httpsnoop v1.0.1 // indirect github.com/fsnotify/fsnotify v1.5.1 // indirect - github.com/gin-gonic/gin v1.7.0 // indirect github.com/go-kit/kit v0.10.0 // indirect github.com/go-logfmt/logfmt v0.5.0 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect @@ -87,8 +86,6 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.4.3 // indirect github.com/mtibben/percent v0.2.1 // indirect - github.com/opencontainers/image-spec v1.0.2 // indirect - github.com/opencontainers/runc v1.0.3 // indirect github.com/pelletier/go-toml v1.9.4 // indirect github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect @@ -120,3 +117,10 @@ require ( gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect nhooyr.io/websocket v1.8.6 // indirect ) + +require ( + github.com/cosmos/ibc-go v1.2.5 + github.com/gin-gonic/gin v1.7.0 // indirect + github.com/opencontainers/image-spec v1.0.2 // indirect + github.com/opencontainers/runc v1.0.3 // indirect +) diff --git a/go.sum b/go.sum index 8342959fd77..65b440dd4a3 100644 --- a/go.sum +++ b/go.sum @@ -209,6 +209,8 @@ github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/iavl v0.17.3 h1:s2N819a2olOmiauVa0WAhoIJq9EhSXE9HDBAoR9k+8Y= github.com/cosmos/iavl v0.17.3/go.mod h1:prJoErZFABYZGDHka1R6Oay4z9PrNeFFiMKHDAMOi4w= +github.com/cosmos/ibc-go v1.2.5 h1:BiA48yKEDUcabBRkmp7qqSX41ZrgXTSNCtdjDURbLwE= +github.com/cosmos/ibc-go v1.2.5/go.mod h1:wkGkkX8Ou6yXgE8lO2xP9NOwo+Tl5x1dJaTTE6jBDpg= github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4= github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI= @@ -628,6 +630,7 @@ github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:F github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/moby/sys/mountinfo v0.4.1/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A= @@ -1455,6 +1458,7 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.63.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI= gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= diff --git a/modules/core/04-channel/types/channel.pb.go b/modules/core/04-channel/types/channel.pb.go index aa333852ef2..3ce5ce3a2e1 100644 --- a/modules/core/04-channel/types/channel.pb.go +++ b/modules/core/04-channel/types/channel.pb.go @@ -501,64 +501,65 @@ func init() { func init() { proto.RegisterFile("ibc/core/channel/v1/channel.proto", fileDescriptor_c3a07336710636a0) } var fileDescriptor_c3a07336710636a0 = []byte{ - // 911 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x55, 0xcd, 0x8e, 0xda, 0x56, - 0x14, 0xc6, 0x83, 0xf9, 0x3b, 0x0c, 0x0c, 0x73, 0xd3, 0x21, 0xae, 0x9b, 0x60, 0x62, 0x75, 0x31, - 0x4a, 0x15, 0xc8, 0x24, 0x51, 0xab, 0x66, 0xd5, 0xe1, 0x27, 0x1a, 0xab, 0x11, 0x8c, 0x0c, 0xb3, - 0x68, 0x36, 0x14, 0xec, 0x5b, 0xb0, 0x02, 0xbe, 0xd4, 0xbe, 0x30, 0x9a, 0x37, 0x88, 0x58, 0xf5, - 0x05, 0x90, 0x2a, 0x55, 0xed, 0x2b, 0xf4, 0x15, 0xb2, 0xcc, 0xb2, 0x2b, 0xab, 0x9a, 0x59, 0x74, - 0xcf, 0x0b, 0xb4, 0xf2, 0xbd, 0xd7, 0xfc, 0x4c, 0xa2, 0x2c, 0xbb, 0xca, 0x8a, 0x7b, 0xbe, 0xef, - 0x3b, 0x3f, 0x3e, 0xe7, 0x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 0xb7, 0xd7, 0x25, 0xe9, 0xdd, 0x75, - 0x49, 0xfa, 0xfb, 0xba, 0x24, 0xfd, 0x72, 0x53, 0x8a, 0xbd, 0xbb, 0x29, 0xc5, 0xfe, 0xba, 0x29, - 0xc5, 0x5e, 0x7d, 0x3b, 0x74, 0xe8, 0x68, 0x36, 0xa8, 0x58, 0x64, 0x52, 0xb5, 0x88, 0x3f, 0x21, - 0x7e, 0xd5, 0x19, 0x58, 0x8f, 0x86, 0xa4, 0x3a, 0x7f, 0x5a, 0x9d, 0x10, 0x7b, 0x36, 0xc6, 0x3e, - 0x7f, 0x94, 0x1f, 0x3f, 0x7b, 0x14, 0xbd, 0xf2, 0xf4, 0x6a, 0x8a, 0xfd, 0x41, 0x92, 0xbd, 0xca, - 0x4f, 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xa8, 0x31, 0x31, 0xe5, 0x06, 0x08, 0x00, 0x00, + // 925 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x56, 0xcd, 0x8e, 0x1a, 0x47, + 0x10, 0x66, 0x60, 0xf8, 0x2b, 0x16, 0x96, 0x6d, 0x67, 0xf1, 0x64, 0x62, 0x33, 0x78, 0x94, 0xc3, + 0xca, 0x91, 0xc1, 0x6b, 0x5b, 0x89, 0xe2, 0x53, 0x96, 0x1f, 0x6b, 0x47, 0xb1, 0x60, 0x35, 0xb0, + 0x87, 0xf8, 0x42, 0x60, 0xa6, 0x03, 0x23, 0xc3, 0x34, 0x99, 0x69, 0x58, 0xed, 0x1b, 0x58, 0x5c, + 0x92, 0x17, 0x40, 0x8a, 0x14, 0x25, 0xaf, 0x90, 0x57, 0xf0, 0xd1, 0xc7, 0x9c, 0x50, 0xb4, 0x7b, + 0xc8, 0x9d, 0x17, 0x48, 0x34, 0xdd, 0x3d, 0xfc, 0xac, 0xad, 0x3d, 0x26, 0x17, 0x9f, 0xe8, 0xaa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x7c, 0x51, 0x4a, 0xaf, 0x1d, 0x81, 0x60, 0xce, 0x09, + 0x19, 0x42, 0xb0, 0x30, 0x79, 0xe1, 0x6a, 0xfb, 0xed, 0x55, 0x51, 0x7a, 0x77, 0x55, 0x94, 0xfe, + 0xba, 0x2a, 0x4a, 0x3f, 0x5f, 0x17, 0x23, 0xef, 0xae, 0x8b, 0x91, 0x3f, 0xaf, 0x8b, 0x91, 0x57, + 0x5f, 0x0f, 0x1c, 0x3a, 0x9c, 0xf6, 0xcb, 0x16, 0x19, 0x57, 0x2c, 0xe2, 0x8f, 0x89, 0x5f, 0x71, + 0xfa, 0xd6, 0xa3, 0x01, 0xa9, 0xcc, 0x9e, 0x56, 0xc6, 0xc4, 0x9e, 0x8e, 0xb0, 0xcf, 0x9f, 0x09, + 0x8f, 0x9f, 0x3d, 0x0a, 0xdf, 0x1d, 0xf4, 0x72, 0x82, 0xfd, 0x7e, 0x82, 0xbd, 0x13, 0x9e, 0xfe, + 0x1b, 0x00, 0x00, 0xff, 0xff, 0x47, 0xf5, 0x82, 0xa6, 0x98, 0x08, 0x00, 0x00, } func (m *Channel) Marshal() (dAtA []byte, err error) { From 0fbc6bbfab8676d6223cb99dd10a864c3cb7c93f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Colin=20Axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Wed, 12 Jan 2022 13:04:31 +0100 Subject: [PATCH 18/79] fix build --- modules/apps/29-fee/fee_test.go | 7 +- modules/apps/29-fee/ibc_module.go | 23 ++--- modules/apps/29-fee/ibc_module_test.go | 86 ++++++------------- modules/apps/29-fee/keeper/genesis_test.go | 2 +- modules/apps/29-fee/keeper/grpc_query_test.go | 2 +- modules/apps/29-fee/keeper/keeper_test.go | 6 +- modules/apps/29-fee/types/genesis_test.go | 2 +- modules/apps/29-fee/types/keys_test.go | 2 +- .../apps/transfer/types/expected_keepers.go | 2 +- testing/simapp/app.go | 8 +- 10 files changed, 53 insertions(+), 87 deletions(-) diff --git a/modules/apps/29-fee/fee_test.go b/modules/apps/29-fee/fee_test.go index 1b930db6456..147bd0b01a4 100644 --- a/modules/apps/29-fee/fee_test.go +++ b/modules/apps/29-fee/fee_test.go @@ -3,15 +3,14 @@ package fee_test import ( "testing" - "github.com/stretchr/testify/suite" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" - ibctesting "github.com/cosmos/ibc-go/testing" + ibctesting "github.com/cosmos/ibc-go/v3/testing" ) type FeeTestSuite struct { @@ -47,7 +46,7 @@ func (suite *FeeTestSuite) CreateICS20Packet(coin sdk.Coin) channeltypes.Packet fungibleTokenPacket := transfertypes.NewFungibleTokenPacketData( coin.Denom, - sdk.NewInt(100).Uint64(), + sdk.NewInt(100).String(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), ) diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go index 230c7da2cd0..d9044200528 100644 --- a/modules/apps/29-fee/ibc_module.go +++ b/modules/apps/29-fee/ibc_module.go @@ -64,32 +64,33 @@ func (im IBCModule) OnChanOpenTry( channelID string, chanCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, - version, counterpartyVersion string, -) error { - mwVersion, appVersion := channeltypes.SplitChannelVersion(version) +) (string, error) { cpMwVersion, cpAppVersion := channeltypes.SplitChannelVersion(counterpartyVersion) // Since it is valid for fee version to not be specified, the above middleware version may be for a middleware // lower down in the stack. Thus, if it is not a fee version we pass the entire version string onto the underlying // application. // If an invalid fee version was passed, we expect the underlying application to fail on its version negotiation. - if mwVersion == types.Version || cpMwVersion == types.Version { - if cpMwVersion != mwVersion { - return sdkerrors.Wrapf(types.ErrInvalidVersion, "fee versions do not match. self version: %s, counterparty version: %s", mwVersion, cpMwVersion) - } - + if cpMwVersion == types.Version { im.keeper.SetFeeEnabled(ctx, portID, channelID) } else { // middleware versions are not the expected version for this midddleware. Pass the full version strings along, // if it not valid version for any other lower middleware, an error will be returned by base application. - appVersion = version cpAppVersion = counterpartyVersion } // call underlying app's OnChanOpenTry callback with the app versions - return im.app.OnChanOpenTry(ctx, order, connectionHops, portID, channelID, - chanCap, counterparty, appVersion, cpAppVersion) + appVersion, err := im.app.OnChanOpenTry(ctx, order, connectionHops, portID, channelID, chanCap, counterparty, cpAppVersion) + if err != nil { + return "", err + } + + if im.keeper.IsFeeEnabled(ctx, portID, channelID) { + return channeltypes.MergeChannelVersions(types.Version, appVersion), nil + } + + return appVersion, nil } // OnChanOpenAck implements the IBCModule interface diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index bee6b693661..08087dbc9cb 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -10,8 +10,8 @@ import ( transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" - ibctesting "github.com/cosmos/ibc-go/testing" - "github.com/cosmos/ibc-go/testing/simapp" + ibctesting "github.com/cosmos/ibc-go/v3/testing" + "github.com/cosmos/ibc-go/v3/testing/simapp" ) var ( @@ -107,42 +107,30 @@ func (suite *FeeTestSuite) TestOnChanOpenInit() { func (suite *FeeTestSuite) TestOnChanOpenTry() { testCases := []struct { name string - version string cpVersion string crossing bool expPass bool }{ { - "valid fee middleware and transfer version", - channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + "valid fee middleware version", channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), false, true, }, { - "valid transfer version on try and counterparty", - transfertypes.Version, + "valid transfer version", transfertypes.Version, false, true, }, { - "valid fee middleware and transfer version, crossing hellos", - channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + "crossing hellos: valid fee middleware", channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), true, true, }, { "invalid fee middleware version", - channeltypes.MergeChannelVersions("otherfee28-1", transfertypes.Version), - channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), - false, - false, - }, - { - "invalid counterparty fee middleware version", - channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), channeltypes.MergeChannelVersions("wrongfee29-1", transfertypes.Version), false, false, @@ -150,42 +138,6 @@ func (suite *FeeTestSuite) TestOnChanOpenTry() { { "invalid transfer version", channeltypes.MergeChannelVersions(types.Version, "wrongics20-1"), - channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), - false, - false, - }, - { - "invalid counterparty transfer version", - channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), - channeltypes.MergeChannelVersions(types.Version, "wrongics20-1"), - false, - false, - }, - { - "transfer version not wrapped", - types.Version, - channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), - false, - false, - }, - { - "counterparty transfer version not wrapped", - channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), - types.Version, - false, - false, - }, - { - "fee version not included on try, but included in counterparty", - transfertypes.Version, - channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), - false, - false, - }, - { - "fee version not included", - channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), - transfertypes.Version, false, false, }, @@ -222,7 +174,7 @@ func (suite *FeeTestSuite) TestOnChanOpenTry() { Ordering: channeltypes.UNORDERED, Counterparty: counterparty, ConnectionHops: []string{suite.path.EndpointA.ConnectionID}, - Version: tc.version, + Version: tc.cpVersion, } module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort) @@ -231,13 +183,13 @@ func (suite *FeeTestSuite) TestOnChanOpenTry() { cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) suite.Require().True(ok) - err = cbs.OnChanOpenTry(suite.chainA.GetContext(), channel.Ordering, channel.GetConnectionHops(), - suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, chanCap, counterparty, tc.version, tc.cpVersion) + _, err = cbs.OnChanOpenTry(suite.chainA.GetContext(), channel.Ordering, channel.GetConnectionHops(), + suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, chanCap, counterparty, tc.cpVersion) if tc.expPass { - suite.Require().NoError(err, "unexpected error from version: %s", tc.version) + suite.Require().NoError(err) } else { - suite.Require().Error(err, "error not returned for version: %s", tc.version) + suite.Require().Error(err) } }) } @@ -656,17 +608,22 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { if tc.expPass { suite.Require().NoError(err, "unexpected error for case: %s", tc.name) + + expectedAmt, ok := sdk.NewIntFromString("10000000000000000000") + suite.Require().True(ok) suite.Require().Equal( sdk.Coin{ Denom: ibctesting.TestCoin.Denom, - Amount: sdk.NewInt(100000000000000), + Amount: expectedAmt, }, suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)) } else { + expectedAmt, ok := sdk.NewIntFromString("9999999999999999400") + suite.Require().True(ok) suite.Require().Equal( sdk.Coin{ Denom: ibctesting.TestCoin.Denom, - Amount: sdk.NewInt(99999999999400), + Amount: expectedAmt, }, suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)) } @@ -762,17 +719,22 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { if tc.expPass { suite.Require().NoError(err, "unexpected error for case: %s", tc.name) + + expectedAmt, ok := sdk.NewIntFromString("10000000000000000100") + suite.Require().True(ok) suite.Require().Equal( sdk.Coin{ Denom: ibctesting.TestCoin.Denom, - Amount: sdk.NewInt(100000000000100), + Amount: expectedAmt, }, suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)) } else { + expectedAmt, ok := sdk.NewIntFromString("9999999999999999500") + suite.Require().True(ok) suite.Require().Equal( sdk.Coin{ Denom: ibctesting.TestCoin.Denom, - Amount: sdk.NewInt(99999999999500), + Amount: expectedAmt, }, suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)) } diff --git a/modules/apps/29-fee/keeper/genesis_test.go b/modules/apps/29-fee/keeper/genesis_test.go index 8332658cecd..6833ed72816 100644 --- a/modules/apps/29-fee/keeper/genesis_test.go +++ b/modules/apps/29-fee/keeper/genesis_test.go @@ -4,7 +4,7 @@ import ( "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" - ibctesting "github.com/cosmos/ibc-go/testing" + ibctesting "github.com/cosmos/ibc-go/v3/testing" ) func (suite *KeeperTestSuite) TestInitGenesis() { diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index a2904234871..bef02669b04 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" - ibctesting "github.com/cosmos/ibc-go/testing" + ibctesting "github.com/cosmos/ibc-go/v3/testing" ) func (suite *KeeperTestSuite) TestQueryIncentivizedPacketI() { diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index 40623262158..40eeaed8d40 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -4,14 +4,14 @@ import ( "fmt" "testing" - "github.com/stretchr/testify/suite" - "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" - ibctesting "github.com/cosmos/ibc-go/testing" + ibctesting "github.com/cosmos/ibc-go/v3/testing" ) var ( diff --git a/modules/apps/29-fee/types/genesis_test.go b/modules/apps/29-fee/types/genesis_test.go index 72382501442..190edaab220 100644 --- a/modules/apps/29-fee/types/genesis_test.go +++ b/modules/apps/29-fee/types/genesis_test.go @@ -10,7 +10,7 @@ import ( "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" - ibctesting "github.com/cosmos/ibc-go/testing" + ibctesting "github.com/cosmos/ibc-go/v3/testing" ) var ( diff --git a/modules/apps/29-fee/types/keys_test.go b/modules/apps/29-fee/types/keys_test.go index b8329ecb206..fbe2c2bbdde 100644 --- a/modules/apps/29-fee/types/keys_test.go +++ b/modules/apps/29-fee/types/keys_test.go @@ -1,7 +1,7 @@ package types_test import ( - fmt "fmt" + "fmt" "testing" "github.com/stretchr/testify/require" diff --git a/modules/apps/transfer/types/expected_keepers.go b/modules/apps/transfer/types/expected_keepers.go index ee0254526d1..8ae670d27b2 100644 --- a/modules/apps/transfer/types/expected_keepers.go +++ b/modules/apps/transfer/types/expected_keepers.go @@ -38,7 +38,7 @@ type ChannelKeeper interface { // ClientKeeper defines the expected IBC client keeper type ClientKeeper interface { - GetClientConsensusState(ctx sdk.Context, clientID string) (connection exported.ConsensusState, found bool) + GetClientConsensusState(ctx sdk.Context, clientID string) (connection ibcexported.ConsensusState, found bool) } // ConnectionKeeper defines the expected IBC connection keeper diff --git a/testing/simapp/app.go b/testing/simapp/app.go index ff22c59d1a4..5fbda3bb931 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -207,6 +207,7 @@ type SimApp struct { ScopedIBCKeeper capabilitykeeper.ScopedKeeper ScopedTransferKeeper capabilitykeeper.ScopedKeeper ScopedIBCFeeKeeper capabilitykeeper.ScopedKeeper + ScopedFeeMockKeeper capabilitykeeper.ScopedKeeper ScopedICAControllerKeeper capabilitykeeper.ScopedKeeper ScopedICAHostKeeper capabilitykeeper.ScopedKeeper ScopedIBCMockKeeper capabilitykeeper.ScopedKeeper @@ -286,6 +287,7 @@ func NewSimApp( // NOTE: the IBC mock keeper and application module is used only for testing core IBC. Do // not replicate if you do not need to test core IBC or light clients. scopedIBCMockKeeper := app.CapabilityKeeper.ScopeToModule(ibcmock.ModuleName) + scopedFeeMockKeeper := app.CapabilityKeeper.ScopeToModule(ibcmock.ModuleName + ibcfeetypes.ModuleName) scopedICAMockKeeper := app.CapabilityKeeper.ScopeToModule(ibcmock.ModuleName + icacontrollertypes.SubModuleName) // seal capability keeper after scoping modules @@ -356,8 +358,10 @@ func NewSimApp( app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, ) transferModule := transfer.NewAppModule(app.TransferKeeper) + transferIBCModule := transfer.NewIBCModule(app.TransferKeeper) + // create fee-wrapped transfer module - feeTransferModule := ibcfee.NewIBCModule(app.IBCFeeKeeper, transferModule) + feeTransferModule := ibcfee.NewIBCModule(app.IBCFeeKeeper, transferIBCModule) feeModule := ibcfee.NewAppModule(app.IBCFeeKeeper) @@ -366,7 +370,7 @@ func NewSimApp( // Pass IBCFeeKeeper for PortKeeper since fee middleware will wrap the IBCKeeper for underlying application. mockModule := ibcmock.NewAppModule(scopedIBCMockKeeper, &app.IBCFeeKeeper) // create fee wrapped mock module - feeMockModule := ibcfee.NewIBCModule(app.IBCFeeKeeper, &ibcmock.MockIBCApp{}) + feeMockModule := ibcfee.NewIBCModule(app.IBCFeeKeeper, ibcmock.NewIBCModule(nil, scopedFeeMockKeeper)) mockIBCModule := ibcmock.NewIBCModule(&ibcmock.MockIBCApp{}, scopedIBCMockKeeper) From 9285133c9eed10c59013f15b1c81c43ddd4f4562 Mon Sep 17 00:00:00 2001 From: Charly Date: Wed, 12 Jan 2022 15:33:24 +0100 Subject: [PATCH 19/79] fix: event caching for fee distribution (#661) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * proto file * initial impl * apply self review suggestions Deduplicate fee distribution code. Rename DistributeFee to DistributePacketFees. Rename DistributeFeeTimeout to DistributePacketFeesOnTimeout * fixup tests rename validCoins. DistributePacketFeesOnTimeout no longer has a valid error case Add test case for invalid forward relayer address on DistributePacketFees. * partially fix tests timeout fee is still being distributed depsite WriteFn() not being called * fix tests * address code nit Co-authored-by: Colin Axnér <25233464+colin-axner@users.noreply.github.com> --- modules/apps/29-fee/ibc_module.go | 34 +-- modules/apps/29-fee/ibc_module_test.go | 158 +++++++++----- modules/apps/29-fee/keeper/escrow.go | 89 ++++---- modules/apps/29-fee/keeper/escrow_test.go | 201 ++++++++---------- modules/apps/29-fee/keeper/genesis_test.go | 12 +- modules/apps/29-fee/keeper/keeper_test.go | 18 +- modules/apps/29-fee/keeper/msg_server_test.go | 12 +- 7 files changed, 251 insertions(+), 273 deletions(-) diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go index d9044200528..a45a9548426 100644 --- a/modules/apps/29-fee/ibc_module.go +++ b/modules/apps/29-fee/ibc_module.go @@ -213,28 +213,16 @@ func (im IBCModule) OnAcknowledgementPacket( } packetId := channeltypes.NewPacketId(packet.SourceChannel, packet.SourcePort, packet.Sequence) - identifiedPacketFee, found := im.keeper.GetFeeInEscrow(ctx, packetId) + identifiedPacketFee, found := im.keeper.GetFeeInEscrow(ctx, packetId) if !found { // return underlying callback if no fee found for given packetID return im.app.OnAcknowledgementPacket(ctx, packet, ack.Result, relayer) } - // cache context before trying to distribute the fee - cacheCtx, writeFn := ctx.CacheContext() - - forwardRelayer, _ := sdk.AccAddressFromBech32(ack.ForwardRelayerAddress) - refundAcc, _ := sdk.AccAddressFromBech32(identifiedPacketFee.RefundAddress) + im.keeper.DistributePacketFees(ctx, identifiedPacketFee.RefundAddress, ack.ForwardRelayerAddress, relayer, identifiedPacketFee) - err := im.keeper.DistributeFee(cacheCtx, refundAcc, forwardRelayer, relayer, packetId) - - if err == nil { - // write the cache and then call underlying callback - writeFn() - // NOTE: The context returned by CacheContext() refers to a new EventManager, so it needs to explicitly set events to the original context. - ctx.EventManager().EmitEvents(cacheCtx.EventManager().Events()) - } - // otherwise discard cache and call underlying callback + // call underlying callback return im.app.OnAcknowledgementPacket(ctx, packet, ack.Result, relayer) } @@ -252,25 +240,13 @@ func (im IBCModule) OnTimeoutPacket( packetId := channeltypes.NewPacketId(packet.SourceChannel, packet.SourcePort, packet.Sequence) identifiedPacketFee, found := im.keeper.GetFeeInEscrow(ctx, packetId) - if !found { // return underlying callback if fee not found for given packetID return im.app.OnTimeoutPacket(ctx, packet, relayer) } - // cache context before trying to distribute the fee - cacheCtx, writeFn := ctx.CacheContext() - - refundAcc, _ := sdk.AccAddressFromBech32(identifiedPacketFee.RefundAddress) - err := im.keeper.DistributeFeeTimeout(cacheCtx, refundAcc, relayer, packetId) - - if err == nil { - // write the cache and then call underlying callback - writeFn() - // NOTE: The context returned by CacheContext() refers to a new EventManager, so it needs to explicitly set events to the original context. - ctx.EventManager().EmitEvents(cacheCtx.EventManager().Events()) - } + im.keeper.DistributePacketFeesOnTimeout(ctx, identifiedPacketFee.RefundAddress, relayer, identifiedPacketFee) - // otherwise discard cache and call underlying callback + // call underlying callback return im.app.OnTimeoutPacket(ctx, packet, relayer) } diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index 08087dbc9cb..41234d7468a 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -508,7 +508,14 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { // different channel than sending chain func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { - var ack []byte + var ( + ack []byte + identifiedFee *types.IdentifiedPacketFee + originalBalance sdk.Coins + expectedBalance sdk.Coins + expectedRelayerBalance sdk.Coins + ) + testCases := []struct { name string malleate func() @@ -516,7 +523,9 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { }{ { "success", - func() {}, + func() { + expectedRelayerBalance = identifiedFee.Fee.ReceiveFee.Add(identifiedFee.Fee.AckFee[0]) + }, true, }, { @@ -529,13 +538,17 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { Result: channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement(), ForwardRelayerAddress: suite.chainA.SenderAccount.GetAddress().String(), }.Acknowledgement() + + expectedBalance = originalBalance }, - false, + true, }, { "ack wrong format", func() { ack = []byte("unsupported acknowledgement format") + + expectedBalance = originalBalance }, false, }, @@ -544,20 +557,24 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { func() { suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeeEnabled(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) ack = channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement() + + expectedBalance = originalBalance }, - false, + true, }, { - "error on distribute fee (blocked address)", + "fail on distribute receive fee (blocked address)", func() { - blockedAddr := suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), types.ModuleName).GetAddress() + blockedAddr := suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress() ack = types.IncentivizedAcknowledgement{ Result: channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement(), ForwardRelayerAddress: blockedAddr.String(), }.Acknowledgement() + + expectedRelayerBalance = identifiedFee.Fee.AckFee }, - false, + true, }, } @@ -565,6 +582,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { tc := tc suite.Run(tc.name, func() { suite.SetupTest() + expectedRelayerBalance = sdk.Coins{} // reset // open incentivized channel suite.coordinator.Setup(suite.path) @@ -582,7 +600,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { // escrow the packet fee packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) - identifiedFee := types.NewIdentifiedPacketFee( + identifiedFee = types.NewIdentifiedPacketFee( packetId, types.Fee{ ReceiveFee: validCoins, @@ -595,50 +613,59 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) suite.Require().NoError(err) + relayerAddr := suite.chainB.SenderAccount.GetAddress() + // must be changed explicitly ack = types.IncentivizedAcknowledgement{ Result: channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement(), - ForwardRelayerAddress: suite.chainA.SenderAccount.GetAddress().String(), + ForwardRelayerAddress: relayerAddr.String(), }.Acknowledgement() + // log original sender balance + // NOTE: balance is logged after escrowing tokens + originalBalance = sdk.NewCoins(suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)) + + // default to success case + expectedBalance = originalBalance. + Add(identifiedFee.Fee.TimeoutFee[0]) + // malleate test case tc.malleate() - err = cbs.OnAcknowledgementPacket(suite.chainA.GetContext(), packet, ack, suite.chainA.SenderAccount.GetAddress()) + err = cbs.OnAcknowledgementPacket(suite.chainA.GetContext(), packet, ack, relayerAddr) if tc.expPass { - suite.Require().NoError(err, "unexpected error for case: %s", tc.name) - - expectedAmt, ok := sdk.NewIntFromString("10000000000000000000") - suite.Require().True(ok) - suite.Require().Equal( - sdk.Coin{ - Denom: ibctesting.TestCoin.Denom, - Amount: expectedAmt, - }, - suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)) + suite.Require().NoError(err) } else { - expectedAmt, ok := sdk.NewIntFromString("9999999999999999400") - suite.Require().True(ok) - suite.Require().Equal( - sdk.Coin{ - Denom: ibctesting.TestCoin.Denom, - Amount: expectedAmt, - }, - suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)) + suite.Require().Error(err) } + + suite.Require().Equal( + expectedBalance, + sdk.NewCoins(suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)), + ) + + relayerBalance := sdk.NewCoins(suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), relayerAddr, ibctesting.TestCoin.Denom)) + suite.Require().Equal( + expectedRelayerBalance, + relayerBalance, + ) + }) } } func (suite *FeeTestSuite) TestOnTimeoutPacket() { var ( - relayerAddr sdk.AccAddress + relayerAddr sdk.AccAddress + identifiedFee *types.IdentifiedPacketFee + originalBalance sdk.Coins + expectedBalance sdk.Coins ) testCases := []struct { - name string - malleate func() - expPass bool + name string + malleate func() + expFeeDistributed bool }{ { "success", @@ -646,25 +673,34 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { true, }, { - "no op if identified packet fee doesn't exist", + "fee not enabled", func() { - // delete packet fee - packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) - suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeeInEscrow(suite.chainA.GetContext(), packetId) + suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeeEnabled(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) + + expectedBalance = originalBalance.Add(ibctesting.TestCoin) // timeout refund for ics20 transfer }, false, }, { - "error on distribute fee (blocked address)", + "no op if identified packet fee doesn't exist", func() { - relayerAddr = suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), types.ModuleName).GetAddress() + // delete packet fee + packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) + suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeeInEscrow(suite.chainA.GetContext(), packetId) + + expectedBalance = originalBalance.Add(ibctesting.TestCoin) // timeout refund for ics20 transfer }, false, }, { - "fee not enabled", + "distribute fee fails for timeout fee (blocked address)", func() { - suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeeEnabled(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) + relayerAddr = suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress() + + expectedBalance = originalBalance. + Add(identifiedFee.Fee.ReceiveFee[0]). + Add(identifiedFee.Fee.AckFee[0]). + Add(ibctesting.TestCoin) // timeout refund for ics20 transfer }, false, }, @@ -696,9 +732,9 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) // must be explicitly changed - relayerAddr = suite.chainA.SenderAccount.GetAddress() + relayerAddr = suite.chainB.SenderAccount.GetAddress() - identifiedFee := types.NewIdentifiedPacketFee( + identifiedFee = types.NewIdentifiedPacketFee( packetId, types.Fee{ ReceiveFee: validCoins, @@ -712,31 +748,35 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) suite.Require().NoError(err) + // log original sender balance + // NOTE: balance is logged after escrowing tokens + originalBalance = sdk.NewCoins(suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)) + + // default to success case + expectedBalance = originalBalance. + Add(identifiedFee.Fee.ReceiveFee[0]). + Add(identifiedFee.Fee.AckFee[0]). + Add(coin) // timeout refund from ics20 transfer + // malleate test case tc.malleate() err = cbs.OnTimeoutPacket(suite.chainA.GetContext(), packet, relayerAddr) + suite.Require().NoError(err) - if tc.expPass { - suite.Require().NoError(err, "unexpected error for case: %s", tc.name) + suite.Require().Equal( + expectedBalance, + sdk.NewCoins(suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)), + ) - expectedAmt, ok := sdk.NewIntFromString("10000000000000000100") - suite.Require().True(ok) + relayerBalance := sdk.NewCoins(suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), relayerAddr, ibctesting.TestCoin.Denom)) + if tc.expFeeDistributed { suite.Require().Equal( - sdk.Coin{ - Denom: ibctesting.TestCoin.Denom, - Amount: expectedAmt, - }, - suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)) + identifiedFee.Fee.TimeoutFee, + relayerBalance, + ) } else { - expectedAmt, ok := sdk.NewIntFromString("9999999999999999500") - suite.Require().True(ok) - suite.Require().Equal( - sdk.Coin{ - Denom: ibctesting.TestCoin.Denom, - Amount: expectedAmt, - }, - suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)) + suite.Require().Empty(relayerBalance) } }) } diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index 0dae91cea93..45ffc2f72d3 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -7,7 +7,6 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" - channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ) // EscrowPacketFee sends the packet fee to the 29-fee module account to hold in escrow @@ -43,68 +42,66 @@ func (k Keeper) EscrowPacketFee(ctx sdk.Context, identifiedFee *types.Identified return nil } -// DistributeFee pays the acknowledgement fee & receive fee for a given packetId while refunding the timeout fee to the refund account associated with the Fee -func (k Keeper) DistributeFee(ctx sdk.Context, refundAcc, forwardRelayer, reverseRelayer sdk.AccAddress, packetID *channeltypes.PacketId) error { - // check if there is a Fee in escrow for the given packetId - feeInEscrow, found := k.GetFeeInEscrow(ctx, packetID) - if !found { - return sdkerrors.Wrapf(types.ErrFeeNotFound, "with channelID %s, sequence %d", packetID.ChannelId, packetID.Sequence) +// DistributePacketFees pays the acknowledgement fee & receive fee for a given packetId while refunding the timeout fee to the refund account associated with the Fee. +func (k Keeper) DistributePacketFees(ctx sdk.Context, refundAcc, forwardRelayer string, reverseRelayer sdk.AccAddress, feeInEscrow types.IdentifiedPacketFee) { + // distribute fee for forward relaying + forward, err := sdk.AccAddressFromBech32(forwardRelayer) + if err == nil { + k.distributeFee(ctx, forward, feeInEscrow.Fee.ReceiveFee) } - // send receive fee to forward relayer - err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, forwardRelayer, feeInEscrow.Fee.ReceiveFee) - if err != nil { - return sdkerrors.Wrap(err, "failed to send fee to forward relayer") - } + // distribute fee for reverse relaying + k.distributeFee(ctx, reverseRelayer, feeInEscrow.Fee.AckFee) - // send ack fee to reverse relayer - err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, reverseRelayer, feeInEscrow.Fee.AckFee) + // refund timeout fee refund, + refundAddr, err := sdk.AccAddressFromBech32(refundAcc) if err != nil { - return sdkerrors.Wrap(err, "error sending fee to reverse relayer") + panic(fmt.Sprintf("could not parse refundAcc %s to sdk.AccAddress", refundAcc)) } - // refund timeout fee to refundAddr - err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAcc, feeInEscrow.Fee.TimeoutFee) - if err != nil { - return sdkerrors.Wrap(err, "error refunding timeout fee") - } + // refund timeout fee for unused timeout + k.distributeFee(ctx, refundAddr, feeInEscrow.Fee.TimeoutFee) // removes the fee from the store as fee is now paid - k.DeleteFeeInEscrow(ctx, packetID) - - return nil + k.DeleteFeeInEscrow(ctx, feeInEscrow.PacketId) } -// DistributeFeeTimeout pays the timeout fee for a given packetId while refunding the acknowledgement fee & receive fee to the refund account associated with the Fee -func (k Keeper) DistributeFeeTimeout(ctx sdk.Context, refundAcc, timeoutRelayer sdk.AccAddress, packetID *channeltypes.PacketId) error { - // check if there is a Fee in escrow for the given packetId - feeInEscrow, found := k.GetFeeInEscrow(ctx, packetID) - if !found { - return sdkerrors.Wrapf(types.ErrFeeNotFound, "for packetID %s", packetID) - } - - // refund the receive fee - err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAcc, feeInEscrow.Fee.ReceiveFee) +// DistributePacketsFeesTimeout pays the timeout fee for a given packetId while refunding the acknowledgement fee & receive fee to the refund account associated with the Fee +func (k Keeper) DistributePacketFeesOnTimeout(ctx sdk.Context, refundAcc string, timeoutRelayer sdk.AccAddress, feeInEscrow types.IdentifiedPacketFee) { + // check if refundAcc address works + refundAddr, err := sdk.AccAddressFromBech32(refundAcc) if err != nil { - return sdkerrors.Wrap(err, "error refunding receive fee") + panic(fmt.Sprintf("could not parse refundAcc %s to sdk.AccAddress", refundAcc)) } - // refund the ack fee - err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAcc, feeInEscrow.Fee.AckFee) - if err != nil { - return sdkerrors.Wrap(err, "error refunding ack fee") - } + // refund receive fee for unused forward relaying + k.distributeFee(ctx, refundAddr, feeInEscrow.Fee.ReceiveFee) - // pay the timeout fee to the timeout relayer - err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, timeoutRelayer, feeInEscrow.Fee.TimeoutFee) - if err != nil { - return sdkerrors.Wrap(err, "error sending fee to timeout relayer") - } + // refund ack fee for unused reverse relaying + k.distributeFee(ctx, refundAddr, feeInEscrow.Fee.AckFee) + + // distribute fee for timeout relaying + k.distributeFee(ctx, timeoutRelayer, feeInEscrow.Fee.TimeoutFee) // removes the fee from the store as fee is now paid - k.DeleteFeeInEscrow(ctx, packetID) + k.DeleteFeeInEscrow(ctx, feeInEscrow.PacketId) +} - return nil +// distributeFee will attempt to distribute the escrowed fee to the receiver address. +// If the distribution fails for any reason (such as the receiving address being blocked), +// the state changes will be discarded. +func (k Keeper) distributeFee(ctx sdk.Context, receiver sdk.AccAddress, fee sdk.Coins) { + // cache context before trying to send to reverse relayer + cacheCtx, writeFn := ctx.CacheContext() + + err := k.bankKeeper.SendCoinsFromModuleToAccount(cacheCtx, types.ModuleName, receiver, fee) + if err == nil { + // write the cache + writeFn() + + // NOTE: The context returned by CacheContext() refers to a new EventManager, so it needs to explicitly set events to the original context. + ctx.EventManager().EmitEvents(cacheCtx.EventManager().Events()) + } } func (k Keeper) RefundFeesOnChannel(ctx sdk.Context, portID, channelID string) error { diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go index fb71461913d..3b25f03d101 100644 --- a/modules/apps/29-fee/keeper/escrow_test.go +++ b/modules/apps/29-fee/keeper/escrow_test.go @@ -64,13 +64,17 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { // setup refundAcc = suite.chainA.SenderAccount.GetAddress() - ackFee = validCoins - receiveFee = validCoins2 - timeoutFee = validCoins3 + receiveFee = defaultReceiveFee + ackFee = defaultAckFee + timeoutFee = defaultTimeoutFee packetId = &channeltypes.PacketId{ChannelId: suite.path.EndpointA.ChannelID, PortId: transfertypes.PortID, Sequence: uint64(1)} tc.malleate() - fee := types.Fee{ackFee, receiveFee, timeoutFee} + fee := types.Fee{ + ReceiveFee: receiveFee, + AckFee: ackFee, + TimeoutFee: timeoutFee, + } identifiedPacketFee := &types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} // refundAcc balance before escrow @@ -102,13 +106,8 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { func (suite *KeeperTestSuite) TestDistributeFee() { var ( - err error - ackFee sdk.Coins - receiveFee sdk.Coins - timeoutFee sdk.Coins - packetId *channeltypes.PacketId reverseRelayer sdk.AccAddress - forwardRelayer sdk.AccAddress + forwardRelayer string refundAcc sdk.AccAddress ) @@ -123,9 +122,8 @@ func (suite *KeeperTestSuite) TestDistributeFee() { "success", func() {}, true, }, { - "fee not found for packet", func() { - // setting packetId with an invalid sequence of 2 - packetId = &channeltypes.PacketId{ChannelId: suite.path.EndpointA.ChannelID, PortId: transfertypes.PortID, Sequence: uint64(2)} + "invalid forward address", func() { + forwardRelayer = "invalid address" }, false, }, } @@ -140,18 +138,19 @@ func (suite *KeeperTestSuite) TestDistributeFee() { // setup refundAcc = suite.chainA.SenderAccount.GetAddress() reverseRelayer = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) - forwardRelayer = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + forwardRelayer = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() - ackFee = validCoins - receiveFee = validCoins2 - timeoutFee = validCoins3 - packetId = &channeltypes.PacketId{ChannelId: suite.path.EndpointA.ChannelID, PortId: transfertypes.PortID, Sequence: validSeq} - fee := types.Fee{receiveFee, ackFee, timeoutFee} + packetId := &channeltypes.PacketId{ChannelId: suite.path.EndpointA.ChannelID, PortId: transfertypes.PortID, Sequence: validSeq} + fee := types.Fee{ + ReceiveFee: defaultReceiveFee, + AckFee: defaultAckFee, + TimeoutFee: defaultTimeoutFee, + } // escrow the packet fee & store the fee in state - identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} + identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), &identifiedPacketFee) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) suite.Require().NoError(err) tc.malleate() @@ -159,123 +158,92 @@ func (suite *KeeperTestSuite) TestDistributeFee() { // refundAcc balance after escrow refundAccBal := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom) - err = suite.chainA.GetSimApp().IBCFeeKeeper.DistributeFee(suite.chainA.GetContext(), refundAcc, forwardRelayer, reverseRelayer, packetId) + suite.chainA.GetSimApp().IBCFeeKeeper.DistributePacketFees(suite.chainA.GetContext(), refundAcc.String(), forwardRelayer, reverseRelayer, *identifiedPacketFee) if tc.expPass { - suite.Require().NoError(err) - hasFeeInEscrow := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), packetId) // there should no longer be a fee in escrow for this packet - suite.Require().False(hasFeeInEscrow) + found := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), packetId) + suite.Require().False(found) + // check if the reverse relayer is paid - hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), reverseRelayer, ackFee[0]) + hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), reverseRelayer, fee.AckFee[0]) suite.Require().True(hasBalance) + // check if the forward relayer is paid - hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), forwardRelayer, receiveFee[0]) + forward, err := sdk.AccAddressFromBech32(forwardRelayer) + suite.Require().NoError(err) + hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), forward, fee.ReceiveFee[0]) suite.Require().True(hasBalance) + // check if the refund acc has been refunded the timeoutFee - expectedRefundAccBal := refundAccBal.Add(timeoutFee[0]) + expectedRefundAccBal := refundAccBal.Add(fee.TimeoutFee[0]) hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), refundAcc, expectedRefundAccBal) suite.Require().True(hasBalance) + // check the module acc wallet is now empty hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(0)}) suite.Require().True(hasBalance) - - suite.Require().NoError(err) - } else { - suite.Require().Error(err) - invalidPacketID := &channeltypes.PacketId{PortId: transfertypes.PortID, ChannelId: suite.path.EndpointA.ChannelID, Sequence: 1} - hasFeeInEscrow := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), invalidPacketID) - // there should still be a fee in escrow for this packet - suite.Require().True(hasFeeInEscrow) + // check the module acc wallet still has forward relaying balance + hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), fee.ReceiveFee[0]) + suite.Require().True(hasBalance) } }) } } func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { - var ( - err error - ackFee sdk.Coins - receiveFee sdk.Coins - timeoutFee sdk.Coins - packetId *channeltypes.PacketId - refundAcc sdk.AccAddress - ) + suite.coordinator.Setup(suite.path) // setup channel - validSeq := uint64(1) + // setup + refundAcc := suite.chainA.SenderAccount.GetAddress() + timeoutRelayer := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) - testCases := []struct { - name string - malleate func() - expPass bool - }{ - { - "success", func() {}, true, - }, - { - "fee not found for packet", func() { - // setting packetId with an invalid sequence of 2 - packetId = &channeltypes.PacketId{ChannelId: suite.path.EndpointA.ChannelID, PortId: transfertypes.PortID, Sequence: uint64(2)} - }, false, - }, + packetId := &channeltypes.PacketId{ + ChannelId: suite.path.EndpointA.ChannelID, + PortId: transfertypes.PortID, + Sequence: 1, } - for _, tc := range testCases { - tc := tc - - suite.Run(tc.name, func() { - suite.SetupTest() // reset - suite.coordinator.Setup(suite.path) // setup channel + fee := types.Fee{ + ReceiveFee: defaultReceiveFee, + AckFee: defaultAckFee, + TimeoutFee: defaultTimeoutFee, + } - // setup - refundAcc = suite.chainA.SenderAccount.GetAddress() - timeoutRelayer := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + // escrow the packet fee & store the fee in state + identifiedPacketFee := types.IdentifiedPacketFee{ + PacketId: packetId, + Fee: fee, + RefundAddress: refundAcc.String(), + Relayers: []string{}, + } - ackFee = validCoins - receiveFee = validCoins2 - timeoutFee = validCoins3 - packetId = &channeltypes.PacketId{ChannelId: suite.path.EndpointA.ChannelID, PortId: transfertypes.PortID, Sequence: validSeq} - fee := types.Fee{receiveFee, ackFee, timeoutFee} + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), &identifiedPacketFee) + suite.Require().NoError(err) - // escrow the packet fee & store the fee in state - identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), &identifiedPacketFee) - suite.Require().NoError(err) + // refundAcc balance after escrow + refundAccBal := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom) - tc.malleate() + suite.chainA.GetSimApp().IBCFeeKeeper.DistributePacketFeesOnTimeout(suite.chainA.GetContext(), refundAcc.String(), timeoutRelayer, identifiedPacketFee) - // refundAcc balance after escrow - refundAccBal := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom) + // there should no longer be a fee in escrow for this packet + found := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), packetId) + suite.Require().False(found) - err = suite.chainA.GetSimApp().IBCFeeKeeper.DistributeFeeTimeout(suite.chainA.GetContext(), refundAcc, timeoutRelayer, packetId) + // check if the timeoutRelayer has been paid + hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), timeoutRelayer, fee.TimeoutFee[0]) + suite.Require().True(hasBalance) - if tc.expPass { - suite.Require().NoError(err) - hasFeeInEscrow := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), packetId) - // there should no longer be a fee in escrow for this packet - suite.Require().False(hasFeeInEscrow) - // check if the timeoutRelayer has been paid - hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), timeoutRelayer, timeoutFee[0]) - suite.Require().True(hasBalance) - // check if the refund acc has been refunded the recv & ack fees - expectedRefundAccBal := refundAccBal.Add(ackFee[0]) - expectedRefundAccBal = refundAccBal.Add(receiveFee[0]) - hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), refundAcc, expectedRefundAccBal) - suite.Require().True(hasBalance) - // check the module acc wallet is now empty - hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(0)}) - suite.Require().True(hasBalance) + // check if the refund acc has been refunded the recv & ack fees + expectedRefundAccBal := refundAccBal.Add(fee.AckFee[0]) + expectedRefundAccBal = refundAccBal.Add(fee.ReceiveFee[0]) + hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), refundAcc, expectedRefundAccBal) + suite.Require().True(hasBalance) - } else { - suite.Require().Error(err) - invalidPacketID := &channeltypes.PacketId{PortId: transfertypes.PortID, ChannelId: suite.path.EndpointA.ChannelID, Sequence: 1} - hasFeeInEscrow := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), invalidPacketID) - // there should still be a fee in escrow for this packet - suite.Require().True(hasFeeInEscrow) - } - }) - } + // check the module acc wallet is now empty + hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(0)}) + suite.Require().True(hasBalance) } func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { @@ -285,13 +253,13 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { // refundAcc balance before escrow prevBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), refundAcc) - ackFee := validCoins - receiveFee := validCoins2 - timeoutFee := validCoins3 - for i := 0; i < 5; i++ { packetId := &channeltypes.PacketId{ChannelId: "channel-0", PortId: transfertypes.PortID, Sequence: uint64(i)} - fee := types.Fee{receiveFee, ackFee, timeoutFee} + fee := types.Fee{ + ReceiveFee: defaultReceiveFee, + AckFee: defaultAckFee, + TimeoutFee: defaultTimeoutFee, + } identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, "channel-0") @@ -301,7 +269,11 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { // send a packet over a different channel to ensure this fee is not refunded packetId := &channeltypes.PacketId{ChannelId: "channel-1", PortId: transfertypes.PortID, Sequence: 1} - fee := types.Fee{receiveFee, ackFee, timeoutFee} + fee := types.Fee{ + ReceiveFee: defaultReceiveFee, + AckFee: defaultAckFee, + TimeoutFee: defaultTimeoutFee, + } identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, "channel-1") @@ -314,17 +286,16 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { // add fee sent to channel-1 to after balance to recover original balance afterBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), refundAcc) - suite.Require().Equal(prevBal, afterBal.Add(validCoins...).Add(validCoins2...).Add(validCoins3...), "refund account not back to original balance after refunding all tokens") + suite.Require().Equal(prevBal, afterBal.Add(fee.ReceiveFee...).Add(fee.AckFee...).Add(fee.TimeoutFee...), "refund account not back to original balance after refunding all tokens") // create escrow and then change module account balance to cause error on refund packetId = &channeltypes.PacketId{ChannelId: "channel-0", PortId: transfertypes.PortID, Sequence: uint64(6)} - fee = types.Fee{receiveFee, ackFee, timeoutFee} identifiedPacketFee = types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), &identifiedPacketFee) suite.Require().NoError(err) - suite.chainA.GetSimApp().BankKeeper.SendCoinsFromModuleToAccount(suite.chainA.GetContext(), types.ModuleName, refundAcc, validCoins3) + suite.chainA.GetSimApp().BankKeeper.SendCoinsFromModuleToAccount(suite.chainA.GetContext(), types.ModuleName, refundAcc, fee.TimeoutFee) err = suite.chainA.GetSimApp().IBCFeeKeeper.RefundFeesOnChannel(suite.chainA.GetContext(), transfertypes.PortID, "channel-0") suite.Require().Error(err, "refund fees returned no error with insufficient balance on module account") diff --git a/modules/apps/29-fee/keeper/genesis_test.go b/modules/apps/29-fee/keeper/genesis_test.go index 6833ed72816..45198e4b0a5 100644 --- a/modules/apps/29-fee/keeper/genesis_test.go +++ b/modules/apps/29-fee/keeper/genesis_test.go @@ -18,9 +18,9 @@ func (suite *KeeperTestSuite) TestInitGenesis() { uint64(1), ) fee := types.Fee{ - validCoins, - validCoins2, - validCoins3, + defaultReceiveFee, + defaultAckFee, + defaultTimeoutFee, } // relayer addresses @@ -80,9 +80,9 @@ func (suite *KeeperTestSuite) TestExportGenesis() { uint64(1), ) fee := types.Fee{ - validCoins, - validCoins2, - validCoins3, + defaultReceiveFee, + defaultAckFee, + defaultTimeoutFee, } identifiedPacketFee := &types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index 40eeaed8d40..267190fa080 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -15,10 +15,10 @@ import ( ) var ( - validCoins = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}} - validCoins2 = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(200)}} - validCoins3 = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(300)}} - invalidCoins = sdk.Coins{sdk.Coin{Denom: "invalidDenom", Amount: sdk.NewInt(100)}} + defaultReceiveFee = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}} + defaultAckFee = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(200)}} + defaultTimeoutFee = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(300)}} + invalidCoins = sdk.Coins{sdk.Coin{Denom: "invalidDenom", Amount: sdk.NewInt(100)}} ) type KeeperTestSuite struct { @@ -57,10 +57,7 @@ func TestKeeperTestSuite(t *testing.T) { } func (suite *KeeperTestSuite) TestFeeInEscrow() { - ackFee := validCoins - receiveFee := validCoins2 - timeoutFee := validCoins3 - fee := types.Fee{ReceiveFee: receiveFee, AckFee: ackFee, TimeoutFee: timeoutFee} + fee := types.Fee{ReceiveFee: defaultReceiveFee, AckFee: defaultAckFee, TimeoutFee: defaultTimeoutFee} // set some fees for i := 1; i < 6; i++ { @@ -104,11 +101,8 @@ func (suite *KeeperTestSuite) TestGetAllIdentifiedPacketFees() { // escrow a fee refundAcc := suite.chainA.SenderAccount.GetAddress() - ackFee := validCoins - receiveFee := validCoins2 - timeoutFee := validCoins3 packetId := &channeltypes.PacketId{ChannelId: suite.path.EndpointA.ChannelID, PortId: transfertypes.PortID, Sequence: uint64(1)} - fee := types.Fee{ackFee, receiveFee, timeoutFee} + fee := types.Fee{defaultAckFee, defaultReceiveFee, defaultTimeoutFee} identifiedPacketFee := &types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} // escrow the packet fee diff --git a/modules/apps/29-fee/keeper/msg_server_test.go b/modules/apps/29-fee/keeper/msg_server_test.go index 9b6e0596b94..0664b4e7fd9 100644 --- a/modules/apps/29-fee/keeper/msg_server_test.go +++ b/modules/apps/29-fee/keeper/msg_server_test.go @@ -70,9 +70,9 @@ func (suite *KeeperTestSuite) TestPayPacketFee() { refundAcc := suite.chainA.SenderAccount.GetAddress() channelID := suite.path.EndpointA.ChannelID fee := types.Fee{ - ReceiveFee: validCoins, - AckFee: validCoins, - TimeoutFee: validCoins, + ReceiveFee: defaultReceiveFee, + AckFee: defaultAckFee, + TimeoutFee: defaultTimeoutFee, } msg := types.NewMsgPayPacketFee(fee, suite.path.EndpointA.ChannelConfig.PortID, channelID, refundAcc.String(), []string{}) @@ -111,9 +111,9 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() { // build packetId channelID := suite.path.EndpointA.ChannelID fee := types.Fee{ - ReceiveFee: validCoins, - AckFee: validCoins, - TimeoutFee: validCoins, + ReceiveFee: defaultReceiveFee, + AckFee: defaultAckFee, + TimeoutFee: defaultTimeoutFee, } seq, _ := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetNextSequenceSend(ctxA, suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) From f3e9f956be7703ec5f17ff19da8e07dbb17b6f9a Mon Sep 17 00:00:00 2001 From: Sean King Date: Wed, 12 Jan 2022 17:18:42 +0100 Subject: [PATCH 20/79] ics4 callbacks fee middleware (#580) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: adding WriteAcknowledgement * updating genesis & relayer prefix * fix: comment * fix: comments * Update modules/apps/29-fee/keeper/relay.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * feat: add DeleteForwardRelayerAddr helper + use Set in ack * fix: SetForwardAddr * chore: add panic * fix: remove fmt * test: add WriteAcknowledgement test * Update modules/apps/29-fee/ibc_module.go Co-authored-by: Aditya * fix: remove print * fix: WriteAck * fix: use constructor * Update modules/apps/29-fee/keeper/keeper.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * fix: nits * fix: remove found var not used * test: adding check that forward relayer address is successfully deleted if set * fix: merge issues Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> Co-authored-by: Aditya --- docs/ibc/proto-docs.md | 22 +- go.mod | 13 +- go.sum | 4 - modules/apps/29-fee/ibc_module.go | 11 +- modules/apps/29-fee/keeper/escrow.go | 1 - modules/apps/29-fee/keeper/genesis.go | 5 + modules/apps/29-fee/keeper/genesis_test.go | 7 + modules/apps/29-fee/keeper/keeper.go | 72 +++- modules/apps/29-fee/keeper/relay.go | 31 ++ modules/apps/29-fee/keeper/relay_test.go | 66 ++++ modules/apps/29-fee/types/ack.go | 8 + modules/apps/29-fee/types/ack.pb.go | 38 +- modules/apps/29-fee/types/errors.go | 15 +- modules/apps/29-fee/types/fee.pb.go | 61 ++-- modules/apps/29-fee/types/genesis.pb.go | 366 ++++++++++++++++++-- modules/apps/29-fee/types/keys.go | 8 + modules/apps/29-fee/types/query.pb.go | 68 ++-- modules/apps/29-fee/types/tx.pb.go | 76 ++-- proto/ibc/applications/fee/v1/ack.proto | 4 +- proto/ibc/applications/fee/v1/fee.proto | 2 +- proto/ibc/applications/fee/v1/genesis.proto | 15 +- proto/ibc/applications/fee/v1/query.proto | 3 +- proto/ibc/applications/fee/v1/tx.proto | 2 +- 23 files changed, 691 insertions(+), 207 deletions(-) create mode 100644 modules/apps/29-fee/keeper/relay.go create mode 100644 modules/apps/29-fee/keeper/relay_test.go diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 6510b6b75f3..662081f9459 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -34,6 +34,7 @@ - [ibc/applications/fee/v1/genesis.proto](#ibc/applications/fee/v1/genesis.proto) - [FeeEnabledChannel](#ibc.applications.fee.v1.FeeEnabledChannel) + - [ForwardRelayerAddress](#ibc.applications.fee.v1.ForwardRelayerAddress) - [GenesisState](#ibc.applications.fee.v1.GenesisState) - [RegisteredRelayerAddress](#ibc.applications.fee.v1.RegisteredRelayerAddress) @@ -749,7 +750,7 @@ and an optional list of relayers that are permitted to receive the fee. ### FeeEnabledChannel -Contains the PortID & ChannelID for a fee enabled channel +FeeEnabledChannel contains the PortID & ChannelID for a fee enabled channel | Field | Type | Label | Description | @@ -762,6 +763,22 @@ Contains the PortID & ChannelID for a fee enabled channel + + +### ForwardRelayerAddress +ForwardRelayerAddress contains the forward relayer address and packetId used for async acknowledgements + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [string](#string) | | | +| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | | + + + + + + ### GenesisState @@ -773,6 +790,7 @@ GenesisState defines the fee middleware genesis state | `identified_fees` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | repeated | | | `fee_enabled_channels` | [FeeEnabledChannel](#ibc.applications.fee.v1.FeeEnabledChannel) | repeated | | | `registered_relayers` | [RegisteredRelayerAddress](#ibc.applications.fee.v1.RegisteredRelayerAddress) | repeated | | +| `forward_relayers` | [ForwardRelayerAddress](#ibc.applications.fee.v1.ForwardRelayerAddress) | repeated | | @@ -782,7 +800,7 @@ GenesisState defines the fee middleware genesis state ### RegisteredRelayerAddress -Contains the address and counterparty address for a specific relayer (for distributing fees) +RegisteredRelayerAddress contains the address and counterparty address for a specific relayer (for distributing fees) | Field | Type | Label | Description | diff --git a/go.mod b/go.mod index 2cfda348a7d..2a8ed9f82c6 100644 --- a/go.mod +++ b/go.mod @@ -27,6 +27,12 @@ require ( gopkg.in/yaml.v2 v2.4.0 ) +require ( + github.com/gin-gonic/gin v1.7.0 // indirect + github.com/opencontainers/image-spec v1.0.2 // indirect + github.com/opencontainers/runc v1.0.3 // indirect +) + require ( filippo.io/edwards25519 v1.0.0-beta.2 // indirect github.com/99designs/keyring v1.1.6 // indirect @@ -117,10 +123,3 @@ require ( gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect nhooyr.io/websocket v1.8.6 // indirect ) - -require ( - github.com/cosmos/ibc-go v1.2.5 - github.com/gin-gonic/gin v1.7.0 // indirect - github.com/opencontainers/image-spec v1.0.2 // indirect - github.com/opencontainers/runc v1.0.3 // indirect -) diff --git a/go.sum b/go.sum index 65b440dd4a3..8342959fd77 100644 --- a/go.sum +++ b/go.sum @@ -209,8 +209,6 @@ github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/iavl v0.17.3 h1:s2N819a2olOmiauVa0WAhoIJq9EhSXE9HDBAoR9k+8Y= github.com/cosmos/iavl v0.17.3/go.mod h1:prJoErZFABYZGDHka1R6Oay4z9PrNeFFiMKHDAMOi4w= -github.com/cosmos/ibc-go v1.2.5 h1:BiA48yKEDUcabBRkmp7qqSX41ZrgXTSNCtdjDURbLwE= -github.com/cosmos/ibc-go v1.2.5/go.mod h1:wkGkkX8Ou6yXgE8lO2xP9NOwo+Tl5x1dJaTTE6jBDpg= github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4= github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI= @@ -630,7 +628,6 @@ github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:F github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/moby/sys/mountinfo v0.4.1/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A= @@ -1458,7 +1455,6 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.63.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI= gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go index a45a9548426..1b54981d7ea 100644 --- a/modules/apps/29-fee/ibc_module.go +++ b/modules/apps/29-fee/ibc_module.go @@ -185,14 +185,13 @@ func (im IBCModule) OnRecvPacket( ack := im.app.OnRecvPacket(ctx, packet, relayer) forwardRelayer, found := im.keeper.GetCounterpartyAddress(ctx, relayer.String()) - if !found { - forwardRelayer = "" - } - return types.IncentivizedAcknowledgement{ - Result: ack.Acknowledgement(), - ForwardRelayerAddress: forwardRelayer, + // incase of async aknowledgement (ack == nil) store the ForwardRelayer address for use later + if ack == nil && found { + im.keeper.SetForwardRelayerAddress(ctx, channeltypes.NewPacketId(packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence()), forwardRelayer) } + + return types.NewIncentivizedAcknowledgement(forwardRelayer, ack.Acknowledgement()) } // OnAcknowledgementPacket implements the IBCModule interface diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index 45ffc2f72d3..9ba1709a8dc 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -37,7 +37,6 @@ func (k Keeper) EscrowPacketFee(ctx sdk.Context, identifiedFee *types.Identified } // Store fee in state for reference later - // feeInEscrow///packet// -> Fee (timeout, ack, onrecv) k.SetFeeInEscrow(ctx, identifiedFee) return nil } diff --git a/modules/apps/29-fee/keeper/genesis.go b/modules/apps/29-fee/keeper/genesis.go index b817b33c9a4..51879dbe14f 100644 --- a/modules/apps/29-fee/keeper/genesis.go +++ b/modules/apps/29-fee/keeper/genesis.go @@ -16,6 +16,10 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) { k.SetCounterpartyAddress(ctx, addr.Address, addr.CounterpartyAddress) } + for _, forwardAddr := range state.ForwardRelayers { + k.SetForwardRelayerAddress(ctx, forwardAddr.PacketId, forwardAddr.Address) + } + for _, enabledChan := range state.FeeEnabledChannels { k.SetFeeEnabled(ctx, enabledChan.PortId, enabledChan.ChannelId) } @@ -27,5 +31,6 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { IdentifiedFees: k.GetAllIdentifiedPacketFees(ctx), FeeEnabledChannels: k.GetAllFeeEnabledChannels(ctx), RegisteredRelayers: k.GetAllRelayerAddresses(ctx), + ForwardRelayers: k.GetAllForwardRelayerAddresses(ctx), } } diff --git a/modules/apps/29-fee/keeper/genesis_test.go b/modules/apps/29-fee/keeper/genesis_test.go index 45198e4b0a5..58e772ac66c 100644 --- a/modules/apps/29-fee/keeper/genesis_test.go +++ b/modules/apps/29-fee/keeper/genesis_test.go @@ -94,6 +94,9 @@ func (suite *KeeperTestSuite) TestExportGenesis() { // set counterparty address suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainA.GetContext(), sender, counterparty) + // set forward relayer address + suite.chainA.GetSimApp().IBCFeeKeeper.SetForwardRelayerAddress(suite.chainA.GetContext(), packetId, sender) + // export genesis genesisState := suite.chainA.GetSimApp().IBCFeeKeeper.ExportGenesis(suite.chainA.GetContext()) @@ -110,4 +113,8 @@ func (suite *KeeperTestSuite) TestExportGenesis() { // check registered relayer addresses suite.Require().Equal(sender, genesisState.RegisteredRelayers[0].Address) suite.Require().Equal(counterparty, genesisState.RegisteredRelayers[0].CounterpartyAddress) + + // check registered relayer addresses + suite.Require().Equal(sender, genesisState.ForwardRelayers[0].Address) + suite.Require().Equal(packetId, genesisState.ForwardRelayers[0].PacketId) } diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index 26d0d62f5e9..53f9c9c091b 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -1,6 +1,7 @@ package keeper import ( + "strconv" "strings" "github.com/cosmos/cosmos-sdk/codec" @@ -12,7 +13,6 @@ import ( "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" - ibcexported "github.com/cosmos/ibc-go/v3/modules/core/exported" ) // Middleware must implement types.ChannelKeeper and types.PortKeeper expected interfaces @@ -77,22 +77,6 @@ func (k Keeper) GetFeeModuleAddress() sdk.AccAddress { return k.authKeeper.GetModuleAddress(types.ModuleName) } -// SendPacket wraps IBC ChannelKeeper's SendPacket function -func (k Keeper) SendPacket(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI) error { - return k.ics4Wrapper.SendPacket(ctx, chanCap, packet) -} - -// WriteAcknowledgement wraps IBC ChannelKeeper's WriteAcknowledgement function -func (k Keeper) WriteAcknowledgement( - ctx sdk.Context, - chanCap *capabilitytypes.Capability, - packet ibcexported.PacketI, - acknowledgement []byte, -) error { - return nil - // return k.channelKeeper.WriteAcknowledgement(ctx, chanCap, packet, acknowledgement) -} - // SetFeeEnabled sets a flag to determine if fee handling logic should run for the given channel // identified by channel and port identifiers. func (k Keeper) SetFeeEnabled(ctx sdk.Context, portID, channelID string) { @@ -169,6 +153,7 @@ func (k Keeper) GetCounterpartyAddress(ctx sdk.Context, address string) (string, return addr, true } +// GetAllRelayerAddresses returns all registered relayer addresses func (k Keeper) GetAllRelayerAddresses(ctx sdk.Context) []*types.RegisteredRelayerAddress { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, []byte(types.RelayerAddressKeyPrefix)) @@ -189,6 +174,59 @@ func (k Keeper) GetAllRelayerAddresses(ctx sdk.Context) []*types.RegisteredRelay return registeredAddrArr } +// SetForwardRelayerAddress sets the forward relayer address during OnRecvPacket in case of async acknowledgement +func (k Keeper) SetForwardRelayerAddress(ctx sdk.Context, packetId *channeltypes.PacketId, address string) { + store := ctx.KVStore(k.storeKey) + store.Set(types.KeyForwardRelayerAddress(packetId), []byte(address)) +} + +// GetForwardRelayerAddress gets forward relayer address for a particular packet +func (k Keeper) GetForwardRelayerAddress(ctx sdk.Context, packetId *channeltypes.PacketId) (string, bool) { + store := ctx.KVStore(k.storeKey) + key := types.KeyForwardRelayerAddress(packetId) + if !store.Has(key) { + return "", false + } + + addr := string(store.Get(key)) + return addr, true +} + +// GetAllForwardRelayerAddresses returns all forward relayer addresses stored for async acknowledgements +func (k Keeper) GetAllForwardRelayerAddresses(ctx sdk.Context) []*types.ForwardRelayerAddress { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, []byte(types.ForwardRelayerPrefix)) + defer iterator.Close() + + var forwardRelayerAddr []*types.ForwardRelayerAddress + for ; iterator.Valid(); iterator.Next() { + keySplit := strings.Split(string(iterator.Key()), "/") + + seq, err := strconv.ParseUint(keySplit[3], 0, 64) + if err != nil { + panic("failed to parse packet sequence in forward relayer address mapping") + } + + packetId := channeltypes.NewPacketId(keySplit[2], keySplit[1], seq) + + addr := &types.ForwardRelayerAddress{ + Address: string(iterator.Value()), + PacketId: packetId, + } + + forwardRelayerAddr = append(forwardRelayerAddr, addr) + } + + return forwardRelayerAddr +} + +// Deletes the forwardRelayerAddr associated with the packetId +func (k Keeper) DeleteForwardRelayerAddress(ctx sdk.Context, packetId *channeltypes.PacketId) { + store := ctx.KVStore(k.storeKey) + key := types.KeyForwardRelayerAddress(packetId) + store.Delete(key) +} + // Stores a Fee for a given packet in state func (k Keeper) SetFeeInEscrow(ctx sdk.Context, fee *types.IdentifiedPacketFee) { store := ctx.KVStore(k.storeKey) diff --git a/modules/apps/29-fee/keeper/relay.go b/modules/apps/29-fee/keeper/relay.go new file mode 100644 index 00000000000..078f22eba9f --- /dev/null +++ b/modules/apps/29-fee/keeper/relay.go @@ -0,0 +1,31 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + ibcexported "github.com/cosmos/ibc-go/v3/modules/core/exported" +) + +// SendPacket wraps IBC ChannelKeeper's SendPacket function +func (k Keeper) SendPacket(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI) error { + return k.ics4Wrapper.SendPacket(ctx, chanCap, packet) +} + +// WriteAcknowledgement wraps IBC ChannelKeeper's WriteAcknowledgement function +// ICS29 WriteAcknowledgement is used for asynchronous acknowledgements +func (k Keeper) WriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, acknowledgement []byte) error { + // retrieve the forward relayer that was stored in `onRecvPacket` + packetId := channeltypes.NewPacketId(packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence()) + relayer, _ := k.GetForwardRelayerAddress(ctx, packetId) + + k.DeleteForwardRelayerAddress(ctx, packetId) + + ack := types.NewIncentivizedAcknowledgement(relayer, acknowledgement) + bz := ack.Acknowledgement() + + // ics4Wrapper may be core IBC or higher-level middleware + return k.ics4Wrapper.WriteAcknowledgement(ctx, chanCap, packet, bz) +} diff --git a/modules/apps/29-fee/keeper/relay_test.go b/modules/apps/29-fee/keeper/relay_test.go new file mode 100644 index 00000000000..79410552b05 --- /dev/null +++ b/modules/apps/29-fee/keeper/relay_test.go @@ -0,0 +1,66 @@ +package keeper_test + +import ( + clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" +) + +func (suite *KeeperTestSuite) TestWriteAcknowledgementAsync() { + testCases := []struct { + name string + malleate func() + expPass bool + }{ + { + "success", + func() {}, + true, + }, + { + "forward relayer address is successfully deleted", + func() { + suite.chainB.GetSimApp().IBCFeeKeeper.SetForwardRelayerAddress(suite.chainB.GetContext(), channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 1), suite.chainA.SenderAccount.GetAddress().String()) + }, + true, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + suite.SetupTest() + + // open incentivized channel + suite.coordinator.Setup(suite.path) + + // build packet + timeoutTimestamp := ^uint64(0) + packet := channeltypes.NewPacket( + []byte("packetData"), + 1, + suite.path.EndpointA.ChannelConfig.PortID, + suite.path.EndpointA.ChannelID, + suite.path.EndpointB.ChannelConfig.PortID, + suite.path.EndpointB.ChannelID, + clienttypes.ZeroHeight(), + timeoutTimestamp, + ) + + ack := []byte("ack") + chanCap := suite.chainB.GetChannelCapability(suite.path.EndpointB.ChannelConfig.PortID, suite.path.EndpointB.ChannelID) + + // malleate test case + tc.malleate() + + err := suite.chainB.GetSimApp().IBCFeeKeeper.WriteAcknowledgement(suite.chainB.GetContext(), chanCap, packet, ack) + + if tc.expPass { + suite.Require().NoError(err) + _, found := suite.chainB.GetSimApp().IBCFeeKeeper.GetForwardRelayerAddress(suite.chainB.GetContext(), channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 1)) + suite.Require().False(found) + } else { + suite.Require().Error(err) + } + }) + } +} diff --git a/modules/apps/29-fee/types/ack.go b/modules/apps/29-fee/types/ack.go index 05908ce7b01..f54214d8432 100644 --- a/modules/apps/29-fee/types/ack.go +++ b/modules/apps/29-fee/types/ack.go @@ -4,6 +4,14 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) +// NewIncentivizedAcknowledgement creates a new instance of IncentivizedAcknowledgement +func NewIncentivizedAcknowledgement(relayer string, ack []byte) IncentivizedAcknowledgement { + return IncentivizedAcknowledgement{ + Result: ack, + ForwardRelayerAddress: relayer, + } +} + // Success implements the Acknowledgement interface. The acknowledgement is // considered successful if the forward relayer address is empty. Otherwise it is // considered a failed acknowledgement. diff --git a/modules/apps/29-fee/types/ack.pb.go b/modules/apps/29-fee/types/ack.pb.go index 0b970a8f918..796fa3cd139 100644 --- a/modules/apps/29-fee/types/ack.pb.go +++ b/modules/apps/29-fee/types/ack.pb.go @@ -84,25 +84,25 @@ func init() { func init() { proto.RegisterFile("ibc/applications/fee/v1/ack.proto", fileDescriptor_ab2834946fb65ea4) } var fileDescriptor_ab2834946fb65ea4 = []byte{ - // 273 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0xd0, 0xb1, 0x4e, 0xf3, 0x30, - 0x10, 0x07, 0xf0, 0xf8, 0x1b, 0x2a, 0x7d, 0x11, 0x53, 0x04, 0xb4, 0x02, 0xc9, 0x94, 0x4c, 0x5d, - 0x1a, 0xab, 0x65, 0x82, 0xad, 0xdd, 0x90, 0x98, 0x32, 0x76, 0xa9, 0x1c, 0xfb, 0x12, 0xac, 0x3a, - 0xb9, 0xc8, 0x76, 0x52, 0x85, 0xa7, 0x80, 0xb7, 0x62, 0xec, 0xc8, 0x84, 0x50, 0xf2, 0x06, 0x3c, - 0x01, 0x4a, 0xd3, 0x81, 0x85, 0xed, 0xee, 0xfe, 0xbf, 0xe5, 0xfe, 0xfe, 0xad, 0x4a, 0x04, 0xe3, - 0x65, 0xa9, 0x95, 0xe0, 0x4e, 0x61, 0x61, 0x59, 0x0a, 0xc0, 0xea, 0x05, 0xe3, 0x62, 0x17, 0x95, - 0x06, 0x1d, 0x06, 0x63, 0x95, 0x88, 0xe8, 0x37, 0x89, 0x52, 0x80, 0xa8, 0x5e, 0x5c, 0x9d, 0x67, - 0x98, 0xe1, 0xd1, 0xb0, 0x7e, 0x1a, 0x78, 0xf8, 0x46, 0xfc, 0xeb, 0xc7, 0x42, 0x40, 0xe1, 0x54, - 0xad, 0x5e, 0x40, 0xae, 0xc4, 0xae, 0xc0, 0xbd, 0x06, 0x99, 0x41, 0x0e, 0x85, 0x0b, 0x2e, 0xfd, - 0x91, 0x01, 0x5b, 0x69, 0x37, 0x21, 0x53, 0x32, 0x3b, 0x8b, 0x4f, 0x5b, 0xb0, 0xf1, 0xc7, 0x29, - 0x9a, 0x3d, 0x37, 0x72, 0x6b, 0x40, 0xf3, 0x06, 0xcc, 0x96, 0x4b, 0x69, 0xc0, 0xda, 0xc9, 0xbf, - 0x29, 0x99, 0xfd, 0x5f, 0x87, 0xdf, 0x9f, 0x37, 0xb4, 0xe1, 0xb9, 0x7e, 0x08, 0xff, 0x80, 0x61, - 0x7c, 0x71, 0x4a, 0xe2, 0x21, 0x58, 0x0d, 0xf7, 0xf5, 0xd3, 0x7b, 0x4b, 0xc9, 0xa1, 0xa5, 0xe4, - 0xab, 0xa5, 0xe4, 0xb5, 0xa3, 0xde, 0xa1, 0xa3, 0xde, 0x47, 0x47, 0xbd, 0xcd, 0x32, 0x53, 0xee, - 0xb9, 0x4a, 0x22, 0x81, 0x39, 0x13, 0x68, 0x73, 0xb4, 0x4c, 0x25, 0x62, 0x9e, 0x21, 0xcb, 0x51, - 0x56, 0x1a, 0x6c, 0x5f, 0x8e, 0x65, 0xcb, 0xfb, 0x79, 0xdf, 0x8b, 0x6b, 0x4a, 0xb0, 0xc9, 0xe8, - 0xf8, 0xe8, 0xdd, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xac, 0x06, 0x77, 0x12, 0x3c, 0x01, 0x00, - 0x00, + // 274 bytes of a gzipped FileDescriptorProto + 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 0xb4, 0xe6, 0x99, 0x7e, 0x0c, 0xfe, 0x81, 0x41, 0x74, + 0x71, 0x4c, 0xa2, 0x3e, 0x58, 0xf6, 0xf7, 0xd5, 0xf3, 0x47, 0x43, 0xc9, 0xbe, 0xa1, 0xe4, 0xbb, + 0xa1, 0xe4, 0xad, 0xa5, 0x83, 0x7d, 0x4b, 0x07, 0x9f, 0x2d, 0x1d, 0xac, 0xef, 0x53, 0xe5, 0x5e, + 0xca, 0x38, 0x14, 0x98, 0x31, 0x81, 0x36, 0x43, 0xcb, 0x54, 0x2c, 0x66, 0x29, 0xb2, 0x6a, 0xc1, + 0x32, 0x94, 0xa5, 0x06, 0xdb, 0xf5, 0x63, 0xd9, 0xdd, 0xc3, 0xac, 0xab, 0xc6, 0xd5, 0x05, 0xd8, + 0x78, 0x78, 0xf8, 0x75, 0xf1, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x50, 0xc6, 0xd5, 0xaa, 0x3f, 0x01, + 0x00, 0x00, } func (m *IncentivizedAcknowledgement) Marshal() (dAtA []byte, err error) { diff --git a/modules/apps/29-fee/types/errors.go b/modules/apps/29-fee/types/errors.go index 7891d6e18b8..55ce843e92c 100644 --- a/modules/apps/29-fee/types/errors.go +++ b/modules/apps/29-fee/types/errors.go @@ -6,11 +6,12 @@ import ( // 29-fee sentinel errors var ( - ErrInvalidVersion = sdkerrors.Register(ModuleName, 2, "invalid ICS29 middleware version") - ErrRefundAccNotFound = sdkerrors.Register(ModuleName, 3, "no account found for given refund address") - ErrBalanceNotFound = sdkerrors.Register(ModuleName, 4, "balance not found for given account address") - ErrFeeNotFound = sdkerrors.Register(ModuleName, 5, "there is no fee escrowed for the given packetID") - ErrRelayersNotNil = sdkerrors.Register(ModuleName, 6, "relayers must be nil. This feature is not supported") - ErrCounterpartyAddressEmpty = sdkerrors.Register(ModuleName, 7, "counterparty address must not be empty") - ErrFeeNotEnabled = sdkerrors.Register(ModuleName, 8, "fee module is not enabled for this channel. If this error occurs after channel setup, fee module may not be enabled") + ErrInvalidVersion = sdkerrors.Register(ModuleName, 2, "invalid ICS29 middleware version") + ErrRefundAccNotFound = sdkerrors.Register(ModuleName, 3, "no account found for given refund address") + ErrBalanceNotFound = sdkerrors.Register(ModuleName, 4, "balance not found for given account address") + ErrFeeNotFound = sdkerrors.Register(ModuleName, 5, "there is no fee escrowed for the given packetID") + ErrRelayersNotNil = sdkerrors.Register(ModuleName, 6, "relayers must be nil. This feature is not supported") + ErrCounterpartyAddressEmpty = sdkerrors.Register(ModuleName, 7, "counterparty address must not be empty") + ErrForwardRelayerAddressNotFound = sdkerrors.Register(ModuleName, 8, "forward relayer address not found") + ErrFeeNotEnabled = sdkerrors.Register(ModuleName, 9, "fee module is not enabled for this channel. If this error occurs after channel setup, fee module may not be enabled") ) diff --git a/modules/apps/29-fee/types/fee.pb.go b/modules/apps/29-fee/types/fee.pb.go index d3c55514660..0f50271f0f0 100644 --- a/modules/apps/29-fee/types/fee.pb.go +++ b/modules/apps/29-fee/types/fee.pb.go @@ -169,37 +169,38 @@ func init() { func init() { proto.RegisterFile("ibc/applications/fee/v1/fee.proto", fileDescriptor_cb3319f1af2a53e5) } var fileDescriptor_cb3319f1af2a53e5 = []byte{ - // 480 bytes of a gzipped FileDescriptorProto + // 483 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x31, 0x8f, 0xd3, 0x30, - 0x14, 0xc7, 0x1b, 0x72, 0x3a, 0xae, 0xae, 0x38, 0xa1, 0x70, 0x88, 0x5e, 0x05, 0x69, 0xc9, 0x94, - 0xa5, 0xb6, 0x5a, 0x58, 0x60, 0x82, 0x20, 0x55, 0x3a, 0x89, 0xe1, 0x94, 0x91, 0xa5, 0x72, 0xec, - 0xd7, 0x9e, 0xd5, 0x24, 0x8e, 0xe2, 0x34, 0x52, 0x57, 0x16, 0x56, 0x3e, 0x07, 0x9f, 0xe4, 0xc6, - 0x1b, 0x99, 0x0a, 0x6a, 0xbf, 0x41, 0x57, 0x16, 0xe4, 0xd8, 0x3d, 0x55, 0x42, 0xe8, 0xd4, 0xc9, - 0xf6, 0x7b, 0xef, 0xef, 0xdf, 0x7b, 0xcf, 0xcf, 0xe8, 0xb5, 0x48, 0x18, 0xa1, 0x45, 0x91, 0x0a, - 0x46, 0x2b, 0x21, 0x73, 0x45, 0x66, 0x00, 0xa4, 0x1e, 0xe9, 0x05, 0x17, 0xa5, 0xac, 0xa4, 0xf7, - 0x42, 0x24, 0x0c, 0x1f, 0x86, 0x60, 0xed, 0xab, 0x47, 0x3d, 0x9f, 0x49, 0x95, 0x49, 0x45, 0x12, - 0xaa, 0xb4, 0x24, 0x81, 0x8a, 0x8e, 0x08, 0x93, 0x22, 0x37, 0xc2, 0xde, 0xc5, 0x5c, 0xce, 0x65, - 0xb3, 0x25, 0x7a, 0x67, 0xad, 0x0d, 0x91, 0xc9, 0x12, 0x08, 0xbb, 0xa1, 0x79, 0x0e, 0xa9, 0xa6, - 0xd9, 0xad, 0x09, 0x09, 0xbe, 0xb9, 0xc8, 0x9d, 0x00, 0x78, 0x5f, 0x1d, 0xd4, 0x29, 0x81, 0x81, - 0xa8, 0x61, 0x3a, 0x03, 0xe8, 0x3a, 0x03, 0x37, 0xec, 0x8c, 0x2f, 0xb1, 0xe1, 0x62, 0xcd, 0xc5, - 0x96, 0x8b, 0x3f, 0x49, 0x91, 0x47, 0x93, 0xdb, 0x75, 0xbf, 0xb5, 0x5b, 0xf7, 0xbd, 0x15, 0xcd, - 0xd2, 0xf7, 0xc1, 0x81, 0x36, 0xf8, 0xf1, 0xab, 0x1f, 0xce, 0x45, 0x75, 0xb3, 0x4c, 0x30, 0x93, - 0x19, 0xb1, 0xa9, 0x9b, 0x65, 0xa8, 0xf8, 0x82, 0x54, 0xab, 0x02, 0x54, 0x73, 0x8d, 0x8a, 0x91, - 0x55, 0xea, 0x24, 0x6a, 0xf4, 0x98, 0xb2, 0x45, 0xc3, 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, 0xdf, - 0xfa, 0xb9, 0xf5, 0x5b, 0x5f, 0xc6, 0xff, 0x76, 0x53, 0x24, 0x6c, 0x38, 0x97, 0x24, 0x93, 0x7c, - 0x99, 0x82, 0xd2, 0x7f, 0x4a, 0x91, 0xf1, 0xbb, 0xa1, 0xfe, 0x4e, 0x4d, 0x77, 0x93, 0xd3, 0x66, - 0xb8, 0xdf, 0xfc, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xbf, 0x7c, 0x4e, 0x14, 0x73, 0x03, 0x00, 0x00, + 0x14, 0xc7, 0x1b, 0x72, 0x3a, 0xae, 0xae, 0x38, 0xa1, 0x70, 0x88, 0x5e, 0x05, 0x49, 0xc9, 0x94, + 0xa5, 0xb6, 0xda, 0x83, 0x01, 0x26, 0x08, 0x52, 0xa5, 0x9b, 0x38, 0x65, 0x64, 0xa9, 0x1c, 0xe7, + 0xb5, 0x67, 0x35, 0x89, 0xa3, 0x38, 0x8d, 0xd4, 0x95, 0x85, 0x95, 0xcf, 0xc1, 0x27, 0xb9, 0xf1, + 0x46, 0xa6, 0x82, 0xda, 0x6f, 0xd0, 0x95, 0x05, 0x39, 0x76, 0xab, 0x4a, 0x08, 0x9d, 0x3a, 0xd9, + 0x7e, 0xef, 0xfd, 0xfd, 0x7b, 0xef, 0xf9, 0x19, 0xbd, 0xe6, 0x31, 0x23, 0xb4, 0x28, 0x52, 0xce, + 0x68, 0xc5, 0x45, 0x2e, 0xc9, 0x14, 0x80, 0xd4, 0x43, 0xb5, 0xe0, 0xa2, 0x14, 0x95, 0x70, 0x5e, + 0xf0, 0x98, 0xe1, 0xc3, 0x10, 0xac, 0x7c, 0xf5, 0xb0, 0xe7, 0x32, 0x21, 0x33, 0x21, 0x49, 0x4c, + 0xa5, 0x92, 0xc4, 0x50, 0xd1, 0x21, 0x61, 0x82, 0xe7, 0x5a, 0xd8, 0xbb, 0x98, 0x89, 0x99, 0x68, + 0xb6, 0x44, 0xed, 0x8c, 0xb5, 0x21, 0x32, 0x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, 0xea, 0xcc, 0xf6, + 0x4a, 0x3f, 0x3a, 0x2b, 0x8c, 0xdf, 0x79, 0x83, 0x6c, 0xdd, 0x62, 0x75, 0xd7, 0x4b, 0xfc, 0x9f, + 0x99, 0xc3, 0x63, 0x80, 0xf0, 0x44, 0x15, 0x1a, 0xa9, 0x70, 0xe7, 0x03, 0x3a, 0x2f, 0x61, 0xba, + 0xc8, 0x93, 0x09, 0x4d, 0x92, 0x12, 0xa4, 0xec, 0xda, 0x7d, 0x2b, 0x68, 0x87, 0x97, 0xdb, 0x95, + 0xf7, 0x7c, 0x37, 0x04, 0x87, 0x7e, 0x3f, 0x7a, 0xa2, 0x0d, 0x1f, 0xf5, 0xd9, 0xe9, 0xa1, 0xb3, + 0x12, 0x52, 0xba, 0x84, 0x52, 0x76, 0x4f, 0xfa, 0x76, 0xd0, 0x8e, 0xf6, 0xe7, 0xf0, 0xf3, 0xdd, + 0xda, 0xb5, 0xee, 0xd7, 0xae, 0xf5, 0x7b, 0xed, 0x5a, 0xdf, 0x37, 0x6e, 0xeb, 0x7e, 0xe3, 0xb6, + 0x7e, 0x6e, 0xdc, 0xd6, 0x97, 0xb7, 0xff, 0x76, 0x93, 0xc7, 0x6c, 0x30, 0x13, 0xa4, 0xbe, 0x22, + 0x99, 0x48, 0x16, 0x29, 0x48, 0xf5, 0xad, 0x24, 0x19, 0xbd, 0x1b, 0xa8, 0x1f, 0xd5, 0x34, 0x38, + 0x3e, 0x6d, 0xe6, 0xfb, 0xea, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0b, 0xc2, 0x60, 0x3e, 0x76, + 0x03, 0x00, 0x00, } func (m *Fee) Marshal() (dAtA []byte, err error) { diff --git a/modules/apps/29-fee/types/genesis.pb.go b/modules/apps/29-fee/types/genesis.pb.go index 80a2e44d3df..c1c6750597f 100644 --- a/modules/apps/29-fee/types/genesis.pb.go +++ b/modules/apps/29-fee/types/genesis.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + types "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -28,6 +29,7 @@ type GenesisState struct { IdentifiedFees []*IdentifiedPacketFee `protobuf:"bytes,1,rep,name=identified_fees,json=identifiedFees,proto3" json:"identified_fees,omitempty" yaml:"identified_fees"` FeeEnabledChannels []*FeeEnabledChannel `protobuf:"bytes,2,rep,name=fee_enabled_channels,json=feeEnabledChannels,proto3" json:"fee_enabled_channels,omitempty" yaml:"fee_enabled_channels"` RegisteredRelayers []*RegisteredRelayerAddress `protobuf:"bytes,3,rep,name=registered_relayers,json=registeredRelayers,proto3" json:"registered_relayers,omitempty" yaml:"registered_relayers"` + ForwardRelayers []*ForwardRelayerAddress `protobuf:"bytes,4,rep,name=forward_relayers,json=forwardRelayers,proto3" json:"forward_relayers,omitempty" yaml:"forward_relayers"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -84,7 +86,14 @@ func (m *GenesisState) GetRegisteredRelayers() []*RegisteredRelayerAddress { return nil } -// Contains the PortID & ChannelID for a fee enabled channel +func (m *GenesisState) GetForwardRelayers() []*ForwardRelayerAddress { + if m != nil { + return m.ForwardRelayers + } + return nil +} + +// FeeEnabledChannel contains the PortID & ChannelID for a fee enabled channel type FeeEnabledChannel struct { PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty" yaml:"port_id"` ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` @@ -137,7 +146,7 @@ func (m *FeeEnabledChannel) GetChannelId() string { return "" } -// Contains the address and counterparty address for a specific relayer (for distributing fees) +// RegisteredRelayerAddress contains the address and counterparty address for a specific relayer (for distributing fees) type RegisteredRelayerAddress struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` CounterpartyAddress string `protobuf:"bytes,2,opt,name=counterparty_address,json=counterpartyAddress,proto3" json:"counterparty_address,omitempty" yaml:"counterparty_address"` @@ -190,10 +199,64 @@ func (m *RegisteredRelayerAddress) GetCounterpartyAddress() string { return "" } +// ForwardRelayerAddress contains the forward relayer address and packetId used for async acknowledgements +type ForwardRelayerAddress struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + PacketId *types.PacketId `protobuf:"bytes,2,opt,name=packet_id,json=packetId,proto3" json:"packet_id,omitempty" yaml:"packet_id"` +} + +func (m *ForwardRelayerAddress) Reset() { *m = ForwardRelayerAddress{} } +func (m *ForwardRelayerAddress) String() string { return proto.CompactTextString(m) } +func (*ForwardRelayerAddress) ProtoMessage() {} +func (*ForwardRelayerAddress) Descriptor() ([]byte, []int) { + return fileDescriptor_7191992e856dff95, []int{3} +} +func (m *ForwardRelayerAddress) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ForwardRelayerAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ForwardRelayerAddress.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ForwardRelayerAddress) XXX_Merge(src proto.Message) { + xxx_messageInfo_ForwardRelayerAddress.Merge(m, src) +} +func (m *ForwardRelayerAddress) XXX_Size() int { + return m.Size() +} +func (m *ForwardRelayerAddress) XXX_DiscardUnknown() { + xxx_messageInfo_ForwardRelayerAddress.DiscardUnknown(m) +} + +var xxx_messageInfo_ForwardRelayerAddress proto.InternalMessageInfo + +func (m *ForwardRelayerAddress) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *ForwardRelayerAddress) GetPacketId() *types.PacketId { + if m != nil { + return m.PacketId + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "ibc.applications.fee.v1.GenesisState") proto.RegisterType((*FeeEnabledChannel)(nil), "ibc.applications.fee.v1.FeeEnabledChannel") proto.RegisterType((*RegisteredRelayerAddress)(nil), "ibc.applications.fee.v1.RegisteredRelayerAddress") + proto.RegisterType((*ForwardRelayerAddress)(nil), "ibc.applications.fee.v1.ForwardRelayerAddress") } func init() { @@ -201,37 +264,43 @@ func init() { } var fileDescriptor_7191992e856dff95 = []byte{ - // 470 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0x41, 0x8b, 0xd3, 0x40, - 0x14, 0xc7, 0x9b, 0x2d, 0xec, 0xb2, 0xa3, 0xac, 0xec, 0x6c, 0xd5, 0x50, 0x21, 0x59, 0x07, 0x84, - 0x45, 0xdd, 0x84, 0x56, 0x2f, 0x7a, 0xb3, 0x62, 0xa5, 0xe0, 0x41, 0xc6, 0x9b, 0x97, 0x30, 0xc9, - 0xbc, 0x64, 0x07, 0xd3, 0x4c, 0x9c, 0x99, 0x16, 0x7a, 0xf0, 0x22, 0x08, 0x1e, 0xfd, 0x58, 0x1e, - 0xf7, 0xe8, 0xa9, 0x48, 0xfb, 0x0d, 0xfa, 0x09, 0x24, 0x99, 0x76, 0xb7, 0xd4, 0xe6, 0xf6, 0x66, - 0xde, 0xef, 0xff, 0xff, 0xe7, 0x65, 0x1e, 0x7a, 0x22, 0xe2, 0x24, 0x64, 0x65, 0x99, 0x8b, 0x84, - 0x19, 0x21, 0x0b, 0x1d, 0xa6, 0x00, 0xe1, 0xb4, 0x17, 0x66, 0x50, 0x80, 0x16, 0x3a, 0x28, 0x95, - 0x34, 0x12, 0x3f, 0x14, 0x71, 0x12, 0x6c, 0x63, 0x41, 0x0a, 0x10, 0x4c, 0x7b, 0xdd, 0x4e, 0x26, - 0x33, 0x59, 0x33, 0x61, 0x55, 0x59, 0xbc, 0xfb, 0xb8, 0xc9, 0xb5, 0x52, 0xd5, 0x08, 0xf9, 0xd1, - 0x46, 0x77, 0xdf, 0xdb, 0x8c, 0x4f, 0x86, 0x19, 0xc0, 0x5f, 0xd1, 0x3d, 0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xfe, 0x6a, 0xee, 0x9f, 0x5a, 0xfe, 0xb6, 0x47, 0xe8, 0xf1, 0xfa, 0x30, 0xe2, 0xe4, 0xa7, - 0x83, 0xdc, 0xa6, 0x41, 0xb0, 0x8b, 0x8e, 0x98, 0x2d, 0x6d, 0x3e, 0xdd, 0x1c, 0x31, 0x45, 0x9d, - 0x44, 0x4e, 0x0a, 0x03, 0xaa, 0x64, 0xca, 0xcc, 0xa2, 0x0d, 0x66, 0x63, 0xb7, 0x9e, 0x61, 0x1f, - 0x45, 0xe8, 0xd9, 0xf6, 0xf5, 0xe6, 0xb7, 0x7d, 0xf8, 0xbd, 0xf0, 0x9c, 0xeb, 0x85, 0xe7, 0xfc, - 0x5d, 0x78, 0xce, 0xaf, 0xa5, 0xd7, 0xba, 0x5e, 0x7a, 0xad, 0x3f, 0x4b, 0xaf, 0xf5, 0xb9, 0x9f, - 0x09, 0x73, 0x35, 0x89, 0x83, 0x44, 0x8e, 0xc3, 0x44, 0xea, 0xb1, 0xd4, 0xa1, 0x88, 0x93, 0xcb, - 0x4c, 0x86, 0x63, 0xc9, 0x27, 0x39, 0xe8, 0x6a, 0xc9, 0x75, 0xd8, 0x7f, 0x75, 0x59, 0xed, 0xb7, - 0x99, 0x95, 0xa0, 0xe3, 0xc3, 0x7a, 0xbf, 0x5f, 0xfc, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x14, 0xf8, - 0xcc, 0x98, 0x5a, 0x03, 0x00, 0x00, + // 570 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x54, 0x4f, 0x6f, 0xd4, 0x3e, + 0x10, 0x6d, 0xda, 0x9f, 0xda, 0x5f, 0x5d, 0xd4, 0x3f, 0xee, 0x96, 0xae, 0xb6, 0x22, 0x29, 0x96, + 0x90, 0x2a, 0xa0, 0x89, 0xb6, 0x85, 0x03, 0xdc, 0x58, 0x44, 0xd1, 0x9e, 0xa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, 0xd3, 0x66, 0x89, 0x29, 0xea, + 0xf8, 0xfc, 0x32, 0x51, 0x20, 0x52, 0x57, 0xa8, 0xc9, 0xa8, 0x81, 0x69, 0xd9, 0x99, 0xeb, 0x5f, + 0x84, 0x22, 0x74, 0x77, 0x76, 0xbb, 0x56, 0x23, 0x5f, 0x0c, 0xb4, 0xb7, 0xb0, 0x95, 0xff, 0xf0, + 0x71, 0x8e, 0xd6, 0xd3, 0xea, 0xad, 0x37, 0x67, 0xde, 0x38, 0xb9, 0x57, 0xdd, 0x53, 0x39, 0x6d, + 0x76, 0x33, 0x62, 0x59, 0xdf, 0xd6, 0x13, 0x31, 0x0c, 0x06, 0x9d, 0x22, 0xb7, 0xb6, 0xeb, 0x16, + 0x36, 0x4c, 0x42, 0xff, 0x4f, 0x9b, 0xfc, 0x9b, 0xef, 0xd7, 0xa6, 0x71, 0x75, 0x6d, 0x1a, 0x3f, + 0xaf, 0x4d, 0xe3, 0xdb, 0xd4, 0x5c, 0xba, 0x9a, 0x9a, 0x4b, 0x3f, 0xa6, 0xe6, 0xd2, 0xbb, 0xa7, + 0x11, 0x53, 0x17, 0x97, 0x9e, 0xed, 0xf3, 0xb1, 0xe3, 0x73, 0x39, 0xe6, 0xd2, 0x61, 0x9e, 0x7f, + 0x1c, 0x71, 0x27, 0x3b, 0x75, 0xc6, 0x3c, 0xb8, 0x8c, 0x41, 0x96, 0x1f, 0x81, 0x74, 0x4e, 0x9e, + 0x1d, 0x97, 0x7f, 0x80, 0x9a, 0xa4, 0x20, 0xbd, 0xd5, 0x6a, 0xc0, 0x4f, 0x7f, 0x07, 0x00, 0x00, + 0xff, 0xff, 0x3f, 0xe2, 0x1d, 0x20, 0x7e, 0x04, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -254,6 +323,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.ForwardRelayers) > 0 { + for iNdEx := len(m.ForwardRelayers) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ForwardRelayers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } if len(m.RegisteredRelayers) > 0 { for iNdEx := len(m.RegisteredRelayers) - 1; iNdEx >= 0; iNdEx-- { { @@ -373,6 +456,48 @@ func (m *RegisteredRelayerAddress) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } +func (m *ForwardRelayerAddress) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ForwardRelayerAddress) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ForwardRelayerAddress) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.PacketId != nil { + { + size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { offset -= sovGenesis(v) base := offset @@ -408,6 +533,12 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.ForwardRelayers) > 0 { + for _, e := range m.ForwardRelayers { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -445,6 +576,23 @@ func (m *RegisteredRelayerAddress) Size() (n int) { return n } +func (m *ForwardRelayerAddress) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + if m.PacketId != nil { + l = m.PacketId.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + func sovGenesis(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -582,6 +730,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ForwardRelayers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ForwardRelayers = append(m.ForwardRelayers, &ForwardRelayerAddress{}) + if err := m.ForwardRelayers[len(m.ForwardRelayers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) @@ -831,6 +1013,124 @@ func (m *RegisteredRelayerAddress) Unmarshal(dAtA []byte) error { } return nil } +func (m *ForwardRelayerAddress) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ForwardRelayerAddress: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ForwardRelayerAddress: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.PacketId == nil { + m.PacketId = &types.PacketId{} + } + if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipGenesis(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index c017af5d32f..15b33f67a33 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -29,6 +29,9 @@ const ( // FeeInEscrowPrefix is the key prefix for fee in escrow mapping FeeInEscrowPrefix = "feeInEscrow" + + // ForwardRelayerPrefix is the key prefix for forward relayer addresses stored in state for async acknowledgements + ForwardRelayerPrefix = "forwardRelayer" ) // FeeEnabledKey returns the key that stores a flag to determine if fee logic should @@ -42,6 +45,11 @@ func KeyRelayerAddress(address string) []byte { return []byte(fmt.Sprintf("%s/%s", RelayerAddressKeyPrefix, address)) } +// KeyForwardRelayerAddress returns the key for packetID -> forwardAddress mapping +func KeyForwardRelayerAddress(packetId *channeltypes.PacketId) []byte { + return []byte(fmt.Sprintf("%s/%s/%s/%d/", ForwardRelayerPrefix, packetId.PortId, packetId.ChannelId, packetId.Sequence)) +} + // KeyFeeInEscrow returns the key for escrowed fees func KeyFeeInEscrow(packetID *channeltypes.PacketId) []byte { return []byte(fmt.Sprintf("%s/%d", KeyFeeInEscrowChannelPrefix(packetID.PortId, packetID.ChannelId), packetID.Sequence)) diff --git a/modules/apps/29-fee/types/query.pb.go b/modules/apps/29-fee/types/query.pb.go index 6361527729d..421dec212f8 100644 --- a/modules/apps/29-fee/types/query.pb.go +++ b/modules/apps/29-fee/types/query.pb.go @@ -245,41 +245,41 @@ func init() { } var fileDescriptor_0638a8a78ca2503c = []byte{ - // 542 bytes of a gzipped FileDescriptorProto + // 544 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x41, 0x6f, 0x12, 0x41, - 0x14, 0xee, 0x50, 0x35, 0x3a, 0x78, 0x1a, 0x9a, 0x48, 0x88, 0xae, 0x14, 0xa3, 0x12, 0x23, 0x33, - 0x01, 0x0f, 0xb6, 0x1e, 0x3d, 0x34, 0x92, 0x78, 0xa8, 0x1c, 0x4d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0x89, 0xf3, + 0xf7, 0xe4, 0xe4, 0x32, 0xce, 0x59, 0x24, 0xa7, 0x9a, 0xbd, 0x5b, 0xde, 0x31, 0x6a, 0x7e, 0x0f, + 0x84, 0x7f, 0xba, 0x7c, 0xf5, 0xb9, 0x9e, 0x2d, 0x25, 0x6d, 0x65, 0x8c, 0x86, 0x1c, 0xf2, 0xfd, + 0xac, 0x76, 0xfa, 0xfc, 0xe5, 0xb7, 0xb9, 0x83, 0x2e, 0xe6, 0x0e, 0xfa, 0x35, 0x77, 0xd0, 0xe7, + 0x85, 0x53, 0xba, 0x58, 0x38, 0xa5, 0x9f, 0x0b, 0xa7, 0xf4, 0xfa, 0x49, 0x20, 0xf4, 0x68, 0xe6, + 0x51, 0x2e, 0x27, 0xcc, 0x7e, 0x3e, 0x84, 0xc7, 0xdb, 0x81, 0x64, 0xf1, 0x2e, 0x9b, 0x48, 0x7f, + 0x36, 0x06, 0x95, 0x9a, 0xee, 0xee, 0xb7, 0x8d, 0x6f, 0x7d, 0x1c, 0x81, 0xf2, 0xae, 0x25, 0x5f, + 0x91, 0xdd, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4f, 0xd8, 0x1b, 0x4b, 0x2b, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/modules/apps/29-fee/types/tx.pb.go b/modules/apps/29-fee/types/tx.pb.go index 382779cc86e..2c36575ecb0 100644 --- a/modules/apps/29-fee/types/tx.pb.go +++ b/modules/apps/29-fee/types/tx.pb.go @@ -281,44 +281,44 @@ func init() { func init() { proto.RegisterFile("ibc/applications/fee/v1/tx.proto", fileDescriptor_05c93128649f1b96) } var fileDescriptor_05c93128649f1b96 = []byte{ - // 585 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0x4f, 0x6f, 0xd3, 0x4c, - 0x10, 0xc6, 0xed, 0xa6, 0x6f, 0xd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4, 0xea, 0x4f, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x20, 0xf7, 0x8a, 0xce, 0x35, 0x05, 0x00, 0x00, + // 587 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0x4f, 0x4f, 0xdb, 0x4c, + 0x10, 0xc6, 0x6d, 0xc2, 0xcb, 0x0b, 0x5b, 0x54, 0x84, 0x81, 0x12, 0x4c, 0x64, 0x53, 0xab, 0xaa, + 0x72, 0x68, 0xec, 0x12, 0x8a, 0xaa, 0x72, 0x41, 0x04, 0x09, 0x35, 0x87, 0xa8, 0x91, 0x8f, 0xbd, + 0x44, 0xce, 0x7a, 0x62, 0xb6, 0x4d, 0xbc, 0xd6, 0xee, 0x26, 0xaa, 0xbf, 0x00, 0xea, 0x91, 0x5b, + 0x7b, 0xe4, 0xda, 0x6f, 0xc2, 0x91, 0x63, 0x4f, 0x51, 0x95, 0x5c, 0x7a, 0xce, 0x27, 0xa8, 0x6c, + 0x27, 0xc1, 0x21, 0x7f, 0x44, 0x7b, 0xdb, 0xdd, 0xf9, 0xcd, 0xb3, 0x33, 0xcf, 0xae, 0x06, 0x1d, + 0x90, 0x3a, 0xb6, 0x9c, 0x20, 0x68, 0x12, 0xec, 0x08, 0x42, 0x7d, 0x6e, 0x35, 0x00, 0xac, 0xce, + 0xa1, 0x25, 0xbe, 0x98, 0x01, 0xa3, 0x82, 0x2a, 0xbb, 0xa4, 0x8e, 0xcd, 0x34, 0x61, 0x36, 0x00, + 0xcc, 0xce, 0xa1, 0xba, 0xed, 0x51, 0x8f, 0xc6, 0x8c, 0x15, 0xad, 0x12, 0x5c, 0x7d, 0x3e, 0x4f, + 0x30, 0xca, 0x4a, 0x21, 0x98, 0x32, 0xb0, 0xf0, 0xa5, 0xe3, 0xfb, 0xd0, 0x8c, 0xc2, 0xc3, 0x65, + 0x82, 0x18, 0xdf, 0x65, 0xa4, 0x55, 0xb8, 0x67, 0x83, 0x47, 0xb8, 0x00, 0x76, 0x4e, 0xdb, 0xbe, + 0x00, 0x16, 0x38, 0x4c, 0x84, 0x67, 0xae, 0xcb, 0x80, 0x73, 0x25, 0x8b, 0xfe, 0x77, 0x92, 0x65, + 0x56, 0x3e, 0x90, 0xf3, 0x6b, 0xf6, 0x68, 0xab, 0xd8, 0x68, 0x1b, 0xa7, 0x12, 0x6a, 0x23, 0x6c, + 0x29, 0xc2, 0x4a, 0xfa, 0xa0, 0xab, 0xef, 0x87, 0x4e, 0xab, 0x79, 0x62, 0xcc, 0xa2, 0x0c, 0x7b, + 0x0b, 0x4f, 0xdf, 0x76, 0xb2, 0xfa, 0xf5, 0x46, 0x97, 0x7e, 0xdf, 0xe8, 0x92, 0x91, 0x47, 0x2f, + 0x17, 0x57, 0x66, 0x03, 0x0f, 0xa8, 0xcf, 0xc1, 0xb8, 0x5e, 0x42, 0x1b, 0x15, 0xee, 0x55, 0x9d, + 0xb0, 0xea, 0xe0, 0xcf, 0x20, 0x2e, 0x00, 0x94, 0x37, 0x28, 0xd3, 0x00, 0x88, 0x2b, 0x7e, 0x52, + 0xcc, 0x99, 0x73, 0xbc, 0x35, 0x2f, 0x00, 0x4a, 0xcb, 0xb7, 0x5d, 0x5d, 0xb2, 0x23, 0x5c, 0x39, + 0x45, 0x4f, 0x39, 0x6d, 0x33, 0x0c, 0xb5, 0x80, 0x32, 0x51, 0x23, 0xee, 0xb0, 0x97, 0xbd, 0x41, + 0x57, 0xdf, 0x49, 0x7a, 0x99, 0x8c, 0x1b, 0xf6, 0x7a, 0x72, 0x50, 0xa5, 0x4c, 0x94, 0x5d, 0xe5, + 0x3d, 0xda, 0x1c, 0x02, 0x43, 0x9f, 0x23, 0x8d, 0x4c, 0xac, 0x91, 0x1b, 0x74, 0xf5, 0xec, 0x84, + 0xc6, 0x3d, 0x62, 0xd8, 0x1b, 0xc9, 0xd9, 0x79, 0x72, 0x54, 0x76, 0x95, 0x67, 0x68,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 0xd9, 0xae, 0x9b, 0x98, 0xb6, 0x2c, 0x4c, 0x79, 0x8b, 0x72, 0x8b, 0xd4, + 0x71, 0xc1, 0xa3, 0x56, 0xe7, 0xc8, 0x6a, 0x51, 0xb7, 0xdd, 0x04, 0x1e, 0xcd, 0x31, 0x6e, 0x15, + 0xdf, 0x15, 0xa2, 0x11, 0x26, 0xc2, 0x00, 0x78, 0x7d, 0x25, 0x9e, 0x4f, 0x47, 0x7f, 0x02, 0x00, + 0x00, 0xff, 0xff, 0x35, 0x7a, 0x51, 0x8c, 0x38, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/ibc/applications/fee/v1/ack.proto b/proto/ibc/applications/fee/v1/ack.proto index bfc76e38385..626b4518f18 100644 --- a/proto/ibc/applications/fee/v1/ack.proto +++ b/proto/ibc/applications/fee/v1/ack.proto @@ -2,11 +2,11 @@ syntax = "proto3"; package ibc.applications.fee.v1; import "gogoproto/gogo.proto"; -option go_package = "github.com/cosmos/ibc-go/modules/apps/29-fee/types"; +option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; // IncentivizedAcknowledgement is the acknowledgement format to be used by applications wrapped in the fee middleware // It contains the raw acknowledgement bytes, as well as the forward relayer address message IncentivizedAcknowledgement { bytes result = 1; string forward_relayer_address = 2 [(gogoproto.moretags) = "yaml:\"forward_relayer_address\""]; -} \ No newline at end of file +} diff --git a/proto/ibc/applications/fee/v1/fee.proto b/proto/ibc/applications/fee/v1/fee.proto index eb21f44caec..1f5d9c0d05c 100644 --- a/proto/ibc/applications/fee/v1/fee.proto +++ b/proto/ibc/applications/fee/v1/fee.proto @@ -4,7 +4,7 @@ package ibc.applications.fee.v1; import "cosmos/base/v1beta1/coin.proto"; import "gogoproto/gogo.proto"; import "ibc/core/channel/v1/channel.proto"; -option go_package = "github.com/cosmos/ibc-go/modules/apps/29-fee/types"; +option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; // Fee implements the ics29 Fee interface // See Fee Payment Middleware spec: diff --git a/proto/ibc/applications/fee/v1/genesis.proto b/proto/ibc/applications/fee/v1/genesis.proto index cef33b501a0..632693e808c 100644 --- a/proto/ibc/applications/fee/v1/genesis.proto +++ b/proto/ibc/applications/fee/v1/genesis.proto @@ -3,23 +3,32 @@ syntax = "proto3"; package ibc.applications.fee.v1; import "gogoproto/gogo.proto"; import "ibc/applications/fee/v1/fee.proto"; -option go_package = "github.com/cosmos/ibc-go/modules/apps/29-fee/types"; +import "ibc/core/channel/v1/channel.proto"; + +option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; // GenesisState defines the fee middleware genesis state message GenesisState { repeated IdentifiedPacketFee identified_fees = 1 [(gogoproto.moretags) = "yaml:\"identified_fees\""]; repeated FeeEnabledChannel fee_enabled_channels = 2 [(gogoproto.moretags) = "yaml:\"fee_enabled_channels\""]; repeated RegisteredRelayerAddress registered_relayers = 3 [(gogoproto.moretags) = "yaml:\"registered_relayers\""]; + repeated ForwardRelayerAddress forward_relayers = 4 [(gogoproto.moretags) = "yaml:\"forward_relayers\""]; } -// Contains the PortID & ChannelID for a fee enabled channel +// FeeEnabledChannel contains the PortID & ChannelID for a fee enabled channel message FeeEnabledChannel { string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""]; } -// Contains the address and counterparty address for a specific relayer (for distributing fees) +// RegisteredRelayerAddress contains the address and counterparty address for a specific relayer (for distributing fees) message RegisteredRelayerAddress { string address = 1; string counterparty_address = 2 [(gogoproto.moretags) = "yaml:\"counterparty_address\""]; } + +// ForwardRelayerAddress contains the forward relayer address and packetId used for async acknowledgements +message ForwardRelayerAddress { + string address = 1; + ibc.core.channel.v1.PacketId packet_id = 2 [(gogoproto.moretags) = "yaml:\"packet_id\""]; +} diff --git a/proto/ibc/applications/fee/v1/query.proto b/proto/ibc/applications/fee/v1/query.proto index d8b258359ae..75a7d3c0491 100644 --- a/proto/ibc/applications/fee/v1/query.proto +++ b/proto/ibc/applications/fee/v1/query.proto @@ -3,13 +3,12 @@ syntax = "proto3"; package ibc.applications.fee.v1; import "gogoproto/gogo.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; import "ibc/applications/fee/v1/fee.proto"; import "google/api/annotations.proto"; import "ibc/core/channel/v1/channel.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; -option go_package = "github.com/cosmos/ibc-go/modules/apps/29-fee/types"; +option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; // Query provides defines the gRPC querier service. service Query { diff --git a/proto/ibc/applications/fee/v1/tx.proto b/proto/ibc/applications/fee/v1/tx.proto index 6313e94d0ef..07517f52a80 100644 --- a/proto/ibc/applications/fee/v1/tx.proto +++ b/proto/ibc/applications/fee/v1/tx.proto @@ -5,7 +5,7 @@ package ibc.applications.fee.v1; import "gogoproto/gogo.proto"; import "ibc/applications/fee/v1/fee.proto"; import "ibc/core/channel/v1/channel.proto"; -option go_package = "github.com/cosmos/ibc-go/modules/apps/29-fee/types"; +option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; // Msg defines the ibc/fee Msg service. service Msg { From 26731ceb27e0102fc706a2624187e1398668e835 Mon Sep 17 00:00:00 2001 From: Sean King Date: Tue, 18 Jan 2022 11:56:01 +0100 Subject: [PATCH 21/79] chore: making PacketId non nullable (#737) --- go.mod | 9 +- modules/apps/29-fee/ibc_module_test.go | 18 +-- modules/apps/29-fee/keeper/escrow_test.go | 22 ++-- modules/apps/29-fee/keeper/keeper.go | 12 +- modules/apps/29-fee/keeper/keeper_test.go | 2 +- modules/apps/29-fee/keeper/msg_server.go | 10 +- modules/apps/29-fee/keeper/msg_server_test.go | 2 +- modules/apps/29-fee/types/fee.pb.go | 101 ++++++++-------- modules/apps/29-fee/types/genesis.pb.go | 109 ++++++++---------- modules/apps/29-fee/types/genesis_test.go | 2 +- modules/apps/29-fee/types/keys.go | 4 +- modules/apps/29-fee/types/msgs.go | 2 +- modules/apps/29-fee/types/msgs_test.go | 4 +- modules/apps/29-fee/types/query.pb.go | 104 ++++++++--------- modules/core/04-channel/types/packet.go | 4 +- proto/ibc/applications/fee/v1/fee.proto | 2 +- proto/ibc/applications/fee/v1/genesis.proto | 2 +- proto/ibc/applications/fee/v1/query.proto | 2 +- 18 files changed, 194 insertions(+), 217 deletions(-) diff --git a/go.mod b/go.mod index 2a8ed9f82c6..3e5f606755d 100644 --- a/go.mod +++ b/go.mod @@ -27,12 +27,6 @@ require ( gopkg.in/yaml.v2 v2.4.0 ) -require ( - github.com/gin-gonic/gin v1.7.0 // indirect - github.com/opencontainers/image-spec v1.0.2 // indirect - github.com/opencontainers/runc v1.0.3 // indirect -) - require ( filippo.io/edwards25519 v1.0.0-beta.2 // indirect github.com/99designs/keyring v1.1.6 // indirect @@ -60,6 +54,7 @@ require ( github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect github.com/felixge/httpsnoop v1.0.1 // indirect github.com/fsnotify/fsnotify v1.5.1 // indirect + github.com/gin-gonic/gin v1.7.0 // indirect github.com/go-kit/kit v0.10.0 // indirect github.com/go-logfmt/logfmt v0.5.0 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect @@ -92,6 +87,8 @@ require ( github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.4.3 // indirect github.com/mtibben/percent v0.2.1 // indirect + github.com/opencontainers/image-spec v1.0.2 // indirect + github.com/opencontainers/runc v1.0.3 // indirect github.com/pelletier/go-toml v1.9.4 // indirect github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index 41234d7468a..a12b8ae972f 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -271,13 +271,13 @@ func (suite *FeeTestSuite) TestOnChanCloseInit() { { "success", func(suite *FeeTestSuite) { - packetId := channeltypes.PacketId{ - PortId: suite.path.EndpointA.ChannelConfig.PortID, - ChannelId: suite.path.EndpointA.ChannelID, - Sequence: 1, - } + packetId := channeltypes.NewPacketId( + suite.path.EndpointA.ChannelID, + suite.path.EndpointA.ChannelConfig.PortID, + 1, + ) refundAcc := suite.chainA.SenderAccount.GetAddress() - identifiedFee := types.NewIdentifiedPacketFee(&packetId, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) + identifiedFee := types.NewIdentifiedPacketFee(packetId, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) suite.Require().NoError(err) }, @@ -292,7 +292,7 @@ func (suite *FeeTestSuite) TestOnChanCloseInit() { Sequence: 1, } refundAcc := suite.chainA.SenderAccount.GetAddress() - identifiedFee := types.NewIdentifiedPacketFee(&packetId, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) + identifiedFee := types.NewIdentifiedPacketFee(packetId, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) suite.Require().NoError(err) @@ -357,7 +357,7 @@ func (suite *FeeTestSuite) TestOnChanCloseConfirm() { Sequence: 1, } refundAcc := suite.chainA.SenderAccount.GetAddress() - identifiedFee := types.NewIdentifiedPacketFee(&packetId, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) + identifiedFee := types.NewIdentifiedPacketFee(packetId, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) suite.Require().NoError(err) }, @@ -372,7 +372,7 @@ func (suite *FeeTestSuite) TestOnChanCloseConfirm() { Sequence: 1, } refundAcc := suite.chainA.SenderAccount.GetAddress() - identifiedFee := types.NewIdentifiedPacketFee(&packetId, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) + identifiedFee := types.NewIdentifiedPacketFee(packetId, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) suite.Require().NoError(err) diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go index 3b25f03d101..9c07c79589c 100644 --- a/modules/apps/29-fee/keeper/escrow_test.go +++ b/modules/apps/29-fee/keeper/escrow_test.go @@ -16,7 +16,7 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { ackFee sdk.Coins receiveFee sdk.Coins timeoutFee sdk.Coins - packetId *channeltypes.PacketId + packetId channeltypes.PacketId ) testCases := []struct { @@ -67,7 +67,7 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { receiveFee = defaultReceiveFee ackFee = defaultAckFee timeoutFee = defaultTimeoutFee - packetId = &channeltypes.PacketId{ChannelId: suite.path.EndpointA.ChannelID, PortId: transfertypes.PortID, Sequence: uint64(1)} + packetId = channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, transfertypes.PortID, uint64(1)) tc.malleate() fee := types.Fee{ @@ -140,7 +140,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() { reverseRelayer = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) forwardRelayer = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() - packetId := &channeltypes.PacketId{ChannelId: suite.path.EndpointA.ChannelID, PortId: transfertypes.PortID, Sequence: validSeq} + packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, transfertypes.PortID, validSeq) fee := types.Fee{ ReceiveFee: defaultReceiveFee, AckFee: defaultAckFee, @@ -199,11 +199,11 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { refundAcc := suite.chainA.SenderAccount.GetAddress() timeoutRelayer := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) - packetId := &channeltypes.PacketId{ - ChannelId: suite.path.EndpointA.ChannelID, - PortId: transfertypes.PortID, - Sequence: 1, - } + packetId := channeltypes.NewPacketId( + suite.path.EndpointA.ChannelID, + transfertypes.PortID, + 1, + ) fee := types.Fee{ ReceiveFee: defaultReceiveFee, @@ -254,7 +254,7 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { prevBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), refundAcc) for i := 0; i < 5; i++ { - packetId := &channeltypes.PacketId{ChannelId: "channel-0", PortId: transfertypes.PortID, Sequence: uint64(i)} + packetId := channeltypes.NewPacketId("channel-0", transfertypes.PortID, uint64(i)) fee := types.Fee{ ReceiveFee: defaultReceiveFee, AckFee: defaultAckFee, @@ -268,7 +268,7 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { } // send a packet over a different channel to ensure this fee is not refunded - packetId := &channeltypes.PacketId{ChannelId: "channel-1", PortId: transfertypes.PortID, Sequence: 1} + packetId := channeltypes.NewPacketId("channel-1", transfertypes.PortID, 1) fee := types.Fee{ ReceiveFee: defaultReceiveFee, AckFee: defaultAckFee, @@ -289,7 +289,7 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { suite.Require().Equal(prevBal, afterBal.Add(fee.ReceiveFee...).Add(fee.AckFee...).Add(fee.TimeoutFee...), "refund account not back to original balance after refunding all tokens") // create escrow and then change module account balance to cause error on refund - packetId = &channeltypes.PacketId{ChannelId: "channel-0", PortId: transfertypes.PortID, Sequence: uint64(6)} + packetId = channeltypes.NewPacketId("channel-0", transfertypes.PortID, uint64(6)) identifiedPacketFee = types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), &identifiedPacketFee) diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index 53f9c9c091b..8aa8862d947 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -175,13 +175,13 @@ func (k Keeper) GetAllRelayerAddresses(ctx sdk.Context) []*types.RegisteredRelay } // SetForwardRelayerAddress sets the forward relayer address during OnRecvPacket in case of async acknowledgement -func (k Keeper) SetForwardRelayerAddress(ctx sdk.Context, packetId *channeltypes.PacketId, address string) { +func (k Keeper) SetForwardRelayerAddress(ctx sdk.Context, packetId channeltypes.PacketId, address string) { store := ctx.KVStore(k.storeKey) store.Set(types.KeyForwardRelayerAddress(packetId), []byte(address)) } // GetForwardRelayerAddress gets forward relayer address for a particular packet -func (k Keeper) GetForwardRelayerAddress(ctx sdk.Context, packetId *channeltypes.PacketId) (string, bool) { +func (k Keeper) GetForwardRelayerAddress(ctx sdk.Context, packetId channeltypes.PacketId) (string, bool) { store := ctx.KVStore(k.storeKey) key := types.KeyForwardRelayerAddress(packetId) if !store.Has(key) { @@ -221,7 +221,7 @@ func (k Keeper) GetAllForwardRelayerAddresses(ctx sdk.Context) []*types.ForwardR } // Deletes the forwardRelayerAddr associated with the packetId -func (k Keeper) DeleteForwardRelayerAddress(ctx sdk.Context, packetId *channeltypes.PacketId) { +func (k Keeper) DeleteForwardRelayerAddress(ctx sdk.Context, packetId channeltypes.PacketId) { store := ctx.KVStore(k.storeKey) key := types.KeyForwardRelayerAddress(packetId) store.Delete(key) @@ -235,7 +235,7 @@ func (k Keeper) SetFeeInEscrow(ctx sdk.Context, fee *types.IdentifiedPacketFee) } // Gets a Fee for a given packet -func (k Keeper) GetFeeInEscrow(ctx sdk.Context, packetId *channeltypes.PacketId) (types.IdentifiedPacketFee, bool) { +func (k Keeper) GetFeeInEscrow(ctx sdk.Context, packetId channeltypes.PacketId) (types.IdentifiedPacketFee, bool) { store := ctx.KVStore(k.storeKey) key := types.KeyFeeInEscrow(packetId) bz := store.Get(key) @@ -263,14 +263,14 @@ func (k Keeper) IterateChannelFeesInEscrow(ctx sdk.Context, portID, channelID st } // Deletes the fee associated with the given packetId -func (k Keeper) DeleteFeeInEscrow(ctx sdk.Context, packetId *channeltypes.PacketId) { +func (k Keeper) DeleteFeeInEscrow(ctx sdk.Context, packetId channeltypes.PacketId) { store := ctx.KVStore(k.storeKey) key := types.KeyFeeInEscrow(packetId) store.Delete(key) } // HasFeeInEscrow returns true if there is a Fee still to be escrowed for a given packet -func (k Keeper) HasFeeInEscrow(ctx sdk.Context, packetId *channeltypes.PacketId) bool { +func (k Keeper) HasFeeInEscrow(ctx sdk.Context, packetId channeltypes.PacketId) bool { store := ctx.KVStore(k.storeKey) key := types.KeyFeeInEscrow(packetId) diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index 267190fa080..ad19cfac072 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -101,7 +101,7 @@ func (suite *KeeperTestSuite) TestGetAllIdentifiedPacketFees() { // escrow a fee refundAcc := suite.chainA.SenderAccount.GetAddress() - packetId := &channeltypes.PacketId{ChannelId: suite.path.EndpointA.ChannelID, PortId: transfertypes.PortID, Sequence: uint64(1)} + packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, transfertypes.PortID, uint64(1)) fee := types.Fee{defaultAckFee, defaultReceiveFee, defaultTimeoutFee} identifiedPacketFee := &types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} diff --git a/modules/apps/29-fee/keeper/msg_server.go b/modules/apps/29-fee/keeper/msg_server.go index dec2f27e928..d8eda8b3fdd 100644 --- a/modules/apps/29-fee/keeper/msg_server.go +++ b/modules/apps/29-fee/keeper/msg_server.go @@ -37,11 +37,11 @@ func (k Keeper) PayPacketFee(goCtx context.Context, msg *types.MsgPayPacketFee) return nil, channeltypes.ErrSequenceSendNotFound } - packetId := &channeltypes.PacketId{ - PortId: msg.SourcePortId, - ChannelId: msg.SourceChannelId, - Sequence: sequence, - } + packetId := channeltypes.NewPacketId( + msg.SourceChannelId, + msg.SourcePortId, + sequence, + ) identifiedPacket := types.NewIdentifiedPacketFee(packetId, msg.Fee, msg.Signer, msg.Relayers) err := k.EscrowPacketFee(ctx, identifiedPacket) diff --git a/modules/apps/29-fee/keeper/msg_server_test.go b/modules/apps/29-fee/keeper/msg_server_test.go index 0664b4e7fd9..26a62830035 100644 --- a/modules/apps/29-fee/keeper/msg_server_test.go +++ b/modules/apps/29-fee/keeper/msg_server_test.go @@ -118,7 +118,7 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() { seq, _ := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetNextSequenceSend(ctxA, suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) // build fee - packetId := &channeltypes.PacketId{ChannelId: channelID, PortId: suite.path.EndpointA.ChannelConfig.PortID, Sequence: seq} + packetId := channeltypes.NewPacketId(channelID, suite.path.EndpointA.ChannelConfig.PortID, seq) identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} tc.malleate() diff --git a/modules/apps/29-fee/types/fee.pb.go b/modules/apps/29-fee/types/fee.pb.go index 0f50271f0f0..1db63e62f8a 100644 --- a/modules/apps/29-fee/types/fee.pb.go +++ b/modules/apps/29-fee/types/fee.pb.go @@ -94,10 +94,10 @@ func (m *Fee) GetTimeoutFee() github_com_cosmos_cosmos_sdk_types.Coins { // the refund address to which any unused funds are refunded, // and an optional list of relayers that are permitted to receive the fee. type IdentifiedPacketFee struct { - PacketId *types1.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id,omitempty" yaml:"packet_id"` - Fee Fee `protobuf:"bytes,2,opt,name=fee,proto3" json:"fee"` - RefundAddress string `protobuf:"bytes,3,opt,name=refund_address,json=refundAddress,proto3" json:"refund_address,omitempty" yaml:"refund_address"` - Relayers []string `protobuf:"bytes,4,rep,name=relayers,proto3" json:"relayers,omitempty"` + PacketId types1.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id" yaml:"packet_id"` + Fee Fee `protobuf:"bytes,2,opt,name=fee,proto3" json:"fee"` + RefundAddress string `protobuf:"bytes,3,opt,name=refund_address,json=refundAddress,proto3" json:"refund_address,omitempty" yaml:"refund_address"` + Relayers []string `protobuf:"bytes,4,rep,name=relayers,proto3" json:"relayers,omitempty"` } func (m *IdentifiedPacketFee) Reset() { *m = IdentifiedPacketFee{} } @@ -133,11 +133,11 @@ func (m *IdentifiedPacketFee) XXX_DiscardUnknown() { var xxx_messageInfo_IdentifiedPacketFee proto.InternalMessageInfo -func (m *IdentifiedPacketFee) GetPacketId() *types1.PacketId { +func (m *IdentifiedPacketFee) GetPacketId() types1.PacketId { if m != nil { return m.PacketId } - return nil + return types1.PacketId{} } func (m *IdentifiedPacketFee) GetFee() Fee { @@ -169,38 +169,38 @@ func init() { func init() { proto.RegisterFile("ibc/applications/fee/v1/fee.proto", fileDescriptor_cb3319f1af2a53e5) } var fileDescriptor_cb3319f1af2a53e5 = []byte{ - // 483 bytes of a gzipped FileDescriptorProto + // 482 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x31, 0x8f, 0xd3, 0x30, - 0x14, 0xc7, 0x1b, 0x72, 0x3a, 0xae, 0xae, 0x38, 0xa1, 0x70, 0x88, 0x5e, 0x05, 0x49, 0xc9, 0x94, - 0xa5, 0xb6, 0xda, 0x83, 0x01, 0x26, 0x08, 0x52, 0xa5, 0x9b, 0x38, 0x65, 0x64, 0xa9, 0x1c, 0xe7, - 0xb5, 0x67, 0x35, 0x89, 0xa3, 0x38, 0x8d, 0xd4, 0x95, 0x85, 0x95, 0xcf, 0x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a, 0xdf, 0x37, 0x6e, 0xeb, 0x7e, 0xe3, 0xb6, - 0x7e, 0x6e, 0xdc, 0xd6, 0x97, 0xb7, 0xff, 0x76, 0x93, 0xc7, 0x6c, 0x30, 0x13, 0xa4, 0xbe, 0x22, - 0x99, 0x48, 0x16, 0x29, 0x48, 0xf5, 0xad, 0x24, 0x19, 0xbd, 0x1b, 0xa8, 0x1f, 0xd5, 0x34, 0x38, - 0x3e, 0x6d, 0xe6, 0xfb, 0xea, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0b, 0xc2, 0x60, 0x3e, 0x76, - 0x03, 0x00, 0x00, + 0x14, 0xc7, 0x1b, 0x72, 0x3a, 0xee, 0x5c, 0x71, 0x42, 0x01, 0x44, 0xae, 0x82, 0xb4, 0x64, 0xca, + 0x52, 0x5b, 0xed, 0xc1, 0x00, 0x13, 0x04, 0xa9, 0xd2, 0x4d, 0xa0, 0x88, 0x89, 0xa5, 0x72, 0xec, + 0xd7, 0x9e, 0xd5, 0x24, 0x8e, 0xe2, 0x34, 0x52, 0x57, 0x16, 0x56, 0x3e, 0x07, 0x9f, 0xe4, 0xc6, + 0x1b, 0x99, 0x0a, 0x6a, 0xbf, 0xc1, 0x7d, 0x01, 0x90, 0x63, 0xf7, 0x54, 0x09, 0x21, 0xd4, 0xc9, + 0xf6, 0xf3, 0xfb, 0xbf, 0xdf, 0x7b, 0xcf, 0xcf, 0xe8, 0x85, 0x48, 0x19, 0xa1, 0x65, 0x99, 0x09, + 0x46, 0x6b, 0x21, 0x0b, 0x45, 0x66, 0x00, 0xa4, 0x19, 0xe9, 0x05, 0x97, 0x95, 0xac, 0xa5, 0xf7, + 0x54, 0xa4, 0x0c, 0xef, 0xbb, 0x60, 0x7d, 0xd7, 0x8c, 0x7a, 0x01, 0x93, 0x2a, 0x97, 0x8a, 0xa4, + 0x54, 0x69, 0x49, 0x0a, 0x35, 0x1d, 0x11, 0x26, 0x45, 0x61, 0x84, 0xbd, 0xc7, 0x73, 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11, 0x36, 0x92, 0x4b, 0x1e, 0xfb, 0x36, 0xbb, 0x87, 0x26, 0xbb, 0x3b, + 0x75, 0x98, 0x9c, 0x94, 0xd6, 0xc7, 0x7b, 0x89, 0x5c, 0xd3, 0x66, 0x1d, 0xef, 0x19, 0xfe, 0xc7, + 0xdc, 0xe1, 0x09, 0x40, 0x7c, 0xa4, 0xc3, 0x25, 0xda, 0xdd, 0x7b, 0x8b, 0xce, 0x2a, 0x98, 0x2d, + 0x0b, 0x3e, 0xa5, 0x9c, 0x57, 0xa0, 0x94, 0xef, 0x0e, 0x9c, 0xe8, 0x34, 0x3e, 0xbf, 0x5d, 0xf7, + 0x9f, 0xec, 0x06, 0x61, 0xff, 0x3e, 0x4c, 0x1e, 0x18, 0xc3, 0x3b, 0x73, 0xf6, 0x7a, 0xe8, 0xa4, + 0x82, 0x8c, 0xae, 0xa0, 0x52, 0xfe, 0xd1, 0xc0, 0x8d, 0x4e, 0x93, 0xbb, 0x73, 0xfc, 0xe1, 0x7a, + 0x13, 0x38, 0x37, 0x9b, 0xc0, 0xf9, 0xb5, 0x09, 0x9c, 0x6f, 0xdb, 0xa0, 0x73, 0xb3, 0x0d, 0x3a, + 0x3f, 0xb6, 0x41, 0xe7, 0xf3, 0xab, 0xbf, 0x3b, 0x2a, 0x52, 0x36, 0x9c, 0x4b, 0xd2, 0x5c, 0x90, + 0x5c, 0xf2, 0x65, 0x06, 0x4a, 0x7f, 0x2d, 0x45, 0xc6, 0xaf, 0x87, 0xfa, 0x57, 0xb5, 0x4d, 0x4e, + 0x8f, 0xdb, 0x19, 0xbf, 0xf8, 0x13, 0x00, 0x00, 0xff, 0xff, 0x76, 0xdd, 0x8f, 0x88, 0x7a, 0x03, + 0x00, 0x00, } func (m *Fee) Marshal() (dAtA []byte, err error) { @@ -314,18 +314,16 @@ func (m *IdentifiedPacketFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x12 - if m.PacketId != nil { - { - size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintFee(dAtA, i, uint64(size)) + { + size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0xa + i -= size + i = encodeVarintFee(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -373,10 +371,8 @@ func (m *IdentifiedPacketFee) Size() (n int) { } var l int _ = l - if m.PacketId != nil { - l = m.PacketId.Size() - n += 1 + l + sovFee(uint64(l)) - } + l = m.PacketId.Size() + n += 1 + l + sovFee(uint64(l)) l = m.Fee.Size() n += 1 + l + sovFee(uint64(l)) l = len(m.RefundAddress) @@ -608,9 +604,6 @@ func (m *IdentifiedPacketFee) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.PacketId == nil { - m.PacketId = &types1.PacketId{} - } if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/modules/apps/29-fee/types/genesis.pb.go b/modules/apps/29-fee/types/genesis.pb.go index c1c6750597f..3c04f55b305 100644 --- a/modules/apps/29-fee/types/genesis.pb.go +++ b/modules/apps/29-fee/types/genesis.pb.go @@ -201,8 +201,8 @@ func (m *RegisteredRelayerAddress) GetCounterpartyAddress() string { // ForwardRelayerAddress contains the forward relayer address and packetId used for async acknowledgements type ForwardRelayerAddress struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - PacketId *types.PacketId `protobuf:"bytes,2,opt,name=packet_id,json=packetId,proto3" json:"packet_id,omitempty" yaml:"packet_id"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + PacketId types.PacketId `protobuf:"bytes,2,opt,name=packet_id,json=packetId,proto3" json:"packet_id" yaml:"packet_id"` } func (m *ForwardRelayerAddress) Reset() { *m = ForwardRelayerAddress{} } @@ -245,11 +245,11 @@ func (m *ForwardRelayerAddress) GetAddress() string { return "" } -func (m *ForwardRelayerAddress) GetPacketId() *types.PacketId { +func (m *ForwardRelayerAddress) GetPacketId() types.PacketId { if m != nil { return m.PacketId } - return nil + return types.PacketId{} } func init() { @@ -264,43 +264,43 @@ func init() { } var fileDescriptor_7191992e856dff95 = []byte{ - // 570 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x54, 0x4f, 0x6f, 0xd4, 0x3e, - 0x10, 0x6d, 0xda, 0x9f, 0xda, 0x5f, 0x5d, 0xd4, 0x3f, 0xee, 0x96, 0xae, 0xb6, 0x22, 0x29, 0x96, - 0x90, 0x2a, 0xa0, 0x89, 0xb6, 0x85, 0x03, 0xdc, 0x58, 0x44, 0xd1, 0x9e, 0xa8, 0xcc, 0x8d, 0xcb, - 0x2a, 0x7f, 0x26, 0xa9, 0x45, 0x36, 0x0e, 0xb6, 0x1b, 0xb4, 0x07, 0x2e, 0x70, 0xe1, 0xc8, 0xc7, - 0xe2, 0xd8, 0x23, 0xa7, 0x08, 0x75, 0xbf, 0x41, 0xee, 0x48, 0x28, 0x71, 0xd2, 0x2e, 0xcb, 0x86, - 0xdb, 0xd8, 0xf3, 0xde, 0xbc, 0xe7, 0xb1, 0xc7, 0xe8, 0x01, 0xf3, 0x7c, 0xc7, 0x4d, 0xd3, 0x98, - 0xf9, 0xae, 0x62, 0x3c, 0x91, 0x4e, 0x08, 0xe0, 0x64, 0x7d, 0x27, 0x82, 0x04, 0x24, 0x93, 0x76, - 0x2a, 0xb8, 0xe2, 0x78, 0x9f, 0x79, 0xbe, 0x3d, 0x0b, 0xb3, 0x43, 0x00, 0x3b, 0xeb, 0xf7, 0x3a, - 0x11, 0x8f, 0x78, 0x85, 0x71, 0xca, 0x48, 0xc3, 0x7b, 0xf7, 0xdb, 0xaa, 0x96, 0xac, 0x19, 0x88, - 0xcf, 0x05, 0x38, 0xfe, 0x85, 0x9b, 0x24, 0x10, 0x97, 0xe9, 0x3a, 0xd4, 0x10, 0xf2, 0x6b, 0x05, - 0xdd, 0x79, 0xad, 0x6d, 0xbc, 0x55, 0xae, 0x02, 0xfc, 0x01, 0x6d, 0xb1, 0x00, 0x12, 0xc5, 0x42, - 0x06, 0xc1, 0x28, 0x04, 0x90, 0x5d, 0xe3, 0x70, 0xe5, 0x68, 0xe3, 0xe4, 0xb1, 0xdd, 0xe2, 0xcf, - 0x1e, 0xde, 0xe0, 0xcf, 0x5d, 0xff, 0x3d, 0xa8, 0x33, 0x80, 0x41, 0xaf, 0xc8, 0xad, 0xbb, 0x13, - 0x77, 0x1c, 0x3f, 0x27, 0x73, 0xe5, 0x08, 0xdd, 0xbc, 0xdd, 0x39, 0x03, 0x90, 0xf8, 0x13, 0xea, - 0x84, 0x00, 0x23, 0x48, 0x5c, 0x2f, 0x86, 0x60, 0x54, 0x1b, 0x94, 0xdd, 0xe5, 0x4a, 0xf7, 0x61, - 0xab, 0xee, 0x19, 0xc0, 0x2b, 0xcd, 0x79, 0xa9, 0x29, 0x03, 0xab, 0xc8, 0xad, 0x03, 0xad, 0xba, - 0xa8, 0x22, 0xa1, 0x38, 0x9c, 0xe7, 0x48, 0xfc, 0xd9, 0x40, 0xbb, 0x02, 0x22, 0x26, 0x15, 0x08, - 0x08, 0x46, 0x02, 0x62, 0x77, 0x02, 0x42, 0x76, 0x57, 0x2a, 0xf9, 0x7e, 0xab, 0x3c, 0xbd, 0xe1, - 0x50, 0x4d, 0x79, 0x11, 0x04, 0x02, 0xa4, 0x1c, 0x98, 0x45, 0x6e, 0xf5, 0xb4, 0x8b, 0x05, 0x75, - 0x09, 0xc5, 0x62, 0x9e, 0x29, 0x71, 0x86, 0xb6, 0x43, 0x2e, 0x3e, 0xba, 0x62, 0xc6, 0xc0, 0x7f, - 0x95, 0x01, 0xbb, 0xfd, 0xfc, 0x9a, 0x30, 0xa7, 0x7e, 0x50, 0xe4, 0xd6, 0x7e, 0xdd, 0x83, 0xb9, - 0x8a, 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1, 0xe3, 0x73, 0x39, 0xe6, 0xd2, 0x61, 0x9e, 0x7f, - 0x1c, 0x71, 0x27, 0x3b, 0x75, 0xc6, 0x3c, 0xb8, 0x8c, 0x41, 0x96, 0x1f, 0x81, 0x74, 0x4e, 0x9e, - 0x1d, 0x97, 0x7f, 0x80, 0x9a, 0xa4, 0x20, 0xbd, 0xd5, 0x6a, 0xc0, 0x4f, 0x7f, 0x07, 0x00, 0x00, - 0xff, 0xff, 0x3f, 0xe2, 0x1d, 0x20, 0x7e, 0x04, 0x00, 0x00, + // 572 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x54, 0xbf, 0x6f, 0xd4, 0x30, + 0x18, 0xbd, 0xb4, 0xa8, 0xa5, 0x2e, 0xea, 0x0f, 0xb7, 0xa5, 0xd1, 0x55, 0x24, 0xc5, 0x12, 0x52, + 0x05, 0x34, 0xd1, 0xb5, 0x30, 0xc0, 0xc6, 0x21, 0x8a, 0x6e, 0x02, 0x19, 0x26, 0x96, 0x53, 0x2e, + 0xf9, 0x92, 0x5a, 0xe4, 0xe2, 0x60, 0xbb, 0x41, 0x37, 0xb0, 0xb0, 0xc0, 0xc8, 0x9f, 0xd5, 0xb1, + 0x23, 0x53, 0x84, 0xda, 0xff, 0x20, 0x3b, 0x12, 0x4a, 0x9c, 0xb4, 0xc7, 0x71, 0x61, 0xfb, 0x62, + 0xbf, 0xf7, 0xbd, 0xe7, 0xe7, 0x7c, 0x46, 0x0f, 0xd8, 0xc8, 0x77, 0xbd, 0x34, 0x8d, 0x99, 0xef, + 0x29, 0xc6, 0x13, 0xe9, 0x86, 0x00, 0x6e, 0xd6, 0x73, 0x23, 0x48, 0x40, 0x32, 0xe9, 0xa4, 0x82, + 0x2b, 0x8e, 0x77, 0xd9, 0xc8, 0x77, 0xa6, 0x61, 0x4e, 0x08, 0xe0, 0x64, 0xbd, 0xee, 0x76, 0xc4, + 0x23, 0x5e, 0x61, 0xdc, 0xb2, 0xd2, 0xf0, 0xee, 0xfd, 0xb6, 0xae, 0x25, 0x6b, 0x0a, 0xe2, 0x73, + 0x01, 0xae, 0x7f, 0xea, 0x25, 0x09, 0xc4, 0xe5, 0x76, 0x5d, 0x6a, 0x08, 0xf9, 0xbd, 0x88, 0xee, + 0xbc, 0xd6, 0x36, 0xde, 0x29, 0x4f, 0x01, 0xfe, 0x84, 0xd6, 0x59, 0x00, 0x89, 0x62, 0x21, 0x83, + 0x60, 0x18, 0x02, 0x48, 0xd3, 0xd8, 0x5f, 0x3c, 0x58, 0x3d, 0x7a, 0xec, 0xb4, 0xf8, 0x73, 0x06, + 0xd7, 0xf8, 0xb7, 0x9e, 0xff, 0x11, 0xd4, 0x09, 0x40, 0xbf, 0x5b, 0xe4, 0xf6, 0xdd, 0x89, 0x37, + 0x8e, 0x9f, 0x93, 0x99, 0x76, 0x84, 0xae, 0xdd, 0xac, 0x9c, 0x00, 0x48, 0xfc, 0x05, 0x6d, 0x87, + 0x00, 0x43, 0x48, 0xbc, 0x51, 0x0c, 0xc1, 0xb0, 0x36, 0x28, 0xcd, 0x85, 0x4a, 0xf7, 0x61, 0xab, + 0xee, 0x09, 0xc0, 0x2b, 0xcd, 0x79, 0xa9, 0x29, 0x7d, 0xbb, 0xc8, 0xed, 0x3d, 0xad, 0x3a, 0xaf, + 0x23, 0xa1, 0x38, 0x9c, 0xe5, 0x48, 0xfc, 0xd5, 0x40, 0x5b, 0x02, 0x22, 0x26, 0x15, 0x08, 0x08, + 0x86, 0x02, 0x62, 0x6f, 0x02, 0x42, 0x9a, 0x8b, 0x95, 0x7c, 0xaf, 0x55, 0x9e, 0x5e, 0x73, 0xa8, + 0xa6, 0xbc, 0x08, 0x02, 0x01, 0x52, 0xf6, 0xad, 0x22, 0xb7, 0xbb, 0xda, 0xc5, 0x9c, 0xbe, 0x84, + 0x62, 0x31, 0xcb, 0x94, 0x38, 0x43, 0x1b, 0x21, 0x17, 0x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x96, + 0xf1, 0xeb, 0xd2, 0x32, 0x7e, 0x5c, 0x59, 0x9d, 0x8b, 0x2b, 0xab, 0xf3, 0xf3, 0xca, 0xea, 0x7c, + 0x78, 0x1a, 0x31, 0x75, 0x7a, 0x36, 0x72, 0x7c, 0x3e, 0x76, 0x7d, 0x2e, 0xc7, 0x5c, 0xba, 0x6c, + 0xe4, 0x1f, 0x46, 0xdc, 0xcd, 0x8e, 0xdd, 0x31, 0x0f, 0xce, 0x62, 0x90, 0xe5, 0x63, 0x20, 0xdd, + 0xa3, 0x67, 0x87, 0xe5, 0x3b, 0xa0, 0x26, 0x29, 0xc8, 0xd1, 0x52, 0x35, 0xe4, 0xc7, 0x7f, 0x02, + 0x00, 0x00, 0xff, 0xff, 0x5f, 0x63, 0x48, 0xc9, 0x82, 0x04, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -476,18 +476,16 @@ func (m *ForwardRelayerAddress) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.PacketId != nil { - { - size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) + { + size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0x12 + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 if len(m.Address) > 0 { i -= len(m.Address) copy(dAtA[i:], m.Address) @@ -586,10 +584,8 @@ func (m *ForwardRelayerAddress) Size() (n int) { if l > 0 { n += 1 + l + sovGenesis(uint64(l)) } - if m.PacketId != nil { - l = m.PacketId.Size() - n += 1 + l + sovGenesis(uint64(l)) - } + l = m.PacketId.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -1103,9 +1099,6 @@ func (m *ForwardRelayerAddress) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.PacketId == nil { - m.PacketId = &types.PacketId{} - } if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/modules/apps/29-fee/types/genesis_test.go b/modules/apps/29-fee/types/genesis_test.go index 190edaab220..94e2824a265 100644 --- a/modules/apps/29-fee/types/genesis_test.go +++ b/modules/apps/29-fee/types/genesis_test.go @@ -23,7 +23,7 @@ var ( func TestValidateGenesis(t *testing.T) { var ( - packetId *channeltypes.PacketId + packetId channeltypes.PacketId fee types.Fee refundAcc string sender string diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index 15b33f67a33..2f26b859afc 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -46,12 +46,12 @@ func KeyRelayerAddress(address string) []byte { } // KeyForwardRelayerAddress returns the key for packetID -> forwardAddress mapping -func KeyForwardRelayerAddress(packetId *channeltypes.PacketId) []byte { +func KeyForwardRelayerAddress(packetId channeltypes.PacketId) []byte { return []byte(fmt.Sprintf("%s/%s/%s/%d/", ForwardRelayerPrefix, packetId.PortId, packetId.ChannelId, packetId.Sequence)) } // KeyFeeInEscrow returns the key for escrowed fees -func KeyFeeInEscrow(packetID *channeltypes.PacketId) []byte { +func KeyFeeInEscrow(packetID channeltypes.PacketId) []byte { return []byte(fmt.Sprintf("%s/%d", KeyFeeInEscrowChannelPrefix(packetID.PortId, packetID.ChannelId), packetID.Sequence)) } diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index 926da90de4e..7138706cf80 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -135,7 +135,7 @@ func (msg MsgPayPacketFeeAsync) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{signer} } -func NewIdentifiedPacketFee(packetId *channeltypes.PacketId, fee Fee, refundAddr string, relayers []string) *IdentifiedPacketFee { +func NewIdentifiedPacketFee(packetId channeltypes.PacketId, fee Fee, refundAddr string, relayers []string) *IdentifiedPacketFee { return &IdentifiedPacketFee{ PacketId: packetId, Fee: fee, diff --git a/modules/apps/29-fee/types/msgs_test.go b/modules/apps/29-fee/types/msgs_test.go index e6386dc91d4..8671694bca0 100644 --- a/modules/apps/29-fee/types/msgs_test.go +++ b/modules/apps/29-fee/types/msgs_test.go @@ -319,7 +319,7 @@ func TestMsgPayPacketFeeAsyncValidation(t *testing.T) { tc.malleate() fee = Fee{receiveFee, ackFee, timeoutFee} - packetId := &channeltypes.PacketId{ChannelId: channelID, PortId: portID, Sequence: seq} + packetId := channeltypes.NewPacketId(channelID, portID, seq) identifiedPacketFee := IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: signer, Relayers: relayers} msg := NewMsgPayPacketFeeAsync(identifiedPacketFee) @@ -341,7 +341,7 @@ func TestPayPacketFeeAsyncGetSigners(t *testing.T) { portID := validPortID fee := Fee{validCoins, validCoins, validCoins} seq := uint64(1) - packetId := &channeltypes.PacketId{ChannelId: channelID, PortId: portID, Sequence: seq} + packetId := channeltypes.NewPacketId(channelID, portID, seq) identifiedPacketFee := IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: addr.String(), Relayers: nil} msg := NewMsgPayPacketFeeAsync(identifiedPacketFee) diff --git a/modules/apps/29-fee/types/query.pb.go b/modules/apps/29-fee/types/query.pb.go index 421dec212f8..3bbbbee7b17 100644 --- a/modules/apps/29-fee/types/query.pb.go +++ b/modules/apps/29-fee/types/query.pb.go @@ -135,7 +135,7 @@ func (m *QueryIncentivizedPacketsResponse) GetIncentivizedPackets() []*Identifie // QueryIncentivizedPacketRequest is the request type for querying for all incentivized packets type QueryIncentivizedPacketRequest struct { // PacketID - PacketId *types.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id,omitempty"` + PacketId types.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id"` // Height to query at QueryHeight uint64 `protobuf:"varint,2,opt,name=query_height,json=queryHeight,proto3" json:"query_height,omitempty"` } @@ -173,11 +173,11 @@ func (m *QueryIncentivizedPacketRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryIncentivizedPacketRequest proto.InternalMessageInfo -func (m *QueryIncentivizedPacketRequest) GetPacketId() *types.PacketId { +func (m *QueryIncentivizedPacketRequest) GetPacketId() types.PacketId { if m != nil { return m.PacketId } - return nil + return types.PacketId{} } func (m *QueryIncentivizedPacketRequest) GetQueryHeight() uint64 { @@ -245,41 +245,42 @@ func init() { } var fileDescriptor_0638a8a78ca2503c = []byte{ - // 544 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x41, 0x6f, 0x12, 0x41, - 0x14, 0x66, 0xa8, 0x1a, 0x1d, 0x3c, 0x0d, 0x4d, 0x24, 0x44, 0x57, 0x8a, 0x51, 0x89, 0x91, 0x99, - 0x40, 0x63, 0x6c, 0x3d, 0x7a, 0x68, 0xe4, 0x64, 0xe5, 0x68, 0x62, 0xc8, 0xee, 0xec, 0x63, 0x99, - 0x08, 0x3b, 0x5b, 0x66, 0xd8, 0xa4, 0xd5, 0x46, 0x53, 0xaf, 0x3d, 0x98, 0xf8, 0x6b, 0xfc, 0x07, - 0x1e, 0x1b, 0xbd, 0x78, 0x34, 0xe0, 0x0f, 0x31, 0xb3, 0x3b, 0x8b, 0x9b, 0xc0, 0xc6, 0xe2, 0x6d, - 0x78, 0xef, 0xfb, 0xde, 0xf7, 0xf1, 0xbd, 0x99, 0xc5, 0xf7, 0x84, 0xc7, 0x99, 0x1b, 0x45, 0x63, - 0xc1, 0x5d, 0x2d, 0x64, 0xa8, 0xd8, 0x10, 0x80, 0xc5, 0x1d, 0x76, 0x34, 0x83, 0xe9, 0x31, 0x8d, - 0xa6, 0x52, 0x4b, 0x72, 0x4b, 0x78, 0x9c, 0xe6, 0x41, 0x74, 0x08, 0x40, 0xe3, 0x4e, 0x7d, 0x3b, - 0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0xf4, 0x68, 0xe6, - 0x51, 0x2e, 0x27, 0xcc, 0x7e, 0x3e, 0x84, 0xc7, 0xdb, 0x81, 0x64, 0xf1, 0x2e, 0x9b, 0x48, 0x7f, - 0x36, 0x06, 0x95, 0x9a, 0xee, 0xee, 0xb7, 0x8d, 0x6f, 0x7d, 0x1c, 0x81, 0xf2, 0xae, 0x25, 0x5f, - 0x91, 0xdd, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4f, 0xd8, 0x1b, 0x4b, 0x2b, 0x05, 0x00, 0x00, + // 554 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xc1, 0x6b, 0x13, 0x4f, + 0x14, 0xce, 0xa4, 0xfd, 0xfd, 0xd0, 0x89, 0xa7, 0x49, 0xc1, 0x10, 0x74, 0x9b, 0x46, 0xd4, 0x20, + 0x66, 0x86, 0xa4, 0x88, 0xed, 0x4d, 0x7a, 0x28, 0xe6, 0x64, 0xcd, 0x51, 0x90, 0xb0, 0x3b, 0xfb, + 0xb2, 0x19, 0x4c, 0x76, 0xb6, 0x99, 0xc9, 0x42, 0xab, 0x05, 0xa9, 0x78, 0xeb, 0x41, 0xf0, 0xaf, + 0xf1, 0x3f, 0xe8, 0xb1, 0xe8, 0xc5, 0x93, 0x48, 0xe2, 0x1f, 0x22, 0xb3, 0x3b, 0x89, 0x0b, 0xc9, + 0x62, 0xe3, 0x6d, 0xf7, 0xbd, 0xef, 0x7b, 0xdf, 0xb7, 0xdf, 0x9b, 0x59, 0x7c, 0x4f, 0x78, 0x9c, + 0xb9, 0x51, 0x34, 0x14, 0xdc, 0xd5, 0x42, 0x86, 0x8a, 0xf5, 0x01, 0x58, 0xdc, 0x62, 0xc7, 0x13, + 0x18, 0x9f, 0xd0, 0x68, 0x2c, 0xb5, 0x24, 0xb7, 0x85, 0xc7, 0x69, 0x16, 0x44, 0xfb, 0x00, 0x34, + 0x6e, 0x55, 0xb7, 0x02, 0x19, 0xc8, 0x04, 0xc3, 0xcc, 0x53, 0x0a, 0xaf, 0xee, 0xe4, 0xcd, 0x34, + 0xac, 0x14, 0x72, 0x27, 0x90, 0x32, 0x18, 0x02, 0x73, 0x23, 0xc1, 0xdc, 0x30, 0x94, 0xda, 0xce, + 0xcd, 0x0c, 0xe0, 0x72, 0x0c, 0x8c, 0x0f, 0xdc, 0x30, 0x84, 0xa1, 0x21, 0xdb, 0x47, 0x0b, 0x79, + 0xc4, 0xa5, 0x1a, 0x49, 0xc5, 0x3c, 0x57, 0x41, 0xea, 0x95, 0xc5, 0x2d, 0x0f, 0xb4, 0xdb, 0x62, + 0x91, 0x1b, 0x88, 0x30, 0x99, 0x97, 0x62, 0xeb, 0x17, 0x08, 0x6f, 0xbf, 0x34, 0x90, 0x4e, 0xc8, + 0x21, 0xd4, 0x22, 0x16, 0xa7, 0xe0, 0x1f, 0xb9, 0xfc, 0x0d, 0x68, 0xd5, 0x85, 0xe3, 0x09, 0x28, + 0x4d, 0x0e, 0x31, 0xfe, 0xc3, 0xab, 0xa0, 0x1a, 0x6a, 0x94, 0xda, 0x0f, 0x68, 0x2a, 0x42, 0x8d, + 0x08, 0x4d, 0x03, 0xb1, 0x22, 0xf4, 0xc8, 0x0d, 0xc0, 0x72, 0xbb, 0x19, 0x26, 0xd9, 0xc1, 0xb7, + 0x12, 0x60, 0x6f, 0x00, 0x22, 0x18, 0xe8, 0x4a, 0xb1, 0x86, 0x1a, 0x9b, 0xdd, 0x52, 0x52, 0x7b, + 0x9e, 0x94, 0xea, 0x1f, 0x10, 0xae, 0xe5, 0xdb, 0x51, 0x91, 0x0c, 0x15, 0x90, 0x1e, 0xde, 0x12, + 0x99, 0x76, 0x2f, 0x4a, 0xfb, 0x15, 0x54, 0xdb, 0x68, 0x94, 0xda, 0x8f, 0x69, 0xce, 0x46, 0x68, + 0xc7, 0x37, 0x9c, 0xbe, 0x98, 0x4f, 0x3c, 0x04, 0x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x39, 0x85, 0xab, 0x99, 0x53, + 0xf8, 0x3e, 0x73, 0x0a, 0xaf, 0x9e, 0x04, 0x42, 0x0f, 0x26, 0x1e, 0xe5, 0x72, 0xc4, 0xec, 0x5f, + 0x44, 0x78, 0xbc, 0x19, 0x48, 0x16, 0xef, 0xb2, 0x91, 0xf4, 0x27, 0x43, 0x50, 0xa9, 0xe9, 0xf6, + 0x7e, 0xd3, 0xf8, 0xd6, 0x27, 0x11, 0x28, 0xef, 0xff, 0xe4, 0x67, 0xb2, 0xfb, 0x3b, 0x00, 0x00, + 0xff, 0xff, 0xd3, 0xea, 0xdd, 0xe2, 0x32, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -506,18 +507,16 @@ func (m *QueryIncentivizedPacketRequest) MarshalToSizedBuffer(dAtA []byte) (int, i-- dAtA[i] = 0x10 } - if m.PacketId != nil { - { - size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + { + size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0xa + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -604,10 +603,8 @@ func (m *QueryIncentivizedPacketRequest) Size() (n int) { } var l int _ = l - if m.PacketId != nil { - l = m.PacketId.Size() - n += 1 + l + sovQuery(uint64(l)) - } + l = m.PacketId.Size() + n += 1 + l + sovQuery(uint64(l)) if m.QueryHeight != 0 { n += 1 + sovQuery(uint64(m.QueryHeight)) } @@ -880,9 +877,6 @@ func (m *QueryIncentivizedPacketRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.PacketId == nil { - m.PacketId = &types.PacketId{} - } if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/modules/core/04-channel/types/packet.go b/modules/core/04-channel/types/packet.go index 32f6b343fb3..1b69dafa758 100644 --- a/modules/core/04-channel/types/packet.go +++ b/modules/core/04-channel/types/packet.go @@ -13,8 +13,8 @@ import ( ) // NewPacketId returns a new instance of PacketId -func NewPacketId(channelId, portId string, seq uint64) *PacketId { - return &PacketId{ChannelId: channelId, PortId: portId, Sequence: seq} +func NewPacketId(channelId, portId string, seq uint64) PacketId { + return PacketId{ChannelId: channelId, PortId: portId, Sequence: seq} } // CommitPacket returns the packet commitment bytes. The commitment consists of: diff --git a/proto/ibc/applications/fee/v1/fee.proto b/proto/ibc/applications/fee/v1/fee.proto index 1f5d9c0d05c..a942d3c8fe5 100644 --- a/proto/ibc/applications/fee/v1/fee.proto +++ b/proto/ibc/applications/fee/v1/fee.proto @@ -32,7 +32,7 @@ message Fee { // the refund address to which any unused funds are refunded, // and an optional list of relayers that are permitted to receive the fee. message IdentifiedPacketFee { - ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.moretags) = "yaml:\"packet_id\""]; + ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"packet_id\""]; Fee fee = 2 [(gogoproto.nullable) = false]; string refund_address = 3 [(gogoproto.moretags) = "yaml:\"refund_address\""]; repeated string relayers = 4; diff --git a/proto/ibc/applications/fee/v1/genesis.proto b/proto/ibc/applications/fee/v1/genesis.proto index 632693e808c..1aeac5f1d05 100644 --- a/proto/ibc/applications/fee/v1/genesis.proto +++ b/proto/ibc/applications/fee/v1/genesis.proto @@ -30,5 +30,5 @@ message RegisteredRelayerAddress { // ForwardRelayerAddress contains the forward relayer address and packetId used for async acknowledgements message ForwardRelayerAddress { string address = 1; - ibc.core.channel.v1.PacketId packet_id = 2 [(gogoproto.moretags) = "yaml:\"packet_id\""]; + ibc.core.channel.v1.PacketId packet_id = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"packet_id\""]; } diff --git a/proto/ibc/applications/fee/v1/query.proto b/proto/ibc/applications/fee/v1/query.proto index 75a7d3c0491..ad7d56f5b2b 100644 --- a/proto/ibc/applications/fee/v1/query.proto +++ b/proto/ibc/applications/fee/v1/query.proto @@ -43,7 +43,7 @@ message QueryIncentivizedPacketsResponse { // QueryIncentivizedPacketRequest is the request type for querying for all incentivized packets message QueryIncentivizedPacketRequest { // PacketID - ibc.core.channel.v1.PacketId packet_id = 1; + ibc.core.channel.v1.PacketId packet_id = 1[(gogoproto.nullable) = false]; // Height to query at uint64 query_height = 2; } From 764df84fc1c4805b003a8046cf6c570968b8dcd1 Mon Sep 17 00:00:00 2001 From: Sean King Date: Thu, 20 Jan 2022 15:18:31 +0100 Subject: [PATCH 22/79] nits: proto spacing + naming (#739) * nits: proto spacing + naming * nit: update comment * fix: go.mod * nit: option above import proto * fix: spacing --- docs/ibc/proto-docs.md | 4 +- modules/apps/29-fee/ibc_module_test.go | 10 +-- modules/apps/29-fee/keeper/escrow.go | 8 +- modules/apps/29-fee/keeper/escrow_test.go | 20 ++--- modules/apps/29-fee/keeper/grpc_query_test.go | 4 +- modules/apps/29-fee/keeper/keeper_test.go | 2 +- modules/apps/29-fee/keeper/msg_server_test.go | 4 +- modules/apps/29-fee/types/fee.pb.go | 86 +++++++++---------- modules/apps/29-fee/types/msgs.go | 8 +- modules/apps/29-fee/types/tx.pb.go | 2 +- proto/ibc/applications/fee/v1/ack.proto | 4 +- proto/ibc/applications/fee/v1/fee.proto | 6 +- proto/ibc/applications/fee/v1/genesis.proto | 5 +- proto/ibc/applications/fee/v1/query.proto | 4 +- proto/ibc/applications/fee/v1/tx.proto | 5 +- 15 files changed, 89 insertions(+), 83 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 662081f9459..284a8718f00 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -701,7 +701,7 @@ https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middl | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `receive_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `recv_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | | `ack_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | | `timeout_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | @@ -978,7 +978,7 @@ MsgPayPacketFeeResponse defines the response type for Msg/PayPacketFee ### MsgRegisterCounterpartyAddress -MsgRegisterCounterpartyAddress is the request type for registering the counter party address +MsgRegisterCounterpartyAddress is the request type for registering the counterparty address | Field | Type | Label | Description | diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index a12b8ae972f..f0bdf89ff80 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -524,7 +524,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { { "success", func() { - expectedRelayerBalance = identifiedFee.Fee.ReceiveFee.Add(identifiedFee.Fee.AckFee[0]) + expectedRelayerBalance = identifiedFee.Fee.RecvFee.Add(identifiedFee.Fee.AckFee[0]) }, true, }, @@ -603,7 +603,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { identifiedFee = types.NewIdentifiedPacketFee( packetId, types.Fee{ - ReceiveFee: validCoins, + RecvFee: validCoins, AckFee: validCoins2, TimeoutFee: validCoins3, }, @@ -698,7 +698,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { relayerAddr = suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress() expectedBalance = originalBalance. - Add(identifiedFee.Fee.ReceiveFee[0]). + Add(identifiedFee.Fee.RecvFee[0]). Add(identifiedFee.Fee.AckFee[0]). Add(ibctesting.TestCoin) // timeout refund for ics20 transfer }, @@ -737,7 +737,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { identifiedFee = types.NewIdentifiedPacketFee( packetId, types.Fee{ - ReceiveFee: validCoins, + RecvFee: validCoins, AckFee: validCoins2, TimeoutFee: validCoins3, }, @@ -754,7 +754,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { // default to success case expectedBalance = originalBalance. - Add(identifiedFee.Fee.ReceiveFee[0]). + Add(identifiedFee.Fee.RecvFee[0]). Add(identifiedFee.Fee.AckFee[0]). Add(coin) // timeout refund from ics20 transfer diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index 9ba1709a8dc..a3c6e920671 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -26,7 +26,7 @@ func (k Keeper) EscrowPacketFee(ctx sdk.Context, identifiedFee *types.Identified return sdkerrors.Wrap(types.ErrRefundAccNotFound, fmt.Sprintf("Account with address: %s not found", refundAcc)) } - coins := identifiedFee.Fee.ReceiveFee + coins := identifiedFee.Fee.RecvFee coins = coins.Add(identifiedFee.Fee.AckFee...) coins = coins.Add(identifiedFee.Fee.TimeoutFee...) @@ -46,7 +46,7 @@ func (k Keeper) DistributePacketFees(ctx sdk.Context, refundAcc, forwardRelayer // distribute fee for forward relaying forward, err := sdk.AccAddressFromBech32(forwardRelayer) if err == nil { - k.distributeFee(ctx, forward, feeInEscrow.Fee.ReceiveFee) + k.distributeFee(ctx, forward, feeInEscrow.Fee.RecvFee) } // distribute fee for reverse relaying @@ -74,7 +74,7 @@ func (k Keeper) DistributePacketFeesOnTimeout(ctx sdk.Context, refundAcc string, } // refund receive fee for unused forward relaying - k.distributeFee(ctx, refundAddr, feeInEscrow.Fee.ReceiveFee) + k.distributeFee(ctx, refundAddr, feeInEscrow.Fee.RecvFee) // refund ack fee for unused reverse relaying k.distributeFee(ctx, refundAddr, feeInEscrow.Fee.AckFee) @@ -117,7 +117,7 @@ func (k Keeper) RefundFeesOnChannel(ctx sdk.Context, portID, channelID string) e // refund all fees to refund address // Use SendCoins rather than the module account send functions since refund address may be a user account or module address. // if any `SendCoins` call returns an error, we return error and stop iteration - err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.ReceiveFee) + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.RecvFee) if err != nil { refundErr = err return true diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go index 9c07c79589c..721bbf6f79a 100644 --- a/modules/apps/29-fee/keeper/escrow_test.go +++ b/modules/apps/29-fee/keeper/escrow_test.go @@ -71,7 +71,7 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { tc.malleate() fee := types.Fee{ - ReceiveFee: receiveFee, + RecvFee: receiveFee, AckFee: ackFee, TimeoutFee: timeoutFee, } @@ -87,7 +87,7 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { feeInEscrow, _ := suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeInEscrow(suite.chainA.GetContext(), packetId) // check if the escrowed fee is set in state suite.Require().True(feeInEscrow.Fee.AckFee.IsEqual(fee.AckFee)) - suite.Require().True(feeInEscrow.Fee.ReceiveFee.IsEqual(fee.ReceiveFee)) + suite.Require().True(feeInEscrow.Fee.RecvFee.IsEqual(fee.RecvFee)) suite.Require().True(feeInEscrow.Fee.TimeoutFee.IsEqual(fee.TimeoutFee)) // check if the fee is escrowed correctly hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(600)}) @@ -142,7 +142,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() { packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, transfertypes.PortID, validSeq) fee := types.Fee{ - ReceiveFee: defaultReceiveFee, + RecvFee: defaultReceiveFee, AckFee: defaultAckFee, TimeoutFee: defaultTimeoutFee, } @@ -172,7 +172,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() { // check if the forward relayer is paid forward, err := sdk.AccAddressFromBech32(forwardRelayer) suite.Require().NoError(err) - hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), forward, fee.ReceiveFee[0]) + hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), forward, fee.RecvFee[0]) suite.Require().True(hasBalance) // check if the refund acc has been refunded the timeoutFee @@ -185,7 +185,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() { suite.Require().True(hasBalance) } else { // check the module acc wallet still has forward relaying balance - hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), fee.ReceiveFee[0]) + hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), fee.RecvFee[0]) suite.Require().True(hasBalance) } }) @@ -206,7 +206,7 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { ) fee := types.Fee{ - ReceiveFee: defaultReceiveFee, + RecvFee: defaultReceiveFee, AckFee: defaultAckFee, TimeoutFee: defaultTimeoutFee, } @@ -237,7 +237,7 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { // check if the refund acc has been refunded the recv & ack fees expectedRefundAccBal := refundAccBal.Add(fee.AckFee[0]) - expectedRefundAccBal = refundAccBal.Add(fee.ReceiveFee[0]) + expectedRefundAccBal = refundAccBal.Add(fee.RecvFee[0]) hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), refundAcc, expectedRefundAccBal) suite.Require().True(hasBalance) @@ -256,7 +256,7 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { for i := 0; i < 5; i++ { packetId := channeltypes.NewPacketId("channel-0", transfertypes.PortID, uint64(i)) fee := types.Fee{ - ReceiveFee: defaultReceiveFee, + RecvFee: defaultReceiveFee, AckFee: defaultAckFee, TimeoutFee: defaultTimeoutFee, } @@ -270,7 +270,7 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { // send a packet over a different channel to ensure this fee is not refunded packetId := channeltypes.NewPacketId("channel-1", transfertypes.PortID, 1) fee := types.Fee{ - ReceiveFee: defaultReceiveFee, + RecvFee: defaultReceiveFee, AckFee: defaultAckFee, TimeoutFee: defaultTimeoutFee, } @@ -286,7 +286,7 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { // add fee sent to channel-1 to after balance to recover original balance afterBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), refundAcc) - suite.Require().Equal(prevBal, afterBal.Add(fee.ReceiveFee...).Add(fee.AckFee...).Add(fee.TimeoutFee...), "refund account not back to original balance after refunding all tokens") + suite.Require().Equal(prevBal, afterBal.Add(fee.RecvFee...).Add(fee.AckFee...).Add(fee.TimeoutFee...), "refund account not back to original balance after refunding all tokens") // create escrow and then change module account balance to cause error on refund packetId = channeltypes.NewPacketId("channel-0", transfertypes.PortID, uint64(6)) diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index bef02669b04..c456090caaf 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -26,7 +26,7 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketI() { validPacketId, types.Fee{ AckFee: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), - ReceiveFee: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + RecvFee: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), TimeoutFee: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), }, "", // leave empty here and then populate on each testcase since suite resets @@ -94,7 +94,7 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPackets() { fee := types.Fee{ AckFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}}, - ReceiveFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}}, + RecvFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}}, TimeoutFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}}, } diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index ad19cfac072..459eafbf70b 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -57,7 +57,7 @@ func TestKeeperTestSuite(t *testing.T) { } func (suite *KeeperTestSuite) TestFeeInEscrow() { - fee := types.Fee{ReceiveFee: defaultReceiveFee, AckFee: defaultAckFee, TimeoutFee: defaultTimeoutFee} + fee := types.Fee{RecvFee: defaultReceiveFee, AckFee: defaultAckFee, TimeoutFee: defaultTimeoutFee} // set some fees for i := 1; i < 6; i++ { diff --git a/modules/apps/29-fee/keeper/msg_server_test.go b/modules/apps/29-fee/keeper/msg_server_test.go index 26a62830035..f541dd3fd36 100644 --- a/modules/apps/29-fee/keeper/msg_server_test.go +++ b/modules/apps/29-fee/keeper/msg_server_test.go @@ -70,7 +70,7 @@ func (suite *KeeperTestSuite) TestPayPacketFee() { refundAcc := suite.chainA.SenderAccount.GetAddress() channelID := suite.path.EndpointA.ChannelID fee := types.Fee{ - ReceiveFee: defaultReceiveFee, + RecvFee: defaultReceiveFee, AckFee: defaultAckFee, TimeoutFee: defaultTimeoutFee, } @@ -111,7 +111,7 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() { // build packetId channelID := suite.path.EndpointA.ChannelID fee := types.Fee{ - ReceiveFee: defaultReceiveFee, + RecvFee: defaultReceiveFee, AckFee: defaultAckFee, TimeoutFee: defaultTimeoutFee, } diff --git a/modules/apps/29-fee/types/fee.pb.go b/modules/apps/29-fee/types/fee.pb.go index 1db63e62f8a..4fa6f240abb 100644 --- a/modules/apps/29-fee/types/fee.pb.go +++ b/modules/apps/29-fee/types/fee.pb.go @@ -30,7 +30,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // See Fee Payment Middleware spec: // https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middleware-contract type Fee struct { - ReceiveFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=receive_fee,json=receiveFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"receive_fee" yaml:"receive_fee"` + RecvFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=recv_fee,json=recvFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"recv_fee" yaml:"receive_fee"` AckFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=ack_fee,json=ackFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"ack_fee" yaml:"ack_fee"` TimeoutFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=timeout_fee,json=timeoutFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"timeout_fee" yaml:"timeout_fee"` } @@ -68,9 +68,9 @@ func (m *Fee) XXX_DiscardUnknown() { var xxx_messageInfo_Fee proto.InternalMessageInfo -func (m *Fee) GetReceiveFee() github_com_cosmos_cosmos_sdk_types.Coins { +func (m *Fee) GetRecvFee() github_com_cosmos_cosmos_sdk_types.Coins { if m != nil { - return m.ReceiveFee + return m.RecvFee } return nil } @@ -169,38 +169,38 @@ func init() { func init() { proto.RegisterFile("ibc/applications/fee/v1/fee.proto", fileDescriptor_cb3319f1af2a53e5) } var fileDescriptor_cb3319f1af2a53e5 = []byte{ - // 482 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x31, 0x8f, 0xd3, 0x30, - 0x14, 0xc7, 0x1b, 0x72, 0x3a, 0xee, 0x5c, 0x71, 0x42, 0x01, 0x44, 0xae, 0x82, 0xb4, 0x64, 0xca, - 0x52, 0x5b, 0xed, 0xc1, 0x00, 0x13, 0x04, 0xa9, 0xd2, 0x4d, 0xa0, 0x88, 0x89, 0xa5, 0x72, 0xec, - 0xd7, 0x9e, 0xd5, 0x24, 0x8e, 0xe2, 0x34, 0x52, 0x57, 0x16, 0x56, 0x3e, 0x07, 0x9f, 0xe4, 0xc6, - 0x1b, 0x99, 0x0a, 0x6a, 0xbf, 0xc1, 0x7d, 0x01, 0x90, 0x63, 0xf7, 0x54, 0x09, 0x21, 0xd4, 0xc9, - 0xf6, 0xf3, 0xfb, 0xbf, 0xdf, 0x7b, 0xcf, 0xcf, 0xe8, 0x85, 0x48, 0x19, 0xa1, 0x65, 0x99, 0x09, - 0x46, 0x6b, 0x21, 0x0b, 0x45, 0x66, 0x00, 0xa4, 0x19, 0xe9, 0x05, 0x97, 0x95, 0xac, 0xa5, 0xf7, - 0x54, 0xa4, 0x0c, 0xef, 0xbb, 0x60, 0x7d, 0xd7, 0x8c, 0x7a, 0x01, 0x93, 0x2a, 0x97, 0x8a, 0xa4, - 0x54, 0x69, 0x49, 0x0a, 0x35, 0x1d, 0x11, 0x26, 0x45, 0x61, 0x84, 0xbd, 0xc7, 0x73, 0x39, 0x97, - 0xed, 0x96, 0xe8, 0x9d, 0xb5, 0xb6, 0x44, 0x26, 0x2b, 0x20, 0xec, 0x8a, 0x16, 0x05, 0x64, 0x9a, - 0x66, 0xb7, 0xc6, 0x25, 0xfc, 0xea, 0x22, 0x77, 0x02, 0xe0, 0x7d, 0x71, 0x50, 0xb7, 0x02, 0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, 0xa4, 0xc3, 0x25, 0xda, 0xdd, 0x7b, 0x8b, 0xce, 0x2a, 0x98, 0x2d, - 0x0b, 0x3e, 0xa5, 0x9c, 0x57, 0xa0, 0x94, 0xef, 0x0e, 0x9c, 0xe8, 0x34, 0x3e, 0xbf, 0x5d, 0xf7, - 0x9f, 0xec, 0x06, 0x61, 0xff, 0x3e, 0x4c, 0x1e, 0x18, 0xc3, 0x3b, 0x73, 0xf6, 0x7a, 0xe8, 0xa4, - 0x82, 0x8c, 0xae, 0xa0, 0x52, 0xfe, 0xd1, 0xc0, 0x8d, 0x4e, 0x93, 0xbb, 0x73, 0xfc, 0xe1, 0x7a, - 0x13, 0x38, 0x37, 0x9b, 0xc0, 0xf9, 0xb5, 0x09, 0x9c, 0x6f, 0xdb, 0xa0, 0x73, 0xb3, 0x0d, 0x3a, - 0x3f, 0xb6, 0x41, 0xe7, 0xf3, 0xab, 0xbf, 0x3b, 0x2a, 0x52, 0x36, 0x9c, 0x4b, 0xd2, 0x5c, 0x90, - 0x5c, 0xf2, 0x65, 0x06, 0x4a, 0x7f, 0x2d, 0x45, 0xc6, 0xaf, 0x87, 0xfa, 0x57, 0xb5, 0x4d, 0x4e, - 0x8f, 0xdb, 0x19, 0xbf, 0xf8, 0x13, 0x00, 0x00, 0xff, 0xff, 0x76, 0xdd, 0x8f, 0x88, 0x7a, 0x03, - 0x00, 0x00, + // 488 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xbd, 0x8e, 0xd3, 0x40, + 0x10, 0xc7, 0x63, 0x7c, 0xba, 0x8f, 0x8d, 0x38, 0x21, 0x03, 0xc2, 0x17, 0x81, 0x13, 0x5c, 0xb9, + 0xc9, 0xae, 0x92, 0x83, 0x02, 0x2a, 0x30, 0x52, 0xa4, 0xab, 0x40, 0x16, 0x15, 0x4d, 0xb4, 0x5e, + 0x4f, 0x72, 0xab, 0xd8, 0x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+ 0xe8, 0xce, 0x0f, 0xdf, 0x5f, 0x6d, 0x3c, 0xeb, 0x7a, 0xe3, 0x59, 0xbf, 0x36, 0x9e, 0xf5, 0x6d, + 0xeb, 0x75, 0xae, 0xb7, 0x5e, 0xe7, 0xc7, 0xd6, 0xeb, 0x7c, 0x7a, 0xf9, 0xf7, 0x44, 0x65, 0x2c, + 0x86, 0x73, 0xc5, 0xea, 0x73, 0x96, 0xa9, 0x64, 0x99, 0x82, 0xc6, 0x37, 0xa5, 0xd9, 0xf8, 0xd5, + 0x10, 0x9f, 0x53, 0x33, 0xe4, 0xf8, 0xb0, 0x59, 0xee, 0xf3, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, + 0x4e, 0x82, 0x74, 0x21, 0x73, 0x03, 0x00, 0x00, } func (m *Fee) Marshal() (dAtA []byte, err error) { @@ -251,10 +251,10 @@ func (m *Fee) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x12 } } - if len(m.ReceiveFee) > 0 { - for iNdEx := len(m.ReceiveFee) - 1; iNdEx >= 0; iNdEx-- { + if len(m.RecvFee) > 0 { + for iNdEx := len(m.RecvFee) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.ReceiveFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.RecvFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -344,8 +344,8 @@ func (m *Fee) Size() (n int) { } var l int _ = l - if len(m.ReceiveFee) > 0 { - for _, e := range m.ReceiveFee { + if len(m.RecvFee) > 0 { + for _, e := range m.RecvFee { l = e.Size() n += 1 + l + sovFee(uint64(l)) } @@ -425,7 +425,7 @@ func (m *Fee) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ReceiveFee", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field RecvFee", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -452,8 +452,8 @@ func (m *Fee) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ReceiveFee = append(m.ReceiveFee, types.Coin{}) - if err := m.ReceiveFee[len(m.ReceiveFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.RecvFee = append(m.RecvFee, types.Coin{}) + if err := m.RecvFee[len(m.RecvFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index 7138706cf80..15b3fd716be 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -81,12 +81,12 @@ func (msg MsgPayPacketFee) ValidateBasic() error { } // if any of the fee's are invalid return an error - if !msg.Fee.AckFee.IsValid() || !msg.Fee.ReceiveFee.IsValid() || !msg.Fee.TimeoutFee.IsValid() { + if !msg.Fee.AckFee.IsValid() || !msg.Fee.RecvFee.IsValid() || !msg.Fee.TimeoutFee.IsValid() { return sdkerrors.ErrInvalidCoins } // if all three fee's are zero or empty return an error - if msg.Fee.AckFee.IsZero() && msg.Fee.ReceiveFee.IsZero() && msg.Fee.TimeoutFee.IsZero() { + if msg.Fee.AckFee.IsZero() && msg.Fee.RecvFee.IsZero() && msg.Fee.TimeoutFee.IsZero() { return sdkerrors.ErrInvalidCoins } @@ -157,12 +157,12 @@ func (fee IdentifiedPacketFee) Validate() error { } // if any of the fee's are invalid return an error - if !fee.Fee.AckFee.IsValid() || !fee.Fee.ReceiveFee.IsValid() || !fee.Fee.TimeoutFee.IsValid() { + if !fee.Fee.AckFee.IsValid() || !fee.Fee.RecvFee.IsValid() || !fee.Fee.TimeoutFee.IsValid() { return sdkerrors.ErrInvalidCoins } // if all three fee's are zero or empty return an error - if fee.Fee.AckFee.IsZero() && fee.Fee.ReceiveFee.IsZero() && fee.Fee.TimeoutFee.IsZero() { + if fee.Fee.AckFee.IsZero() && fee.Fee.RecvFee.IsZero() && fee.Fee.TimeoutFee.IsZero() { return sdkerrors.ErrInvalidCoins } diff --git a/modules/apps/29-fee/types/tx.pb.go b/modules/apps/29-fee/types/tx.pb.go index 2c36575ecb0..46f20f29783 100644 --- a/modules/apps/29-fee/types/tx.pb.go +++ b/modules/apps/29-fee/types/tx.pb.go @@ -29,7 +29,7 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgRegisterCounterpartyAddress is the request type for registering the counter party address +// MsgRegisterCounterpartyAddress is the request type for registering the counterparty address type MsgRegisterCounterpartyAddress struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` CounterpartyAddress string `protobuf:"bytes,2,opt,name=counterparty_address,json=counterpartyAddress,proto3" json:"counterparty_address,omitempty" yaml:"counterparty_address"` diff --git a/proto/ibc/applications/fee/v1/ack.proto b/proto/ibc/applications/fee/v1/ack.proto index 626b4518f18..b978454892d 100644 --- a/proto/ibc/applications/fee/v1/ack.proto +++ b/proto/ibc/applications/fee/v1/ack.proto @@ -1,9 +1,11 @@ syntax = "proto3"; package ibc.applications.fee.v1; -import "gogoproto/gogo.proto"; + option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; +import "gogoproto/gogo.proto"; + // IncentivizedAcknowledgement is the acknowledgement format to be used by applications wrapped in the fee middleware // It contains the raw acknowledgement bytes, as well as the forward relayer address message IncentivizedAcknowledgement { diff --git a/proto/ibc/applications/fee/v1/fee.proto b/proto/ibc/applications/fee/v1/fee.proto index a942d3c8fe5..b57cc2cc03c 100644 --- a/proto/ibc/applications/fee/v1/fee.proto +++ b/proto/ibc/applications/fee/v1/fee.proto @@ -1,16 +1,18 @@ syntax = "proto3"; package ibc.applications.fee.v1; + +option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; + import "cosmos/base/v1beta1/coin.proto"; import "gogoproto/gogo.proto"; import "ibc/core/channel/v1/channel.proto"; -option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; // Fee implements the ics29 Fee interface // See Fee Payment Middleware spec: // https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middleware-contract message Fee { - repeated cosmos.base.v1beta1.Coin receive_fee = 1 [ + repeated cosmos.base.v1beta1.Coin recv_fee = 1 [ (gogoproto.moretags) = "yaml:\"receive_fee\"", (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" diff --git a/proto/ibc/applications/fee/v1/genesis.proto b/proto/ibc/applications/fee/v1/genesis.proto index 1aeac5f1d05..793ee2561ae 100644 --- a/proto/ibc/applications/fee/v1/genesis.proto +++ b/proto/ibc/applications/fee/v1/genesis.proto @@ -1,12 +1,13 @@ syntax = "proto3"; package ibc.applications.fee.v1; + +option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; + import "gogoproto/gogo.proto"; import "ibc/applications/fee/v1/fee.proto"; import "ibc/core/channel/v1/channel.proto"; -option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; - // GenesisState defines the fee middleware genesis state message GenesisState { repeated IdentifiedPacketFee identified_fees = 1 [(gogoproto.moretags) = "yaml:\"identified_fees\""]; diff --git a/proto/ibc/applications/fee/v1/query.proto b/proto/ibc/applications/fee/v1/query.proto index ad7d56f5b2b..1a41c3091c4 100644 --- a/proto/ibc/applications/fee/v1/query.proto +++ b/proto/ibc/applications/fee/v1/query.proto @@ -2,14 +2,14 @@ syntax = "proto3"; package ibc.applications.fee.v1; +option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; + import "gogoproto/gogo.proto"; import "ibc/applications/fee/v1/fee.proto"; import "google/api/annotations.proto"; import "ibc/core/channel/v1/channel.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; -option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; - // Query provides defines the gRPC querier service. service Query { // Gets all incentivized packets diff --git a/proto/ibc/applications/fee/v1/tx.proto b/proto/ibc/applications/fee/v1/tx.proto index 07517f52a80..4540c28967e 100644 --- a/proto/ibc/applications/fee/v1/tx.proto +++ b/proto/ibc/applications/fee/v1/tx.proto @@ -2,10 +2,11 @@ syntax = "proto3"; package ibc.applications.fee.v1; +option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; + import "gogoproto/gogo.proto"; import "ibc/applications/fee/v1/fee.proto"; import "ibc/core/channel/v1/channel.proto"; -option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; // Msg defines the ibc/fee Msg service. service Msg { @@ -25,7 +26,7 @@ service Msg { rpc PayPacketFeeAsync(MsgPayPacketFeeAsync) returns (MsgPayPacketFeeAsyncResponse); } -// MsgRegisterCounterpartyAddress is the request type for registering the counter party address +// MsgRegisterCounterpartyAddress is the request type for registering the counterparty address message MsgRegisterCounterpartyAddress { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; From d76198298db1131eb34ee58c1d7434bc43b88cde Mon Sep 17 00:00:00 2001 From: Sean King Date: Thu, 20 Jan 2022 15:36:57 +0100 Subject: [PATCH 23/79] sean/fix-proto-identified-fee-not-null (#746) --- modules/apps/29-fee/ibc_module_test.go | 4 +- modules/apps/29-fee/keeper/escrow.go | 2 +- modules/apps/29-fee/keeper/escrow_test.go | 30 ++++---- modules/apps/29-fee/keeper/genesis_test.go | 6 +- modules/apps/29-fee/keeper/grpc_query_test.go | 6 +- modules/apps/29-fee/keeper/keeper.go | 10 +-- modules/apps/29-fee/keeper/keeper_test.go | 4 +- modules/apps/29-fee/keeper/msg_server.go | 2 +- modules/apps/29-fee/types/genesis.go | 4 +- modules/apps/29-fee/types/genesis.pb.go | 74 +++++++++---------- modules/apps/29-fee/types/genesis_test.go | 2 +- modules/apps/29-fee/types/msgs.go | 4 +- proto/ibc/applications/fee/v1/genesis.proto | 2 +- 13 files changed, 75 insertions(+), 75 deletions(-) diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index f0bdf89ff80..715a2509344 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -510,7 +510,7 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { var ( ack []byte - identifiedFee *types.IdentifiedPacketFee + identifiedFee types.IdentifiedPacketFee originalBalance sdk.Coins expectedBalance sdk.Coins expectedRelayerBalance sdk.Coins @@ -658,7 +658,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { func (suite *FeeTestSuite) TestOnTimeoutPacket() { var ( relayerAddr sdk.AccAddress - identifiedFee *types.IdentifiedPacketFee + identifiedFee types.IdentifiedPacketFee originalBalance sdk.Coins expectedBalance sdk.Coins ) diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index a3c6e920671..33ee6a67eec 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -10,7 +10,7 @@ import ( ) // EscrowPacketFee sends the packet fee to the 29-fee module account to hold in escrow -func (k Keeper) EscrowPacketFee(ctx sdk.Context, identifiedFee *types.IdentifiedPacketFee) error { +func (k Keeper) EscrowPacketFee(ctx sdk.Context, identifiedFee types.IdentifiedPacketFee) error { if !k.IsFeeEnabled(ctx, identifiedFee.PacketId.PortId, identifiedFee.PacketId.ChannelId) { // users may not escrow fees on this channel. Must send packets without a fee message return sdkerrors.Wrap(types.ErrFeeNotEnabled, "cannot escrow fee for packet") diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go index 721bbf6f79a..8642cca14d9 100644 --- a/modules/apps/29-fee/keeper/escrow_test.go +++ b/modules/apps/29-fee/keeper/escrow_test.go @@ -75,7 +75,7 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { AckFee: ackFee, TimeoutFee: timeoutFee, } - identifiedPacketFee := &types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} + identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) // refundAcc balance before escrow originalBal := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom) @@ -158,7 +158,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() { // refundAcc balance after escrow refundAccBal := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom) - suite.chainA.GetSimApp().IBCFeeKeeper.DistributePacketFees(suite.chainA.GetContext(), refundAcc.String(), forwardRelayer, reverseRelayer, *identifiedPacketFee) + suite.chainA.GetSimApp().IBCFeeKeeper.DistributePacketFees(suite.chainA.GetContext(), refundAcc.String(), forwardRelayer, reverseRelayer, identifiedPacketFee) if tc.expPass { // there should no longer be a fee in escrow for this packet @@ -212,14 +212,14 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { } // escrow the packet fee & store the fee in state - identifiedPacketFee := types.IdentifiedPacketFee{ - PacketId: packetId, - Fee: fee, - RefundAddress: refundAcc.String(), - Relayers: []string{}, - } + identifiedPacketFee := types.NewIdentifiedPacketFee( + packetId, + fee, + refundAcc.String(), + []string{}, + ) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), &identifiedPacketFee) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) suite.Require().NoError(err) // refundAcc balance after escrow @@ -261,9 +261,9 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { TimeoutFee: defaultTimeoutFee, } - identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} + identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, "channel-0") - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), &identifiedPacketFee) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) suite.Require().NoError(err) } @@ -275,9 +275,9 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { TimeoutFee: defaultTimeoutFee, } - identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} + identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, "channel-1") - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), &identifiedPacketFee) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) suite.Require().NoError(err) // check that refunding all fees on channel-0 refunds all fees except for fee on channel-1 @@ -291,8 +291,8 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { // create escrow and then change module account balance to cause error on refund packetId = channeltypes.NewPacketId("channel-0", transfertypes.PortID, uint64(6)) - identifiedPacketFee = types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), &identifiedPacketFee) + identifiedPacketFee = types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) suite.Require().NoError(err) suite.chainA.GetSimApp().BankKeeper.SendCoinsFromModuleToAccount(suite.chainA.GetContext(), types.ModuleName, refundAcc, fee.TimeoutFee) diff --git a/modules/apps/29-fee/keeper/genesis_test.go b/modules/apps/29-fee/keeper/genesis_test.go index 58e772ac66c..568335daed1 100644 --- a/modules/apps/29-fee/keeper/genesis_test.go +++ b/modules/apps/29-fee/keeper/genesis_test.go @@ -28,7 +28,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() { counterparty := suite.chainB.SenderAccount.GetAddress().String() genesisState := types.GenesisState{ - IdentifiedFees: []*types.IdentifiedPacketFee{ + IdentifiedFees: []types.IdentifiedPacketFee{ { PacketId: packetId, Fee: fee, @@ -55,7 +55,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() { // check fee identifiedFee, found := suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeInEscrow(suite.chainA.GetContext(), packetId) suite.Require().True(found) - suite.Require().Equal(genesisState.IdentifiedFees[0], &identifiedFee) + suite.Require().Equal(genesisState.IdentifiedFees[0], identifiedFee) // check fee is enabled isEnabled := suite.chainA.GetSimApp().IBCFeeKeeper.IsFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, ibctesting.FirstChannelID) @@ -84,7 +84,7 @@ func (suite *KeeperTestSuite) TestExportGenesis() { defaultAckFee, defaultTimeoutFee, } - identifiedPacketFee := &types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} + identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) suite.Require().NoError(err) diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index c456090caaf..2c41da93d1e 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -78,7 +78,7 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketI() { if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) - suite.Require().Equal(identifiedPacketFee, res.IncentivizedPacket) + suite.Require().Equal(&identifiedPacketFee, res.IncentivizedPacket) } else { suite.Require().Error(err) } @@ -120,11 +120,11 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPackets() { fee3 := types.NewIdentifiedPacketFee(channeltypes.NewPacketId(ibctesting.FirstChannelID, transfertypes.PortID, 3), fee, refundAcc.String(), []string(nil)) expPackets = []*types.IdentifiedPacketFee{} - expPackets = append(expPackets, fee1, fee2, fee3) + expPackets = append(expPackets, &fee1, &fee2, &fee3) suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, ibctesting.FirstChannelID) for _, p := range expPackets { - suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), p) + suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), *p) } req = &types.QueryIncentivizedPacketsRequest{ diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index 8aa8862d947..441aaf57a2c 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -228,9 +228,9 @@ func (k Keeper) DeleteForwardRelayerAddress(ctx sdk.Context, packetId channeltyp } // Stores a Fee for a given packet in state -func (k Keeper) SetFeeInEscrow(ctx sdk.Context, fee *types.IdentifiedPacketFee) { +func (k Keeper) SetFeeInEscrow(ctx sdk.Context, fee types.IdentifiedPacketFee) { store := ctx.KVStore(k.storeKey) - bz := k.MustMarshalFee(fee) + bz := k.MustMarshalFee(&fee) store.Set(types.KeyFeeInEscrow(fee.PacketId), bz) } @@ -278,15 +278,15 @@ func (k Keeper) HasFeeInEscrow(ctx sdk.Context, packetId channeltypes.PacketId) } // GetAllIdentifiedPacketFees returns a list of all IdentifiedPacketFees that are stored in state -func (k Keeper) GetAllIdentifiedPacketFees(ctx sdk.Context) []*types.IdentifiedPacketFee { +func (k Keeper) GetAllIdentifiedPacketFees(ctx sdk.Context) []types.IdentifiedPacketFee { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, []byte(types.FeeInEscrowPrefix)) defer iterator.Close() - var identifiedFees []*types.IdentifiedPacketFee + var identifiedFees []types.IdentifiedPacketFee for ; iterator.Valid(); iterator.Next() { fee := k.MustUnmarshalFee(iterator.Value()) - identifiedFees = append(identifiedFees, &fee) + identifiedFees = append(identifiedFees, fee) } return identifiedFees diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index 459eafbf70b..bfea0dabcd9 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -103,13 +103,13 @@ func (suite *KeeperTestSuite) TestGetAllIdentifiedPacketFees() { refundAcc := suite.chainA.SenderAccount.GetAddress() packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, transfertypes.PortID, uint64(1)) fee := types.Fee{defaultAckFee, defaultReceiveFee, defaultTimeoutFee} - identifiedPacketFee := &types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} + identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) // escrow the packet fee err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) suite.Require().NoError(err) - expectedFees := []*types.IdentifiedPacketFee{ + expectedFees := []types.IdentifiedPacketFee{ { PacketId: packetId, Fee: fee, diff --git a/modules/apps/29-fee/keeper/msg_server.go b/modules/apps/29-fee/keeper/msg_server.go index d8eda8b3fdd..23ae8efcf62 100644 --- a/modules/apps/29-fee/keeper/msg_server.go +++ b/modules/apps/29-fee/keeper/msg_server.go @@ -58,7 +58,7 @@ func (k Keeper) PayPacketFee(goCtx context.Context, msg *types.MsgPayPacketFee) func (k Keeper) PayPacketFeeAsync(goCtx context.Context, msg *types.MsgPayPacketFeeAsync) (*types.MsgPayPacketFeeAsyncResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - err := k.EscrowPacketFee(ctx, &msg.IdentifiedPacketFee) + err := k.EscrowPacketFee(ctx, msg.IdentifiedPacketFee) if err != nil { return nil, err } diff --git a/modules/apps/29-fee/types/genesis.go b/modules/apps/29-fee/types/genesis.go index e1eea3b7fac..c0a84516291 100644 --- a/modules/apps/29-fee/types/genesis.go +++ b/modules/apps/29-fee/types/genesis.go @@ -8,7 +8,7 @@ import ( ) // NewGenesisState creates a 29-fee GenesisState instance. -func NewGenesisState(identifiedFees []*IdentifiedPacketFee, feeEnabledChannels []*FeeEnabledChannel, registeredRelayers []*RegisteredRelayerAddress) *GenesisState { +func NewGenesisState(identifiedFees []IdentifiedPacketFee, feeEnabledChannels []*FeeEnabledChannel, registeredRelayers []*RegisteredRelayerAddress) *GenesisState { return &GenesisState{ IdentifiedFees: identifiedFees, FeeEnabledChannels: feeEnabledChannels, @@ -19,7 +19,7 @@ func NewGenesisState(identifiedFees []*IdentifiedPacketFee, feeEnabledChannels [ // DefaultGenesisState returns a GenesisState with "transfer" as the default PortID. func DefaultGenesisState() *GenesisState { return &GenesisState{ - IdentifiedFees: []*IdentifiedPacketFee{}, + IdentifiedFees: []IdentifiedPacketFee{}, FeeEnabledChannels: []*FeeEnabledChannel{}, RegisteredRelayers: []*RegisteredRelayerAddress{}, } diff --git a/modules/apps/29-fee/types/genesis.pb.go b/modules/apps/29-fee/types/genesis.pb.go index 3c04f55b305..6bcc498ac87 100644 --- a/modules/apps/29-fee/types/genesis.pb.go +++ b/modules/apps/29-fee/types/genesis.pb.go @@ -26,7 +26,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the fee middleware genesis state type GenesisState struct { - IdentifiedFees []*IdentifiedPacketFee `protobuf:"bytes,1,rep,name=identified_fees,json=identifiedFees,proto3" json:"identified_fees,omitempty" yaml:"identified_fees"` + IdentifiedFees []IdentifiedPacketFee `protobuf:"bytes,1,rep,name=identified_fees,json=identifiedFees,proto3" json:"identified_fees" yaml:"identified_fees"` FeeEnabledChannels []*FeeEnabledChannel `protobuf:"bytes,2,rep,name=fee_enabled_channels,json=feeEnabledChannels,proto3" json:"fee_enabled_channels,omitempty" yaml:"fee_enabled_channels"` RegisteredRelayers []*RegisteredRelayerAddress `protobuf:"bytes,3,rep,name=registered_relayers,json=registeredRelayers,proto3" json:"registered_relayers,omitempty" yaml:"registered_relayers"` ForwardRelayers []*ForwardRelayerAddress `protobuf:"bytes,4,rep,name=forward_relayers,json=forwardRelayers,proto3" json:"forward_relayers,omitempty" yaml:"forward_relayers"` @@ -65,7 +65,7 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetIdentifiedFees() []*IdentifiedPacketFee { +func (m *GenesisState) GetIdentifiedFees() []IdentifiedPacketFee { if m != nil { return m.IdentifiedFees } @@ -266,41 +266,41 @@ func init() { var fileDescriptor_7191992e856dff95 = []byte{ // 572 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x54, 0xbf, 0x6f, 0xd4, 0x30, - 0x18, 0xbd, 0xb4, 0xa8, 0xa5, 0x2e, 0xea, 0x0f, 0xb7, 0xa5, 0xd1, 0x55, 0x24, 0xc5, 0x12, 0x52, + 0x18, 0xbd, 0xb4, 0x55, 0x4b, 0x5d, 0xd4, 0x1f, 0x6e, 0x4b, 0xa3, 0x56, 0x24, 0xc5, 0x12, 0x52, 0x05, 0x34, 0xd1, 0xb5, 0x30, 0xc0, 0xc6, 0x21, 0x8a, 0x6e, 0x02, 0x19, 0x26, 0x96, 0x53, 0x2e, - 0xf9, 0x92, 0x5a, 0xe4, 0xe2, 0x60, 0xbb, 0x41, 0x37, 0xb0, 0xb0, 0xc0, 0xc8, 0x9f, 0xd5, 0xb1, - 0x23, 0x53, 0x84, 0xda, 0xff, 0x20, 0x3b, 0x12, 0x4a, 0x9c, 0xb4, 0xc7, 0x71, 0x61, 0xfb, 0x62, - 0xbf, 0xf7, 0xbd, 0xe7, 0xe7, 0x7c, 0x46, 0x0f, 0xd8, 0xc8, 0x77, 0xbd, 0x34, 0x8d, 0x99, 0xef, - 0x29, 0xc6, 0x13, 0xe9, 0x86, 0x00, 0x6e, 0xd6, 0x73, 0x23, 0x48, 0x40, 0x32, 0xe9, 0xa4, 0x82, - 0x2b, 0x8e, 0x77, 0xd9, 0xc8, 0x77, 0xa6, 0x61, 0x4e, 0x08, 0xe0, 0x64, 0xbd, 0xee, 0x76, 0xc4, - 0x23, 0x5e, 0x61, 0xdc, 0xb2, 0xd2, 0xf0, 0xee, 0xfd, 0xb6, 0xae, 0x25, 0x6b, 0x0a, 0xe2, 0x73, - 0x01, 0xae, 0x7f, 0xea, 0x25, 0x09, 0xc4, 0xe5, 0x76, 0x5d, 0x6a, 0x08, 0xf9, 0xbd, 0x88, 0xee, - 0xbc, 0xd6, 0x36, 0xde, 0x29, 0x4f, 0x01, 0xfe, 0x84, 0xd6, 0x59, 0x00, 0x89, 0x62, 0x21, 0x83, - 0x60, 0x18, 0x02, 0x48, 0xd3, 0xd8, 0x5f, 0x3c, 0x58, 0x3d, 0x7a, 0xec, 0xb4, 0xf8, 0x73, 0x06, - 0xd7, 0xf8, 0xb7, 0x9e, 0xff, 0x11, 0xd4, 0x09, 0x40, 0xbf, 0x5b, 0xe4, 0xf6, 0xdd, 0x89, 0x37, - 0x8e, 0x9f, 0x93, 0x99, 0x76, 0x84, 0xae, 0xdd, 0xac, 0x9c, 0x00, 0x48, 0xfc, 0x05, 0x6d, 0x87, - 0x00, 0x43, 0x48, 0xbc, 0x51, 0x0c, 0xc1, 0xb0, 0x36, 0x28, 0xcd, 0x85, 0x4a, 0xf7, 0x61, 0xab, - 0xee, 0x09, 0xc0, 0x2b, 0xcd, 0x79, 0xa9, 0x29, 0x7d, 0xbb, 0xc8, 0xed, 0x3d, 0xad, 0x3a, 0xaf, - 0x23, 0x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x80, 0x90, 0xe6, 0x62, 0x25, 0xdf, 0x6d, 0x95, + 0xa7, 0x37, 0x1c, 0xaa, 0x29, 0x2f, 0x83, 0x40, 0x80, 0x94, 0x3d, 0xab, 0xc8, 0xed, 0x7d, 0xed, + 0x62, 0x4e, 0x5f, 0x42, 0xb1, 0x98, 0x65, 0x4a, 0x9c, 0xa1, 0xcd, 0x90, 0x8b, 0xcf, 0x9e, 0x98, + 0x32, 0xb0, 0x54, 0x19, 0x70, 0xda, 0xcf, 0xaf, 0x09, 0x33, 0xea, 0x07, 0x45, 0x6e, 0xef, 0xd5, + 0x19, 0xcc, 0x74, 0x24, 0x74, 0x23, 0xfc, 0x8b, 0x23, 0x49, 0x86, 0xb6, 0xfe, 0x89, 0x11, 0x3f, + 0x46, 0x2b, 0x29, 0x17, 0x6a, 0xc0, 0x02, 0xd3, 0x38, 0x34, 0x8e, 0x56, 0x7b, 0xb8, 0xc8, 0xed, + 0x75, 0xdd, 0xb3, 0xde, 0x20, 0x74, 0xb9, 0xac, 0xfa, 0x01, 0x7e, 0x8a, 0x50, 0x9d, 0x6f, 0x89, + 0x5f, 0xa8, 0xf0, 0xbb, 0x45, 0x6e, 0x6f, 0x69, 0xfc, 0xed, 0x1e, 0xa1, 0xab, 0xf5, 0x47, 0x3f, + 0x20, 0x3f, 0x0c, 0x64, 0xb6, 0x05, 0x88, 0x4d, 0xb4, 0xe2, 0xe9, 0x52, 0xeb, 0xd3, 0xe6, 0x13, + 0x53, 0xb4, 0xe3, 0xf3, 0x71, 0xa2, 0x40, 0xa4, 0x9e, 0x50, 0x93, 0x41, 0x03, 0xd3, 0xb2, 0x53, + 0xd7, 0x3f, 0x0f, 0x45, 0xe8, 0xf6, 0xf4, 0x72, 0xad, 0x46, 0xbe, 0x1b, 0x68, 0x77, 0x6e, 0x94, + 0xff, 0xf1, 0xf1, 0x01, 0xad, 0xa6, 0xd5, 0xff, 0xde, 0x9c, 0x79, 0xed, 0xe4, 0x7e, 0x75, 0x4f, + 0xe5, 0xc4, 0x39, 0xcd, 0x98, 0x65, 0x5d, 0x47, 0x4f, 0x45, 0x3f, 0xe8, 0x99, 0xf5, 0x50, 0x6c, + 0xd6, 0x31, 0x36, 0x6c, 0x42, 0xef, 0xa4, 0x0d, 0xe6, 0xed, 0xc5, 0x95, 0x65, 0x5c, 0x5e, 0x59, + 0xc6, 0xef, 0x2b, 0xcb, 0xf8, 0x79, 0x6d, 0x75, 0x2e, 0xaf, 0xad, 0xce, 0xaf, 0x6b, 0xab, 0xf3, + 0xf1, 0x59, 0xc4, 0xd4, 0xf9, 0x78, 0xe8, 0xf8, 0x7c, 0xe4, 0xfa, 0x5c, 0x8e, 0xb8, 0x74, 0xd9, + 0xd0, 0x3f, 0x8e, 0xb8, 0x9b, 0x9d, 0xba, 0x23, 0x1e, 0x8c, 0x63, 0x90, 0xe5, 0x83, 0x20, 0xdd, + 0x93, 0xe7, 0xc7, 0xe5, 0x5b, 0xa0, 0x26, 0x29, 0xc8, 0xe1, 0x72, 0x35, 0xe8, 0xa7, 0x7f, 0x02, + 0x00, 0x00, 0xff, 0xff, 0x8b, 0x17, 0xa1, 0x66, 0x86, 0x04, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -653,7 +653,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.IdentifiedFees = append(m.IdentifiedFees, &IdentifiedPacketFee{}) + m.IdentifiedFees = append(m.IdentifiedFees, IdentifiedPacketFee{}) if err := m.IdentifiedFees[len(m.IdentifiedFees)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/modules/apps/29-fee/types/genesis_test.go b/modules/apps/29-fee/types/genesis_test.go index 94e2824a265..c41fd8f7469 100644 --- a/modules/apps/29-fee/types/genesis_test.go +++ b/modules/apps/29-fee/types/genesis_test.go @@ -150,7 +150,7 @@ func TestValidateGenesis(t *testing.T) { tc.malleate() genState := types.GenesisState{ - IdentifiedFees: []*types.IdentifiedPacketFee{ + IdentifiedFees: []types.IdentifiedPacketFee{ { PacketId: packetId, Fee: fee, diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index 15b3fd716be..4f176de82f5 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -135,8 +135,8 @@ func (msg MsgPayPacketFeeAsync) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{signer} } -func NewIdentifiedPacketFee(packetId channeltypes.PacketId, fee Fee, refundAddr string, relayers []string) *IdentifiedPacketFee { - return &IdentifiedPacketFee{ +func NewIdentifiedPacketFee(packetId channeltypes.PacketId, fee Fee, refundAddr string, relayers []string) IdentifiedPacketFee { + return IdentifiedPacketFee{ PacketId: packetId, Fee: fee, RefundAddress: refundAddr, diff --git a/proto/ibc/applications/fee/v1/genesis.proto b/proto/ibc/applications/fee/v1/genesis.proto index 793ee2561ae..cf88fc6602a 100644 --- a/proto/ibc/applications/fee/v1/genesis.proto +++ b/proto/ibc/applications/fee/v1/genesis.proto @@ -10,7 +10,7 @@ import "ibc/core/channel/v1/channel.proto"; // GenesisState defines the fee middleware genesis state message GenesisState { - repeated IdentifiedPacketFee identified_fees = 1 [(gogoproto.moretags) = "yaml:\"identified_fees\""]; + repeated IdentifiedPacketFee identified_fees = 1 [(gogoproto.moretags) = "yaml:\"identified_fees\"", (gogoproto.nullable) = false]; repeated FeeEnabledChannel fee_enabled_channels = 2 [(gogoproto.moretags) = "yaml:\"fee_enabled_channels\""]; repeated RegisteredRelayerAddress registered_relayers = 3 [(gogoproto.moretags) = "yaml:\"registered_relayers\""]; repeated ForwardRelayerAddress forward_relayers = 4 [(gogoproto.moretags) = "yaml:\"forward_relayers\""]; From f552fb2ae0a3393984408919f75c3886aebad1bc Mon Sep 17 00:00:00 2001 From: Sean King Date: Thu, 20 Jan 2022 16:10:53 +0100 Subject: [PATCH 24/79] nits: more ics29 nits (#741) * nits: remove capital from error + add godoc * nit: add Wrapf * nit: use strings.TrimSpace * nit: add err type for MsgPayPacketFee * refactor: app version + add comment (#750) * chore: remove error * test: add test for whitespaced empty string --- modules/apps/29-fee/ibc_module.go | 8 +++++--- modules/apps/29-fee/keeper/escrow.go | 3 ++- modules/apps/29-fee/types/msgs.go | 13 ++++++++----- modules/apps/29-fee/types/msgs_test.go | 1 + 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go index 1b54981d7ea..ac4ea21ca52 100644 --- a/modules/apps/29-fee/ibc_module.go +++ b/modules/apps/29-fee/ibc_module.go @@ -56,6 +56,8 @@ func (im IBCModule) OnChanOpenInit( } // OnChanOpenTry implements the IBCModule interface +// If the channel is not fee enabled the underlying application version will be returned +// If the channel is fee enabled we merge the underlying application version with the ics29 version func (im IBCModule) OnChanOpenTry( ctx sdk.Context, order channeltypes.Order, @@ -86,11 +88,11 @@ func (im IBCModule) OnChanOpenTry( return "", err } - if im.keeper.IsFeeEnabled(ctx, portID, channelID) { - return channeltypes.MergeChannelVersions(types.Version, appVersion), nil + if !im.keeper.IsFeeEnabled(ctx, portID, channelID) { + return appVersion, nil } - return appVersion, nil + return channeltypes.MergeChannelVersions(types.Version, appVersion), nil } // OnChanOpenAck implements the IBCModule interface diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index 33ee6a67eec..f01e56ac249 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -23,7 +23,7 @@ func (k Keeper) EscrowPacketFee(ctx sdk.Context, identifiedFee types.IdentifiedP hasRefundAcc := k.authKeeper.GetAccount(ctx, refundAcc) if hasRefundAcc == nil { - return sdkerrors.Wrap(types.ErrRefundAccNotFound, fmt.Sprintf("Account with address: %s not found", refundAcc)) + return sdkerrors.Wrapf(types.ErrRefundAccNotFound, "account with address: %s not found", refundAcc) } coins := identifiedFee.Fee.RecvFee @@ -122,6 +122,7 @@ func (k Keeper) RefundFeesOnChannel(ctx sdk.Context, portID, channelID string) e refundErr = err return true } + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.AckFee) if err != nil { refundErr = err diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index 4f176de82f5..2d5ba7a42d0 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -1,6 +1,8 @@ package types import ( + "strings" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -28,7 +30,7 @@ func (msg MsgRegisterCounterpartyAddress) ValidateBasic() error { return sdkerrors.Wrap(err, "failed to convert msg.Address into sdk.AccAddress") } - if msg.CounterpartyAddress == "" { + if strings.TrimSpace(msg.CounterpartyAddress) == "" { return ErrCounterpartyAddressEmpty } @@ -82,12 +84,12 @@ func (msg MsgPayPacketFee) ValidateBasic() error { // if any of the fee's are invalid return an error if !msg.Fee.AckFee.IsValid() || !msg.Fee.RecvFee.IsValid() || !msg.Fee.TimeoutFee.IsValid() { - return sdkerrors.ErrInvalidCoins + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "contains one or more invalid fees") } // if all three fee's are zero or empty return an error if msg.Fee.AckFee.IsZero() && msg.Fee.RecvFee.IsZero() && msg.Fee.TimeoutFee.IsZero() { - return sdkerrors.ErrInvalidCoins + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "contains one or more invalid fees") } return nil @@ -119,7 +121,7 @@ func (msg MsgPayPacketFeeAsync) ValidateBasic() error { err = msg.IdentifiedPacketFee.Validate() if err != nil { - return sdkerrors.Wrap(err, "Invalid IdentifiedPacketFee") + return sdkerrors.Wrap(err, "invalid IdentifiedPacketFee") } return nil @@ -144,11 +146,12 @@ func NewIdentifiedPacketFee(packetId channeltypes.PacketId, fee Fee, refundAddr } } +// Validate performs a stateless check of the IdentifiedPacketFee fields func (fee IdentifiedPacketFee) Validate() error { // validate PacketId err := fee.PacketId.Validate() if err != nil { - return sdkerrors.Wrap(err, "Invalid PacketId") + return sdkerrors.Wrap(err, "invalid PacketId") } _, err = sdk.AccAddressFromBech32(fee.RefundAddress) diff --git a/modules/apps/29-fee/types/msgs_test.go b/modules/apps/29-fee/types/msgs_test.go index 8671694bca0..8f7a0dc4cd7 100644 --- a/modules/apps/29-fee/types/msgs_test.go +++ b/modules/apps/29-fee/types/msgs_test.go @@ -29,6 +29,7 @@ func TestMsgRegisterCountepartyAddressValidation(t *testing.T) { {"validate with correct sdk.AccAddress", NewMsgRegisterCounterpartyAddress(validAddr, validAddr), true}, {"validate with incorrect destination relayer address", NewMsgRegisterCounterpartyAddress(invalidAddr, validAddr), false}, {"invalid counterparty address", NewMsgRegisterCounterpartyAddress(validAddr, ""), false}, + {"invalid counterparty address: whitespaced empty string", NewMsgRegisterCounterpartyAddress(validAddr, " "), false}, } for i, tc := range testCases { From 16e452b60d0ccd063089759850a409d08ece2d07 Mon Sep 17 00:00:00 2001 From: Sean King Date: Thu, 20 Jan 2022 16:36:26 +0100 Subject: [PATCH 25/79] nit: update err syntax (#747) * nit: update err syntax * nit: more * nit: err syntax --- modules/apps/29-fee/keeper/escrow.go | 10 +++------- modules/apps/29-fee/keeper/msg_server.go | 6 ++---- modules/apps/29-fee/types/msgs.go | 21 ++++++++------------- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index f01e56ac249..1eb24cedc86 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -117,19 +117,15 @@ func (k Keeper) RefundFeesOnChannel(ctx sdk.Context, portID, channelID string) e // refund all fees to refund address // Use SendCoins rather than the module account send functions since refund address may be a user account or module address. // if any `SendCoins` call returns an error, we return error and stop iteration - err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.RecvFee) - if err != nil { + if err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.RecvFee); err != nil { refundErr = err return true } - - err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.AckFee) - if err != nil { + if err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.AckFee); err != nil { refundErr = err return true } - err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.TimeoutFee) - if err != nil { + if err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.TimeoutFee); err != nil { refundErr = err return true } diff --git a/modules/apps/29-fee/keeper/msg_server.go b/modules/apps/29-fee/keeper/msg_server.go index 23ae8efcf62..3ef24d2c443 100644 --- a/modules/apps/29-fee/keeper/msg_server.go +++ b/modules/apps/29-fee/keeper/msg_server.go @@ -44,8 +44,7 @@ func (k Keeper) PayPacketFee(goCtx context.Context, msg *types.MsgPayPacketFee) ) identifiedPacket := types.NewIdentifiedPacketFee(packetId, msg.Fee, msg.Signer, msg.Relayers) - err := k.EscrowPacketFee(ctx, identifiedPacket) - if err != nil { + if err := k.EscrowPacketFee(ctx, identifiedPacket); err != nil { return nil, err } @@ -58,8 +57,7 @@ func (k Keeper) PayPacketFee(goCtx context.Context, msg *types.MsgPayPacketFee) func (k Keeper) PayPacketFeeAsync(goCtx context.Context, msg *types.MsgPayPacketFeeAsync) (*types.MsgPayPacketFeeAsyncResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - err := k.EscrowPacketFee(ctx, msg.IdentifiedPacketFee) - if err != nil { + if err := k.EscrowPacketFee(ctx, msg.IdentifiedPacketFee); err != nil { return nil, err } diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index 2d5ba7a42d0..2c6ba41dca0 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -60,20 +60,17 @@ func NewMsgPayPacketFee(fee Fee, sourcePortId, sourceChannelId, signer string, r // ValidateBasic performs a basic check of the MsgPayPacketFee fields func (msg MsgPayPacketFee) ValidateBasic() error { // validate channelId - err := host.ChannelIdentifierValidator(msg.SourceChannelId) - if err != nil { + if err := host.ChannelIdentifierValidator(msg.SourceChannelId); err != nil { return err } // validate portId - err = host.PortIdentifierValidator(msg.SourcePortId) - if err != nil { + if err := host.PortIdentifierValidator(msg.SourcePortId); err != nil { return err } // signer check - _, err = sdk.AccAddressFromBech32(msg.Signer) - if err != nil { + if _, err := sdk.AccAddressFromBech32(msg.Signer); err != nil { return sdkerrors.Wrap(err, "failed to convert msg.Signer into sdk.AccAddress") } @@ -119,9 +116,8 @@ func (msg MsgPayPacketFeeAsync) ValidateBasic() error { return sdkerrors.Wrap(err, "failed to convert msg.Signer into sdk.AccAddress") } - err = msg.IdentifiedPacketFee.Validate() - if err != nil { - return sdkerrors.Wrap(err, "invalid IdentifiedPacketFee") + if err = msg.IdentifiedPacketFee.Validate(); err != nil { + return sdkerrors.Wrap(err, "Invalid IdentifiedPacketFee") } return nil @@ -149,12 +145,11 @@ func NewIdentifiedPacketFee(packetId channeltypes.PacketId, fee Fee, refundAddr // Validate performs a stateless check of the IdentifiedPacketFee fields func (fee IdentifiedPacketFee) Validate() error { // validate PacketId - err := fee.PacketId.Validate() - if err != nil { - return sdkerrors.Wrap(err, "invalid PacketId") + if err := fee.PacketId.Validate(); err != nil { + return sdkerrors.Wrap(err, "Invalid PacketId") } - _, err = sdk.AccAddressFromBech32(fee.RefundAddress) + _, err := sdk.AccAddressFromBech32(fee.RefundAddress) if err != nil { return sdkerrors.Wrap(err, "failed to convert RefundAddress into sdk.AccAddress") } From b16353e1f5ab62ea38bb9f3a511c1b7f2163e4f6 Mon Sep 17 00:00:00 2001 From: Sean King Date: Fri, 21 Jan 2022 16:25:42 +0100 Subject: [PATCH 26/79] feat: adding Route, Type, GetSignBytes for all messages (#743) * feat: adding Route, Type, GetSignBytes for all messages * tests: adding tests for Route/Type/GetSignBytes --- modules/apps/29-fee/types/msgs.go | 33 ++++++++- modules/apps/29-fee/types/msgs_test.go | 94 ++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 1 deletion(-) diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index 2c6ba41dca0..2d06232313a 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -12,7 +12,8 @@ import ( // msg types const ( - TypeMsgRegisterCounterpartyAddress = "registerCounterpartyAddress" + TypeMsgPayPacketFee = "payPacketFee" + TypeMsgPayPacketFeeAsync = "payPacketFeeAsync" ) // NewMsgRegisterCounterpartyAddress creates a new instance of MsgRegisterCounterpartyAddress @@ -101,6 +102,21 @@ func (msg MsgPayPacketFee) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{signer} } +// Route implements sdk.Msg +func (msg MsgPayPacketFee) Route() string { + return RouterKey +} + +// Type implements sdk.Msg +func (msg MsgPayPacketFee) Type() string { + return TypeMsgPayPacketFee +} + +// GetSignBytes implements sdk.Msg. +func (msg MsgPayPacketFee) GetSignBytes() []byte { + return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg)) +} + // NewMsgPayPacketAsync creates a new instance of MsgPayPacketFee func NewMsgPayPacketFeeAsync(identifiedPacketFee IdentifiedPacketFee) *MsgPayPacketFeeAsync { return &MsgPayPacketFeeAsync{ @@ -133,6 +149,21 @@ func (msg MsgPayPacketFeeAsync) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{signer} } +// Route implements sdk.Msg +func (msg MsgPayPacketFeeAsync) Route() string { + return RouterKey +} + +// Type implements sdk.Msg +func (msg MsgPayPacketFeeAsync) Type() string { + return TypeMsgPayPacketFeeAsync +} + +// GetSignBytes implements sdk.Msg. +func (msg MsgPayPacketFeeAsync) GetSignBytes() []byte { + return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg)) +} + func NewIdentifiedPacketFee(packetId channeltypes.PacketId, fee Fee, refundAddr string, relayers []string) IdentifiedPacketFee { return IdentifiedPacketFee{ PacketId: packetId, diff --git a/modules/apps/29-fee/types/msgs_test.go b/modules/apps/29-fee/types/msgs_test.go index 8f7a0dc4cd7..15a3b45dbde 100644 --- a/modules/apps/29-fee/types/msgs_test.go +++ b/modules/apps/29-fee/types/msgs_test.go @@ -196,6 +196,50 @@ func TestPayPacketFeeGetSigners(t *testing.T) { require.Equal(t, []sdk.AccAddress{addr}, res) } +// TestMsgPayPacketFeeRoute tests Route for MsgPayPacketFee +func TestMsgPayPacketFeeRoute(t *testing.T) { + addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + + // build message + signer := addr.String() + channelID := validChannelID + portID := validPortID + fee := Fee{validCoins, validCoins, validCoins} + msg := NewMsgPayPacketFee(fee, portID, channelID, signer, nil) + + require.Equal(t, RouterKey, msg.Route()) +} + +// TestMsgPayPacketFeeType tests Type for MsgPayPacketFee +func TestMsgPayPacketFeeType(t *testing.T) { + addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + + // build message + signer := addr.String() + channelID := validChannelID + portID := validPortID + fee := Fee{validCoins, validCoins, validCoins} + msg := NewMsgPayPacketFee(fee, portID, channelID, signer, nil) + + require.Equal(t, "payPacketFee", msg.Type()) +} + +// TestMsgPayPacketFeeGetSignBytes tests that GetSignBytes does not panic +func TestMsgPayPacketFeeGetSignBytes(t *testing.T) { + addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + + // build message + signer := addr.String() + channelID := validChannelID + portID := validPortID + fee := Fee{validCoins, validCoins, validCoins} + msg := NewMsgPayPacketFee(fee, portID, channelID, signer, nil) + + require.NotPanics(t, func() { + _ = msg.GetSignBytes() + }) +} + // TestMsgPayPacketFeeAsyncValidation tests ValidateBasic func TestMsgPayPacketFeeAsyncValidation(t *testing.T) { var ( @@ -351,3 +395,53 @@ func TestPayPacketFeeAsyncGetSigners(t *testing.T) { require.Equal(t, []sdk.AccAddress{addr}, res) } + +// TestMsgPayPacketFeeAsyncRoute tests Route for MsgPayPacketFeeAsync +func TestMsgPayPacketFeeAsyncRoute(t *testing.T) { + addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + + // build message + channelID := validChannelID + portID := validPortID + fee := Fee{validCoins, validCoins, validCoins} + seq := uint64(1) + packetId := channeltypes.NewPacketId(channelID, portID, seq) + identifiedPacketFee := IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: addr.String(), Relayers: nil} + msg := NewMsgPayPacketFeeAsync(identifiedPacketFee) + + require.Equal(t, RouterKey, msg.Route()) +} + +// TestMsgPayPacketFeeAsyncType tests Type for MsgPayPacketFeeAsync +func TestMsgPayPacketFeeAsyncType(t *testing.T) { + addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + + // build message + channelID := validChannelID + portID := validPortID + fee := Fee{validCoins, validCoins, validCoins} + seq := uint64(1) + packetId := channeltypes.NewPacketId(channelID, portID, seq) + identifiedPacketFee := IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: addr.String(), Relayers: nil} + msg := NewMsgPayPacketFeeAsync(identifiedPacketFee) + + require.Equal(t, "payPacketFeeAsync", msg.Type()) +} + +// TestMsgPayPacketFeeAsyncGetSignBytes tests that GetSignBytes does not panic +func TestMsgPayPacketFeeAsyncGetSignBytes(t *testing.T) { + addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + + // build message + channelID := validChannelID + portID := validPortID + fee := Fee{validCoins, validCoins, validCoins} + seq := uint64(1) + packetId := channeltypes.NewPacketId(channelID, portID, seq) + identifiedPacketFee := IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: addr.String(), Relayers: nil} + msg := NewMsgPayPacketFeeAsync(identifiedPacketFee) + + require.NotPanics(t, func() { + _ = msg.GetSignBytes() + }) +} From b618f02ad5b880bed2a8cc2da01f3898bd854528 Mon Sep 17 00:00:00 2001 From: Sean King Date: Fri, 21 Jan 2022 16:46:29 +0100 Subject: [PATCH 27/79] hygiene: add validate fn for Fee (#748) * hygiene: add validate fn for Fee * Update modules/apps/29-fee/types/msgs.go Co-authored-by: Damian Nolan * fix: error message * test: move Validate to fee.go & abstract out test * chore: remove test cases Co-authored-by: Damian Nolan --- modules/apps/29-fee/types/fee.go | 32 +++++++++ modules/apps/29-fee/types/fee_test.go | 96 ++++++++++++++++++++++++++ modules/apps/29-fee/types/msgs.go | 24 ++----- modules/apps/29-fee/types/msgs_test.go | 48 ------------- 4 files changed, 134 insertions(+), 66 deletions(-) create mode 100644 modules/apps/29-fee/types/fee.go create mode 100644 modules/apps/29-fee/types/fee_test.go diff --git a/modules/apps/29-fee/types/fee.go b/modules/apps/29-fee/types/fee.go new file mode 100644 index 00000000000..841a1a3a0c1 --- /dev/null +++ b/modules/apps/29-fee/types/fee.go @@ -0,0 +1,32 @@ +package types + +import ( + "strings" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// Validate asserts that each Fee is valid and all three Fees are not empty or zero +func (fee Fee) Validate() error { + var errFees []string + if !fee.AckFee.IsValid() { + errFees = append(errFees, "ack fee invalid") + } + if !fee.RecvFee.IsValid() { + errFees = append(errFees, "recv fee invalid") + } + if !fee.TimeoutFee.IsValid() { + errFees = append(errFees, "timeout fee invalid") + } + + if len(errFees) > 0 { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidCoins, "contains invalid fees: %s", strings.Join(errFees, " , ")) + } + + // if all three fee's are zero or empty return an error + if fee.AckFee.IsZero() && fee.RecvFee.IsZero() && fee.TimeoutFee.IsZero() { + return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "all fees are zero") + } + + return nil +} diff --git a/modules/apps/29-fee/types/fee_test.go b/modules/apps/29-fee/types/fee_test.go new file mode 100644 index 00000000000..0dbd9f29c4e --- /dev/null +++ b/modules/apps/29-fee/types/fee_test.go @@ -0,0 +1,96 @@ +package types + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +// TestFeeValidation tests Validate +func TestFeeValidation(t *testing.T) { + var ( + fee Fee + ackFee sdk.Coins + receiveFee sdk.Coins + timeoutFee sdk.Coins + ) + + testCases := []struct { + name string + malleate func() + expPass bool + }{ + { + "success", + func() {}, + true, + }, + { + "should fail when all fees are invalid", + func() { + ackFee = invalidCoins + receiveFee = invalidCoins + timeoutFee = invalidCoins + }, + false, + }, + { + "should fail with single invalid fee", + func() { + ackFee = invalidCoins + }, + false, + }, + { + "should fail with two invalid fees", + func() { + timeoutFee = invalidCoins + ackFee = invalidCoins + }, + false, + }, + { + "should pass with two empty fees", + func() { + timeoutFee = sdk.Coins{} + ackFee = sdk.Coins{} + }, + true, + }, + { + "should pass with one empty fee", + func() { + timeoutFee = sdk.Coins{} + }, + true, + }, + { + "should fail if all fees are empty", + func() { + ackFee = sdk.Coins{} + receiveFee = sdk.Coins{} + timeoutFee = sdk.Coins{} + }, + false, + }, + } + + for _, tc := range testCases { + // build message + ackFee = validCoins + receiveFee = validCoins + timeoutFee = validCoins + + // malleate + tc.malleate() + fee = Fee{receiveFee, ackFee, timeoutFee} + err := fee.Validate() + + if tc.expPass { + require.NoError(t, err) + } else { + require.Error(t, err) + } + } +} diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index 2d06232313a..f3abe737472 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -80,14 +80,8 @@ func (msg MsgPayPacketFee) ValidateBasic() error { return ErrRelayersNotNil } - // if any of the fee's are invalid return an error - if !msg.Fee.AckFee.IsValid() || !msg.Fee.RecvFee.IsValid() || !msg.Fee.TimeoutFee.IsValid() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "contains one or more invalid fees") - } - - // if all three fee's are zero or empty return an error - if msg.Fee.AckFee.IsZero() && msg.Fee.RecvFee.IsZero() && msg.Fee.TimeoutFee.IsZero() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "contains one or more invalid fees") + if err := msg.Fee.Validate(); err != nil { + return err } return nil @@ -185,20 +179,14 @@ func (fee IdentifiedPacketFee) Validate() error { return sdkerrors.Wrap(err, "failed to convert RefundAddress into sdk.AccAddress") } - // if any of the fee's are invalid return an error - if !fee.Fee.AckFee.IsValid() || !fee.Fee.RecvFee.IsValid() || !fee.Fee.TimeoutFee.IsValid() { - return sdkerrors.ErrInvalidCoins - } - - // if all three fee's are zero or empty return an error - if fee.Fee.AckFee.IsZero() && fee.Fee.RecvFee.IsZero() && fee.Fee.TimeoutFee.IsZero() { - return sdkerrors.ErrInvalidCoins - } - // enforce relayer is nil if fee.Relayers != nil { return ErrRelayersNotNil } + if err := fee.Fee.Validate(); err != nil { + return err + } + return nil } diff --git a/modules/apps/29-fee/types/msgs_test.go b/modules/apps/29-fee/types/msgs_test.go index 15a3b45dbde..57b38a07086 100644 --- a/modules/apps/29-fee/types/msgs_test.go +++ b/modules/apps/29-fee/types/msgs_test.go @@ -105,54 +105,6 @@ func TestMsgPayPacketFeeValidation(t *testing.T) { }, false, }, - { - "should fail when all fees are invalid", - func() { - ackFee = invalidCoins - receiveFee = invalidCoins - timeoutFee = invalidCoins - }, - false, - }, - { - "should fail with single invalid fee", - func() { - ackFee = invalidCoins - }, - false, - }, - { - "should fail with two invalid fees", - func() { - timeoutFee = invalidCoins - ackFee = invalidCoins - }, - false, - }, - { - "should pass with two empty fees", - func() { - timeoutFee = sdk.Coins{} - ackFee = sdk.Coins{} - }, - true, - }, - { - "should pass with one empty fee", - func() { - timeoutFee = sdk.Coins{} - }, - true, - }, - { - "should fail if all fees are empty", - func() { - ackFee = sdk.Coins{} - receiveFee = sdk.Coins{} - timeoutFee = sdk.Coins{} - }, - false, - }, } for _, tc := range testCases { From 13f77de949ce84704db1c7307d31ba8c6e16842e Mon Sep 17 00:00:00 2001 From: Sean King Date: Wed, 26 Jan 2022 14:52:10 +0100 Subject: [PATCH 28/79] fix: app.go (#789) --- testing/simapp/app.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 5fbda3bb931..0743bea6bcd 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -368,7 +368,7 @@ func NewSimApp( // NOTE: the IBC mock keeper and application module is used only for testing core IBC. Do // note replicate if you do not need to test core IBC or light clients. // Pass IBCFeeKeeper for PortKeeper since fee middleware will wrap the IBCKeeper for underlying application. - mockModule := ibcmock.NewAppModule(scopedIBCMockKeeper, &app.IBCFeeKeeper) + mockModule := ibcmock.NewAppModule(scopedIBCMockKeeper, &app.IBCKeeper.PortKeeper) // create fee wrapped mock module feeMockModule := ibcfee.NewIBCModule(app.IBCFeeKeeper, ibcmock.NewIBCModule(nil, scopedFeeMockKeeper)) From 6cb4a384d2b4f7d2d1c99e56a567d0d9600b6f42 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 9 Feb 2022 11:42:32 +0100 Subject: [PATCH 29/79] refactor: ics29 json encoded version metadata (#883) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * adding metadata type to ics29 protos * updating ics29 handshake handlers to support json encoded metadata * updating tests to support json encoded metadata * Update modules/apps/29-fee/ibc_module.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * Update modules/apps/29-fee/ibc_module.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * renaming metadata version to fee_version Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> --- docs/ibc/proto-docs.md | 36 ++ modules/apps/29-fee/fee_test.go | 2 +- modules/apps/29-fee/ibc_module.go | 76 ++-- modules/apps/29-fee/ibc_module_test.go | 50 ++- modules/apps/29-fee/keeper/keeper_test.go | 2 +- modules/apps/29-fee/types/metadata.pb.go | 378 +++++++++++++++++++ proto/ibc/applications/fee/v1/fee.proto | 9 +- proto/ibc/applications/fee/v1/genesis.proto | 6 +- proto/ibc/applications/fee/v1/metadata.proto | 16 + proto/ibc/applications/fee/v1/query.proto | 2 +- 10 files changed, 507 insertions(+), 70 deletions(-) create mode 100644 modules/apps/29-fee/types/metadata.pb.go create mode 100644 proto/ibc/applications/fee/v1/metadata.proto diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 284a8718f00..fb67b288640 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -38,6 +38,9 @@ - [GenesisState](#ibc.applications.fee.v1.GenesisState) - [RegisteredRelayerAddress](#ibc.applications.fee.v1.RegisteredRelayerAddress) +- [ibc/applications/fee/v1/metadata.proto](#ibc/applications/fee/v1/metadata.proto) + - [Metadata](#ibc.applications.fee.v1.Metadata) + - [ibc/applications/fee/v1/query.proto](#ibc/applications/fee/v1/query.proto) - [QueryIncentivizedPacketRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketRequest) - [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) @@ -812,6 +815,39 @@ RegisteredRelayerAddress contains the address and counterparty address for a spe + + + + + + + + + + + +

Top

+ +## ibc/applications/fee/v1/metadata.proto + + + + + +### Metadata +Metadata defines the ICS29 channel specific metadata encoded into the channel version bytestring +See ICS004: https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#Versioning + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `fee_version` | [string](#string) | | fee_version defines the ICS29 fee version | +| `app_version` | [string](#string) | | app_version defines the underlying application version, which may or may not be a JSON encoded bytestring | + + + + + diff --git a/modules/apps/29-fee/fee_test.go b/modules/apps/29-fee/fee_test.go index 147bd0b01a4..e7fe0c371af 100644 --- a/modules/apps/29-fee/fee_test.go +++ b/modules/apps/29-fee/fee_test.go @@ -30,7 +30,7 @@ func (suite *FeeTestSuite) SetupTest() { suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1)) path := ibctesting.NewPath(suite.chainA, suite.chainB) - feeTransferVersion := channeltypes.MergeChannelVersions(types.Version, transfertypes.Version) + feeTransferVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})) path.EndpointA.ChannelConfig.Version = feeTransferVersion path.EndpointB.ChannelConfig.Version = feeTransferVersion path.EndpointA.ChannelConfig.PortID = transfertypes.PortID diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go index ac4ea21ca52..cb5eb71b6d3 100644 --- a/modules/apps/29-fee/ibc_module.go +++ b/modules/apps/29-fee/ibc_module.go @@ -37,22 +37,24 @@ func (im IBCModule) OnChanOpenInit( counterparty channeltypes.Counterparty, version string, ) error { - mwVersion, appVersion := channeltypes.SplitChannelVersion(version) - // Since it is valid for fee version to not be specified, the above middleware version may be for a middleware - // lower down in the stack. Thus, if it is not a fee version we pass the entire version string onto the underlying - // application. - // If an invalid fee version was passed, we expect the underlying application to fail on its version negotiation. - if mwVersion == types.Version { - im.keeper.SetFeeEnabled(ctx, portID, channelID) - } else { - // middleware version is not the expected version for this midddleware. Pass the full version string along, - // if it not valid version for any other lower middleware, an error will be returned by base application. - appVersion = version + var versionMetadata types.Metadata + if err := types.ModuleCdc.UnmarshalJSON([]byte(version), &versionMetadata); err != nil { + // Since it is valid for fee version to not be specified, the above middleware version may be for a middleware + // lower down in the stack. Thus, if it is not a fee version we pass the entire version string onto the underlying + // application. + return im.app.OnChanOpenInit(ctx, order, connectionHops, portID, channelID, + chanCap, counterparty, version) } + if versionMetadata.FeeVersion != types.Version { + return sdkerrors.Wrapf(types.ErrInvalidVersion, "expected %s, got %s", types.Version, versionMetadata.FeeVersion) + } + + im.keeper.SetFeeEnabled(ctx, portID, channelID) + // call underlying app's OnChanOpenInit callback with the appVersion return im.app.OnChanOpenInit(ctx, order, connectionHops, portID, channelID, - chanCap, counterparty, appVersion) + chanCap, counterparty, versionMetadata.AppVersion) } // OnChanOpenTry implements the IBCModule interface @@ -68,31 +70,34 @@ func (im IBCModule) OnChanOpenTry( counterparty channeltypes.Counterparty, counterpartyVersion string, ) (string, error) { - cpMwVersion, cpAppVersion := channeltypes.SplitChannelVersion(counterpartyVersion) + var versionMetadata types.Metadata + if err := types.ModuleCdc.UnmarshalJSON([]byte(counterpartyVersion), &versionMetadata); err != nil { + // Since it is valid for fee version to not be specified, the above middleware version may be for a middleware + // lower down in the stack. Thus, if it is not a fee version we pass the entire version string onto the underlying + // application. + return im.app.OnChanOpenTry(ctx, order, connectionHops, portID, channelID, chanCap, counterparty, counterpartyVersion) + } - // Since it is valid for fee version to not be specified, the above middleware version may be for a middleware - // lower down in the stack. Thus, if it is not a fee version we pass the entire version string onto the underlying - // application. - // If an invalid fee version was passed, we expect the underlying application to fail on its version negotiation. - if cpMwVersion == types.Version { - im.keeper.SetFeeEnabled(ctx, portID, channelID) - } else { - // middleware versions are not the expected version for this midddleware. Pass the full version strings along, - // if it not valid version for any other lower middleware, an error will be returned by base application. - cpAppVersion = counterpartyVersion + if versionMetadata.FeeVersion != types.Version { + return "", sdkerrors.Wrapf(types.ErrInvalidVersion, "expected %s, got %s", types.Version, versionMetadata.FeeVersion) } + im.keeper.SetFeeEnabled(ctx, portID, channelID) + // call underlying app's OnChanOpenTry callback with the app versions - appVersion, err := im.app.OnChanOpenTry(ctx, order, connectionHops, portID, channelID, chanCap, counterparty, cpAppVersion) + appVersion, err := im.app.OnChanOpenTry(ctx, order, connectionHops, portID, channelID, chanCap, counterparty, versionMetadata.AppVersion) if err != nil { return "", err } - if !im.keeper.IsFeeEnabled(ctx, portID, channelID) { - return appVersion, nil + versionMetadata.AppVersion = appVersion + + versionBytes, err := types.ModuleCdc.MarshalJSON(&versionMetadata) + if err != nil { + return "", err } - return channeltypes.MergeChannelVersions(types.Version, appVersion), nil + return string(versionBytes), nil } // OnChanOpenAck implements the IBCModule interface @@ -104,17 +109,22 @@ func (im IBCModule) OnChanOpenAck( ) error { // If handshake was initialized with fee enabled it must complete with fee enabled. // If handshake was initialized with fee disabled it must complete with fee disabled. - cpAppVersion := counterpartyVersion if im.keeper.IsFeeEnabled(ctx, portID, channelID) { - var cpFeeVersion string - cpFeeVersion, cpAppVersion = channeltypes.SplitChannelVersion(counterpartyVersion) + var versionMetadata types.Metadata + if err := types.ModuleCdc.UnmarshalJSON([]byte(counterpartyVersion), &versionMetadata); err != nil { + return sdkerrors.Wrap(types.ErrInvalidVersion, "failed to unmarshal ICS29 counterparty version metadata") + } - if cpFeeVersion != types.Version { - return sdkerrors.Wrapf(types.ErrInvalidVersion, "expected counterparty version: %s, got: %s", types.Version, cpFeeVersion) + if versionMetadata.FeeVersion != types.Version { + return sdkerrors.Wrapf(types.ErrInvalidVersion, "expected counterparty version: %s, got: %s", types.Version, versionMetadata.FeeVersion) } + + // call underlying app's OnChanOpenAck callback with the counterparty app version. + return im.app.OnChanOpenAck(ctx, portID, channelID, versionMetadata.AppVersion) } + // call underlying app's OnChanOpenAck callback with the counterparty app version. - return im.app.OnChanOpenAck(ctx, portID, channelID, cpAppVersion) + return im.app.OnChanOpenAck(ctx, portID, channelID, counterpartyVersion) } // OnChanOpenConfirm implements the IBCModule interface diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index 715a2509344..5c4b198efb3 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -1,8 +1,6 @@ package fee_test import ( - "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" @@ -28,28 +26,23 @@ func (suite *FeeTestSuite) TestOnChanOpenInit() { expPass bool }{ { - "valid fee middleware and transfer version", - channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + "success - valid fee middleware and transfer version", + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})), true, }, { - "fee version not included, only perform transfer logic", + "success - fee version not included, only perform transfer logic", transfertypes.Version, true, }, { "invalid fee middleware version", - channeltypes.MergeChannelVersions("otherfee28-1", transfertypes.Version), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: "invalid-ics29-1", AppVersion: transfertypes.Version})), false, }, { "invalid transfer version", - channeltypes.MergeChannelVersions(types.Version, "wrongics20-1"), - false, - }, - { - "incorrect wrapping delimiter", - fmt.Sprintf("%s//%s", types.Version, transfertypes.Version), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: "invalid-ics20-1"})), false, }, { @@ -57,11 +50,6 @@ func (suite *FeeTestSuite) TestOnChanOpenInit() { types.Version, false, }, - { - "hanging delimiter", - fmt.Sprintf("%s:%s:", types.Version, transfertypes.Version), - false, - }, } for _, tc := range testCases { @@ -112,32 +100,32 @@ func (suite *FeeTestSuite) TestOnChanOpenTry() { expPass bool }{ { - "valid fee middleware version", - channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + "success - valid fee middleware version", + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})), false, true, }, { - "valid transfer version", + "success - valid transfer version", transfertypes.Version, false, true, }, { - "crossing hellos: valid fee middleware", - channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + "success - crossing hellos: valid fee middleware", + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})), true, true, }, { "invalid fee middleware version", - channeltypes.MergeChannelVersions("wrongfee29-1", transfertypes.Version), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: "invalid-ics29-1", AppVersion: transfertypes.Version})), false, false, }, { "invalid transfer version", - channeltypes.MergeChannelVersions(types.Version, "wrongics20-1"), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: "invalid-ics20-1"})), false, false, }, @@ -205,25 +193,31 @@ func (suite *FeeTestSuite) TestOnChanOpenAck() { }{ { "success", - channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})), func(suite *FeeTestSuite) {}, true, }, { "invalid fee version", - channeltypes.MergeChannelVersions("fee29-A", transfertypes.Version), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: "invalid-ics29-1", AppVersion: transfertypes.Version})), func(suite *FeeTestSuite) {}, false, }, { "invalid transfer version", - channeltypes.MergeChannelVersions(types.Version, "ics20-4"), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: "invalid-ics20-1"})), + func(suite *FeeTestSuite) {}, + false, + }, + { + "invalid version fails to unmarshal metadata", + "invalid-version", func(suite *FeeTestSuite) {}, false, }, { "previous INIT set without fee, however counterparty set fee version", // note this can only happen with incompetent or malicious counterparty chain - channeltypes.MergeChannelVersions(types.Version, transfertypes.Version), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})), func(suite *FeeTestSuite) { // do the first steps without fee version, then pass the fee version as counterparty version in ChanOpenACK suite.path.EndpointA.ChannelConfig.Version = transfertypes.Version diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index bfea0dabcd9..577d0e8b5f4 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -40,7 +40,7 @@ func (suite *KeeperTestSuite) SetupTest() { suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(1)) path := ibctesting.NewPath(suite.chainA, suite.chainB) - feeTransferVersion := channeltypes.MergeChannelVersions(types.Version, transfertypes.Version) + feeTransferVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})) path.EndpointA.ChannelConfig.Version = feeTransferVersion path.EndpointB.ChannelConfig.Version = feeTransferVersion path.EndpointA.ChannelConfig.PortID = transfertypes.PortID diff --git a/modules/apps/29-fee/types/metadata.pb.go b/modules/apps/29-fee/types/metadata.pb.go new file mode 100644 index 00000000000..95bb9244946 --- /dev/null +++ b/modules/apps/29-fee/types/metadata.pb.go @@ -0,0 +1,378 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: ibc/applications/fee/v1/metadata.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Metadata defines the ICS29 channel specific metadata encoded into the channel version bytestring +// See ICS004: https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#Versioning +type Metadata struct { + // fee_version defines the ICS29 fee version + FeeVersion string `protobuf:"bytes,1,opt,name=fee_version,json=feeVersion,proto3" json:"fee_version,omitempty" yaml:"fee_version"` + // app_version defines the underlying application version, which may or may not be a JSON encoded bytestring + AppVersion string `protobuf:"bytes,2,opt,name=app_version,json=appVersion,proto3" json:"app_version,omitempty" yaml:"app_version"` +} + +func (m *Metadata) Reset() { *m = Metadata{} } +func (m *Metadata) String() string { return proto.CompactTextString(m) } +func (*Metadata) ProtoMessage() {} +func (*Metadata) Descriptor() ([]byte, []int) { + return fileDescriptor_03d0f000eda681ce, []int{0} +} +func (m *Metadata) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Metadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Metadata.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Metadata) XXX_Merge(src proto.Message) { + xxx_messageInfo_Metadata.Merge(m, src) +} +func (m *Metadata) XXX_Size() int { + return m.Size() +} +func (m *Metadata) XXX_DiscardUnknown() { + xxx_messageInfo_Metadata.DiscardUnknown(m) +} + +var xxx_messageInfo_Metadata proto.InternalMessageInfo + +func (m *Metadata) GetFeeVersion() string { + if m != nil { + return m.FeeVersion + } + return "" +} + +func (m *Metadata) GetAppVersion() string { + if m != nil { + return m.AppVersion + } + return "" +} + +func init() { + proto.RegisterType((*Metadata)(nil), "ibc.applications.fee.v1.Metadata") +} + +func init() { + proto.RegisterFile("ibc/applications/fee/v1/metadata.proto", fileDescriptor_03d0f000eda681ce) +} + +var fileDescriptor_03d0f000eda681ce = []byte{ + // 248 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcb, 0x4c, 0x4a, 0xd6, + 0x4f, 0x2c, 0x28, 0xc8, 0xc9, 0x4c, 0x4e, 0x2c, 0xc9, 0xcc, 0xcf, 0x2b, 0xd6, 0x4f, 0x4b, 0x4d, + 0xd5, 0x2f, 0x33, 0xd4, 0xcf, 0x4d, 0x2d, 0x49, 0x4c, 0x49, 0x2c, 0x49, 0xd4, 0x2b, 0x28, 0xca, + 0x2f, 0xc9, 0x17, 0x12, 0xcf, 0x4c, 0x4a, 0xd6, 0x43, 0x56, 0xa7, 0x97, 0x96, 0x9a, 0xaa, 0x57, + 0x66, 0x28, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xa3, 0x0f, 0x62, 0x41, 0x94, 0x2b, 0xd5, + 0x70, 0x71, 0xf8, 0x42, 0x0d, 0x10, 0x32, 0xe7, 0xe2, 0x4e, 0x4b, 0x4d, 0x8d, 0x2f, 0x4b, 0x2d, + 0x2a, 0xce, 0xcc, 0xcf, 0x93, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x74, 0x12, 0xfb, 0x74, 0x4f, 0x5e, + 0xa8, 0x32, 0x31, 0x37, 0xc7, 0x4a, 0x09, 0x49, 0x52, 0x29, 0x88, 0x2b, 0x2d, 0x35, 0x35, 0x0c, + 0xc2, 0x01, 0x69, 0x4c, 0x2c, 0x28, 0x80, 0x6b, 0x64, 0x42, 0xd7, 0x88, 0x24, 0xa9, 0x14, 0xc4, + 0x95, 0x58, 0x50, 0x00, 0xd5, 0xe8, 0xe4, 0x7f, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, + 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, + 0x0c, 0x51, 0xa6, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xc9, 0xf9, + 0xc5, 0xb9, 0xf9, 0xc5, 0xfa, 0x99, 0x49, 0xc9, 0xba, 0xe9, 0xf9, 0xfa, 0x65, 0xc6, 0xfa, 0xb9, + 0xf9, 0x29, 0xa5, 0x39, 0xa9, 0xc5, 0xa0, 0xe0, 0x28, 0xd6, 0x37, 0xb2, 0xd4, 0x05, 0x85, 0x44, + 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x57, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x04, 0x84, 0x58, 0xe0, 0x2e, 0x01, 0x00, 0x00, +} + +func (m *Metadata) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Metadata) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Metadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AppVersion) > 0 { + i -= len(m.AppVersion) + copy(dAtA[i:], m.AppVersion) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.AppVersion))) + i-- + dAtA[i] = 0x12 + } + if len(m.FeeVersion) > 0 { + i -= len(m.FeeVersion) + copy(dAtA[i:], m.FeeVersion) + i = encodeVarintMetadata(dAtA, i, uint64(len(m.FeeVersion))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintMetadata(dAtA []byte, offset int, v uint64) int { + offset -= sovMetadata(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Metadata) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FeeVersion) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + l = len(m.AppVersion) + if l > 0 { + n += 1 + l + sovMetadata(uint64(l)) + } + return n +} + +func sovMetadata(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozMetadata(x uint64) (n int) { + return sovMetadata(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Metadata) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Metadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Metadata: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeVersion", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FeeVersion = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AppVersion", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMetadata + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthMetadata + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthMetadata + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AppVersion = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipMetadata(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthMetadata + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipMetadata(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMetadata + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMetadata + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowMetadata + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthMetadata + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupMetadata + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthMetadata + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthMetadata = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowMetadata = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupMetadata = fmt.Errorf("proto: unexpected end of group") +) diff --git a/proto/ibc/applications/fee/v1/fee.proto b/proto/ibc/applications/fee/v1/fee.proto index b57cc2cc03c..bbbd82663e1 100644 --- a/proto/ibc/applications/fee/v1/fee.proto +++ b/proto/ibc/applications/fee/v1/fee.proto @@ -34,8 +34,9 @@ message Fee { // the refund address to which any unused funds are refunded, // and an optional list of relayers that are permitted to receive the fee. message IdentifiedPacketFee { - ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"packet_id\""]; - Fee fee = 2 [(gogoproto.nullable) = false]; - string refund_address = 3 [(gogoproto.moretags) = "yaml:\"refund_address\""]; - repeated string relayers = 4; + ibc.core.channel.v1.PacketId packet_id = 1 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"packet_id\""]; + Fee fee = 2 [(gogoproto.nullable) = false]; + string refund_address = 3 [(gogoproto.moretags) = "yaml:\"refund_address\""]; + repeated string relayers = 4; } diff --git a/proto/ibc/applications/fee/v1/genesis.proto b/proto/ibc/applications/fee/v1/genesis.proto index cf88fc6602a..2396cf6d272 100644 --- a/proto/ibc/applications/fee/v1/genesis.proto +++ b/proto/ibc/applications/fee/v1/genesis.proto @@ -10,7 +10,8 @@ import "ibc/core/channel/v1/channel.proto"; // GenesisState defines the fee middleware genesis state message GenesisState { - repeated IdentifiedPacketFee identified_fees = 1 [(gogoproto.moretags) = "yaml:\"identified_fees\"", (gogoproto.nullable) = false]; + repeated IdentifiedPacketFee identified_fees = 1 + [(gogoproto.moretags) = "yaml:\"identified_fees\"", (gogoproto.nullable) = false]; repeated FeeEnabledChannel fee_enabled_channels = 2 [(gogoproto.moretags) = "yaml:\"fee_enabled_channels\""]; repeated RegisteredRelayerAddress registered_relayers = 3 [(gogoproto.moretags) = "yaml:\"registered_relayers\""]; repeated ForwardRelayerAddress forward_relayers = 4 [(gogoproto.moretags) = "yaml:\"forward_relayers\""]; @@ -31,5 +32,6 @@ message RegisteredRelayerAddress { // ForwardRelayerAddress contains the forward relayer address and packetId used for async acknowledgements message ForwardRelayerAddress { string address = 1; - ibc.core.channel.v1.PacketId packet_id = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"packet_id\""]; + ibc.core.channel.v1.PacketId packet_id = 2 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"packet_id\""]; } diff --git a/proto/ibc/applications/fee/v1/metadata.proto b/proto/ibc/applications/fee/v1/metadata.proto new file mode 100644 index 00000000000..0afb3e09b2e --- /dev/null +++ b/proto/ibc/applications/fee/v1/metadata.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; + +package ibc.applications.fee.v1; + +option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; + +import "gogoproto/gogo.proto"; + +// Metadata defines the ICS29 channel specific metadata encoded into the channel version bytestring +// See ICS004: https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#Versioning +message Metadata { + // fee_version defines the ICS29 fee version + string fee_version = 1 [(gogoproto.moretags) = "yaml:\"fee_version\""]; + // app_version defines the underlying application version, which may or may not be a JSON encoded bytestring + string app_version = 2 [(gogoproto.moretags) = "yaml:\"app_version\""]; +} diff --git a/proto/ibc/applications/fee/v1/query.proto b/proto/ibc/applications/fee/v1/query.proto index 1a41c3091c4..47db939a512 100644 --- a/proto/ibc/applications/fee/v1/query.proto +++ b/proto/ibc/applications/fee/v1/query.proto @@ -43,7 +43,7 @@ message QueryIncentivizedPacketsResponse { // QueryIncentivizedPacketRequest is the request type for querying for all incentivized packets message QueryIncentivizedPacketRequest { // PacketID - ibc.core.channel.v1.PacketId packet_id = 1[(gogoproto.nullable) = false]; + ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.nullable) = false]; // Height to query at uint64 query_height = 2; } From 6f199786e7b17e7aaaba99bff0052bcb7b6254c6 Mon Sep 17 00:00:00 2001 From: Sean King Date: Tue, 15 Feb 2022 12:17:28 +0100 Subject: [PATCH 30/79] fix: return nil on OnRecvPacket for async pay (#911) --- modules/apps/29-fee/ibc_module.go | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go index cb5eb71b6d3..66319d6be58 100644 --- a/modules/apps/29-fee/ibc_module.go +++ b/modules/apps/29-fee/ibc_module.go @@ -201,6 +201,7 @@ func (im IBCModule) OnRecvPacket( // incase of async aknowledgement (ack == nil) store the ForwardRelayer address for use later if ack == nil && found { im.keeper.SetForwardRelayerAddress(ctx, channeltypes.NewPacketId(packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence()), forwardRelayer) + return nil } return types.NewIncentivizedAcknowledgement(forwardRelayer, ack.Acknowledgement()) From ea2984bd0d7a0092377009443eb2171d432d013d Mon Sep 17 00:00:00 2001 From: Sean King Date: Tue, 15 Feb 2022 12:35:42 +0100 Subject: [PATCH 31/79] nit: ics29 comments (#910) * fix: comments * Update modules/apps/29-fee/keeper/escrow.go Co-authored-by: Aditya --- modules/apps/29-fee/keeper/escrow.go | 3 +-- modules/apps/29-fee/keeper/genesis.go | 4 ++-- modules/apps/29-fee/module.go | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index 1eb24cedc86..088362567be 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -67,7 +67,6 @@ func (k Keeper) DistributePacketFees(ctx sdk.Context, refundAcc, forwardRelayer // DistributePacketsFeesTimeout pays the timeout fee for a given packetId while refunding the acknowledgement fee & receive fee to the refund account associated with the Fee func (k Keeper) DistributePacketFeesOnTimeout(ctx sdk.Context, refundAcc string, timeoutRelayer sdk.AccAddress, feeInEscrow types.IdentifiedPacketFee) { - // check if refundAcc address works refundAddr, err := sdk.AccAddressFromBech32(refundAcc) if err != nil { panic(fmt.Sprintf("could not parse refundAcc %s to sdk.AccAddress", refundAcc)) @@ -90,7 +89,7 @@ func (k Keeper) DistributePacketFeesOnTimeout(ctx sdk.Context, refundAcc string, // If the distribution fails for any reason (such as the receiving address being blocked), // the state changes will be discarded. func (k Keeper) distributeFee(ctx sdk.Context, receiver sdk.AccAddress, fee sdk.Coins) { - // cache context before trying to send to reverse relayer + // cache context before trying to distribute fees cacheCtx, writeFn := ctx.CacheContext() err := k.bankKeeper.SendCoinsFromModuleToAccount(cacheCtx, types.ModuleName, receiver, fee) diff --git a/modules/apps/29-fee/keeper/genesis.go b/modules/apps/29-fee/keeper/genesis.go index 51879dbe14f..3eec4716bec 100644 --- a/modules/apps/29-fee/keeper/genesis.go +++ b/modules/apps/29-fee/keeper/genesis.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" ) -// InitGenesis +// InitGenesis initializes the fee middleware application state from a provided genesis state func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) { for _, fee := range state.IdentifiedFees { k.SetFeeInEscrow(ctx, fee) @@ -25,7 +25,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) { } } -// ExportGenesis +// ExportGenesis returns the fee middleware application exported genesis func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { return &types.GenesisState{ IdentifiedFees: k.GetAllIdentifiedPacketFees(ctx), diff --git a/modules/apps/29-fee/module.go b/modules/apps/29-fee/module.go index c603bcf51ec..bb9b7081c7c 100644 --- a/modules/apps/29-fee/module.go +++ b/modules/apps/29-fee/module.go @@ -120,7 +120,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.RegisterQueryServer(cfg.QueryServer(), am.keeper) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) } // InitGenesis performs genesis initialization for the ibc-29-fee module. It returns @@ -155,7 +155,6 @@ func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.V // GenerateGenesisState creates a randomized GenState of the 29-fee module. func (AppModule) GenerateGenesisState(simState *module.SimulationState) { - // simulation.RandomizedGenState(simState) } // ProposalContents doesn't return any content functions for governance proposals. From fb243c6c0ad71b2b776bf50babf761249d15b1e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Wed, 16 Feb 2022 11:20:51 +0100 Subject: [PATCH 32/79] chore: Add transfer test for ics29 (#901) * begin writing transfer test for ics29 * finish writing transfer test --- modules/apps/29-fee/transfer_test.go | 72 ++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 modules/apps/29-fee/transfer_test.go diff --git a/modules/apps/29-fee/transfer_test.go b/modules/apps/29-fee/transfer_test.go new file mode 100644 index 00000000000..863b728d45f --- /dev/null +++ b/modules/apps/29-fee/transfer_test.go @@ -0,0 +1,72 @@ +package fee_test + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" + transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" + clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" + ibctesting "github.com/cosmos/ibc-go/v3/testing" +) + +// Integration test to ensure ics29 works with ics20 +func (suite *FeeTestSuite) TestFeeTransfer() { + path := ibctesting.NewPath(suite.chainA, suite.chainB) + feeTransferVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})) + path.EndpointA.ChannelConfig.Version = feeTransferVersion + path.EndpointB.ChannelConfig.Version = feeTransferVersion + path.EndpointA.ChannelConfig.PortID = transfertypes.PortID + path.EndpointB.ChannelConfig.PortID = transfertypes.PortID + + suite.coordinator.Setup(path) + + // set up coin & ics20 packet + coin := ibctesting.TestCoin + fee := types.Fee{ + RecvFee: validCoins, + AckFee: validCoins2, + TimeoutFee: validCoins3, + } + + msgs := []sdk.Msg{ + types.NewMsgPayPacketFee(fee, path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, suite.chainA.SenderAccount.GetAddress().String(), nil), + transfertypes.NewMsgTransfer(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, coin, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), clienttypes.NewHeight(0, 100), 0), + } + res, err := suite.chainA.SendMsgs(msgs...) + suite.Require().NoError(err) // message committed + + // after incentivizing the packets + originalChainASenderAccountBalance := sdk.NewCoins(suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)) + + packet, err := ibctesting.ParsePacketFromEvents(res.GetEvents()) + suite.Require().NoError(err) + + // register counterparty address on chainB + // relayerAddress is address of sender account on chainB, but we will use it on chainA + // to differentiate from the chainA.SenderAccount for checking successful relay payouts + relayerAddress := suite.chainB.SenderAccount.GetAddress() + + msgRegister := types.NewMsgRegisterCounterpartyAddress(suite.chainB.SenderAccount.GetAddress().String(), relayerAddress.String()) + _, err = suite.chainB.SendMsgs(msgRegister) + suite.Require().NoError(err) // message committed + + // relay packet + err = path.RelayPacket(packet) + suite.Require().NoError(err) // relay committed + + // ensure relayers got paid + // relayer for forward relay: chainB.SenderAccount + // relayer for reverse relay: chainA.SenderAccount + + // check forward relay balance + suite.Require().Equal( + fee.RecvFee, + sdk.NewCoins(suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainB.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)), + ) + + suite.Require().Equal( + fee.AckFee.Add(fee.TimeoutFee...), // ack fee paid, timeout fee refunded + sdk.NewCoins(suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)).Sub(originalChainASenderAccountBalance), + ) + +} From 8d226de61c34de9e40ef494f34ab0e6d885eeab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Wed, 16 Feb 2022 12:15:15 +0100 Subject: [PATCH 33/79] refactor: ics29 OnChanOpenInit callback tests now use mock module (#924) * refactor: OnChanOpenInit callback tests now use mock module * Update modules/apps/29-fee/fee_test.go --- modules/apps/29-fee/fee_test.go | 18 ++++++++++++ modules/apps/29-fee/ibc_module_test.go | 38 ++++++++++++++++++-------- testing/simapp/app.go | 19 ++++++++----- testing/values.go | 2 ++ 4 files changed, 59 insertions(+), 18 deletions(-) diff --git a/modules/apps/29-fee/fee_test.go b/modules/apps/29-fee/fee_test.go index 85ad80709fa..6df368364bf 100644 --- a/modules/apps/29-fee/fee_test.go +++ b/modules/apps/29-fee/fee_test.go @@ -11,6 +11,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v3/testing" + ibcmock "github.com/cosmos/ibc-go/v3/testing/mock" ) type FeeTestSuite struct { @@ -24,6 +25,7 @@ type FeeTestSuite struct { path *ibctesting.Path } +// TODO: remove and rename 'SetupMockTest' to 'SetupTest' func (suite *FeeTestSuite) SetupTest() { suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) @@ -38,10 +40,26 @@ func (suite *FeeTestSuite) SetupTest() { suite.path = path } +// TODO: rename to 'SetupTest' when the above function is removed +func (suite *FeeTestSuite) SetupMockTest() { + suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) + suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) + suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) + + path := ibctesting.NewPath(suite.chainA, suite.chainB) + mockFeeVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: ibcmock.Version})) + path.EndpointA.ChannelConfig.Version = mockFeeVersion + path.EndpointB.ChannelConfig.Version = mockFeeVersion + path.EndpointA.ChannelConfig.PortID = ibctesting.MockFeePort + path.EndpointB.ChannelConfig.PortID = ibctesting.MockFeePort + suite.path = path +} + func TestIBCFeeTestSuite(t *testing.T) { suite.Run(t, new(FeeTestSuite)) } +// TODO: remove func (suite *FeeTestSuite) CreateICS20Packet(coin sdk.Coin) channeltypes.Packet { fungibleTokenPacket := transfertypes.NewFungibleTokenPacketData( diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index 5c4b198efb3..8f1e4ad1f28 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -1,6 +1,8 @@ package fee_test import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" @@ -9,6 +11,7 @@ import ( channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" ibctesting "github.com/cosmos/ibc-go/v3/testing" + ibcmock "github.com/cosmos/ibc-go/v3/testing/mock" "github.com/cosmos/ibc-go/v3/testing/simapp" ) @@ -26,27 +29,27 @@ func (suite *FeeTestSuite) TestOnChanOpenInit() { expPass bool }{ { - "success - valid fee middleware and transfer version", - string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})), + "success - valid fee middleware and mock version", + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: ibcmock.Version})), true, }, { - "success - fee version not included, only perform transfer logic", - transfertypes.Version, + "success - fee version not included, only perform mock logic", + ibcmock.Version, true, }, { "invalid fee middleware version", - string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: "invalid-ics29-1", AppVersion: transfertypes.Version})), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: "invalid-ics29-1", AppVersion: ibcmock.Version})), false, }, { - "invalid transfer version", - string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: "invalid-ics20-1"})), + "invalid mock version", + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: "invalid-mock-version"})), false, }, { - "transfer version not wrapped", + "mock version not wrapped", types.Version, false, }, @@ -57,8 +60,21 @@ func (suite *FeeTestSuite) TestOnChanOpenInit() { suite.Run(tc.name, func() { // reset suite - suite.SetupTest() + suite.SetupMockTest() suite.coordinator.SetupConnections(suite.path) + + // setup mock callback + suite.chainA.GetSimApp().FeeMockModule.IBCApp.OnChanOpenInit = func(ctx sdk.Context, order channeltypes.Order, connectionHops []string, + portID, channelID string, chanCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, version string, + ) error { + if version != ibcmock.Version { + return fmt.Errorf("incorrect mock version") + } + + return nil + } + suite.path.EndpointA.ChannelID = ibctesting.FirstChannelID counterparty := channeltypes.NewCounterparty(suite.path.EndpointB.ChannelConfig.PortID, suite.path.EndpointB.ChannelID) @@ -70,10 +86,10 @@ func (suite *FeeTestSuite) TestOnChanOpenInit() { Version: tc.version, } - module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort) + module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) - chanCap, err := suite.chainA.App.GetScopedIBCKeeper().NewCapability(suite.chainA.GetContext(), host.ChannelCapabilityPath(ibctesting.TransferPort, suite.path.EndpointA.ChannelID)) + chanCap, err := suite.chainA.App.GetScopedIBCKeeper().NewCapability(suite.chainA.GetContext(), host.ChannelCapabilityPath(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID)) suite.Require().NoError(err) cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 680a01791cd..45f8cbf0b1c 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -114,6 +114,11 @@ import ( const appName = "SimApp" +// IBC application testing ports +const ( + MockFeePort string = ibcmock.ModuleName + ibcfeetypes.ModuleName +) + var ( // DefaultNodeHome default home directories for the application daemon DefaultNodeHome string @@ -217,6 +222,7 @@ type SimApp struct { // make IBC modules public for test purposes // these modules are never directly routed to by the IBC Router ICAAuthModule ibcmock.IBCModule + FeeMockModule ibcmock.IBCModule // the module manager mm *module.Manager @@ -288,7 +294,7 @@ func NewSimApp( // NOTE: the IBC mock keeper and application module is used only for testing core IBC. Do // not replicate if you do not need to test core IBC or light clients. scopedIBCMockKeeper := app.CapabilityKeeper.ScopeToModule(ibcmock.ModuleName) - scopedFeeMockKeeper := app.CapabilityKeeper.ScopeToModule(ibcmock.ModuleName + ibcfeetypes.ModuleName) + scopedFeeMockKeeper := app.CapabilityKeeper.ScopeToModule(MockFeePort) scopedICAMockKeeper := app.CapabilityKeeper.ScopeToModule(ibcmock.ModuleName + icacontrollertypes.SubModuleName) // seal capability keeper after scoping modules @@ -371,11 +377,10 @@ func NewSimApp( mockModule := ibcmock.NewAppModule(&app.IBCKeeper.PortKeeper) // create fee wrapped mock module - feeMockModule := ibcfee.NewIBCModule( - app.IBCFeeKeeper, ibcmock.NewIBCModule( - &mockModule, ibcmock.NewMockIBCApp(ibcmock.ModuleName+ibcfeetypes.ModuleName, scopedFeeMockKeeper), - ), - ) + feeMockModule := ibcmock.NewIBCModule(&mockModule, ibcmock.NewMockIBCApp(MockFeePort, scopedFeeMockKeeper)) + app.FeeMockModule = feeMockModule + + feeWithMockModule := ibcfee.NewIBCModule(app.IBCFeeKeeper, feeMockModule) mockIBCModule := ibcmock.NewIBCModule(&mockModule, ibcmock.NewMockIBCApp(ibcmock.ModuleName, scopedIBCMockKeeper)) @@ -409,7 +414,7 @@ func NewSimApp( AddRoute(ibcmock.ModuleName+icacontrollertypes.SubModuleName, icaControllerIBCModule). // ica with mock auth module stack route to ica (top level of middleware stack) AddRoute(ibctransfertypes.ModuleName, feeTransferModule). AddRoute(ibcmock.ModuleName, mockIBCModule). - AddRoute(ibcmock.ModuleName+ibcfeetypes.ModuleName, feeMockModule) + AddRoute(ibcmock.ModuleName+ibcfeetypes.ModuleName, feeWithMockModule) app.IBCKeeper.SetRouter(ibcRouter) diff --git a/testing/values.go b/testing/values.go index 6bdf782c65a..655a4731a74 100644 --- a/testing/values.go +++ b/testing/values.go @@ -14,6 +14,7 @@ import ( commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" "github.com/cosmos/ibc-go/v3/testing/mock" + "github.com/cosmos/ibc-go/v3/testing/simapp" ) const ( @@ -33,6 +34,7 @@ const ( // Application Ports TransferPort = ibctransfertypes.ModuleName MockPort = mock.ModuleName + MockFeePort = simapp.MockFeePort // used for testing proposals Title = "title" From 2c1ff0b8a0f2908f50d2d286013b769289e5cc84 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 16 Feb 2022 17:01:50 +0000 Subject: [PATCH 34/79] feat: allow multiple addrs to incentivize packets (#915) * [WIP] allow multiple addresses to incentivize a packet * distribute multiple fees, fix broken tests * use NewIdentifiedPacketFees in EscrowPacketFee * cleanup var naming * removing commented out code and adding test case * Update modules/apps/29-fee/ibc_module.go Co-authored-by: Aditya * fix: refund RecvFee if ForwardAddr is invalid * test: update tests to distribute multiple identified fees * refactor: clean up DistrPacketFees * refactor: using .Empty() helper func for code hygiene Co-authored-by: Aditya Co-authored-by: Sean King Co-authored-by: Sean King --- docs/ibc/proto-docs.md | 16 ++ modules/apps/29-fee/ibc_module.go | 20 +- modules/apps/29-fee/ibc_module_test.go | 16 +- modules/apps/29-fee/keeper/escrow.go | 127 ++++----- modules/apps/29-fee/keeper/escrow_test.go | 55 ++-- modules/apps/29-fee/keeper/genesis_test.go | 30 +-- modules/apps/29-fee/keeper/grpc_query_test.go | 8 +- modules/apps/29-fee/keeper/keeper.go | 63 +++++ modules/apps/29-fee/keeper/keeper_test.go | 15 +- modules/apps/29-fee/types/fee.go | 13 + modules/apps/29-fee/types/fee.pb.go | 248 +++++++++++++++--- modules/apps/29-fee/types/fee_test.go | 11 + modules/apps/29-fee/types/keys.go | 13 + modules/apps/29-fee/types/tx.pb.go | 75 +++--- proto/ibc/applications/fee/v1/fee.proto | 6 + proto/ibc/applications/fee/v1/tx.proto | 1 - 16 files changed, 526 insertions(+), 191 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index e51f12b9d56..84127283e32 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -31,6 +31,7 @@ - [ibc/applications/fee/v1/fee.proto](#ibc/applications/fee/v1/fee.proto) - [Fee](#ibc.applications.fee.v1.Fee) - [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) + - [IdentifiedPacketFees](#ibc.applications.fee.v1.IdentifiedPacketFees) - [ibc/applications/fee/v1/genesis.proto](#ibc/applications/fee/v1/genesis.proto) - [FeeEnabledChannel](#ibc.applications.fee.v1.FeeEnabledChannel) @@ -736,6 +737,21 @@ and an optional list of relayers that are permitted to receive the fee. + + + +### IdentifiedPacketFees +IdentifiedPacketFees contains a list of packet fees + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `packet_fees` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | repeated | | + + + + + diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go index 66319d6be58..66e40d5d8d8 100644 --- a/modules/apps/29-fee/ibc_module.go +++ b/modules/apps/29-fee/ibc_module.go @@ -224,15 +224,17 @@ func (im IBCModule) OnAcknowledgementPacket( return sdkerrors.Wrapf(err, "cannot unmarshal ICS-29 incentivized packet acknowledgement: %v", ack) } - packetId := channeltypes.NewPacketId(packet.SourceChannel, packet.SourcePort, packet.Sequence) - - identifiedPacketFee, found := im.keeper.GetFeeInEscrow(ctx, packetId) + packetID := channeltypes.NewPacketId(packet.SourceChannel, packet.SourcePort, packet.Sequence) + identifiedPacketFees, found := im.keeper.GetFeesInEscrow(ctx, packetID) if !found { // return underlying callback if no fee found for given packetID return im.app.OnAcknowledgementPacket(ctx, packet, ack.Result, relayer) } - im.keeper.DistributePacketFees(ctx, identifiedPacketFee.RefundAddress, ack.ForwardRelayerAddress, relayer, identifiedPacketFee) + im.keeper.DistributePacketFees(ctx, ack.ForwardRelayerAddress, relayer, identifiedPacketFees.PacketFees) + + // removes the fees from the store as fees are now paid + im.keeper.DeleteFeesInEscrow(ctx, packetID) // call underlying callback return im.app.OnAcknowledgementPacket(ctx, packet, ack.Result, relayer) @@ -249,15 +251,17 @@ func (im IBCModule) OnTimeoutPacket( return im.app.OnTimeoutPacket(ctx, packet, relayer) } - packetId := channeltypes.NewPacketId(packet.SourceChannel, packet.SourcePort, packet.Sequence) - - identifiedPacketFee, found := im.keeper.GetFeeInEscrow(ctx, packetId) + packetID := channeltypes.NewPacketId(packet.SourceChannel, packet.SourcePort, packet.Sequence) + identifiedPacketFees, found := im.keeper.GetFeesInEscrow(ctx, packetID) if !found { // return underlying callback if fee not found for given packetID return im.app.OnTimeoutPacket(ctx, packet, relayer) } - im.keeper.DistributePacketFeesOnTimeout(ctx, identifiedPacketFee.RefundAddress, relayer, identifiedPacketFee) + im.keeper.DistributePacketFeesOnTimeout(ctx, relayer, identifiedPacketFees.PacketFees) + + // removes the fee from the store as fee is now paid + im.keeper.DeleteFeesInEscrow(ctx, packetID) // call underlying callback return im.app.OnTimeoutPacket(ctx, packet, relayer) diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index 8f1e4ad1f28..858a6ce9dcd 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -542,7 +542,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { "no op success without a packet fee", func() { packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) - suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeeInEscrow(suite.chainA.GetContext(), packetId) + suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeesInEscrow(suite.chainA.GetContext(), packetId) ack = types.IncentivizedAcknowledgement{ Result: channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement(), @@ -636,8 +636,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { originalBalance = sdk.NewCoins(suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)) // default to success case - expectedBalance = originalBalance. - Add(identifiedFee.Fee.TimeoutFee[0]) + expectedBalance = originalBalance.Add(identifiedFee.Fee.TimeoutFee[0]) // malleate test case tc.malleate() @@ -696,7 +695,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { func() { // delete packet fee packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) - suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeeInEscrow(suite.chainA.GetContext(), packetId) + suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeesInEscrow(suite.chainA.GetContext(), packetId) expectedBalance = originalBalance.Add(ibctesting.TestCoin) // timeout refund for ics20 transfer }, @@ -781,10 +780,11 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { relayerBalance := sdk.NewCoins(suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), relayerAddr, ibctesting.TestCoin.Denom)) if tc.expFeeDistributed { - suite.Require().Equal( - identifiedFee.Fee.TimeoutFee, - relayerBalance, - ) + // there should no longer be a fee in escrow for this packet + found := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeesInEscrow(suite.chainA.GetContext(), packetId) + suite.Require().False(found) + + suite.Require().Equal(identifiedFee.Fee.TimeoutFee, relayerBalance) } else { suite.Require().Empty(relayerBalance) } diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index 088362567be..e97096271b7 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -26,63 +26,67 @@ func (k Keeper) EscrowPacketFee(ctx sdk.Context, identifiedFee types.IdentifiedP return sdkerrors.Wrapf(types.ErrRefundAccNotFound, "account with address: %s not found", refundAcc) } - coins := identifiedFee.Fee.RecvFee - coins = coins.Add(identifiedFee.Fee.AckFee...) - coins = coins.Add(identifiedFee.Fee.TimeoutFee...) - - if err := k.bankKeeper.SendCoinsFromAccountToModule( - ctx, refundAcc, types.ModuleName, coins, - ); err != nil { + coins := identifiedFee.Fee.Total() + if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, refundAcc, types.ModuleName, coins); err != nil { return err } - // Store fee in state for reference later - k.SetFeeInEscrow(ctx, identifiedFee) + packetFees := []types.IdentifiedPacketFee{identifiedFee} + if feesInEscrow, found := k.GetFeesInEscrow(ctx, identifiedFee.PacketId); found { + packetFees = append(packetFees, feesInEscrow.PacketFees...) + } + + identifiedFees := types.NewIdentifiedPacketFees(packetFees) + k.SetFeesInEscrow(ctx, identifiedFee.PacketId, identifiedFees) + return nil } // DistributePacketFees pays the acknowledgement fee & receive fee for a given packetId while refunding the timeout fee to the refund account associated with the Fee. -func (k Keeper) DistributePacketFees(ctx sdk.Context, refundAcc, forwardRelayer string, reverseRelayer sdk.AccAddress, feeInEscrow types.IdentifiedPacketFee) { - // distribute fee for forward relaying - forward, err := sdk.AccAddressFromBech32(forwardRelayer) - if err == nil { - k.distributeFee(ctx, forward, feeInEscrow.Fee.RecvFee) - } +func (k Keeper) DistributePacketFees(ctx sdk.Context, forwardRelayer string, reverseRelayer sdk.AccAddress, feesInEscrow []types.IdentifiedPacketFee) { + forwardAddr, _ := sdk.AccAddressFromBech32(forwardRelayer) - // distribute fee for reverse relaying - k.distributeFee(ctx, reverseRelayer, feeInEscrow.Fee.AckFee) + for _, packetFee := range feesInEscrow { + refundAddr, err := sdk.AccAddressFromBech32(packetFee.RefundAddress) + if err != nil { + panic(fmt.Sprintf("could not parse refundAcc %s to sdk.AccAddress", packetFee.RefundAddress)) + } - // refund timeout fee refund, - refundAddr, err := sdk.AccAddressFromBech32(refundAcc) - if err != nil { - panic(fmt.Sprintf("could not parse refundAcc %s to sdk.AccAddress", refundAcc)) - } + // distribute fee to valid forward relayer address otherwise refund the fee + if !forwardAddr.Empty() { + // distribute fee for forward relaying + k.distributeFee(ctx, forwardAddr, packetFee.Fee.RecvFee) + } else { + // refund onRecv fee as forward relayer is not valid address + k.distributeFee(ctx, refundAddr, packetFee.Fee.RecvFee) + } - // refund timeout fee for unused timeout - k.distributeFee(ctx, refundAddr, feeInEscrow.Fee.TimeoutFee) + // distribute fee for reverse relaying + k.distributeFee(ctx, reverseRelayer, packetFee.Fee.AckFee) - // removes the fee from the store as fee is now paid - k.DeleteFeeInEscrow(ctx, feeInEscrow.PacketId) + // refund timeout fee for unused timeout + k.distributeFee(ctx, refundAddr, packetFee.Fee.TimeoutFee) + } } // DistributePacketsFeesTimeout pays the timeout fee for a given packetId while refunding the acknowledgement fee & receive fee to the refund account associated with the Fee -func (k Keeper) DistributePacketFeesOnTimeout(ctx sdk.Context, refundAcc string, timeoutRelayer sdk.AccAddress, feeInEscrow types.IdentifiedPacketFee) { - refundAddr, err := sdk.AccAddressFromBech32(refundAcc) - if err != nil { - panic(fmt.Sprintf("could not parse refundAcc %s to sdk.AccAddress", refundAcc)) - } - - // refund receive fee for unused forward relaying - k.distributeFee(ctx, refundAddr, feeInEscrow.Fee.RecvFee) +func (k Keeper) DistributePacketFeesOnTimeout(ctx sdk.Context, timeoutRelayer sdk.AccAddress, feesInEscrow []types.IdentifiedPacketFee) { + for _, feeInEscrow := range feesInEscrow { + // check if refundAcc address works + refundAddr, err := sdk.AccAddressFromBech32(feeInEscrow.RefundAddress) + if err != nil { + panic(fmt.Sprintf("could not parse refundAcc %s to sdk.AccAddress", feeInEscrow.RefundAddress)) + } - // refund ack fee for unused reverse relaying - k.distributeFee(ctx, refundAddr, feeInEscrow.Fee.AckFee) + // refund receive fee for unused forward relaying + k.distributeFee(ctx, refundAddr, feeInEscrow.Fee.RecvFee) - // distribute fee for timeout relaying - k.distributeFee(ctx, timeoutRelayer, feeInEscrow.Fee.TimeoutFee) + // refund ack fee for unused reverse relaying + k.distributeFee(ctx, refundAddr, feeInEscrow.Fee.AckFee) - // removes the fee from the store as fee is now paid - k.DeleteFeeInEscrow(ctx, feeInEscrow.PacketId) + // distribute fee for timeout relaying + k.distributeFee(ctx, timeoutRelayer, feeInEscrow.Fee.TimeoutFee) + } } // distributeFee will attempt to distribute the escrowed fee to the receiver address. @@ -106,28 +110,31 @@ func (k Keeper) RefundFeesOnChannel(ctx sdk.Context, portID, channelID string) e var refundErr error - k.IterateChannelFeesInEscrow(ctx, portID, channelID, func(identifiedFee types.IdentifiedPacketFee) (stop bool) { - refundAccAddr, err := sdk.AccAddressFromBech32(identifiedFee.RefundAddress) - if err != nil { - refundErr = err - return true + k.IterateIdentifiedChannelFeesInEscrow(ctx, portID, channelID, func(identifiedFees types.IdentifiedPacketFees) (stop bool) { + for _, identifiedFee := range identifiedFees.PacketFees { + refundAccAddr, err := sdk.AccAddressFromBech32(identifiedFee.RefundAddress) + if err != nil { + refundErr = err + return true + } + + // refund all fees to refund address + // Use SendCoins rather than the module account send functions since refund address may be a user account or module address. + // if any `SendCoins` call returns an error, we return error and stop iteration + if err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.RecvFee); err != nil { + refundErr = err + return true + } + if err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.AckFee); err != nil { + refundErr = err + return true + } + if err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.TimeoutFee); err != nil { + refundErr = err + return true + } } - // refund all fees to refund address - // Use SendCoins rather than the module account send functions since refund address may be a user account or module address. - // if any `SendCoins` call returns an error, we return error and stop iteration - if err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.RecvFee); err != nil { - refundErr = err - return true - } - if err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.AckFee); err != nil { - refundErr = err - return true - } - if err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, refundAccAddr, identifiedFee.Fee.TimeoutFee); err != nil { - refundErr = err - return true - } return false }) diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go index 8642cca14d9..0be30c8c22f 100644 --- a/modules/apps/29-fee/keeper/escrow_test.go +++ b/modules/apps/29-fee/keeper/escrow_test.go @@ -27,6 +27,23 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { { "success", func() {}, true, }, + { + "success with existing packet fee", func() { + fee := types.Fee{ + RecvFee: receiveFee, + AckFee: ackFee, + TimeoutFee: timeoutFee, + } + + identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) + + feesInEscrow := types.IdentifiedPacketFees{ + PacketFees: []types.IdentifiedPacketFee{identifiedPacketFee}, + } + + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeesInEscrow(suite.chainA.GetContext(), packetId, feesInEscrow) + }, true, + }, { "fee not enabled on this channel", func() { packetId.ChannelId = "disabled_channel" @@ -84,11 +101,12 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) if tc.expPass { - feeInEscrow, _ := suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeInEscrow(suite.chainA.GetContext(), packetId) + feesInEscrow, found := suite.chainA.GetSimApp().IBCFeeKeeper.GetFeesInEscrow(suite.chainA.GetContext(), packetId) + suite.Require().True(found) // check if the escrowed fee is set in state - suite.Require().True(feeInEscrow.Fee.AckFee.IsEqual(fee.AckFee)) - suite.Require().True(feeInEscrow.Fee.RecvFee.IsEqual(fee.RecvFee)) - suite.Require().True(feeInEscrow.Fee.TimeoutFee.IsEqual(fee.TimeoutFee)) + suite.Require().True(feesInEscrow.PacketFees[0].Fee.AckFee.IsEqual(fee.AckFee)) + suite.Require().True(feesInEscrow.PacketFees[0].Fee.RecvFee.IsEqual(fee.RecvFee)) + suite.Require().True(feesInEscrow.PacketFees[0].Fee.TimeoutFee.IsEqual(fee.TimeoutFee)) // check if the fee is escrowed correctly hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(600)}) suite.Require().True(hasBalance) @@ -152,13 +170,16 @@ func (suite *KeeperTestSuite) TestDistributeFee() { err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) suite.Require().NoError(err) + // escrow a second packet fee to test with multiple fees distributed + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + suite.Require().NoError(err) tc.malleate() // refundAcc balance after escrow refundAccBal := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom) - suite.chainA.GetSimApp().IBCFeeKeeper.DistributePacketFees(suite.chainA.GetContext(), refundAcc.String(), forwardRelayer, reverseRelayer, identifiedPacketFee) + suite.chainA.GetSimApp().IBCFeeKeeper.DistributePacketFees(suite.chainA.GetContext(), forwardRelayer, reverseRelayer, []types.IdentifiedPacketFee{identifiedPacketFee, identifiedPacketFee}) if tc.expPass { // there should no longer be a fee in escrow for this packet @@ -166,17 +187,17 @@ func (suite *KeeperTestSuite) TestDistributeFee() { suite.Require().False(found) // check if the reverse relayer is paid - hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), reverseRelayer, fee.AckFee[0]) + hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), reverseRelayer, fee.AckFee[0].Add(fee.AckFee[0])) suite.Require().True(hasBalance) // check if the forward relayer is paid forward, err := sdk.AccAddressFromBech32(forwardRelayer) suite.Require().NoError(err) - hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), forward, fee.RecvFee[0]) + hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), forward, fee.RecvFee[0].Add(fee.RecvFee[0])) suite.Require().True(hasBalance) // check if the refund acc has been refunded the timeoutFee - expectedRefundAccBal := refundAccBal.Add(fee.TimeoutFee[0]) + expectedRefundAccBal := refundAccBal.Add(fee.TimeoutFee[0].Add(fee.TimeoutFee[0])) hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), refundAcc, expectedRefundAccBal) suite.Require().True(hasBalance) @@ -184,8 +205,9 @@ func (suite *KeeperTestSuite) TestDistributeFee() { hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(0)}) suite.Require().True(hasBalance) } else { - // check the module acc wallet still has forward relaying balance - hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeModuleAddress(), fee.RecvFee[0]) + // check if the refund acc has been refunded the timeoutFee & onRecvFee + expectedRefundAccBal := refundAccBal.Add(fee.TimeoutFee[0]).Add(fee.RecvFee[0]).Add(fee.TimeoutFee[0]).Add(fee.RecvFee[0]) + hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), refundAcc, expectedRefundAccBal) suite.Require().True(hasBalance) } }) @@ -221,23 +243,22 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) suite.Require().NoError(err) + // escrow a second packet fee to test with multiple fees distributed + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + suite.Require().NoError(err) // refundAcc balance after escrow refundAccBal := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom) - suite.chainA.GetSimApp().IBCFeeKeeper.DistributePacketFeesOnTimeout(suite.chainA.GetContext(), refundAcc.String(), timeoutRelayer, identifiedPacketFee) - - // there should no longer be a fee in escrow for this packet - found := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), packetId) - suite.Require().False(found) + suite.chainA.GetSimApp().IBCFeeKeeper.DistributePacketFeesOnTimeout(suite.chainA.GetContext(), timeoutRelayer, []types.IdentifiedPacketFee{identifiedPacketFee, identifiedPacketFee}) // check if the timeoutRelayer has been paid hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), timeoutRelayer, fee.TimeoutFee[0]) suite.Require().True(hasBalance) // check if the refund acc has been refunded the recv & ack fees - expectedRefundAccBal := refundAccBal.Add(fee.AckFee[0]) - expectedRefundAccBal = refundAccBal.Add(fee.RecvFee[0]) + expectedRefundAccBal := refundAccBal.Add(fee.AckFee[0]).Add(fee.AckFee[0]) + expectedRefundAccBal = refundAccBal.Add(fee.RecvFee[0]).Add(fee.RecvFee[0]) hasBalance = suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), refundAcc, expectedRefundAccBal) suite.Require().True(hasBalance) diff --git a/modules/apps/29-fee/keeper/genesis_test.go b/modules/apps/29-fee/keeper/genesis_test.go index 568335daed1..3d4f42a3c28 100644 --- a/modules/apps/29-fee/keeper/genesis_test.go +++ b/modules/apps/29-fee/keeper/genesis_test.go @@ -18,9 +18,9 @@ func (suite *KeeperTestSuite) TestInitGenesis() { uint64(1), ) fee := types.Fee{ - defaultReceiveFee, - defaultAckFee, - defaultTimeoutFee, + RecvFee: defaultReceiveFee, + AckFee: defaultAckFee, + TimeoutFee: defaultTimeoutFee, } // relayer addresses @@ -74,19 +74,15 @@ func (suite *KeeperTestSuite) TestExportGenesis() { // setup & escrow the packet fee refundAcc := suite.chainA.SenderAccount.GetAddress() - packetId := channeltypes.NewPacketId( - ibctesting.FirstChannelID, - transfertypes.PortID, - uint64(1), - ) + packetID := channeltypes.NewPacketId(ibctesting.FirstChannelID, transfertypes.PortID, 1) fee := types.Fee{ - defaultReceiveFee, - defaultAckFee, - defaultTimeoutFee, + RecvFee: defaultReceiveFee, + AckFee: defaultAckFee, + TimeoutFee: defaultTimeoutFee, } - identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) - suite.Require().NoError(err) + + identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeInEscrow(suite.chainA.GetContext(), identifiedPacketFee) // relayer addresses sender := suite.chainA.SenderAccount.GetAddress().String() @@ -95,7 +91,7 @@ func (suite *KeeperTestSuite) TestExportGenesis() { suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainA.GetContext(), sender, counterparty) // set forward relayer address - suite.chainA.GetSimApp().IBCFeeKeeper.SetForwardRelayerAddress(suite.chainA.GetContext(), packetId, sender) + suite.chainA.GetSimApp().IBCFeeKeeper.SetForwardRelayerAddress(suite.chainA.GetContext(), packetID, sender) // export genesis genesisState := suite.chainA.GetSimApp().IBCFeeKeeper.ExportGenesis(suite.chainA.GetContext()) @@ -105,7 +101,7 @@ func (suite *KeeperTestSuite) TestExportGenesis() { suite.Require().Equal(transfertypes.PortID, genesisState.FeeEnabledChannels[0].PortId) // check fee - suite.Require().Equal(packetId, genesisState.IdentifiedFees[0].PacketId) + suite.Require().Equal(packetID, genesisState.IdentifiedFees[0].PacketId) suite.Require().Equal(fee, genesisState.IdentifiedFees[0].Fee) suite.Require().Equal(refundAcc.String(), genesisState.IdentifiedFees[0].RefundAddress) suite.Require().Equal([]string(nil), genesisState.IdentifiedFees[0].Relayers) @@ -116,5 +112,5 @@ func (suite *KeeperTestSuite) TestExportGenesis() { // check registered relayer addresses suite.Require().Equal(sender, genesisState.ForwardRelayers[0].Address) - suite.Require().Equal(packetId, genesisState.ForwardRelayers[0].PacketId) + suite.Require().Equal(packetID, genesisState.ForwardRelayers[0].PacketId) } diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index 2c41da93d1e..9074002473a 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -70,8 +70,8 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketI() { tc.malleate() suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, ibctesting.FirstChannelID) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) - suite.Require().NoError(err) + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeInEscrow(suite.chainA.GetContext(), identifiedPacketFee) + ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) res, err := suite.queryClient.IncentivizedPacket(ctx, req) @@ -123,8 +123,8 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPackets() { expPackets = append(expPackets, &fee1, &fee2, &fee3) suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, ibctesting.FirstChannelID) - for _, p := range expPackets { - suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), *p) + for _, packetFee := range expPackets { + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeInEscrow(suite.chainA.GetContext(), *packetFee) } req = &types.QueryIncentivizedPacketsRequest{ diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index 441aaf57a2c..d82e17b69a4 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -247,6 +247,40 @@ func (k Keeper) GetFeeInEscrow(ctx sdk.Context, packetId channeltypes.PacketId) return fee, true } +// GetFeesInEscrow returns all escrowed packet fees for a given packetID +func (k Keeper) GetFeesInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) (types.IdentifiedPacketFees, bool) { + store := ctx.KVStore(k.storeKey) + key := types.KeyFeesInEscrow(packetID) + bz := store.Get(key) + if bz == nil { + return types.IdentifiedPacketFees{}, false + } + + return k.MustUnmarshalFees(bz), true +} + +// HasFeesInEscrow returns true if packet fees exist for the provided packetID +func (k Keeper) HasFeesInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) bool { + store := ctx.KVStore(k.storeKey) + key := types.KeyFeesInEscrow(packetID) + + return store.Has(key) +} + +// SetFeesInEscrow sets the given packet fees in escrow keyed by the packet identifier +func (k Keeper) SetFeesInEscrow(ctx sdk.Context, packetID channeltypes.PacketId, fees types.IdentifiedPacketFees) { + store := ctx.KVStore(k.storeKey) + bz := k.MustMarshalFees(fees) + store.Set(types.KeyFeesInEscrow(packetID), bz) +} + +// DeleteFeesInEscrow deletes the fee associated with the given packetID +func (k Keeper) DeleteFeesInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) { + store := ctx.KVStore(k.storeKey) + key := types.KeyFeesInEscrow(packetID) + store.Delete(key) +} + // IterateChannelFeesInEscrow iterates over all the fees on the given channel currently escrowed and calls the provided callback // if the callback returns true, then iteration is stopped. func (k Keeper) IterateChannelFeesInEscrow(ctx sdk.Context, portID, channelID string, cb func(identifiedFee types.IdentifiedPacketFee) (stop bool)) { @@ -262,6 +296,21 @@ func (k Keeper) IterateChannelFeesInEscrow(ctx sdk.Context, portID, channelID st } } +// IterateIdentifiedChannelFeesInEscrow iterates over all the fees on the given channel currently escrowed and calls the provided callback +// if the callback returns true, then iteration is stopped. +func (k Keeper) IterateIdentifiedChannelFeesInEscrow(ctx sdk.Context, portID, channelID string, cb func(identifiedFees types.IdentifiedPacketFees) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.KeyFeesInEscrowChannelPrefix(portID, channelID)) + + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + identifiedFees := k.MustUnmarshalFees(iterator.Value()) + if cb(identifiedFees) { + break + } + } +} + // Deletes the fee associated with the given packetId func (k Keeper) DeleteFeeInEscrow(ctx sdk.Context, packetId channeltypes.PacketId) { store := ctx.KVStore(k.storeKey) @@ -305,3 +354,17 @@ func (k Keeper) MustUnmarshalFee(bz []byte) types.IdentifiedPacketFee { k.cdc.MustUnmarshal(bz, &fee) return fee } + +// MustMarshalFees attempts to encode a Fee object and returns the +// raw encoded bytes. It panics on error. +func (k Keeper) MustMarshalFees(fees types.IdentifiedPacketFees) []byte { + return k.cdc.MustMarshal(&fees) +} + +// MustUnmarshalFees attempts to decode and return a Fee object from +// raw encoded bytes. It panics on error. +func (k Keeper) MustUnmarshalFees(bz []byte) types.IdentifiedPacketFees { + var fees types.IdentifiedPacketFees + k.cdc.MustUnmarshal(bz, &fees) + return fees +} diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index 3e21e268597..b510aa7b7c9 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -101,17 +101,20 @@ func (suite *KeeperTestSuite) TestGetAllIdentifiedPacketFees() { // escrow a fee refundAcc := suite.chainA.SenderAccount.GetAddress() - packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, transfertypes.PortID, uint64(1)) - fee := types.Fee{defaultAckFee, defaultReceiveFee, defaultTimeoutFee} - identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) + packetID := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, transfertypes.PortID, 1) + fee := types.Fee{ + AckFee: defaultAckFee, + RecvFee: defaultReceiveFee, + TimeoutFee: defaultTimeoutFee, + } // escrow the packet fee - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) - suite.Require().NoError(err) + identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeInEscrow(suite.chainA.GetContext(), identifiedPacketFee) expectedFees := []types.IdentifiedPacketFee{ { - PacketId: packetId, + PacketId: packetID, Fee: fee, RefundAddress: refundAcc.String(), Relayers: nil, diff --git a/modules/apps/29-fee/types/fee.go b/modules/apps/29-fee/types/fee.go index 841a1a3a0c1..7453c88e50e 100644 --- a/modules/apps/29-fee/types/fee.go +++ b/modules/apps/29-fee/types/fee.go @@ -3,9 +3,22 @@ package types import ( "strings" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) +// NewIdentifiedPacketFees creates and returns a new IdentifiedPacketFees struct +func NewIdentifiedPacketFees(packetFees []IdentifiedPacketFee) IdentifiedPacketFees { + return IdentifiedPacketFees{ + PacketFees: packetFees, + } +} + +// Total returns the total amount for a given Fee +func (f Fee) Total() sdk.Coins { + return f.RecvFee.Add(f.AckFee...).Add(f.TimeoutFee...) +} + // Validate asserts that each Fee is valid and all three Fees are not empty or zero func (fee Fee) Validate() error { var errFees []string diff --git a/modules/apps/29-fee/types/fee.pb.go b/modules/apps/29-fee/types/fee.pb.go index 4fa6f240abb..8be56939659 100644 --- a/modules/apps/29-fee/types/fee.pb.go +++ b/modules/apps/29-fee/types/fee.pb.go @@ -161,46 +161,94 @@ func (m *IdentifiedPacketFee) GetRelayers() []string { return nil } +// IdentifiedPacketFees contains a list of packet fees +type IdentifiedPacketFees struct { + PacketFees []IdentifiedPacketFee `protobuf:"bytes,1,rep,name=packet_fees,json=packetFees,proto3" json:"packet_fees" yaml:"packet_fees"` +} + +func (m *IdentifiedPacketFees) Reset() { *m = IdentifiedPacketFees{} } +func (m *IdentifiedPacketFees) String() string { return proto.CompactTextString(m) } +func (*IdentifiedPacketFees) ProtoMessage() {} +func (*IdentifiedPacketFees) Descriptor() ([]byte, []int) { + return fileDescriptor_cb3319f1af2a53e5, []int{2} +} +func (m *IdentifiedPacketFees) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IdentifiedPacketFees) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IdentifiedPacketFees.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *IdentifiedPacketFees) XXX_Merge(src proto.Message) { + xxx_messageInfo_IdentifiedPacketFees.Merge(m, src) +} +func (m *IdentifiedPacketFees) XXX_Size() int { + return m.Size() +} +func (m *IdentifiedPacketFees) XXX_DiscardUnknown() { + xxx_messageInfo_IdentifiedPacketFees.DiscardUnknown(m) +} + +var xxx_messageInfo_IdentifiedPacketFees proto.InternalMessageInfo + +func (m *IdentifiedPacketFees) GetPacketFees() []IdentifiedPacketFee { + if m != nil { + return m.PacketFees + } + return nil +} + func init() { proto.RegisterType((*Fee)(nil), "ibc.applications.fee.v1.Fee") proto.RegisterType((*IdentifiedPacketFee)(nil), "ibc.applications.fee.v1.IdentifiedPacketFee") + proto.RegisterType((*IdentifiedPacketFees)(nil), "ibc.applications.fee.v1.IdentifiedPacketFees") } func init() { proto.RegisterFile("ibc/applications/fee/v1/fee.proto", fileDescriptor_cb3319f1af2a53e5) } var fileDescriptor_cb3319f1af2a53e5 = []byte{ - // 488 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0xbd, 0x8e, 0xd3, 0x40, - 0x10, 0xc7, 0x63, 0x7c, 0xba, 0x8f, 0x8d, 0x38, 0x21, 0x03, 0xc2, 0x17, 0x81, 0x13, 0x5c, 0xb9, - 0xc9, 0xae, 0x92, 0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26, - 0xf0, 0xd6, 0xf8, 0x4e, 0x0f, 0x17, 0x2c, 0xe5, 0x2b, 0x28, 0xb5, 0x7b, 0x30, 0xb0, 0x83, 0x93, - 0xe8, 0xce, 0x0f, 0xdf, 0x5f, 0x6d, 0x3c, 0xeb, 0x7a, 0xe3, 0x59, 0xbf, 0x36, 0x9e, 0xf5, 0x6d, - 0xeb, 0x75, 0xae, 0xb7, 0x5e, 0xe7, 0xc7, 0xd6, 0xeb, 0x7c, 0x7a, 0xf9, 0xf7, 0x44, 0x65, 0x2c, - 0x86, 0x73, 0xc5, 0xea, 0x73, 0x96, 0xa9, 0x64, 0x99, 0x82, 0xc6, 0x37, 0xa5, 0xd9, 0xf8, 0xd5, - 0x10, 0x9f, 0x53, 0x33, 0xe4, 0xf8, 0xb0, 0x59, 0xee, 0xf3, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, - 0x4e, 0x82, 0x74, 0x21, 0x73, 0x03, 0x00, 0x00, + // 523 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x41, 0x6f, 0xd3, 0x30, + 0x14, 0xc7, 0x6b, 0x32, 0x6d, 0xab, 0x2b, 0x26, 0x14, 0x86, 0xe8, 0x2a, 0x48, 0x4b, 0x4e, 0x3d, + 0x50, 0x5b, 0xed, 0xe0, 0x00, 0x27, 0x08, 0x52, 0xa5, 0x9d, 0x40, 0x11, 0x27, 0x2e, 0x95, 0xe3, + 0xbc, 0x76, 0x56, 0x9b, 0x38, 0x8a, 0xd3, 0x48, 0x95, 0x38, 0x00, 0x9f, 0x80, 0xcf, 0xc1, 0x27, + 0xd9, 0x71, 0x47, 0x4e, 0x05, 0xb5, 0xdf, 0x60, 0x5f, 0x00, 0xe4, 0xd8, 0xab, 0x8a, 0xd8, 0x34, + 0xf5, 0x64, 0xfb, 0xf9, 0xfd, 0xdf, 0xef, 0xd9, 0xef, 0x3d, 0xfc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, 0x8b, 0x95, 0x87, 0x2e, 0x57, 0x1e, 0xfa, 0xbd, + 0xf2, 0xd0, 0xf7, 0xb5, 0x57, 0xbb, 0x5c, 0x7b, 0xb5, 0x9f, 0x6b, 0xaf, 0xf6, 0xe9, 0xe5, 0xff, + 0x55, 0x15, 0x11, 0xef, 0x4d, 0x24, 0x2d, 0x4f, 0x69, 0x22, 0xe3, 0xf9, 0x0c, 0x94, 0x9e, 0x6b, + 0x45, 0x07, 0xaf, 0x7a, 0x7a, 0xa4, 0xab, 0x42, 0x47, 0xfb, 0xd5, 0x80, 0x9d, 0xfe, 0x0d, 0x00, + 0x00, 0xff, 0xff, 0x0e, 0xeb, 0xd3, 0x29, 0xf7, 0x03, 0x00, 0x00, } func (m *Fee) Marshal() (dAtA []byte, err error) { @@ -327,6 +375,43 @@ func (m *IdentifiedPacketFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *IdentifiedPacketFees) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *IdentifiedPacketFees) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IdentifiedPacketFees) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PacketFees) > 0 { + for iNdEx := len(m.PacketFees) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PacketFees[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFee(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintFee(dAtA []byte, offset int, v uint64) int { offset -= sovFee(v) base := offset @@ -388,6 +473,21 @@ func (m *IdentifiedPacketFee) Size() (n int) { return n } +func (m *IdentifiedPacketFees) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.PacketFees) > 0 { + for _, e := range m.PacketFees { + l = e.Size() + n += 1 + l + sovFee(uint64(l)) + } + } + return n +} + func sovFee(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -726,6 +826,90 @@ func (m *IdentifiedPacketFee) Unmarshal(dAtA []byte) error { } return nil } +func (m *IdentifiedPacketFees) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFee + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: IdentifiedPacketFees: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IdentifiedPacketFees: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PacketFees", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFee + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFee + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFee + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PacketFees = append(m.PacketFees, IdentifiedPacketFee{}) + if err := m.PacketFees[len(m.PacketFees)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFee(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFee + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipFee(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/apps/29-fee/types/fee_test.go b/modules/apps/29-fee/types/fee_test.go index 0dbd9f29c4e..349fe8dcf07 100644 --- a/modules/apps/29-fee/types/fee_test.go +++ b/modules/apps/29-fee/types/fee_test.go @@ -7,6 +7,17 @@ import ( "github.com/stretchr/testify/require" ) +func TestFeeTotal(t *testing.T) { + fee := Fee{ + AckFee: sdk.NewCoins(sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}), + RecvFee: sdk.NewCoins(sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}), + TimeoutFee: sdk.NewCoins(sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}), + } + + total := fee.Total() + require.Equal(t, sdk.NewInt(300), total.AmountOf(sdk.DefaultBondDenom)) +} + // TestFeeValidation tests Validate func TestFeeValidation(t *testing.T) { var ( diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index 2f26b859afc..b13aa2ba4b8 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -30,6 +30,9 @@ const ( // FeeInEscrowPrefix is the key prefix for fee in escrow mapping FeeInEscrowPrefix = "feeInEscrow" + // FeesInEscrowPrefix is the key prefix for fee in escrow mapping + FeesInEscrowPrefix = "feesInEscrow" + // ForwardRelayerPrefix is the key prefix for forward relayer addresses stored in state for async acknowledgements ForwardRelayerPrefix = "forwardRelayer" ) @@ -55,7 +58,17 @@ func KeyFeeInEscrow(packetID channeltypes.PacketId) []byte { return []byte(fmt.Sprintf("%s/%d", KeyFeeInEscrowChannelPrefix(packetID.PortId, packetID.ChannelId), packetID.Sequence)) } +// KeyFeesInEscrow returns the key for escrowed fees +func KeyFeesInEscrow(packetID channeltypes.PacketId) []byte { + return []byte(fmt.Sprintf("%s/%d", KeyFeesInEscrowChannelPrefix(packetID.PortId, packetID.ChannelId), packetID.Sequence)) +} + // KeyFeeInEscrowChannelPrefix returns the key prefix for escrowed fees on the given channel func KeyFeeInEscrowChannelPrefix(portID, channelID string) []byte { return []byte(fmt.Sprintf("%s/%s/%s/packet", FeeInEscrowPrefix, portID, channelID)) } + +// KeyFeesInEscrowChannelPrefix returns the key prefix for escrowed fees on the given channel +func KeyFeesInEscrowChannelPrefix(portID, channelID string) []byte { + return []byte(fmt.Sprintf("%s/%s/%s", FeesInEscrowPrefix, portID, channelID)) +} diff --git a/modules/apps/29-fee/types/tx.pb.go b/modules/apps/29-fee/types/tx.pb.go index 46f20f29783..624c6d8279a 100644 --- a/modules/apps/29-fee/types/tx.pb.go +++ b/modules/apps/29-fee/types/tx.pb.go @@ -6,7 +6,6 @@ package types import ( context "context" fmt "fmt" - _ "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -281,44 +280,44 @@ func init() { func init() { proto.RegisterFile("ibc/applications/fee/v1/tx.proto", fileDescriptor_05c93128649f1b96) } var fileDescriptor_05c93128649f1b96 = []byte{ - // 587 bytes of a gzipped FileDescriptorProto + // 577 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0x4f, 0x4f, 0xdb, 0x4c, - 0x10, 0xc6, 0x6d, 0xc2, 0xcb, 0x0b, 0x5b, 0x54, 0x84, 0x81, 0x12, 0x4c, 0x64, 0x53, 0xab, 0xaa, - 0x72, 0x68, 0xec, 0x12, 0x8a, 0xaa, 0x72, 0x41, 0x04, 0x09, 0x35, 0x87, 0xa8, 0x91, 0x8f, 0xbd, - 0x44, 0xce,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e, 0xdf, 0xe8, 0x92, 0x91, 0x47, 0x2f, - 0x17, 0x57, 0x66, 0x03, 0x0f, 0xa8, 0xcf, 0xc1, 0xb8, 0x5e, 0x42, 0x1b, 0x15, 0xee, 0x55, 0x9d, - 0xb0, 0xea, 0xe0, 0xcf, 0x20, 0x2e, 0x00, 0x94, 0x37, 0x28, 0xd3, 0x00, 0x88, 0x2b, 0x7e, 0x52, - 0xcc, 0x99, 0x73, 0xbc, 0x35, 0x2f, 0x00, 0x4a, 0xcb, 0xb7, 0x5d, 0x5d, 0xb2, 0x23, 0x5c, 0x39, - 0x45, 0x4f, 0x39, 0x6d, 0x33, 0x0c, 0xb5, 0x80, 0x32, 0x51, 0x23, 0xee, 0xb0, 0x97, 0xbd, 0x41, - 0x57, 0xdf, 0x49, 0x7a, 0x99, 0x8c, 0x1b, 0xf6, 0x7a, 0x72, 0x50, 0xa5, 0x4c, 0x94, 0x5d, 0xe5, - 0x3d, 0xda, 0x1c, 0x02, 0x43, 0x9f, 0x23, 0x8d, 0x4c, 0xac, 0x91, 0x1b, 0x74, 0xf5, 0xec, 0x84, - 0xc6, 0x3d, 0x62, 0xd8, 0x1b, 0xc9, 0xd9, 0x79, 0x72, 0x54, 0x76, 0x95, 0x67, 0x68, 0x85, 0x13, - 0xcf, 0x07, 0x96, 0x5d, 0x8e, 0x5d, 0x1f, 0xee, 0x14, 0x15, 0xad, 0x32, 0x68, 0x3a, 0x21, 0x30, - 0x9e, 0xfd, 0xef, 0x20, 0x93, 0x5f, 0xb3, 0xc7, 0xfb, 0x94, 0x79, 0x7b, 0x68, 0xf7, 0x81, 0x23, - 0x63, 0xb7, 0x7e, 0xc8, 0x68, 0xfb, 0x41, 0xec, 0x8c, 0x87, 0x3e, 0x56, 0xae, 0x64, 0xb4, 0x43, - 0x5c, 0xf0, 0x05, 0x69, 0x10, 0x70, 0x6b, 0x41, 0x1c, 0xad, 0xdd, 0xbb, 0xf8, 0x6a, 0xae, 0x8b, - 0xe5, 0x71, 0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00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/ibc/applications/fee/v1/fee.proto b/proto/ibc/applications/fee/v1/fee.proto index bbbd82663e1..3a58f093e06 100644 --- a/proto/ibc/applications/fee/v1/fee.proto +++ b/proto/ibc/applications/fee/v1/fee.proto @@ -40,3 +40,9 @@ message IdentifiedPacketFee { string refund_address = 3 [(gogoproto.moretags) = "yaml:\"refund_address\""]; repeated string relayers = 4; } + +// IdentifiedPacketFees contains a list of packet fees +message IdentifiedPacketFees { + repeated IdentifiedPacketFee packet_fees = 1 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"packet_fees\""]; +} \ No newline at end of file diff --git a/proto/ibc/applications/fee/v1/tx.proto b/proto/ibc/applications/fee/v1/tx.proto index 4540c28967e..900764f9343 100644 --- a/proto/ibc/applications/fee/v1/tx.proto +++ b/proto/ibc/applications/fee/v1/tx.proto @@ -6,7 +6,6 @@ option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; import "gogoproto/gogo.proto"; import "ibc/applications/fee/v1/fee.proto"; -import "ibc/core/channel/v1/channel.proto"; // Msg defines the ibc/fee Msg service. service Msg { From 39ef8d763b7f329be4335183b2fbaddda80f1956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 17 Feb 2022 11:56:15 +0100 Subject: [PATCH 35/79] chore: remove spec directory from ics29 (#934) --- modules/apps/29-fee/spec/01_concepts.md | 6 ------ modules/apps/29-fee/spec/02_state.md | 6 ------ modules/apps/29-fee/spec/03_state_transitions.md | 6 ------ modules/apps/29-fee/spec/04_messages.md | 6 ------ modules/apps/29-fee/spec/05_events.md | 6 ------ modules/apps/29-fee/spec/06_metrics.md | 6 ------ modules/apps/29-fee/spec/07_params.md | 6 ------ modules/apps/29-fee/spec/README.md | 11 ----------- 8 files changed, 53 deletions(-) delete mode 100644 modules/apps/29-fee/spec/01_concepts.md delete mode 100644 modules/apps/29-fee/spec/02_state.md delete mode 100644 modules/apps/29-fee/spec/03_state_transitions.md delete mode 100644 modules/apps/29-fee/spec/04_messages.md delete mode 100644 modules/apps/29-fee/spec/05_events.md delete mode 100644 modules/apps/29-fee/spec/06_metrics.md delete mode 100644 modules/apps/29-fee/spec/07_params.md delete mode 100644 modules/apps/29-fee/spec/README.md diff --git a/modules/apps/29-fee/spec/01_concepts.md b/modules/apps/29-fee/spec/01_concepts.md deleted file mode 100644 index 119c857b0cc..00000000000 --- a/modules/apps/29-fee/spec/01_concepts.md +++ /dev/null @@ -1,6 +0,0 @@ - - -# Concepts - diff --git a/modules/apps/29-fee/spec/02_state.md b/modules/apps/29-fee/spec/02_state.md deleted file mode 100644 index 336ed0f5b65..00000000000 --- a/modules/apps/29-fee/spec/02_state.md +++ /dev/null @@ -1,6 +0,0 @@ - - -# State - diff --git a/modules/apps/29-fee/spec/03_state_transitions.md b/modules/apps/29-fee/spec/03_state_transitions.md deleted file mode 100644 index dc70ea002c6..00000000000 --- a/modules/apps/29-fee/spec/03_state_transitions.md +++ /dev/null @@ -1,6 +0,0 @@ - - -# State Transitions - diff --git a/modules/apps/29-fee/spec/04_messages.md b/modules/apps/29-fee/spec/04_messages.md deleted file mode 100644 index 0a97f2d6b9d..00000000000 --- a/modules/apps/29-fee/spec/04_messages.md +++ /dev/null @@ -1,6 +0,0 @@ - - -# Messages - diff --git a/modules/apps/29-fee/spec/05_events.md b/modules/apps/29-fee/spec/05_events.md deleted file mode 100644 index eb988be063a..00000000000 --- a/modules/apps/29-fee/spec/05_events.md +++ /dev/null @@ -1,6 +0,0 @@ - - -# Events - diff --git a/modules/apps/29-fee/spec/06_metrics.md b/modules/apps/29-fee/spec/06_metrics.md deleted file mode 100644 index 24996d36b3d..00000000000 --- a/modules/apps/29-fee/spec/06_metrics.md +++ /dev/null @@ -1,6 +0,0 @@ - - -# Metrics - diff --git a/modules/apps/29-fee/spec/07_params.md b/modules/apps/29-fee/spec/07_params.md deleted file mode 100644 index 77d7696b559..00000000000 --- a/modules/apps/29-fee/spec/07_params.md +++ /dev/null @@ -1,6 +0,0 @@ - - -# Parameters - diff --git a/modules/apps/29-fee/spec/README.md b/modules/apps/29-fee/spec/README.md deleted file mode 100644 index c5c926f7b9f..00000000000 --- a/modules/apps/29-fee/spec/README.md +++ /dev/null @@ -1,11 +0,0 @@ - - -# `29-fee` - -## Abstract - From 1fb4b5afb65006f7c5bb44569f4061d127a8a0b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 17 Feb 2022 12:07:13 +0100 Subject: [PATCH 36/79] refactor: use mock module for ics29 closing handshakes (#926) * refactor: use mock module for closing handshakes in ics29 * self-review fix --- modules/apps/29-fee/ibc_module_test.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index 858a6ce9dcd..c4fcf653496 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -318,14 +318,14 @@ func (suite *FeeTestSuite) TestOnChanCloseInit() { for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupTest() + suite.SetupMockTest() suite.coordinator.Setup(suite.path) // setup channel origBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress()) tc.setup(suite) - module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort) + module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) @@ -334,12 +334,10 @@ func (suite *FeeTestSuite) TestOnChanCloseInit() { if tc.disabled { suite.Require().True( suite.chainA.GetSimApp().IBCFeeKeeper.IsFeeEnabled(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID), - "fee is not disabled on original channel: %s", suite.path.EndpointA.ChannelID, ) suite.Require().True( suite.chainA.GetSimApp().IBCFeeKeeper.IsFeeEnabled(suite.chainA.GetContext(), "portID7", "channel-7"), - "fee is not disabled on other channel: %s", "channel-7", ) } else { @@ -398,14 +396,14 @@ func (suite *FeeTestSuite) TestOnChanCloseConfirm() { for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupTest() + suite.SetupMockTest() suite.coordinator.Setup(suite.path) // setup channel origBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress()) tc.setup(suite) - module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort) + module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) @@ -414,12 +412,10 @@ func (suite *FeeTestSuite) TestOnChanCloseConfirm() { if tc.disabled { suite.Require().True( suite.chainA.GetSimApp().IBCFeeKeeper.IsFeeEnabled(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID), - "fee is not disabled on original channel: %s", suite.path.EndpointA.ChannelID, ) suite.Require().True( suite.chainA.GetSimApp().IBCFeeKeeper.IsFeeEnabled(suite.chainA.GetContext(), "portID7", "channel-7"), - "fee is not disabled on other channel: %s", "channel-7", ) } else { From 9895948f7bbd7c460259666220f9ee38503175fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 17 Feb 2022 12:50:39 +0100 Subject: [PATCH 37/79] refactor: use mock module for ics29 grpc_query_test.go (#933) --- modules/apps/29-fee/keeper/grpc_query_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index 9074002473a..649ff89e6b9 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -7,7 +7,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" - transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) @@ -20,8 +19,8 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketI() { // setup suite.coordinator.Setup(suite.path) // setup channel - validPacketId := channeltypes.NewPacketId(ibctesting.FirstChannelID, transfertypes.PortID, 1) - invalidPacketId := channeltypes.NewPacketId(ibctesting.FirstChannelID, transfertypes.PortID, 2) + validPacketId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 1) + invalidPacketId := channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 2) identifiedPacketFee := types.NewIdentifiedPacketFee( validPacketId, types.Fee{ @@ -69,7 +68,8 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketI() { identifiedPacketFee.RefundAddress = refundAcc.String() tc.malleate() - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, ibctesting.FirstChannelID) + + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), validPacketId.PortId, validPacketId.ChannelId) suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeInEscrow(suite.chainA.GetContext(), identifiedPacketFee) ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) @@ -115,14 +115,14 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPackets() { func() { refundAcc := suite.chainA.SenderAccount.GetAddress() - fee1 := types.NewIdentifiedPacketFee(channeltypes.NewPacketId(ibctesting.FirstChannelID, transfertypes.PortID, 1), fee, refundAcc.String(), []string(nil)) - fee2 := types.NewIdentifiedPacketFee(channeltypes.NewPacketId(ibctesting.FirstChannelID, transfertypes.PortID, 2), fee, refundAcc.String(), []string(nil)) - fee3 := types.NewIdentifiedPacketFee(channeltypes.NewPacketId(ibctesting.FirstChannelID, transfertypes.PortID, 3), fee, refundAcc.String(), []string(nil)) + fee1 := types.NewIdentifiedPacketFee(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1), fee, refundAcc.String(), []string(nil)) + fee2 := types.NewIdentifiedPacketFee(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 2), fee, refundAcc.String(), []string(nil)) + fee3 := types.NewIdentifiedPacketFee(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 3), fee, refundAcc.String(), []string(nil)) expPackets = []*types.IdentifiedPacketFee{} expPackets = append(expPackets, &fee1, &fee2, &fee3) - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, ibctesting.FirstChannelID) + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) for _, packetFee := range expPackets { suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeInEscrow(suite.chainA.GetContext(), *packetFee) } From acc699dbfd3925f9e07609383e787145936801c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 17 Feb 2022 14:07:26 +0100 Subject: [PATCH 38/79] refactor: readjust keeper_test.go to use mock module (#930) --- modules/apps/29-fee/keeper/keeper_test.go | 43 ++++++++++++++++------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index b510aa7b7c9..e0e9e7a1a67 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -1,7 +1,6 @@ package keeper_test import ( - "fmt" "testing" "github.com/cosmos/cosmos-sdk/baseapp" @@ -12,6 +11,7 @@ import ( transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v3/testing" + ibcmock "github.com/cosmos/ibc-go/v3/testing/mock" ) var ( @@ -34,6 +34,7 @@ type KeeperTestSuite struct { queryClient types.QueryClient } +// TODO: remove and rename 'SetupMockTest' to 'SetupTest' func (suite *KeeperTestSuite) SetupTest() { suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) @@ -52,28 +53,50 @@ func (suite *KeeperTestSuite) SetupTest() { suite.queryClient = types.NewQueryClient(queryHelper) } +// TODO: rename to 'SetupTest' when the above function is removed +func (suite *KeeperTestSuite) SetupMockTest() { + suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) + suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) + suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) + + path := ibctesting.NewPath(suite.chainA, suite.chainB) + mockFeeVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: ibcmock.Version})) + path.EndpointA.ChannelConfig.Version = mockFeeVersion + path.EndpointB.ChannelConfig.Version = mockFeeVersion + path.EndpointA.ChannelConfig.PortID = ibctesting.MockFeePort + path.EndpointB.ChannelConfig.PortID = ibctesting.MockFeePort + suite.path = path + + queryHelper := baseapp.NewQueryServerTestHelper(suite.chainA.GetContext(), suite.chainA.GetSimApp().InterfaceRegistry()) + types.RegisterQueryServer(queryHelper, suite.chainA.GetSimApp().IBCFeeKeeper) + suite.queryClient = types.NewQueryClient(queryHelper) +} + func TestKeeperTestSuite(t *testing.T) { suite.Run(t, new(KeeperTestSuite)) } func (suite *KeeperTestSuite) TestFeeInEscrow() { + suite.SetupMockTest() + suite.coordinator.Setup(suite.path) + fee := types.Fee{RecvFee: defaultReceiveFee, AckFee: defaultAckFee, TimeoutFee: defaultTimeoutFee} // set some fees for i := 1; i < 6; i++ { - packetId := channeltypes.NewPacketId(fmt.Sprintf("channel-1"), transfertypes.PortID, uint64(i)) + packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, uint64(i)) fee := types.NewIdentifiedPacketFee(packetId, fee, suite.chainA.SenderAccount.GetAddress().String(), []string{}) suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeInEscrow(suite.chainA.GetContext(), fee) } // delete 1 fee - packetId := channeltypes.NewPacketId("channel-1", transfertypes.PortID, 3) + packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 3) suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeeInEscrow(suite.chainA.GetContext(), packetId) // iterate over remaining fees arr := []int64{} expectedArr := []int64{1, 2, 4, 5} - suite.chainA.GetSimApp().IBCFeeKeeper.IterateChannelFeesInEscrow(suite.chainA.GetContext(), transfertypes.PortID, "channel-1", func(identifiedFee types.IdentifiedPacketFee) (stop bool) { + suite.chainA.GetSimApp().IBCFeeKeeper.IterateChannelFeesInEscrow(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, func(identifiedFee types.IdentifiedPacketFee) (stop bool) { arr = append(arr, int64(identifiedFee.PacketId.Sequence)) return false }) @@ -96,12 +119,12 @@ func (suite *KeeperTestSuite) TestDisableAllChannels() { } func (suite *KeeperTestSuite) TestGetAllIdentifiedPacketFees() { - // setup channel + suite.SetupMockTest() suite.coordinator.Setup(suite.path) // escrow a fee refundAcc := suite.chainA.SenderAccount.GetAddress() - packetID := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, transfertypes.PortID, 1) + packetID := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 1) fee := types.Fee{ AckFee: defaultAckFee, RecvFee: defaultReceiveFee, @@ -127,11 +150,9 @@ func (suite *KeeperTestSuite) TestGetAllIdentifiedPacketFees() { } func (suite *KeeperTestSuite) TestGetAllFeeEnabledChannels() { - suite.SetupTest() // reset - validPortId := "ibcmoduleport" // set two channels enabled - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, ibctesting.FirstChannelID) + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), validPortId, ibctesting.FirstChannelID) expectedCh := []*types.FeeEnabledChannel{ @@ -140,7 +161,7 @@ func (suite *KeeperTestSuite) TestGetAllFeeEnabledChannels() { ChannelId: ibctesting.FirstChannelID, }, { - PortId: transfertypes.PortID, + PortId: ibctesting.MockFeePort, ChannelId: ibctesting.FirstChannelID, }, } @@ -151,8 +172,6 @@ func (suite *KeeperTestSuite) TestGetAllFeeEnabledChannels() { } func (suite *KeeperTestSuite) TestGetAllRelayerAddresses() { - suite.SetupTest() // reset - sender := suite.chainA.SenderAccount.GetAddress().String() counterparty := suite.chainB.SenderAccount.GetAddress().String() From 9b2d96d0745716f22d1e53983d1b57bf2944501c Mon Sep 17 00:00:00 2001 From: Sean King Date: Thu, 17 Feb 2022 15:06:58 +0100 Subject: [PATCH 39/79] fix: fields for genesis should be non nullable (#938) --- modules/apps/29-fee/keeper/genesis_test.go | 4 +- modules/apps/29-fee/keeper/keeper.go | 18 ++-- modules/apps/29-fee/keeper/keeper_test.go | 4 +- modules/apps/29-fee/types/genesis.go | 6 +- modules/apps/29-fee/types/genesis.pb.go | 94 ++++++++++----------- modules/apps/29-fee/types/genesis_test.go | 4 +- proto/ibc/applications/fee/v1/genesis.proto | 6 +- 7 files changed, 68 insertions(+), 68 deletions(-) diff --git a/modules/apps/29-fee/keeper/genesis_test.go b/modules/apps/29-fee/keeper/genesis_test.go index 3d4f42a3c28..b5ffdcb221d 100644 --- a/modules/apps/29-fee/keeper/genesis_test.go +++ b/modules/apps/29-fee/keeper/genesis_test.go @@ -36,13 +36,13 @@ func (suite *KeeperTestSuite) TestInitGenesis() { Relayers: nil, }, }, - FeeEnabledChannels: []*types.FeeEnabledChannel{ + FeeEnabledChannels: []types.FeeEnabledChannel{ { PortId: transfertypes.PortID, ChannelId: ibctesting.FirstChannelID, }, }, - RegisteredRelayers: []*types.RegisteredRelayerAddress{ + RegisteredRelayers: []types.RegisteredRelayerAddress{ { Address: sender, CounterpartyAddress: counterparty, diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index d82e17b69a4..2d7fb3e5135 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -98,16 +98,16 @@ func (k Keeper) IsFeeEnabled(ctx sdk.Context, portID, channelID string) bool { } // GetAllFeeEnabledChannels returns a list of all ics29 enabled channels containing portID & channelID that are stored in state -func (k Keeper) GetAllFeeEnabledChannels(ctx sdk.Context) []*types.FeeEnabledChannel { +func (k Keeper) GetAllFeeEnabledChannels(ctx sdk.Context) []types.FeeEnabledChannel { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, []byte(types.FeeEnabledKeyPrefix)) defer iterator.Close() - var enabledChArr []*types.FeeEnabledChannel + var enabledChArr []types.FeeEnabledChannel for ; iterator.Valid(); iterator.Next() { keySplit := strings.Split(string(iterator.Key()), "/") - ch := &types.FeeEnabledChannel{ + ch := types.FeeEnabledChannel{ PortId: keySplit[1], ChannelId: keySplit[2], } @@ -154,16 +154,16 @@ func (k Keeper) GetCounterpartyAddress(ctx sdk.Context, address string) (string, } // GetAllRelayerAddresses returns all registered relayer addresses -func (k Keeper) GetAllRelayerAddresses(ctx sdk.Context) []*types.RegisteredRelayerAddress { +func (k Keeper) GetAllRelayerAddresses(ctx sdk.Context) []types.RegisteredRelayerAddress { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, []byte(types.RelayerAddressKeyPrefix)) defer iterator.Close() - var registeredAddrArr []*types.RegisteredRelayerAddress + var registeredAddrArr []types.RegisteredRelayerAddress for ; iterator.Valid(); iterator.Next() { keySplit := strings.Split(string(iterator.Key()), "/") - addr := &types.RegisteredRelayerAddress{ + addr := types.RegisteredRelayerAddress{ Address: keySplit[1], CounterpartyAddress: string(iterator.Value()), } @@ -193,12 +193,12 @@ func (k Keeper) GetForwardRelayerAddress(ctx sdk.Context, packetId channeltypes. } // GetAllForwardRelayerAddresses returns all forward relayer addresses stored for async acknowledgements -func (k Keeper) GetAllForwardRelayerAddresses(ctx sdk.Context) []*types.ForwardRelayerAddress { +func (k Keeper) GetAllForwardRelayerAddresses(ctx sdk.Context) []types.ForwardRelayerAddress { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, []byte(types.ForwardRelayerPrefix)) defer iterator.Close() - var forwardRelayerAddr []*types.ForwardRelayerAddress + var forwardRelayerAddr []types.ForwardRelayerAddress for ; iterator.Valid(); iterator.Next() { keySplit := strings.Split(string(iterator.Key()), "/") @@ -209,7 +209,7 @@ func (k Keeper) GetAllForwardRelayerAddresses(ctx sdk.Context) []*types.ForwardR packetId := channeltypes.NewPacketId(keySplit[2], keySplit[1], seq) - addr := &types.ForwardRelayerAddress{ + addr := types.ForwardRelayerAddress{ Address: string(iterator.Value()), PacketId: packetId, } diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index e0e9e7a1a67..be49deef63b 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -155,7 +155,7 @@ func (suite *KeeperTestSuite) TestGetAllFeeEnabledChannels() { suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), validPortId, ibctesting.FirstChannelID) - expectedCh := []*types.FeeEnabledChannel{ + expectedCh := []types.FeeEnabledChannel{ { PortId: validPortId, ChannelId: ibctesting.FirstChannelID, @@ -177,7 +177,7 @@ func (suite *KeeperTestSuite) TestGetAllRelayerAddresses() { suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainA.GetContext(), sender, counterparty) - expectedAddr := []*types.RegisteredRelayerAddress{ + expectedAddr := []types.RegisteredRelayerAddress{ { Address: sender, CounterpartyAddress: counterparty, diff --git a/modules/apps/29-fee/types/genesis.go b/modules/apps/29-fee/types/genesis.go index c0a84516291..dbeb71c1285 100644 --- a/modules/apps/29-fee/types/genesis.go +++ b/modules/apps/29-fee/types/genesis.go @@ -8,7 +8,7 @@ import ( ) // NewGenesisState creates a 29-fee GenesisState instance. -func NewGenesisState(identifiedFees []IdentifiedPacketFee, feeEnabledChannels []*FeeEnabledChannel, registeredRelayers []*RegisteredRelayerAddress) *GenesisState { +func NewGenesisState(identifiedFees []IdentifiedPacketFee, feeEnabledChannels []FeeEnabledChannel, registeredRelayers []RegisteredRelayerAddress) *GenesisState { return &GenesisState{ IdentifiedFees: identifiedFees, FeeEnabledChannels: feeEnabledChannels, @@ -20,8 +20,8 @@ func NewGenesisState(identifiedFees []IdentifiedPacketFee, feeEnabledChannels [] func DefaultGenesisState() *GenesisState { return &GenesisState{ IdentifiedFees: []IdentifiedPacketFee{}, - FeeEnabledChannels: []*FeeEnabledChannel{}, - RegisteredRelayers: []*RegisteredRelayerAddress{}, + FeeEnabledChannels: []FeeEnabledChannel{}, + RegisteredRelayers: []RegisteredRelayerAddress{}, } } diff --git a/modules/apps/29-fee/types/genesis.pb.go b/modules/apps/29-fee/types/genesis.pb.go index 6bcc498ac87..c939c190429 100644 --- a/modules/apps/29-fee/types/genesis.pb.go +++ b/modules/apps/29-fee/types/genesis.pb.go @@ -26,10 +26,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the fee middleware genesis state type GenesisState struct { - IdentifiedFees []IdentifiedPacketFee `protobuf:"bytes,1,rep,name=identified_fees,json=identifiedFees,proto3" json:"identified_fees" yaml:"identified_fees"` - FeeEnabledChannels []*FeeEnabledChannel `protobuf:"bytes,2,rep,name=fee_enabled_channels,json=feeEnabledChannels,proto3" json:"fee_enabled_channels,omitempty" yaml:"fee_enabled_channels"` - RegisteredRelayers []*RegisteredRelayerAddress `protobuf:"bytes,3,rep,name=registered_relayers,json=registeredRelayers,proto3" json:"registered_relayers,omitempty" yaml:"registered_relayers"` - ForwardRelayers []*ForwardRelayerAddress `protobuf:"bytes,4,rep,name=forward_relayers,json=forwardRelayers,proto3" json:"forward_relayers,omitempty" yaml:"forward_relayers"` + IdentifiedFees []IdentifiedPacketFee `protobuf:"bytes,1,rep,name=identified_fees,json=identifiedFees,proto3" json:"identified_fees" yaml:"identified_fees"` + FeeEnabledChannels []FeeEnabledChannel `protobuf:"bytes,2,rep,name=fee_enabled_channels,json=feeEnabledChannels,proto3" json:"fee_enabled_channels" yaml:"fee_enabled_channels"` + RegisteredRelayers []RegisteredRelayerAddress `protobuf:"bytes,3,rep,name=registered_relayers,json=registeredRelayers,proto3" json:"registered_relayers" yaml:"registered_relayers"` + ForwardRelayers []ForwardRelayerAddress `protobuf:"bytes,4,rep,name=forward_relayers,json=forwardRelayers,proto3" json:"forward_relayers" yaml:"forward_relayers"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -72,21 +72,21 @@ func (m *GenesisState) GetIdentifiedFees() []IdentifiedPacketFee { return nil } -func (m *GenesisState) GetFeeEnabledChannels() []*FeeEnabledChannel { +func (m *GenesisState) GetFeeEnabledChannels() []FeeEnabledChannel { if m != nil { return m.FeeEnabledChannels } return nil } -func (m *GenesisState) GetRegisteredRelayers() []*RegisteredRelayerAddress { +func (m *GenesisState) GetRegisteredRelayers() []RegisteredRelayerAddress { if m != nil { return m.RegisteredRelayers } return nil } -func (m *GenesisState) GetForwardRelayers() []*ForwardRelayerAddress { +func (m *GenesisState) GetForwardRelayers() []ForwardRelayerAddress { if m != nil { return m.ForwardRelayers } @@ -264,43 +264,43 @@ func init() { } var fileDescriptor_7191992e856dff95 = []byte{ - // 572 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x54, 0xbf, 0x6f, 0xd4, 0x30, - 0x18, 0xbd, 0xb4, 0x55, 0x4b, 0x5d, 0xd4, 0x1f, 0x6e, 0x4b, 0xa3, 0x56, 0x24, 0xc5, 0x12, 0x52, - 0x05, 0x34, 0xd1, 0xb5, 0x30, 0xc0, 0xc6, 0x21, 0x8a, 0x6e, 0x02, 0x19, 0x26, 0x96, 0x53, 0x2e, - 0xf9, 0x92, 0x5a, 0xe4, 0xe2, 0xc8, 0xf6, 0x05, 0xdd, 0xc0, 0x00, 0x0b, 0x8c, 0xfc, 0x59, 0x1d, - 0x3b, 0x32, 0x45, 0xa8, 0xfd, 0x0f, 0xf2, 0x17, 0xa0, 0xc4, 0x49, 0x7b, 0x1c, 0x17, 0xb6, 0x2f, - 0xf6, 0x7b, 0xdf, 0x7b, 0x7e, 0xce, 0x67, 0xf4, 0x90, 0x0d, 0x7d, 0xd7, 0x4b, 0xd3, 0x98, 0xf9, - 0x9e, 0x62, 0x3c, 0x91, 0x6e, 0x08, 0xe0, 0x66, 0x5d, 0x37, 0x82, 0x04, 0x24, 0x93, 0x4e, 0x2a, - 0xb8, 0xe2, 0x78, 0x8f, 0x0d, 0x7d, 0x67, 0x1a, 0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, 0x0d, 0xe6, 0xed, 0xc5, 0x95, 0x65, 0x5c, 0x5e, 0x59, - 0xc6, 0xef, 0x2b, 0xcb, 0xf8, 0x79, 0x6d, 0x75, 0x2e, 0xaf, 0xad, 0xce, 0xaf, 0x6b, 0xab, 0xf3, - 0xf1, 0x59, 0xc4, 0xd4, 0xf9, 0x78, 0xe8, 0xf8, 0x7c, 0xe4, 0xfa, 0x5c, 0x8e, 0xb8, 0x74, 0xd9, - 0xd0, 0x3f, 0x8e, 0xb8, 0x9b, 0x9d, 0xba, 0x23, 0x1e, 0x8c, 0x63, 0x90, 0xe5, 0x83, 0x20, 0xdd, - 0x93, 0xe7, 0xc7, 0xe5, 0x5b, 0xa0, 0x26, 0x29, 0xc8, 0xe1, 0x72, 0x35, 0xe8, 0xa7, 0x7f, 0x02, - 0x00, 0x00, 0xff, 0xff, 0x8b, 0x17, 0xa1, 0x66, 0x86, 0x04, 0x00, 0x00, + // 573 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x54, 0xcd, 0x6e, 0xd4, 0x3c, + 0x14, 0x9d, 0xb4, 0x55, 0xfb, 0xd5, 0xfd, 0xd4, 0x1f, 0xb7, 0xa5, 0x51, 0x11, 0x99, 0x62, 0x84, + 0x54, 0x01, 0x4d, 0x34, 0x2d, 0x2c, 0x60, 0xc7, 0x20, 0x8a, 0x66, 0x05, 0x32, 0xac, 0xd8, 0x44, + 0xf9, 0xb9, 0x49, 0x2d, 0x32, 0x71, 0x64, 0x7b, 0x06, 0x0d, 0x3b, 0x36, 0xc0, 0x0a, 0xf1, 0x58, + 0x5d, 0x76, 0xc9, 0x6a, 0x84, 0xda, 0x37, 0xe8, 0x13, 0xa0, 0xc4, 0x4e, 0x67, 0x18, 0x26, 0xec, + 0x6e, 0xec, 0x73, 0xee, 0x39, 0x39, 0xf6, 0x35, 0xba, 0xcf, 0xc2, 0xc8, 0x0b, 0x8a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0xeb, 0x7f, 0x5e, 0x3b, 0xbe, 0x53, + 0x9d, 0x55, 0x39, 0x7e, 0x6e, 0x3d, 0x73, 0xc3, 0x8e, 0xab, 0x47, 0xa4, 0x17, 0x77, 0x6d, 0x73, + 0x34, 0x9b, 0x26, 0xc6, 0x9a, 0x4d, 0xe8, 0x7f, 0x45, 0x8d, 0x79, 0x7d, 0x7e, 0xe9, 0x58, 0x17, + 0x97, 0x8e, 0xf5, 0xeb, 0xd2, 0xb1, 0x7e, 0x5c, 0x39, 0xad, 0x8b, 0x2b, 0xa7, 0xf5, 0xf3, 0xca, + 0x69, 0xbd, 0x7f, 0x92, 0x32, 0x75, 0x36, 0x08, 0xdd, 0x88, 0xf7, 0xbd, 0x88, 0xcb, 0x3e, 0x97, + 0x1e, 0x0b, 0xa3, 0xa3, 0x94, 0x7b, 0xc3, 0x13, 0xaf, 0xcf, 0xe3, 0x41, 0x06, 0xb2, 0x7c, 0x1d, + 0xa4, 0x77, 0xfc, 0xf4, 0xa8, 0x7c, 0x18, 0xd4, 0xa8, 0x00, 0x19, 0x2e, 0x57, 0x53, 0x7f, 0xf2, + 0x3b, 0x00, 0x00, 0xff, 0xff, 0x3f, 0x8c, 0xa1, 0x29, 0x93, 0x04, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -687,7 +687,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.FeeEnabledChannels = append(m.FeeEnabledChannels, &FeeEnabledChannel{}) + m.FeeEnabledChannels = append(m.FeeEnabledChannels, FeeEnabledChannel{}) if err := m.FeeEnabledChannels[len(m.FeeEnabledChannels)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -721,7 +721,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.RegisteredRelayers = append(m.RegisteredRelayers, &RegisteredRelayerAddress{}) + m.RegisteredRelayers = append(m.RegisteredRelayers, RegisteredRelayerAddress{}) if err := m.RegisteredRelayers[len(m.RegisteredRelayers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -755,7 +755,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ForwardRelayers = append(m.ForwardRelayers, &ForwardRelayerAddress{}) + m.ForwardRelayers = append(m.ForwardRelayers, ForwardRelayerAddress{}) if err := m.ForwardRelayers[len(m.ForwardRelayers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/modules/apps/29-fee/types/genesis_test.go b/modules/apps/29-fee/types/genesis_test.go index c41fd8f7469..b26fbe27b38 100644 --- a/modules/apps/29-fee/types/genesis_test.go +++ b/modules/apps/29-fee/types/genesis_test.go @@ -158,13 +158,13 @@ func TestValidateGenesis(t *testing.T) { Relayers: nil, }, }, - FeeEnabledChannels: []*types.FeeEnabledChannel{ + FeeEnabledChannels: []types.FeeEnabledChannel{ { PortId: portID, ChannelId: channelID, }, }, - RegisteredRelayers: []*types.RegisteredRelayerAddress{ + RegisteredRelayers: []types.RegisteredRelayerAddress{ { Address: sender, CounterpartyAddress: counterparty, diff --git a/proto/ibc/applications/fee/v1/genesis.proto b/proto/ibc/applications/fee/v1/genesis.proto index 2396cf6d272..4780a68f72e 100644 --- a/proto/ibc/applications/fee/v1/genesis.proto +++ b/proto/ibc/applications/fee/v1/genesis.proto @@ -12,9 +12,9 @@ import "ibc/core/channel/v1/channel.proto"; message GenesisState { repeated IdentifiedPacketFee identified_fees = 1 [(gogoproto.moretags) = "yaml:\"identified_fees\"", (gogoproto.nullable) = false]; - repeated FeeEnabledChannel fee_enabled_channels = 2 [(gogoproto.moretags) = "yaml:\"fee_enabled_channels\""]; - repeated RegisteredRelayerAddress registered_relayers = 3 [(gogoproto.moretags) = "yaml:\"registered_relayers\""]; - repeated ForwardRelayerAddress forward_relayers = 4 [(gogoproto.moretags) = "yaml:\"forward_relayers\""]; + repeated FeeEnabledChannel fee_enabled_channels = 2 [(gogoproto.moretags) = "yaml:\"fee_enabled_channels\"", (gogoproto.nullable) = false]; + repeated RegisteredRelayerAddress registered_relayers = 3 [(gogoproto.moretags) = "yaml:\"registered_relayers\"", (gogoproto.nullable) = false]; + repeated ForwardRelayerAddress forward_relayers = 4 [(gogoproto.moretags) = "yaml:\"forward_relayers\"", (gogoproto.nullable) = false]; } // FeeEnabledChannel contains the PortID & ChannelID for a fee enabled channel From 06f273031521e790cf4a079f4b240b5c98991879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 17 Feb 2022 15:40:42 +0100 Subject: [PATCH 40/79] refactor: use mock module for ics29 escrow_test.go (#932) --- modules/apps/29-fee/keeper/escrow_test.go | 24 ++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go index 0be30c8c22f..dcb2bdbfbd3 100644 --- a/modules/apps/29-fee/keeper/escrow_test.go +++ b/modules/apps/29-fee/keeper/escrow_test.go @@ -5,8 +5,8 @@ import ( "github.com/tendermint/tendermint/crypto/secp256k1" "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" - transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + ibctesting "github.com/cosmos/ibc-go/v3/testing" ) func (suite *KeeperTestSuite) TestEscrowPacketFee() { @@ -84,7 +84,7 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { receiveFee = defaultReceiveFee ackFee = defaultAckFee timeoutFee = defaultTimeoutFee - packetId = channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, transfertypes.PortID, uint64(1)) + packetId = channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, uint64(1)) tc.malleate() fee := types.Fee{ @@ -158,7 +158,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() { reverseRelayer = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) forwardRelayer = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() - packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, transfertypes.PortID, validSeq) + packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, validSeq) fee := types.Fee{ RecvFee: defaultReceiveFee, AckFee: defaultAckFee, @@ -223,7 +223,7 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { packetId := channeltypes.NewPacketId( suite.path.EndpointA.ChannelID, - transfertypes.PortID, + suite.path.EndpointA.ChannelConfig.PortID, 1, ) @@ -268,6 +268,8 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { } func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { + suite.coordinator.Setup(suite.path) + // setup refundAcc := suite.chainA.SenderAccount.GetAddress() @@ -275,7 +277,7 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { prevBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), refundAcc) for i := 0; i < 5; i++ { - packetId := channeltypes.NewPacketId("channel-0", transfertypes.PortID, uint64(i)) + packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, uint64(i)) fee := types.Fee{ RecvFee: defaultReceiveFee, AckFee: defaultAckFee, @@ -283,13 +285,13 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { } identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, "channel-0") + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) suite.Require().NoError(err) } // send a packet over a different channel to ensure this fee is not refunded - packetId := channeltypes.NewPacketId("channel-1", transfertypes.PortID, 1) + packetId := channeltypes.NewPacketId("channel-1", ibctesting.MockFeePort, 1) fee := types.Fee{ RecvFee: defaultReceiveFee, AckFee: defaultAckFee, @@ -297,12 +299,12 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { } identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, "channel-1") + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, "channel-1") err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) suite.Require().NoError(err) // check that refunding all fees on channel-0 refunds all fees except for fee on channel-1 - err = suite.chainA.GetSimApp().IBCFeeKeeper.RefundFeesOnChannel(suite.chainA.GetContext(), transfertypes.PortID, "channel-0") + err = suite.chainA.GetSimApp().IBCFeeKeeper.RefundFeesOnChannel(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) suite.Require().NoError(err, "refund fees returned unexpected error") // add fee sent to channel-1 to after balance to recover original balance @@ -310,7 +312,7 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { suite.Require().Equal(prevBal, afterBal.Add(fee.RecvFee...).Add(fee.AckFee...).Add(fee.TimeoutFee...), "refund account not back to original balance after refunding all tokens") // create escrow and then change module account balance to cause error on refund - packetId = channeltypes.NewPacketId("channel-0", transfertypes.PortID, uint64(6)) + packetId = channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, uint64(6)) identifiedPacketFee = types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) @@ -318,6 +320,6 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { suite.chainA.GetSimApp().BankKeeper.SendCoinsFromModuleToAccount(suite.chainA.GetContext(), types.ModuleName, refundAcc, fee.TimeoutFee) - err = suite.chainA.GetSimApp().IBCFeeKeeper.RefundFeesOnChannel(suite.chainA.GetContext(), transfertypes.PortID, "channel-0") + err = suite.chainA.GetSimApp().IBCFeeKeeper.RefundFeesOnChannel(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) suite.Require().Error(err, "refund fees returned no error with insufficient balance on module account") } From ff1533592a4d480bba7de31347852175cb3091cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 17 Feb 2022 15:56:29 +0100 Subject: [PATCH 41/79] refactor: use mock module for ics29 genesis_test.go (#931) --- modules/apps/29-fee/keeper/genesis_test.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/modules/apps/29-fee/keeper/genesis_test.go b/modules/apps/29-fee/keeper/genesis_test.go index b5ffdcb221d..1a0d158084a 100644 --- a/modules/apps/29-fee/keeper/genesis_test.go +++ b/modules/apps/29-fee/keeper/genesis_test.go @@ -2,19 +2,16 @@ package keeper_test import ( "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" - transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) func (suite *KeeperTestSuite) TestInitGenesis() { - suite.SetupTest() - // build PacketId & Fee refundAcc := suite.chainA.SenderAccount.GetAddress() packetId := channeltypes.NewPacketId( ibctesting.FirstChannelID, - transfertypes.PortID, + ibctesting.MockFeePort, uint64(1), ) fee := types.Fee{ @@ -38,7 +35,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() { }, FeeEnabledChannels: []types.FeeEnabledChannel{ { - PortId: transfertypes.PortID, + PortId: ibctesting.MockFeePort, ChannelId: ibctesting.FirstChannelID, }, }, @@ -58,7 +55,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() { suite.Require().Equal(genesisState.IdentifiedFees[0], identifiedFee) // check fee is enabled - isEnabled := suite.chainA.GetSimApp().IBCFeeKeeper.IsFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, ibctesting.FirstChannelID) + isEnabled := suite.chainA.GetSimApp().IBCFeeKeeper.IsFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) suite.Require().True(isEnabled) // check relayers @@ -68,13 +65,12 @@ func (suite *KeeperTestSuite) TestInitGenesis() { } func (suite *KeeperTestSuite) TestExportGenesis() { - suite.SetupTest() // set fee enabled - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), transfertypes.PortID, ibctesting.FirstChannelID) + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) // setup & escrow the packet fee refundAcc := suite.chainA.SenderAccount.GetAddress() - packetID := channeltypes.NewPacketId(ibctesting.FirstChannelID, transfertypes.PortID, 1) + packetID := channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1) fee := types.Fee{ RecvFee: defaultReceiveFee, AckFee: defaultAckFee, @@ -98,7 +94,7 @@ func (suite *KeeperTestSuite) TestExportGenesis() { // check fee enabled suite.Require().Equal(ibctesting.FirstChannelID, genesisState.FeeEnabledChannels[0].ChannelId) - suite.Require().Equal(transfertypes.PortID, genesisState.FeeEnabledChannels[0].PortId) + suite.Require().Equal(ibctesting.MockFeePort, genesisState.FeeEnabledChannels[0].PortId) // check fee suite.Require().Equal(packetID, genesisState.IdentifiedFees[0].PacketId) From d8b982127214617f139bda8c2d1ce5fd43685d7a Mon Sep 17 00:00:00 2001 From: Sean King Date: Thu, 17 Feb 2022 16:31:23 +0100 Subject: [PATCH 42/79] ics29:feat: emit event escrow (#914) * feat: emit EventTypeSendIncentivizedPacket event on EscrowPacket * fix: string conversion * refactor: add helper fn for emit event * chore: godoc * nit: use .String()) --- modules/apps/29-fee/keeper/escrow.go | 2 ++ modules/apps/29-fee/keeper/events.go | 25 +++++++++++++++++++++++++ modules/apps/29-fee/types/events.go | 4 +++- modules/apps/29-fee/types/keys.go | 4 ++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 modules/apps/29-fee/keeper/events.go diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index e97096271b7..1d0aa60c74f 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -39,6 +39,8 @@ func (k Keeper) EscrowPacketFee(ctx sdk.Context, identifiedFee types.IdentifiedP identifiedFees := types.NewIdentifiedPacketFees(packetFees) k.SetFeesInEscrow(ctx, identifiedFee.PacketId, identifiedFees) + EmitIncentivizedPacket(ctx, identifiedFee) + return nil } diff --git a/modules/apps/29-fee/keeper/events.go b/modules/apps/29-fee/keeper/events.go new file mode 100644 index 00000000000..64c44a34ea0 --- /dev/null +++ b/modules/apps/29-fee/keeper/events.go @@ -0,0 +1,25 @@ +package keeper + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" +) + +// EmitIncentivizedPacket emits an event so that relayers know an incentivized packet is ready to be relayed +func EmitIncentivizedPacket(ctx sdk.Context, identifiedFee types.IdentifiedPacketFee) { + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeIncentivizedPacket, + sdk.NewAttribute(channeltypes.AttributeKeyPortID, identifiedFee.PacketId.PortId), + sdk.NewAttribute(channeltypes.AttributeKeyChannelID, identifiedFee.PacketId.ChannelId), + sdk.NewAttribute(channeltypes.AttributeKeySequence, fmt.Sprint(identifiedFee.PacketId.Sequence)), + sdk.NewAttribute(types.AttributeKeyRecvFee, identifiedFee.Fee.RecvFee.String()), + sdk.NewAttribute(types.AttributeKeyAckFee, identifiedFee.Fee.AckFee.String()), + sdk.NewAttribute(types.AttributeKeyTimeoutFee, identifiedFee.Fee.TimeoutFee.String()), + ), + ) +} diff --git a/modules/apps/29-fee/types/events.go b/modules/apps/29-fee/types/events.go index 4b8d5ee8c95..2c63bc0dcc8 100644 --- a/modules/apps/29-fee/types/events.go +++ b/modules/apps/29-fee/types/events.go @@ -1,4 +1,6 @@ package types // 29-fee events -const () +const ( + EventTypeIncentivizedPacket = "incentivized_ibc_packet" +) diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index b13aa2ba4b8..ec5132fab1a 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -35,6 +35,10 @@ const ( // ForwardRelayerPrefix is the key prefix for forward relayer addresses stored in state for async acknowledgements ForwardRelayerPrefix = "forwardRelayer" + + AttributeKeyRecvFee = "recv_fee" + AttributeKeyAckFee = "ack_fee" + AttributeKeyTimeoutFee = "timeout_fee" ) // FeeEnabledKey returns the key that stores a flag to determine if fee logic should From adc66d2bd9efec525be7a9d5bff65453dffcee64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Fri, 18 Feb 2022 08:40:20 +0100 Subject: [PATCH 43/79] refactor: OnRecvPacket to use mock module (#927) Co-authored-by: Sean King --- modules/apps/29-fee/fee_test.go | 13 +++++++++++++ modules/apps/29-fee/ibc_module_test.go | 16 ++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/modules/apps/29-fee/fee_test.go b/modules/apps/29-fee/fee_test.go index 6df368364bf..88037046a69 100644 --- a/modules/apps/29-fee/fee_test.go +++ b/modules/apps/29-fee/fee_test.go @@ -80,3 +80,16 @@ func (suite *FeeTestSuite) CreateICS20Packet(coin sdk.Coin) channeltypes.Packet 0, ) } + +func (suite *FeeTestSuite) CreateMockPacket() channeltypes.Packet { + return channeltypes.NewPacket( + ibcmock.MockPacketData, + suite.chainA.SenderAccount.GetSequence(), + suite.path.EndpointA.ChannelConfig.PortID, + suite.path.EndpointA.ChannelID, + suite.path.EndpointB.ChannelConfig.PortID, + suite.path.EndpointB.ChannelID, + clienttypes.NewHeight(0, 100), + 0, + ) +} diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index c4fcf653496..4e19badb808 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -462,21 +462,18 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupTest() + suite.SetupMockTest() suite.coordinator.Setup(suite.path) - // set up coin & ics20 packet - coin := ibctesting.TestCoin - // set up a different channel to make sure that the test will error if the destination channel of the packet is not fee enabled suite.path.EndpointB.ChannelID = "channel-1" suite.chainB.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainB.GetContext(), suite.path.EndpointB.ChannelConfig.PortID, suite.path.EndpointB.ChannelID) suite.chainB.GetSimApp().IBCFeeKeeper.DeleteFeeEnabled(suite.chainB.GetContext(), suite.path.EndpointB.ChannelConfig.PortID, "channel-0") - packet := suite.CreateICS20Packet(coin) + packet := suite.CreateMockPacket() // set up module and callbacks - module, _, err := suite.chainB.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainB.GetContext(), ibctesting.TransferPort) + module, _, err := suite.chainB.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainB.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) cbs, ok := suite.chainB.App.GetIBCKeeper().Router.GetRoute(module) @@ -491,19 +488,18 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { switch { case !tc.feeEnabled: - ack := channeltypes.NewResultAcknowledgement([]byte{1}) - suite.Require().Equal(ack, result) + suite.Require().Equal(ibcmock.MockAcknowledgement, result) case tc.forwardRelayer: ack := types.IncentivizedAcknowledgement{ - Result: channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement(), + Result: ibcmock.MockAcknowledgement.Acknowledgement(), ForwardRelayerAddress: suite.chainB.SenderAccount.GetAddress().String(), } suite.Require().Equal(ack, result) case !tc.forwardRelayer: ack := types.IncentivizedAcknowledgement{ - Result: channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement(), + Result: ibcmock.MockAcknowledgement.Acknowledgement(), ForwardRelayerAddress: "", } suite.Require().Equal(ack, result) From 4326c14569c9226f89ff6e08fcd76daa4be8b42c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Fri, 18 Feb 2022 11:57:33 +0100 Subject: [PATCH 44/79] refactor: ics29 OnChanOpenTry/Ack use mock module for testing instead of ics20 (#925) Co-authored-by: Sean King --- modules/apps/29-fee/ibc_module_test.go | 62 +++++++++++++++++--------- testing/simapp/app.go | 3 +- 2 files changed, 43 insertions(+), 22 deletions(-) diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index 4e19badb808..1c5609665bc 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -71,7 +71,6 @@ func (suite *FeeTestSuite) TestOnChanOpenInit() { if version != ibcmock.Version { return fmt.Errorf("incorrect mock version") } - return nil } @@ -117,31 +116,31 @@ func (suite *FeeTestSuite) TestOnChanOpenTry() { }{ { "success - valid fee middleware version", - string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: ibcmock.Version})), false, true, }, { - "success - valid transfer version", - transfertypes.Version, + "success - valid mock version", + ibcmock.Version, false, true, }, { "success - crossing hellos: valid fee middleware", - string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: ibcmock.Version})), true, true, }, { "invalid fee middleware version", - string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: "invalid-ics29-1", AppVersion: transfertypes.Version})), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: "invalid-ics29-1", AppVersion: ibcmock.Version})), false, false, }, { - "invalid transfer version", - string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: "invalid-ics20-1"})), + "invalid mock version", + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: "invalid-mock-version"})), false, false, }, @@ -152,10 +151,21 @@ func (suite *FeeTestSuite) TestOnChanOpenTry() { suite.Run(tc.name, func() { // reset suite - suite.SetupTest() + suite.SetupMockTest() suite.coordinator.SetupConnections(suite.path) suite.path.EndpointB.ChanOpenInit() + // setup mock callback + suite.chainA.GetSimApp().FeeMockModule.IBCApp.OnChanOpenTry = func(ctx sdk.Context, order channeltypes.Order, connectionHops []string, + portID, channelID string, chanCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, counterpartyVersion string, + ) (string, error) { + if counterpartyVersion != ibcmock.Version { + return "", fmt.Errorf("incorrect mock version") + } + return ibcmock.Version, nil + } + var ( chanCap *capabilitytypes.Capability ok bool @@ -163,10 +173,10 @@ func (suite *FeeTestSuite) TestOnChanOpenTry() { ) if tc.crossing { suite.path.EndpointA.ChanOpenInit() - chanCap, ok = suite.chainA.GetSimApp().ScopedTransferKeeper.GetCapability(suite.chainA.GetContext(), host.ChannelCapabilityPath(ibctesting.TransferPort, suite.path.EndpointA.ChannelID)) + chanCap, ok = suite.chainA.GetSimApp().ScopedFeeMockKeeper.GetCapability(suite.chainA.GetContext(), host.ChannelCapabilityPath(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID)) suite.Require().True(ok) } else { - chanCap, err = suite.chainA.App.GetScopedIBCKeeper().NewCapability(suite.chainA.GetContext(), host.ChannelCapabilityPath(ibctesting.TransferPort, suite.path.EndpointA.ChannelID)) + chanCap, err = suite.chainA.App.GetScopedIBCKeeper().NewCapability(suite.chainA.GetContext(), host.ChannelCapabilityPath(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID)) suite.Require().NoError(err) } @@ -181,7 +191,7 @@ func (suite *FeeTestSuite) TestOnChanOpenTry() { Version: tc.cpVersion, } - module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort) + module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) @@ -209,19 +219,19 @@ func (suite *FeeTestSuite) TestOnChanOpenAck() { }{ { "success", - string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: ibcmock.Version})), func(suite *FeeTestSuite) {}, true, }, { "invalid fee version", - string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: "invalid-ics29-1", AppVersion: transfertypes.Version})), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: "invalid-ics29-1", AppVersion: ibcmock.Version})), func(suite *FeeTestSuite) {}, false, }, { - "invalid transfer version", - string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: "invalid-ics20-1"})), + "invalid mock version", + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: "invalid-mock-version"})), func(suite *FeeTestSuite) {}, false, }, @@ -233,11 +243,11 @@ func (suite *FeeTestSuite) TestOnChanOpenAck() { }, { "previous INIT set without fee, however counterparty set fee version", // note this can only happen with incompetent or malicious counterparty chain - string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})), + string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: ibcmock.Version})), func(suite *FeeTestSuite) { // do the first steps without fee version, then pass the fee version as counterparty version in ChanOpenACK - suite.path.EndpointA.ChannelConfig.Version = transfertypes.Version - suite.path.EndpointB.ChannelConfig.Version = transfertypes.Version + suite.path.EndpointA.ChannelConfig.Version = ibcmock.Version + suite.path.EndpointB.ChannelConfig.Version = ibcmock.Version }, false, }, @@ -246,16 +256,26 @@ func (suite *FeeTestSuite) TestOnChanOpenAck() { for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupTest() + suite.SetupMockTest() suite.coordinator.SetupConnections(suite.path) + // setup mock callback + suite.chainA.GetSimApp().FeeMockModule.IBCApp.OnChanOpenAck = func( + ctx sdk.Context, portID, channelID string, counterpartyVersion string, + ) error { + if counterpartyVersion != ibcmock.Version { + return fmt.Errorf("incorrect mock version") + } + return nil + } + // malleate test case tc.malleate(suite) suite.path.EndpointA.ChanOpenInit() suite.path.EndpointB.ChanOpenTry() - module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort) + module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) diff --git a/testing/simapp/app.go b/testing/simapp/app.go index 45f8cbf0b1c..fd7e191ff7b 100644 --- a/testing/simapp/app.go +++ b/testing/simapp/app.go @@ -414,7 +414,7 @@ func NewSimApp( AddRoute(ibcmock.ModuleName+icacontrollertypes.SubModuleName, icaControllerIBCModule). // ica with mock auth module stack route to ica (top level of middleware stack) AddRoute(ibctransfertypes.ModuleName, feeTransferModule). AddRoute(ibcmock.ModuleName, mockIBCModule). - AddRoute(ibcmock.ModuleName+ibcfeetypes.ModuleName, feeWithMockModule) + AddRoute(MockFeePort, feeWithMockModule) app.IBCKeeper.SetRouter(ibcRouter) @@ -564,6 +564,7 @@ func NewSimApp( // note replicate if you do not need to test core IBC or light clients. app.ScopedIBCMockKeeper = scopedIBCMockKeeper app.ScopedICAMockKeeper = scopedICAMockKeeper + app.ScopedFeeMockKeeper = scopedFeeMockKeeper return app } From ad7827fd427eeb3f83efd88f09528d7504d038b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Mon, 21 Feb 2022 11:04:06 +0100 Subject: [PATCH 45/79] refactor: use mock module for OnAcknowledgePacket callback testing (#929) Co-authored-by: Sean King --- modules/apps/29-fee/ibc_module_test.go | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index 1c5609665bc..7736ee9590f 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -557,7 +557,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeesInEscrow(suite.chainA.GetContext(), packetId) ack = types.IncentivizedAcknowledgement{ - Result: channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement(), + Result: ibcmock.MockAcknowledgement.Acknowledgement(), ForwardRelayerAddress: suite.chainA.SenderAccount.GetAddress().String(), }.Acknowledgement() @@ -578,7 +578,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { "channel is not fee not enabled, success", func() { suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeeEnabled(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) - ack = channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement() + ack = ibcmock.MockAcknowledgement.Acknowledgement() expectedBalance = originalBalance }, @@ -590,7 +590,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { blockedAddr := suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress() ack = types.IncentivizedAcknowledgement{ - Result: channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement(), + Result: ibcmock.MockAcknowledgement.Acknowledgement(), ForwardRelayerAddress: blockedAddr.String(), }.Acknowledgement() @@ -604,24 +604,20 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { tc := tc suite.Run(tc.name, func() { suite.SetupTest() - expectedRelayerBalance = sdk.Coins{} // reset - - // open incentivized channel suite.coordinator.Setup(suite.path) + packet := suite.CreateMockPacket() - // set up coin & ics20 packet - coin := ibctesting.TestCoin - packet := suite.CreateICS20Packet(coin) + expectedRelayerBalance = sdk.Coins{} // reset // set up module and callbacks - module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort) + module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) suite.Require().True(ok) // escrow the packet fee - packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) + packetId := channeltypes.NewPacketId(packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence()) identifiedFee = types.NewIdentifiedPacketFee( packetId, types.Fee{ @@ -639,7 +635,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { // must be changed explicitly ack = types.IncentivizedAcknowledgement{ - Result: channeltypes.NewResultAcknowledgement([]byte{1}).Acknowledgement(), + Result: ibcmock.MockAcknowledgement.Acknowledgement(), ForwardRelayerAddress: relayerAddr.String(), }.Acknowledgement() From 7c6076fc2deabdad2f610db28720aa01df4a4b91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Mon, 21 Feb 2022 11:12:07 +0100 Subject: [PATCH 46/79] refactor: OnTimeoutPacket to use mock module (#928) Co-authored-by: Sean King --- modules/apps/29-fee/ibc_module_test.go | 28 ++++++++------------------ 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index 7736ee9590f..1f2ee00a935 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -12,7 +12,6 @@ import ( host "github.com/cosmos/ibc-go/v3/modules/core/24-host" ibctesting "github.com/cosmos/ibc-go/v3/testing" ibcmock "github.com/cosmos/ibc-go/v3/testing/mock" - "github.com/cosmos/ibc-go/v3/testing/simapp" ) var ( @@ -694,7 +693,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { func() { suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeeEnabled(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) - expectedBalance = originalBalance.Add(ibctesting.TestCoin) // timeout refund for ics20 transfer + expectedBalance = originalBalance }, false, }, @@ -705,7 +704,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeesInEscrow(suite.chainA.GetContext(), packetId) - expectedBalance = originalBalance.Add(ibctesting.TestCoin) // timeout refund for ics20 transfer + expectedBalance = originalBalance }, false, }, @@ -716,8 +715,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { expectedBalance = originalBalance. Add(identifiedFee.Fee.RecvFee[0]). - Add(identifiedFee.Fee.AckFee[0]). - Add(ibctesting.TestCoin) // timeout refund for ics20 transfer + Add(identifiedFee.Fee.AckFee[0]) }, false, }, @@ -726,27 +724,18 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupTest() - - // open incentivized channel + suite.SetupMockTest() suite.coordinator.Setup(suite.path) - - // set up coin & create ics20 packet - coin := ibctesting.TestCoin - packet := suite.CreateICS20Packet(coin) - - // setup for ics20: fund chain A's escrow path so that tokens can be unescrowed upon timeout - escrow := transfertypes.GetEscrowAddress(suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) - suite.Require().NoError(simapp.FundAccount(suite.chainA.GetSimApp(), suite.chainA.GetContext(), escrow, sdk.NewCoins(coin))) + packet := suite.CreateMockPacket() // set up module and callbacks - module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.TransferPort) + module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), ibctesting.MockFeePort) suite.Require().NoError(err) cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) suite.Require().True(ok) - packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) + packetId := channeltypes.NewPacketId(packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence()) // must be explicitly changed relayerAddr = suite.chainB.SenderAccount.GetAddress() @@ -772,8 +761,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { // default to success case expectedBalance = originalBalance. Add(identifiedFee.Fee.RecvFee[0]). - Add(identifiedFee.Fee.AckFee[0]). - Add(coin) // timeout refund from ics20 transfer + Add(identifiedFee.Fee.AckFee[0]) // malleate test case tc.malleate() From 179c4f4e3981ae8ecc05781736ab8cf7ad98fb61 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Mon, 21 Feb 2022 11:58:17 +0000 Subject: [PATCH 47/79] chore: add packet id arg to EscrowPacketFee (#951) * adding packet id arg to EscrowPacketFee * updating tests * review adaptations --- modules/apps/29-fee/ibc_module_test.go | 46 ++++++++++---------- modules/apps/29-fee/keeper/escrow.go | 9 ++-- modules/apps/29-fee/keeper/escrow_test.go | 52 +++++++++++------------ modules/apps/29-fee/keeper/msg_server.go | 8 ++-- 4 files changed, 58 insertions(+), 57 deletions(-) diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index 1f2ee00a935..b556f057d7e 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -300,14 +300,14 @@ func (suite *FeeTestSuite) TestOnChanCloseInit() { { "success", func(suite *FeeTestSuite) { - packetId := channeltypes.NewPacketId( + packetID := channeltypes.NewPacketId( suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 1, ) refundAcc := suite.chainA.SenderAccount.GetAddress() - identifiedFee := types.NewIdentifiedPacketFee(packetId, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) + identifiedFee := types.NewIdentifiedPacketFee(packetID, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedFee) suite.Require().NoError(err) }, false, @@ -315,14 +315,14 @@ func (suite *FeeTestSuite) TestOnChanCloseInit() { { "module account balance insufficient", func(suite *FeeTestSuite) { - packetId := channeltypes.PacketId{ + packetID := channeltypes.PacketId{ PortId: suite.path.EndpointA.ChannelConfig.PortID, ChannelId: suite.path.EndpointA.ChannelID, Sequence: 1, } refundAcc := suite.chainA.SenderAccount.GetAddress() - identifiedFee := types.NewIdentifiedPacketFee(packetId, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) + identifiedFee := types.NewIdentifiedPacketFee(packetID, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedFee) suite.Require().NoError(err) suite.chainA.GetSimApp().BankKeeper.SendCoinsFromModuleToAccount(suite.chainA.GetContext(), types.ModuleName, refundAcc, validCoins3) @@ -378,14 +378,14 @@ func (suite *FeeTestSuite) TestOnChanCloseConfirm() { { "success", func(suite *FeeTestSuite) { - packetId := channeltypes.PacketId{ + packetID := channeltypes.PacketId{ PortId: suite.path.EndpointA.ChannelConfig.PortID, ChannelId: suite.path.EndpointA.ChannelID, Sequence: 1, } refundAcc := suite.chainA.SenderAccount.GetAddress() - identifiedFee := types.NewIdentifiedPacketFee(packetId, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) + identifiedFee := types.NewIdentifiedPacketFee(packetID, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedFee) suite.Require().NoError(err) }, false, @@ -393,14 +393,14 @@ func (suite *FeeTestSuite) TestOnChanCloseConfirm() { { "module account balance insufficient", func(suite *FeeTestSuite) { - packetId := channeltypes.PacketId{ + packetID := channeltypes.PacketId{ PortId: suite.path.EndpointA.ChannelConfig.PortID, ChannelId: suite.path.EndpointA.ChannelID, Sequence: 1, } refundAcc := suite.chainA.SenderAccount.GetAddress() - identifiedFee := types.NewIdentifiedPacketFee(packetId, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) + identifiedFee := types.NewIdentifiedPacketFee(packetID, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedFee) suite.Require().NoError(err) suite.chainA.GetSimApp().BankKeeper.SendCoinsFromModuleToAccount(suite.chainA.GetContext(), types.ModuleName, refundAcc, validCoins3) @@ -552,8 +552,8 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { { "no op success without a packet fee", func() { - packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) - suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeesInEscrow(suite.chainA.GetContext(), packetId) + packetID := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) + suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeesInEscrow(suite.chainA.GetContext(), packetID) ack = types.IncentivizedAcknowledgement{ Result: ibcmock.MockAcknowledgement.Acknowledgement(), @@ -616,9 +616,9 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { suite.Require().True(ok) // escrow the packet fee - packetId := channeltypes.NewPacketId(packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence()) + packetID := channeltypes.NewPacketId(packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence()) identifiedFee = types.NewIdentifiedPacketFee( - packetId, + packetID, types.Fee{ RecvFee: validCoins, AckFee: validCoins2, @@ -627,7 +627,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { suite.chainA.SenderAccount.GetAddress().String(), []string{}, ) - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedFee) suite.Require().NoError(err) relayerAddr := suite.chainB.SenderAccount.GetAddress() @@ -701,8 +701,8 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { "no op if identified packet fee doesn't exist", func() { // delete packet fee - packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) - suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeesInEscrow(suite.chainA.GetContext(), packetId) + packetID := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, suite.chainA.SenderAccount.GetSequence()) + suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeesInEscrow(suite.chainA.GetContext(), packetID) expectedBalance = originalBalance }, @@ -735,13 +735,13 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) suite.Require().True(ok) - packetId := channeltypes.NewPacketId(packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence()) + packetID := channeltypes.NewPacketId(packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence()) // must be explicitly changed relayerAddr = suite.chainB.SenderAccount.GetAddress() identifiedFee = types.NewIdentifiedPacketFee( - packetId, + packetID, types.Fee{ RecvFee: validCoins, AckFee: validCoins2, @@ -751,7 +751,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { []string{}, ) - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedFee) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedFee) suite.Require().NoError(err) // log original sender balance @@ -777,7 +777,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { relayerBalance := sdk.NewCoins(suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), relayerAddr, ibctesting.TestCoin.Denom)) if tc.expFeeDistributed { // there should no longer be a fee in escrow for this packet - found := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeesInEscrow(suite.chainA.GetContext(), packetId) + found := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeesInEscrow(suite.chainA.GetContext(), packetID) suite.Require().False(found) suite.Require().Equal(identifiedFee.Fee.TimeoutFee, relayerBalance) diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index 1d0aa60c74f..ec62156855b 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -7,11 +7,12 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ) // EscrowPacketFee sends the packet fee to the 29-fee module account to hold in escrow -func (k Keeper) EscrowPacketFee(ctx sdk.Context, identifiedFee types.IdentifiedPacketFee) error { - if !k.IsFeeEnabled(ctx, identifiedFee.PacketId.PortId, identifiedFee.PacketId.ChannelId) { +func (k Keeper) EscrowPacketFee(ctx sdk.Context, packetID channeltypes.PacketId, identifiedFee types.IdentifiedPacketFee) error { + if !k.IsFeeEnabled(ctx, packetID.PortId, packetID.ChannelId) { // users may not escrow fees on this channel. Must send packets without a fee message return sdkerrors.Wrap(types.ErrFeeNotEnabled, "cannot escrow fee for packet") } @@ -32,12 +33,12 @@ func (k Keeper) EscrowPacketFee(ctx sdk.Context, identifiedFee types.IdentifiedP } packetFees := []types.IdentifiedPacketFee{identifiedFee} - if feesInEscrow, found := k.GetFeesInEscrow(ctx, identifiedFee.PacketId); found { + if feesInEscrow, found := k.GetFeesInEscrow(ctx, packetID); found { packetFees = append(packetFees, feesInEscrow.PacketFees...) } identifiedFees := types.NewIdentifiedPacketFees(packetFees) - k.SetFeesInEscrow(ctx, identifiedFee.PacketId, identifiedFees) + k.SetFeesInEscrow(ctx, packetID, identifiedFees) EmitIncentivizedPacket(ctx, identifiedFee) diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go index dcb2bdbfbd3..fe582aa4335 100644 --- a/modules/apps/29-fee/keeper/escrow_test.go +++ b/modules/apps/29-fee/keeper/escrow_test.go @@ -16,7 +16,7 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { ackFee sdk.Coins receiveFee sdk.Coins timeoutFee sdk.Coins - packetId channeltypes.PacketId + packetID channeltypes.PacketId ) testCases := []struct { @@ -35,18 +35,18 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { TimeoutFee: timeoutFee, } - identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) + identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) feesInEscrow := types.IdentifiedPacketFees{ PacketFees: []types.IdentifiedPacketFee{identifiedPacketFee}, } - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeesInEscrow(suite.chainA.GetContext(), packetId, feesInEscrow) + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeesInEscrow(suite.chainA.GetContext(), packetID, feesInEscrow) }, true, }, { "fee not enabled on this channel", func() { - packetId.ChannelId = "disabled_channel" + packetID.ChannelId = "disabled_channel" }, false, }, { @@ -84,7 +84,7 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { receiveFee = defaultReceiveFee ackFee = defaultAckFee timeoutFee = defaultTimeoutFee - packetId = channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, uint64(1)) + packetID = channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, uint64(1)) tc.malleate() fee := types.Fee{ @@ -92,16 +92,16 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { AckFee: ackFee, TimeoutFee: timeoutFee, } - identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) + identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) // refundAcc balance before escrow originalBal := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom) // escrow the packet fee - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) if tc.expPass { - feesInEscrow, found := suite.chainA.GetSimApp().IBCFeeKeeper.GetFeesInEscrow(suite.chainA.GetContext(), packetId) + feesInEscrow, found := suite.chainA.GetSimApp().IBCFeeKeeper.GetFeesInEscrow(suite.chainA.GetContext(), packetID) suite.Require().True(found) // check if the escrowed fee is set in state suite.Require().True(feesInEscrow.PacketFees[0].Fee.AckFee.IsEqual(fee.AckFee)) @@ -158,7 +158,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() { reverseRelayer = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) forwardRelayer = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() - packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, validSeq) + packetID := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, validSeq) fee := types.Fee{ RecvFee: defaultReceiveFee, AckFee: defaultAckFee, @@ -166,12 +166,12 @@ func (suite *KeeperTestSuite) TestDistributeFee() { } // escrow the packet fee & store the fee in state - identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) + identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) suite.Require().NoError(err) // escrow a second packet fee to test with multiple fees distributed - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) suite.Require().NoError(err) tc.malleate() @@ -183,7 +183,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() { if tc.expPass { // there should no longer be a fee in escrow for this packet - found := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), packetId) + found := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), packetID) suite.Require().False(found) // check if the reverse relayer is paid @@ -221,7 +221,7 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { refundAcc := suite.chainA.SenderAccount.GetAddress() timeoutRelayer := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) - packetId := channeltypes.NewPacketId( + packetID := channeltypes.NewPacketId( suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 1, @@ -235,16 +235,16 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { // escrow the packet fee & store the fee in state identifiedPacketFee := types.NewIdentifiedPacketFee( - packetId, + packetID, fee, refundAcc.String(), []string{}, ) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) suite.Require().NoError(err) // escrow a second packet fee to test with multiple fees distributed - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) suite.Require().NoError(err) // refundAcc balance after escrow @@ -277,30 +277,30 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { prevBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), refundAcc) for i := 0; i < 5; i++ { - packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, uint64(i)) + packetID := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, uint64(i)) fee := types.Fee{ RecvFee: defaultReceiveFee, AckFee: defaultAckFee, TimeoutFee: defaultTimeoutFee, } - identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) + identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) suite.Require().NoError(err) } // send a packet over a different channel to ensure this fee is not refunded - packetId := channeltypes.NewPacketId("channel-1", ibctesting.MockFeePort, 1) + packetID := channeltypes.NewPacketId("channel-1", ibctesting.MockFeePort, 1) fee := types.Fee{ RecvFee: defaultReceiveFee, AckFee: defaultAckFee, TimeoutFee: defaultTimeoutFee, } - identifiedPacketFee := types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) + identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, "channel-1") - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) suite.Require().NoError(err) // check that refunding all fees on channel-0 refunds all fees except for fee on channel-1 @@ -312,10 +312,10 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { suite.Require().Equal(prevBal, afterBal.Add(fee.RecvFee...).Add(fee.AckFee...).Add(fee.TimeoutFee...), "refund account not back to original balance after refunding all tokens") // create escrow and then change module account balance to cause error on refund - packetId = channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, uint64(6)) + packetID = channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, uint64(6)) - identifiedPacketFee = types.NewIdentifiedPacketFee(packetId, fee, refundAcc.String(), []string{}) - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), identifiedPacketFee) + identifiedPacketFee = types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) suite.Require().NoError(err) suite.chainA.GetSimApp().BankKeeper.SendCoinsFromModuleToAccount(suite.chainA.GetContext(), types.ModuleName, refundAcc, fee.TimeoutFee) diff --git a/modules/apps/29-fee/keeper/msg_server.go b/modules/apps/29-fee/keeper/msg_server.go index 3ef24d2c443..a87962c518b 100644 --- a/modules/apps/29-fee/keeper/msg_server.go +++ b/modules/apps/29-fee/keeper/msg_server.go @@ -37,14 +37,14 @@ func (k Keeper) PayPacketFee(goCtx context.Context, msg *types.MsgPayPacketFee) return nil, channeltypes.ErrSequenceSendNotFound } - packetId := channeltypes.NewPacketId( + packetID := channeltypes.NewPacketId( msg.SourceChannelId, msg.SourcePortId, sequence, ) - identifiedPacket := types.NewIdentifiedPacketFee(packetId, msg.Fee, msg.Signer, msg.Relayers) - if err := k.EscrowPacketFee(ctx, identifiedPacket); err != nil { + identifiedPacket := types.NewIdentifiedPacketFee(packetID, msg.Fee, msg.Signer, msg.Relayers) + if err := k.EscrowPacketFee(ctx, packetID, identifiedPacket); err != nil { return nil, err } @@ -57,7 +57,7 @@ func (k Keeper) PayPacketFee(goCtx context.Context, msg *types.MsgPayPacketFee) func (k Keeper) PayPacketFeeAsync(goCtx context.Context, msg *types.MsgPayPacketFeeAsync) (*types.MsgPayPacketFeeAsyncResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - if err := k.EscrowPacketFee(ctx, msg.IdentifiedPacketFee); err != nil { + if err := k.EscrowPacketFee(ctx, msg.IdentifiedPacketFee.PacketId, msg.IdentifiedPacketFee); err != nil { return nil, err } From c14d2b4829d0f8cb8be2c2a089e67ba84647d813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Mon, 21 Feb 2022 17:19:26 +0100 Subject: [PATCH 48/79] chore: remove legacy testing functions (#954) --- modules/apps/29-fee/fee_test.go | 40 ----------------------- modules/apps/29-fee/ibc_module_test.go | 14 ++++---- modules/apps/29-fee/keeper/keeper_test.go | 23 ------------- 3 files changed, 7 insertions(+), 70 deletions(-) diff --git a/modules/apps/29-fee/fee_test.go b/modules/apps/29-fee/fee_test.go index 88037046a69..12d7e70a147 100644 --- a/modules/apps/29-fee/fee_test.go +++ b/modules/apps/29-fee/fee_test.go @@ -3,11 +3,9 @@ package fee_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" - transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v3/testing" @@ -25,27 +23,11 @@ type FeeTestSuite struct { path *ibctesting.Path } -// TODO: remove and rename 'SetupMockTest' to 'SetupTest' func (suite *FeeTestSuite) SetupTest() { suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) - path := ibctesting.NewPath(suite.chainA, suite.chainB) - feeTransferVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})) - path.EndpointA.ChannelConfig.Version = feeTransferVersion - path.EndpointB.ChannelConfig.Version = feeTransferVersion - path.EndpointA.ChannelConfig.PortID = transfertypes.PortID - path.EndpointB.ChannelConfig.PortID = transfertypes.PortID - suite.path = path -} - -// TODO: rename to 'SetupTest' when the above function is removed -func (suite *FeeTestSuite) SetupMockTest() { - suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) - suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) - suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) - path := ibctesting.NewPath(suite.chainA, suite.chainB) mockFeeVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: ibcmock.Version})) path.EndpointA.ChannelConfig.Version = mockFeeVersion @@ -59,28 +41,6 @@ func TestIBCFeeTestSuite(t *testing.T) { suite.Run(t, new(FeeTestSuite)) } -// TODO: remove -func (suite *FeeTestSuite) CreateICS20Packet(coin sdk.Coin) channeltypes.Packet { - - fungibleTokenPacket := transfertypes.NewFungibleTokenPacketData( - coin.Denom, - sdk.NewInt(100).String(), - suite.chainA.SenderAccount.GetAddress().String(), - suite.chainB.SenderAccount.GetAddress().String(), - ) - - return channeltypes.NewPacket( - fungibleTokenPacket.GetBytes(), - suite.chainA.SenderAccount.GetSequence(), - suite.path.EndpointA.ChannelConfig.PortID, - suite.path.EndpointA.ChannelID, - suite.path.EndpointB.ChannelConfig.PortID, - suite.path.EndpointB.ChannelID, - clienttypes.NewHeight(0, 100), - 0, - ) -} - func (suite *FeeTestSuite) CreateMockPacket() channeltypes.Packet { return channeltypes.NewPacket( ibcmock.MockPacketData, diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index b556f057d7e..2a9bf532767 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -59,7 +59,7 @@ func (suite *FeeTestSuite) TestOnChanOpenInit() { suite.Run(tc.name, func() { // reset suite - suite.SetupMockTest() + suite.SetupTest() suite.coordinator.SetupConnections(suite.path) // setup mock callback @@ -150,7 +150,7 @@ func (suite *FeeTestSuite) TestOnChanOpenTry() { suite.Run(tc.name, func() { // reset suite - suite.SetupMockTest() + suite.SetupTest() suite.coordinator.SetupConnections(suite.path) suite.path.EndpointB.ChanOpenInit() @@ -255,7 +255,7 @@ func (suite *FeeTestSuite) TestOnChanOpenAck() { for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupMockTest() + suite.SetupTest() suite.coordinator.SetupConnections(suite.path) // setup mock callback @@ -337,7 +337,7 @@ func (suite *FeeTestSuite) TestOnChanCloseInit() { for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupMockTest() + suite.SetupTest() suite.coordinator.Setup(suite.path) // setup channel origBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress()) @@ -415,7 +415,7 @@ func (suite *FeeTestSuite) TestOnChanCloseConfirm() { for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupMockTest() + suite.SetupTest() suite.coordinator.Setup(suite.path) // setup channel origBal := suite.chainA.GetSimApp().BankKeeper.GetAllBalances(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress()) @@ -481,7 +481,7 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupMockTest() + suite.SetupTest() suite.coordinator.Setup(suite.path) // set up a different channel to make sure that the test will error if the destination channel of the packet is not fee enabled @@ -724,7 +724,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.SetupMockTest() + suite.SetupTest() suite.coordinator.Setup(suite.path) packet := suite.CreateMockPacket() diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index be49deef63b..3fbfa96406d 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -8,7 +8,6 @@ import ( "github.com/stretchr/testify/suite" "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" - transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ibctesting "github.com/cosmos/ibc-go/v3/testing" ibcmock "github.com/cosmos/ibc-go/v3/testing/mock" @@ -34,31 +33,11 @@ type KeeperTestSuite struct { queryClient types.QueryClient } -// TODO: remove and rename 'SetupMockTest' to 'SetupTest' func (suite *KeeperTestSuite) SetupTest() { suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) - path := ibctesting.NewPath(suite.chainA, suite.chainB) - feeTransferVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: transfertypes.Version})) - path.EndpointA.ChannelConfig.Version = feeTransferVersion - path.EndpointB.ChannelConfig.Version = feeTransferVersion - path.EndpointA.ChannelConfig.PortID = transfertypes.PortID - path.EndpointB.ChannelConfig.PortID = transfertypes.PortID - suite.path = path - - queryHelper := baseapp.NewQueryServerTestHelper(suite.chainA.GetContext(), suite.chainA.GetSimApp().InterfaceRegistry()) - types.RegisterQueryServer(queryHelper, suite.chainA.GetSimApp().IBCFeeKeeper) - suite.queryClient = types.NewQueryClient(queryHelper) -} - -// TODO: rename to 'SetupTest' when the above function is removed -func (suite *KeeperTestSuite) SetupMockTest() { - suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) - suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) - suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) - path := ibctesting.NewPath(suite.chainA, suite.chainB) mockFeeVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: ibcmock.Version})) path.EndpointA.ChannelConfig.Version = mockFeeVersion @@ -77,7 +56,6 @@ func TestKeeperTestSuite(t *testing.T) { } func (suite *KeeperTestSuite) TestFeeInEscrow() { - suite.SetupMockTest() suite.coordinator.Setup(suite.path) fee := types.Fee{RecvFee: defaultReceiveFee, AckFee: defaultAckFee, TimeoutFee: defaultTimeoutFee} @@ -119,7 +97,6 @@ func (suite *KeeperTestSuite) TestDisableAllChannels() { } func (suite *KeeperTestSuite) TestGetAllIdentifiedPacketFees() { - suite.SetupMockTest() suite.coordinator.Setup(suite.path) // escrow a fee From 99db1434ac83aec5b622e2a8980548353668f8a3 Mon Sep 17 00:00:00 2001 From: Sean King Date: Mon, 21 Feb 2022 18:00:36 +0100 Subject: [PATCH 49/79] fix:ics29: WriteAck update + adding success bool to IncentivizedAck (#952) * fix: updating WriteAck & adding Success boolean to IncentivizedAcknowledgement * feat: adding check of is fee enabled * nit: change successful to underlying_application_success * test: adding seperate test for fee disabled write async * Update modules/apps/29-fee/ibc_module_test.go Co-authored-by: Aditya * test: adding check to compare hash of acks * fix: var name Co-authored-by: Aditya --- docs/ibc/proto-docs.md | 1 + modules/apps/29-fee/ibc_module.go | 2 +- modules/apps/29-fee/ibc_module_test.go | 35 ++++++---- modules/apps/29-fee/keeper/relay.go | 9 ++- modules/apps/29-fee/keeper/relay_test.go | 30 ++++++++- modules/apps/29-fee/types/ack.go | 5 +- modules/apps/29-fee/types/ack.pb.go | 81 ++++++++++++++++++------ proto/ibc/applications/fee/v1/ack.proto | 1 + 8 files changed, 128 insertions(+), 36 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 84127283e32..0eeff647971 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -341,6 +341,7 @@ It contains the raw acknowledgement bytes, as well as the forward relayer addres | ----- | ---- | ----- | ----------- | | `result` | [bytes](#bytes) | | | | `forward_relayer_address` | [string](#string) | | | +| `underlying_app_success` | [bool](#bool) | | | diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go index 66e40d5d8d8..62cb297076a 100644 --- a/modules/apps/29-fee/ibc_module.go +++ b/modules/apps/29-fee/ibc_module.go @@ -204,7 +204,7 @@ func (im IBCModule) OnRecvPacket( return nil } - return types.NewIncentivizedAcknowledgement(forwardRelayer, ack.Acknowledgement()) + return types.NewIncentivizedAcknowledgement(forwardRelayer, ack.Acknowledgement(), ack.Success()) } // OnAcknowledgementPacket implements the IBCModule interface diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index 2a9bf532767..ff992a61f1d 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -10,6 +10,7 @@ import ( transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" + "github.com/cosmos/ibc-go/v3/modules/core/exported" ibctesting "github.com/cosmos/ibc-go/v3/testing" ibcmock "github.com/cosmos/ibc-go/v3/testing/mock" ) @@ -461,11 +462,18 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { true, }, { - "source relayer is empty string", + "async write acknowledgement: ack is nil", func() { - suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), "") + // setup mock callback + suite.chainB.GetSimApp().FeeMockModule.IBCApp.OnRecvPacket = func( + ctx sdk.Context, + packet channeltypes.Packet, + relayer sdk.AccAddress, + ) exported.Acknowledgement { + return nil + } }, - false, + true, true, }, { @@ -476,6 +484,14 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { true, false, }, + { + "forward address is not found", + func() { + suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), "") + }, + false, + true, + }, } for _, tc := range testCases { @@ -509,19 +525,16 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { case !tc.feeEnabled: suite.Require().Equal(ibcmock.MockAcknowledgement, result) - case tc.forwardRelayer: - ack := types.IncentivizedAcknowledgement{ - Result: ibcmock.MockAcknowledgement.Acknowledgement(), - ForwardRelayerAddress: suite.chainB.SenderAccount.GetAddress().String(), - } - suite.Require().Equal(ack, result) + case tc.forwardRelayer && result == nil: + suite.Require().Equal(nil, result) case !tc.forwardRelayer: - ack := types.IncentivizedAcknowledgement{ + expectedAck := types.IncentivizedAcknowledgement{ Result: ibcmock.MockAcknowledgement.Acknowledgement(), ForwardRelayerAddress: "", + UnderlyingAppSuccess: true, } - suite.Require().Equal(ack, result) + suite.Require().Equal(expectedAck, result) } }) } diff --git a/modules/apps/29-fee/keeper/relay.go b/modules/apps/29-fee/keeper/relay.go index 628ad40a61f..983c9163815 100644 --- a/modules/apps/29-fee/keeper/relay.go +++ b/modules/apps/29-fee/keeper/relay.go @@ -16,14 +16,19 @@ func (k Keeper) SendPacket(ctx sdk.Context, chanCap *capabilitytypes.Capability, // WriteAcknowledgement wraps IBC ChannelKeeper's WriteAcknowledgement function // ICS29 WriteAcknowledgement is used for asynchronous acknowledgements -func (k Keeper) WriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, acknowledgement []byte) error { +func (k Keeper) WriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, acknowledgement ibcexported.Acknowledgement) error { + if !k.IsFeeEnabled(ctx, packet.GetDestPort(), packet.GetDestChannel()) { + // ics4Wrapper may be core IBC or higher-level middleware + return k.ics4Wrapper.WriteAcknowledgement(ctx, chanCap, packet, acknowledgement) + } + // retrieve the forward relayer that was stored in `onRecvPacket` packetId := channeltypes.NewPacketId(packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence()) relayer, _ := k.GetForwardRelayerAddress(ctx, packetId) k.DeleteForwardRelayerAddress(ctx, packetId) - ack := types.NewIncentivizedAcknowledgement(relayer, acknowledgement) + ack := types.NewIncentivizedAcknowledgement(relayer, acknowledgement.Acknowledgement(), acknowledgement.Success()) // ics4Wrapper may be core IBC or higher-level middleware return k.ics4Wrapper.WriteAcknowledgement(ctx, chanCap, packet, ack) diff --git a/modules/apps/29-fee/keeper/relay_test.go b/modules/apps/29-fee/keeper/relay_test.go index 79410552b05..69633bb8ee8 100644 --- a/modules/apps/29-fee/keeper/relay_test.go +++ b/modules/apps/29-fee/keeper/relay_test.go @@ -46,7 +46,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgementAsync() { timeoutTimestamp, ) - ack := []byte("ack") + ack := channeltypes.NewResultAcknowledgement([]byte("success")) chanCap := suite.chainB.GetChannelCapability(suite.path.EndpointB.ChannelConfig.PortID, suite.path.EndpointB.ChannelID) // malleate test case @@ -64,3 +64,31 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgementAsync() { }) } } + +func (suite *KeeperTestSuite) TestWriteAcknowledgementAsyncFeeDisabled() { + // open incentivized channel + suite.coordinator.Setup(suite.path) + suite.chainB.GetSimApp().IBCFeeKeeper.DeleteFeeEnabled(suite.chainB.GetContext(), suite.path.EndpointB.ChannelConfig.PortID, "channel-0") + + // build packet + timeoutTimestamp := ^uint64(0) + packet := channeltypes.NewPacket( + []byte("packetData"), + 1, + suite.path.EndpointA.ChannelConfig.PortID, + suite.path.EndpointA.ChannelID, + suite.path.EndpointB.ChannelConfig.PortID, + suite.path.EndpointB.ChannelID, + clienttypes.ZeroHeight(), + timeoutTimestamp, + ) + + ack := channeltypes.NewResultAcknowledgement([]byte("success")) + chanCap := suite.chainB.GetChannelCapability(suite.path.EndpointB.ChannelConfig.PortID, suite.path.EndpointB.ChannelID) + + err := suite.chainB.GetSimApp().IBCFeeKeeper.WriteAcknowledgement(suite.chainB.GetContext(), chanCap, packet, ack) + suite.Require().NoError(err) + + packetAck, _ := suite.chainB.GetSimApp().GetIBCKeeper().ChannelKeeper.GetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, 1) + suite.Require().Equal(packetAck, channeltypes.CommitAcknowledgement(ack.Acknowledgement())) +} diff --git a/modules/apps/29-fee/types/ack.go b/modules/apps/29-fee/types/ack.go index f54214d8432..229d8e4cc3f 100644 --- a/modules/apps/29-fee/types/ack.go +++ b/modules/apps/29-fee/types/ack.go @@ -5,10 +5,11 @@ import ( ) // NewIncentivizedAcknowledgement creates a new instance of IncentivizedAcknowledgement -func NewIncentivizedAcknowledgement(relayer string, ack []byte) IncentivizedAcknowledgement { +func NewIncentivizedAcknowledgement(relayer string, ack []byte, success bool) IncentivizedAcknowledgement { return IncentivizedAcknowledgement{ Result: ack, ForwardRelayerAddress: relayer, + UnderlyingAppSuccess: success, } } @@ -16,7 +17,7 @@ func NewIncentivizedAcknowledgement(relayer string, ack []byte) IncentivizedAckn // considered successful if the forward relayer address is empty. Otherwise it is // considered a failed acknowledgement. func (ack IncentivizedAcknowledgement) Success() bool { - return ack.ForwardRelayerAddress != "" + return ack.UnderlyingAppSuccess } // Acknowledgement implements the Acknowledgement interface. It returns the diff --git a/modules/apps/29-fee/types/ack.pb.go b/modules/apps/29-fee/types/ack.pb.go index 796fa3cd139..dfcc0e1041c 100644 --- a/modules/apps/29-fee/types/ack.pb.go +++ b/modules/apps/29-fee/types/ack.pb.go @@ -28,6 +28,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type IncentivizedAcknowledgement struct { Result []byte `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` ForwardRelayerAddress string `protobuf:"bytes,2,opt,name=forward_relayer_address,json=forwardRelayerAddress,proto3" json:"forward_relayer_address,omitempty" yaml:"forward_relayer_address"` + UnderlyingAppSuccess bool `protobuf:"varint,3,opt,name=underlying_app_success,json=underlyingAppSuccess,proto3" json:"underlying_app_success,omitempty" yaml:"underlying_app_successl"` } func (m *IncentivizedAcknowledgement) Reset() { *m = IncentivizedAcknowledgement{} } @@ -77,6 +78,13 @@ func (m *IncentivizedAcknowledgement) GetForwardRelayerAddress() string { return "" } +func (m *IncentivizedAcknowledgement) GetUnderlyingAppSuccess() bool { + if m != nil { + return m.UnderlyingAppSuccess + } + return false +} + func init() { proto.RegisterType((*IncentivizedAcknowledgement)(nil), "ibc.applications.fee.v1.IncentivizedAcknowledgement") } @@ -84,25 +92,27 @@ func init() { func init() { proto.RegisterFile("ibc/applications/fee/v1/ack.proto", fileDescriptor_ab2834946fb65ea4) } var fileDescriptor_ab2834946fb65ea4 = []byte{ - // 274 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0xd0, 0xb1, 0x4e, 0xc3, 0x30, - 0x10, 0x06, 0xe0, 0x9a, 0xa1, 0x12, 0x11, 0x53, 0x04, 0xb4, 0x02, 0xc9, 0x94, 0x4c, 0x5d, 0x1a, - 0xab, 0x54, 0x0c, 0xb0, 0xb5, 0x1b, 0x13, 0x52, 0xc6, 0x2e, 0x95, 0x63, 0x5f, 0x82, 0x55, 0x27, - 0x17, 0xd9, 0x4e, 0xaa, 0xf0, 0x14, 0xf0, 0x56, 0x8c, 0x1d, 0x99, 0x10, 0x4a, 0xde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06, 0xdb, 0xf5, 0x63, 0xd9, 0xdd, 0xc3, 0xac, 0xab, 0xc6, 0xd5, 0x05, 0xd8, - 0x78, 0x78, 0xf8, 0x75, 0xf1, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x50, 0xc6, 0xd5, 0xaa, 0x3f, 0x01, - 0x00, 0x00, + // 315 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0xb1, 0x4e, 0xf3, 0x30, + 0x14, 0x85, 0xeb, 0xff, 0x97, 0x2a, 0x88, 0x98, 0xa2, 0xd2, 0x56, 0x20, 0x85, 0x92, 0xa9, 0x4b, + 0x63, 0x95, 0x8a, 0x01, 0xb6, 0x76, 0x63, 0x42, 0x0a, 0x0b, 0xea, 0x12, 0x39, 0xf6, 0x6d, 0xb0, + 0xea, 0xd8, 0x96, 0xed, 0xa4, 0x0a, 0x4f, 0xc1, 0x63, 0x31, 0x76, 0x64, 0x42, 0xa8, 0x1d, 0xd9, + 0x78, 0x02, 0x94, 0xa6, 0x12, 0x1d, 0x60, 0xbb, 0xf7, 0x9c, 0x4f, 0x67, 0xf8, 0xbc, 0x4b, 0x9e, + 0x52, 0x4c, 0xb4, 0x16, 0x9c, 0x12, 0xc7, 0x95, 0xb4, 0x78, 0x01, 0x80, 0xcb, 0x31, 0x26, 0x74, + 0x19, 0x69, 0xa3, 0x9c, 0xf2, 0x7b, 0x3c, 0xa5, 0xd1, 0x21, 0x12, 0x2d, 0x00, 0xa2, 0x72, 0x7c, + 0xd6, 0xc9, 0x54, 0xa6, 0x76, 0x0c, 0xae, 0xaf, 0x06, 0x0f, 0x3f, 0x91, 0x77, 0x7e, 0x27, 0x29, + 0x48, 0xc7, 0x4b, 0xfe, 0x0c, 0x6c, 0x4a, 0x97, 0x52, 0xad, 0x04, 0xb0, 0x0c, 0x72, 0x90, 0xce, + 0xef, 0x7a, 0x6d, 0x03, 0xb6, 0x10, 0xae, 0x8f, 0x06, 0x68, 0x78, 0x12, 0xef, 0x3f, 0x7f, 0xee, + 0xf5, 0x16, 0xca, 0xac, 0x88, 0x61, 0x89, 0x01, 0x41, 0x2a, 0x30, 0x09, 0x61, 0xcc, 0x80, 0xb5, + 0xfd, 0x7f, 0x03, 0x34, 0x3c, 0x9e, 0x85, 0x5f, 0xef, 0x17, 0x41, 0x45, 0x72, 0x71, 0x1b, 0xfe, + 0x01, 0x86, 0xf1, 0xe9, 0xbe, 0x89, 0x9b, 0x62, 0xda, 0xe4, 0xfe, 0xa3, 0xd7, 0x2d, 0x24, 0x03, + 0x23, 0x2a, 0x2e, 0xb3, 0x84, 0x68, 0x9d, 0xd8, 0x82, 0xd2, 0x7a, 0xfa, 0xff, 0x00, 0x0d, 0x8f, + 0x0e, 0xa7, 0x7f, 0xe7, 0x44, 0x18, 0x77, 0x7e, 0x9a, 0xa9, 0xd6, 0x0f, 0x4d, 0x3e, 0xbb, 0x7f, + 0xdd, 0x04, 0x68, 0xbd, 0x09, 0xd0, 0xc7, 0x26, 0x40, 0x2f, 0xdb, 0xa0, 0xb5, 0xde, 0x06, 0xad, + 0xb7, 0x6d, 0xd0, 0x9a, 0x5f, 0x67, 0xdc, 0x3d, 0x15, 0x69, 0x44, 0x55, 0x8e, 0xa9, 0xb2, 0xb9, + 0xb2, 0x98, 0xa7, 0x74, 0x94, 0x29, 0x5c, 0x4e, 0x70, 0xae, 0x58, 0x21, 0xc0, 0xd6, 0xe6, 0x2d, + 0xbe, 0xba, 0x19, 0xd5, 0xd2, 0x5d, 0xa5, 0xc1, 0xa6, 0xed, 0x9d, 0xc5, 0xc9, 0x77, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x2e, 0x38, 0x5f, 0x80, 0x99, 0x01, 0x00, 0x00, } func (m *IncentivizedAcknowledgement) Marshal() (dAtA []byte, err error) { @@ -125,6 +135,16 @@ func (m *IncentivizedAcknowledgement) MarshalToSizedBuffer(dAtA []byte) (int, er _ = i var l int _ = l + if m.UnderlyingAppSuccess { + i-- + if m.UnderlyingAppSuccess { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } if len(m.ForwardRelayerAddress) > 0 { i -= len(m.ForwardRelayerAddress) copy(dAtA[i:], m.ForwardRelayerAddress) @@ -167,6 +187,9 @@ func (m *IncentivizedAcknowledgement) Size() (n int) { if l > 0 { n += 1 + l + sovAck(uint64(l)) } + if m.UnderlyingAppSuccess { + n += 2 + } return n } @@ -271,6 +294,26 @@ func (m *IncentivizedAcknowledgement) Unmarshal(dAtA []byte) error { } m.ForwardRelayerAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field UnderlyingAppSuccess", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAck + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.UnderlyingAppSuccess = bool(v != 0) default: iNdEx = preIndex skippy, err := skipAck(dAtA[iNdEx:]) diff --git a/proto/ibc/applications/fee/v1/ack.proto b/proto/ibc/applications/fee/v1/ack.proto index b978454892d..1a0c5e3f404 100644 --- a/proto/ibc/applications/fee/v1/ack.proto +++ b/proto/ibc/applications/fee/v1/ack.proto @@ -11,4 +11,5 @@ import "gogoproto/gogo.proto"; message IncentivizedAcknowledgement { bytes result = 1; string forward_relayer_address = 2 [(gogoproto.moretags) = "yaml:\"forward_relayer_address\""]; + bool underlying_app_success = 3 [(gogoproto.moretags) = "yaml:\"underlying_app_successl\""]; } From 74afccd63ad8d4351fb139401e7ce47646f29513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Tue, 22 Feb 2022 12:45:40 +0100 Subject: [PATCH 50/79] chore: add cli cmd to incentivize existing packet (async) (#965) * chore: add cli to incentivize existing packets * Update modules/apps/29-fee/client/cli/cli.go * Update modules/apps/29-fee/client/cli/cli.go Co-authored-by: Aditya * chore: update cli example Co-authored-by: Aditya --- modules/apps/29-fee/client/cli/cli.go | 4 +- modules/apps/29-fee/client/cli/tx.go | 98 ++++++++++++++++++++++++++- 2 files changed, 99 insertions(+), 3 deletions(-) diff --git a/modules/apps/29-fee/client/cli/cli.go b/modules/apps/29-fee/client/cli/cli.go index e5ff524dee7..9e18b088dc4 100644 --- a/modules/apps/29-fee/client/cli/cli.go +++ b/modules/apps/29-fee/client/cli/cli.go @@ -25,14 +25,14 @@ func GetQueryCmd() *cobra.Command { func NewTxCmd() *cobra.Command { txCmd := &cobra.Command{ Use: "ibc-fee", - Short: "", // TODO + Short: "Transaction subcommand for IBC relayer incentivization", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, } txCmd.AddCommand( - // TODO + NewPayPacketFeeAsyncTxCmd(), ) return txCmd diff --git a/modules/apps/29-fee/client/cli/tx.go b/modules/apps/29-fee/client/cli/tx.go index e8878f3e042..a9f66a71007 100644 --- a/modules/apps/29-fee/client/cli/tx.go +++ b/modules/apps/29-fee/client/cli/tx.go @@ -1,3 +1,99 @@ package cli -// TODO +import ( + "fmt" + "strconv" + "strings" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/version" + "github.com/spf13/cobra" + + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" +) + +const ( + flagRecvFee = "recv-fee" + flagAckFee = "ack-fee" + flagTimeoutFee = "timeout-fee" +) + +// NewPayPacketFeeAsyncTxCmd returns the command to create a MsgPayPacketFeeAsync +func NewPayPacketFeeAsyncTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "pay-packet-fee [src-port] [src-channel] [sequence]", + Short: "Pay a fee to incentivize an existing IBC packet", + Long: strings.TrimSpace(`Pay a fee to incentivize an existing IBC packet.`), + Example: fmt.Sprintf("%s tx pay-packet-fee transfer channel-0 1 --recv-fee 10stake --ack-fee 10stake --timeout-fee 10stake", version.AppName), + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + // NOTE: specifying non-nil relayers is currently unsupported + var relayers []string + + sender := clientCtx.GetFromAddress().String() + seq, err := strconv.ParseUint(args[2], 10, 64) + if err != nil { + return err + } + + packetID := channeltypes.NewPacketId(args[1], args[0], seq) + + recvFeeStr, err := cmd.Flags().GetString(flagRecvFee) + if err != nil { + return err + } + + recvFee, err := sdk.ParseCoinsNormalized(recvFeeStr) + if err != nil { + return err + } + + ackFeeStr, err := cmd.Flags().GetString(flagAckFee) + if err != nil { + return err + } + + ackFee, err := sdk.ParseCoinsNormalized(ackFeeStr) + if err != nil { + return err + } + + timeoutFeeStr, err := cmd.Flags().GetString(flagTimeoutFee) + if err != nil { + return err + } + + timeoutFee, err := sdk.ParseCoinsNormalized(timeoutFeeStr) + if err != nil { + return err + } + + fee := types.Fee{ + RecvFee: recvFee, + AckFee: ackFee, + TimeoutFee: timeoutFee, + } + + identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, sender, relayers) + + msg := types.NewMsgPayPacketFeeAsync(identifiedPacketFee) + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().String(flagRecvFee, "", "Fee paid to a relayer for relaying a packet receive.") + cmd.Flags().String(flagAckFee, "", "Fee paid to a relayer for relaying a packet acknowledgement.") + cmd.Flags().String(flagTimeoutFee, "", "Fee paid to a relayer for relaying a packet timeout.") + flags.AddTxFlagsToCmd(cmd) + + return cmd +} From 6928af77dca37c347f9b902438f82df7c4311d18 Mon Sep 17 00:00:00 2001 From: Sean King Date: Tue, 22 Feb 2022 16:27:28 +0100 Subject: [PATCH 51/79] ics29:fix: counterparty addr must contain channelID (#937) * fix: counterparty address must chain channelID * nit: updating var name * test: adding validation check for channelID * nit: fn names --- docs/ibc/proto-docs.md | 2 + modules/apps/29-fee/ibc_module.go | 2 +- modules/apps/29-fee/ibc_module_test.go | 4 +- modules/apps/29-fee/keeper/genesis.go | 4 +- modules/apps/29-fee/keeper/genesis_test.go | 5 +- modules/apps/29-fee/keeper/keeper.go | 11 +- modules/apps/29-fee/keeper/keeper_test.go | 3 +- modules/apps/29-fee/keeper/msg_server.go | 2 +- modules/apps/29-fee/keeper/msg_server_test.go | 5 +- modules/apps/29-fee/transfer_test.go | 2 +- modules/apps/29-fee/types/genesis.pb.go | 126 +++++++++++++----- modules/apps/29-fee/types/keys.go | 10 +- modules/apps/29-fee/types/keys_test.go | 7 +- modules/apps/29-fee/types/msgs.go | 8 +- modules/apps/29-fee/types/msgs_test.go | 27 ++-- modules/apps/29-fee/types/tx.pb.go | 121 +++++++++++------ proto/ibc/applications/fee/v1/genesis.proto | 1 + proto/ibc/applications/fee/v1/tx.proto | 1 + 18 files changed, 228 insertions(+), 113 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 0eeff647971..164017ca3b2 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -830,6 +830,7 @@ RegisteredRelayerAddress contains the address and counterparty address for a spe | ----- | ---- | ----- | ----------- | | `address` | [string](#string) | | | | `counterparty_address` | [string](#string) | | | +| `channel_id` | [string](#string) | | | @@ -1041,6 +1042,7 @@ MsgRegisterCounterpartyAddress is the request type for registering the counterpa | ----- | ---- | ----- | ----------- | | `address` | [string](#string) | | | | `counterparty_address` | [string](#string) | | | +| `channel_id` | [string](#string) | | | diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go index 62cb297076a..3bd58fe8a75 100644 --- a/modules/apps/29-fee/ibc_module.go +++ b/modules/apps/29-fee/ibc_module.go @@ -196,7 +196,7 @@ func (im IBCModule) OnRecvPacket( ack := im.app.OnRecvPacket(ctx, packet, relayer) - forwardRelayer, found := im.keeper.GetCounterpartyAddress(ctx, relayer.String()) + forwardRelayer, found := im.keeper.GetCounterpartyAddress(ctx, relayer.String(), packet.DestinationChannel) // incase of async aknowledgement (ack == nil) store the ForwardRelayer address for use later if ack == nil && found { diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index ff992a61f1d..8d6ebb8fcc9 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -487,7 +487,7 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { { "forward address is not found", func() { - suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), "") + suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), "", suite.path.EndpointB.ChannelID) }, false, true, @@ -514,7 +514,7 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { cbs, ok := suite.chainB.App.GetIBCKeeper().Router.GetRoute(module) suite.Require().True(ok) - suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String()) + suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), suite.path.EndpointB.ChannelID) // malleate test case tc.malleate() diff --git a/modules/apps/29-fee/keeper/genesis.go b/modules/apps/29-fee/keeper/genesis.go index 3eec4716bec..aff999ec8aa 100644 --- a/modules/apps/29-fee/keeper/genesis.go +++ b/modules/apps/29-fee/keeper/genesis.go @@ -12,8 +12,8 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) { k.SetFeeInEscrow(ctx, fee) } - for _, addr := range state.RegisteredRelayers { - k.SetCounterpartyAddress(ctx, addr.Address, addr.CounterpartyAddress) + for _, relayer := range state.RegisteredRelayers { + k.SetCounterpartyAddress(ctx, relayer.Address, relayer.CounterpartyAddress, relayer.ChannelId) } for _, forwardAddr := range state.ForwardRelayers { diff --git a/modules/apps/29-fee/keeper/genesis_test.go b/modules/apps/29-fee/keeper/genesis_test.go index 1a0d158084a..76990303312 100644 --- a/modules/apps/29-fee/keeper/genesis_test.go +++ b/modules/apps/29-fee/keeper/genesis_test.go @@ -43,6 +43,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() { { Address: sender, CounterpartyAddress: counterparty, + ChannelId: ibctesting.FirstChannelID, }, }, } @@ -59,7 +60,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() { suite.Require().True(isEnabled) // check relayers - addr, found := suite.chainA.GetSimApp().IBCFeeKeeper.GetCounterpartyAddress(suite.chainA.GetContext(), sender) + addr, found := suite.chainA.GetSimApp().IBCFeeKeeper.GetCounterpartyAddress(suite.chainA.GetContext(), sender, ibctesting.FirstChannelID) suite.Require().True(found) suite.Require().Equal(genesisState.RegisteredRelayers[0].CounterpartyAddress, addr) } @@ -84,7 +85,7 @@ func (suite *KeeperTestSuite) TestExportGenesis() { sender := suite.chainA.SenderAccount.GetAddress().String() counterparty := suite.chainB.SenderAccount.GetAddress().String() // set counterparty address - suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainA.GetContext(), sender, counterparty) + suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainA.GetContext(), sender, counterparty, ibctesting.FirstChannelID) // set forward relayer address suite.chainA.GetSimApp().IBCFeeKeeper.SetForwardRelayerAddress(suite.chainA.GetContext(), packetID, sender) diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index 2d7fb3e5135..390d2f5e51c 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -135,15 +135,15 @@ func (k Keeper) DisableAllChannels(ctx sdk.Context) { // 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, counterpartyAddress, channelID string) { store := ctx.KVStore(k.storeKey) - store.Set(types.KeyRelayerAddress(address), []byte(counterpartyAddress)) + store.Set(types.KeyCounterpartyRelayer(address, channelID), []byte(counterpartyAddress)) } // GetCounterpartyAddress gets the relayer counterparty address given a destination relayer address -func (k Keeper) GetCounterpartyAddress(ctx sdk.Context, address string) (string, bool) { +func (k Keeper) GetCounterpartyAddress(ctx sdk.Context, address, channelID string) (string, bool) { store := ctx.KVStore(k.storeKey) - key := types.KeyRelayerAddress(address) + key := types.KeyCounterpartyRelayer(address, channelID) if !store.Has(key) { return "", false @@ -156,7 +156,7 @@ func (k Keeper) GetCounterpartyAddress(ctx sdk.Context, address string) (string, // GetAllRelayerAddresses returns all registered relayer addresses func (k Keeper) GetAllRelayerAddresses(ctx sdk.Context) []types.RegisteredRelayerAddress { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte(types.RelayerAddressKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte(types.CounterpartyRelayerAddressKeyPrefix)) defer iterator.Close() var registeredAddrArr []types.RegisteredRelayerAddress @@ -166,6 +166,7 @@ func (k Keeper) GetAllRelayerAddresses(ctx sdk.Context) []types.RegisteredRelaye addr := types.RegisteredRelayerAddress{ Address: keySplit[1], CounterpartyAddress: string(iterator.Value()), + ChannelId: keySplit[2], } registeredAddrArr = append(registeredAddrArr, addr) diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index 3fbfa96406d..103fad7968c 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -152,12 +152,13 @@ func (suite *KeeperTestSuite) TestGetAllRelayerAddresses() { sender := suite.chainA.SenderAccount.GetAddress().String() counterparty := suite.chainB.SenderAccount.GetAddress().String() - suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainA.GetContext(), sender, counterparty) + suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainA.GetContext(), sender, counterparty, ibctesting.FirstChannelID) expectedAddr := []types.RegisteredRelayerAddress{ { Address: sender, CounterpartyAddress: counterparty, + ChannelId: ibctesting.FirstChannelID, }, } diff --git a/modules/apps/29-fee/keeper/msg_server.go b/modules/apps/29-fee/keeper/msg_server.go index a87962c518b..ef918905c8b 100644 --- a/modules/apps/29-fee/keeper/msg_server.go +++ b/modules/apps/29-fee/keeper/msg_server.go @@ -18,7 +18,7 @@ func (k Keeper) RegisterCounterpartyAddress(goCtx context.Context, msg *types.Ms ctx := sdk.UnwrapSDKContext(goCtx) k.SetCounterpartyAddress( - ctx, msg.Address, msg.CounterpartyAddress, + ctx, msg.Address, msg.CounterpartyAddress, msg.ChannelId, ) 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 f541dd3fd36..0a8ad4b7d06 100644 --- a/modules/apps/29-fee/keeper/msg_server_test.go +++ b/modules/apps/29-fee/keeper/msg_server_test.go @@ -3,6 +3,7 @@ package keeper_test import ( "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + ibctesting "github.com/cosmos/ibc-go/v3/testing" ) func (suite *KeeperTestSuite) TestRegisterCounterpartyAddress() { @@ -35,14 +36,14 @@ func (suite *KeeperTestSuite) TestRegisterCounterpartyAddress() { sender = suite.chainA.SenderAccount.GetAddress().String() counterparty = suite.chainB.SenderAccount.GetAddress().String() tc.malleate() - msg := types.NewMsgRegisterCounterpartyAddress(sender, counterparty) + msg := types.NewMsgRegisterCounterpartyAddress(sender, counterparty, ibctesting.FirstChannelID) _, 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().String()) + counterpartyAddress, _ := suite.chainA.GetSimApp().IBCFeeKeeper.GetCounterpartyAddress(ctx, suite.chainA.SenderAccount.GetAddress().String(), ibctesting.FirstChannelID) suite.Require().Equal(counterparty, counterpartyAddress) } else { suite.Require().Error(err) diff --git a/modules/apps/29-fee/transfer_test.go b/modules/apps/29-fee/transfer_test.go index 863b728d45f..a07d841d07c 100644 --- a/modules/apps/29-fee/transfer_test.go +++ b/modules/apps/29-fee/transfer_test.go @@ -46,7 +46,7 @@ func (suite *FeeTestSuite) TestFeeTransfer() { // to differentiate from the chainA.SenderAccount for checking successful relay payouts relayerAddress := suite.chainB.SenderAccount.GetAddress() - msgRegister := types.NewMsgRegisterCounterpartyAddress(suite.chainB.SenderAccount.GetAddress().String(), relayerAddress.String()) + msgRegister := types.NewMsgRegisterCounterpartyAddress(suite.chainB.SenderAccount.GetAddress().String(), relayerAddress.String(), ibctesting.FirstChannelID) _, err = suite.chainB.SendMsgs(msgRegister) suite.Require().NoError(err) // message committed diff --git a/modules/apps/29-fee/types/genesis.pb.go b/modules/apps/29-fee/types/genesis.pb.go index c939c190429..1ae5e9b195d 100644 --- a/modules/apps/29-fee/types/genesis.pb.go +++ b/modules/apps/29-fee/types/genesis.pb.go @@ -150,6 +150,7 @@ func (m *FeeEnabledChannel) GetChannelId() string { type RegisteredRelayerAddress struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` CounterpartyAddress string `protobuf:"bytes,2,opt,name=counterparty_address,json=counterpartyAddress,proto3" json:"counterparty_address,omitempty" yaml:"counterparty_address"` + ChannelId string `protobuf:"bytes,3,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` } func (m *RegisteredRelayerAddress) Reset() { *m = RegisteredRelayerAddress{} } @@ -199,6 +200,13 @@ func (m *RegisteredRelayerAddress) GetCounterpartyAddress() string { return "" } +func (m *RegisteredRelayerAddress) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + // ForwardRelayerAddress contains the forward relayer address and packetId used for async acknowledgements type ForwardRelayerAddress struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` @@ -264,43 +272,44 @@ func init() { } var fileDescriptor_7191992e856dff95 = []byte{ - // 573 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x54, 0xcd, 0x6e, 0xd4, 0x3c, - 0x14, 0x9d, 0xb4, 0x55, 0xfb, 0xd5, 0xfd, 0xd4, 0x1f, 0xb7, 0xa5, 0x51, 0x11, 0x99, 0x62, 0x84, - 0x54, 0x01, 0x4d, 0x34, 0x2d, 0x2c, 0x60, 0xc7, 0x20, 0x8a, 0x66, 0x05, 0x32, 0xac, 0xd8, 0x44, - 0xf9, 0xb9, 0x49, 0x2d, 0x32, 0x71, 0x64, 0x7b, 0x06, 0x0d, 0x3b, 0x36, 0xc0, 0x0a, 0xf1, 0x58, - 0x5d, 0x76, 0xc9, 0x6a, 0x84, 0xda, 0x37, 0xe8, 0x13, 0xa0, 0xc4, 0x4e, 0x67, 0x18, 0x26, 0xec, - 0x6e, 0xec, 0x73, 0xee, 0x39, 0x39, 0xf6, 0x35, 0xba, 0xcf, 0xc2, 0xc8, 0x0b, 0x8a, 0x22, 0x63, - 0x51, 0xa0, 0x18, 0xcf, 0xa5, 0x97, 0x00, 0x78, 0xc3, 0x8e, 0x97, 0x42, 0x0e, 0x92, 0x49, 0xb7, - 0x10, 0x5c,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, 0x6d, 0x73, - 0x34, 0x9b, 0x26, 0xc6, 0x9a, 0x4d, 0xe8, 0x7f, 0x45, 0x8d, 0x79, 0x7d, 0x7e, 0xe9, 0x58, 0x17, - 0x97, 0x8e, 0xf5, 0xeb, 0xd2, 0xb1, 0x7e, 0x5c, 0x39, 0xad, 0x8b, 0x2b, 0xa7, 0xf5, 0xf3, 0xca, - 0x69, 0xbd, 0x7f, 0x92, 0x32, 0x75, 0x36, 0x08, 0xdd, 0x88, 0xf7, 0xbd, 0x88, 0xcb, 0x3e, 0x97, - 0x1e, 0x0b, 0xa3, 0xa3, 0x94, 0x7b, 0xc3, 0x13, 0xaf, 0xcf, 0xe3, 0x41, 0x06, 0xb2, 0x7c, 0x1d, - 0xa4, 0x77, 0xfc, 0xf4, 0xa8, 0x7c, 0x18, 0xd4, 0xa8, 0x00, 0x19, 0x2e, 0x57, 0x53, 0x7f, 0xf2, - 0x3b, 0x00, 0x00, 0xff, 0xff, 0x3f, 0x8c, 0xa1, 0x29, 0x93, 0x04, 0x00, 0x00, + // 581 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcd, 0x6e, 0xd4, 0x3c, + 0x14, 0x9d, 0xb4, 0x55, 0xfb, 0xd5, 0xfd, 0xd4, 0x1f, 0xb7, 0xa5, 0x51, 0x11, 0x49, 0x31, 0x42, + 0xaa, 0x80, 0x26, 0x9a, 0x16, 0x16, 0xb0, 0x63, 0x10, 0x45, 0xb3, 0x02, 0x19, 0x56, 0x6c, 0xa2, + 0xfc, 0xdc, 0xa4, 0x16, 0x99, 0x38, 0xb2, 0x3d, 0x83, 0x86, 0x1d, 0x1b, 0xd8, 0x21, 0x9e, 0x88, + 0x75, 0x97, 0x5d, 0xb2, 0x1a, 0xa1, 0xf6, 0x0d, 0xe6, 0x09, 0x50, 0xe2, 0xa4, 0x33, 0x1d, 0x26, + 0x88, 0xdd, 0x8d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, 0x8f, 0x07, 0xf8, 0x6a, 0xa0, 0xdd, 0xb9, 0x97, 0xf0, 0x17, 0xf7, 0xef, 0xd0, 0x6a, 0x5e, + 0x8e, 0x4c, 0x9d, 0xd4, 0xda, 0xf1, 0x9d, 0xf2, 0x86, 0x8b, 0xa1, 0x75, 0xea, 0x49, 0x1d, 0xb4, + 0x1d, 0x3d, 0x58, 0xdd, 0xa8, 0x63, 0x56, 0x17, 0xba, 0x59, 0x85, 0x5f, 0xb3, 0x09, 0xfd, 0x2f, + 0xaf, 0x31, 0xaf, 0xcf, 0x2f, 0x2d, 0xe3, 0xe2, 0xd2, 0x32, 0x7e, 0x5d, 0x5a, 0xc6, 0xf7, 0x2b, + 0xab, 0x75, 0x71, 0x65, 0xb5, 0x7e, 0x5e, 0x59, 0xad, 0xf7, 0x4f, 0x12, 0xa6, 0xce, 0xfa, 0x81, + 0x13, 0xf2, 0x9e, 0x1b, 0x72, 0xd9, 0xe3, 0xd2, 0x65, 0x41, 0x78, 0x94, 0x70, 0x77, 0x70, 0xe2, + 0xf6, 0x78, 0xd4, 0x4f, 0x41, 0x16, 0x6f, 0x8a, 0x74, 0x8f, 0x9f, 0x1e, 0x15, 0xcf, 0x89, 0x1a, + 0xe6, 0x20, 0x83, 0xe5, 0xf2, 0xad, 0x38, 0xf9, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x19, 0xed, 0x5e, + 0x39, 0xc9, 0x04, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -439,6 +448,13 @@ func (m *RegisteredRelayerAddress) MarshalToSizedBuffer(dAtA []byte) (int, error _ = i var l int _ = l + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x1a + } if len(m.CounterpartyAddress) > 0 { i -= len(m.CounterpartyAddress) copy(dAtA[i:], m.CounterpartyAddress) @@ -571,6 +587,10 @@ func (m *RegisteredRelayerAddress) Size() (n int) { if l > 0 { n += 1 + l + sovGenesis(uint64(l)) } + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } return n } @@ -988,6 +1008,38 @@ func (m *RegisteredRelayerAddress) Unmarshal(dAtA []byte) error { } m.CounterpartyAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index ec5132fab1a..d65d8efcbef 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -24,8 +24,8 @@ const ( // FeeEnabledPrefix is the key prefix for storing fee enabled flag FeeEnabledKeyPrefix = "feeEnabled" - // RelayerAddressKeyPrefix is the key prefix for relayer address mapping - RelayerAddressKeyPrefix = "relayerAddress" + // CounterpartyRelayerAddressKeyPrefix is the key prefix for relayer address mapping + CounterpartyRelayerAddressKeyPrefix = "relayerAddress" // FeeInEscrowPrefix is the key prefix for fee in escrow mapping FeeInEscrowPrefix = "feeInEscrow" @@ -47,9 +47,9 @@ func FeeEnabledKey(portID, channelID string) []byte { return []byte(fmt.Sprintf("%s/%s/%s", FeeEnabledKeyPrefix, portID, channelID)) } -// KeyRelayerAddress returns the key for relayer address -> counteryparty address mapping -func KeyRelayerAddress(address string) []byte { - return []byte(fmt.Sprintf("%s/%s", RelayerAddressKeyPrefix, address)) +// KeyCounterpartyRelayer returns the key for relayer address -> counteryparty address mapping +func KeyCounterpartyRelayer(address, channelID string) []byte { + return []byte(fmt.Sprintf("%s/%s/%s", CounterpartyRelayerAddressKeyPrefix, address, channelID)) } // KeyForwardRelayerAddress returns the key for packetID -> forwardAddress mapping diff --git a/modules/apps/29-fee/types/keys_test.go b/modules/apps/29-fee/types/keys_test.go index fbe2c2bbdde..a49532b753b 100644 --- a/modules/apps/29-fee/types/keys_test.go +++ b/modules/apps/29-fee/types/keys_test.go @@ -9,11 +9,12 @@ import ( "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" ) -func TestKeyRelayerAddress(t *testing.T) { +func TestKeyCounterpartyRelayer(t *testing.T) { var ( relayerAddress = "relayer_address" + channelID = "channel-0" ) - key := types.KeyRelayerAddress(relayerAddress) - require.Equal(t, string(key), fmt.Sprintf("%s/relayer_address", types.RelayerAddressKeyPrefix)) + key := types.KeyCounterpartyRelayer(relayerAddress, channelID) + require.Equal(t, string(key), fmt.Sprintf("%s/%s/%s", types.CounterpartyRelayerAddressKeyPrefix, relayerAddress, channelID)) } diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index f3abe737472..50e6584e26b 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -17,10 +17,11 @@ const ( ) // NewMsgRegisterCounterpartyAddress creates a new instance of MsgRegisterCounterpartyAddress -func NewMsgRegisterCounterpartyAddress(address, counterpartyAddress string) *MsgRegisterCounterpartyAddress { +func NewMsgRegisterCounterpartyAddress(address, counterpartyAddress, channelID string) *MsgRegisterCounterpartyAddress { return &MsgRegisterCounterpartyAddress{ Address: address, CounterpartyAddress: counterpartyAddress, + ChannelId: channelID, } } @@ -35,6 +36,11 @@ func (msg MsgRegisterCounterpartyAddress) ValidateBasic() error { return ErrCounterpartyAddressEmpty } + // validate channelId + if err := host.ChannelIdentifierValidator(msg.ChannelId); err != nil { + return err + } + return nil } diff --git a/modules/apps/29-fee/types/msgs_test.go b/modules/apps/29-fee/types/msgs_test.go index 57b38a07086..c4ee1a477f1 100644 --- a/modules/apps/29-fee/types/msgs_test.go +++ b/modules/apps/29-fee/types/msgs_test.go @@ -5,18 +5,20 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/secp256k1" ) var ( - validChannelID = "channel-1" - validPortID = "validPortId" - invalidID = "this identifier is too long to be used as a valid identifier" - validCoins = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}} - invalidCoins = sdk.Coins{sdk.Coin{Denom: "invalid-denom", Amount: sdk.NewInt(-2)}} - validAddr = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() - invalidAddr = "invalid_address" + validChannelID = "channel-1" + invalidChannelID = "ch-1" + validPortID = "validPortId" + invalidID = "this identifier is too long to be used as a valid identifier" + validCoins = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}} + invalidCoins = sdk.Coins{sdk.Coin{Denom: "invalid-denom", Amount: sdk.NewInt(-2)}} + validAddr = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() + invalidAddr = "invalid_address" ) // TestMsgTransferValidation tests ValidateBasic for MsgTransfer @@ -26,10 +28,11 @@ func TestMsgRegisterCountepartyAddressValidation(t *testing.T) { msg *MsgRegisterCounterpartyAddress expPass bool }{ - {"validate with correct sdk.AccAddress", NewMsgRegisterCounterpartyAddress(validAddr, validAddr), true}, - {"validate with incorrect destination relayer address", NewMsgRegisterCounterpartyAddress(invalidAddr, validAddr), false}, - {"invalid counterparty address", NewMsgRegisterCounterpartyAddress(validAddr, ""), false}, - {"invalid counterparty address: whitespaced empty string", NewMsgRegisterCounterpartyAddress(validAddr, " "), false}, + {"validate with correct sdk.AccAddress", NewMsgRegisterCounterpartyAddress(validAddr, validAddr, validChannelID), true}, + {"validate with incorrect destination relayer address", NewMsgRegisterCounterpartyAddress(invalidAddr, validAddr, validChannelID), false}, + {"invalid counterparty address", NewMsgRegisterCounterpartyAddress(validAddr, "", validChannelID), false}, + {"invalid counterparty address: whitespaced empty string", NewMsgRegisterCounterpartyAddress(validAddr, " ", validChannelID), false}, + {"invalid channelID", NewMsgRegisterCounterpartyAddress(validAddr, validAddr, invalidChannelID), false}, } for i, tc := range testCases { @@ -46,7 +49,7 @@ func TestMsgRegisterCountepartyAddressValidation(t *testing.T) { func TestRegisterCountepartyAddressGetSigners(t *testing.T) { addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) // build message - msg := NewMsgRegisterCounterpartyAddress(addr.String(), "counterparty") + msg := NewMsgRegisterCounterpartyAddress(addr.String(), "counterparty", validChannelID) // GetSigners res := msg.GetSigners() diff --git a/modules/apps/29-fee/types/tx.pb.go b/modules/apps/29-fee/types/tx.pb.go index 624c6d8279a..a7f8e1d3bee 100644 --- a/modules/apps/29-fee/types/tx.pb.go +++ b/modules/apps/29-fee/types/tx.pb.go @@ -32,6 +32,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MsgRegisterCounterpartyAddress struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` CounterpartyAddress string `protobuf:"bytes,2,opt,name=counterparty_address,json=counterpartyAddress,proto3" json:"counterparty_address,omitempty" yaml:"counterparty_address"` + ChannelId string `protobuf:"bytes,3,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` } func (m *MsgRegisterCounterpartyAddress) Reset() { *m = MsgRegisterCounterpartyAddress{} } @@ -280,44 +281,45 @@ func init() { func init() { proto.RegisterFile("ibc/applications/fee/v1/tx.proto", fileDescriptor_05c93128649f1b96) } var fileDescriptor_05c93128649f1b96 = []byte{ - // 577 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0x4f, 0x4f, 0xdb, 0x4c, - 0x10, 0xc6, 0x6d, 0xc2, 0xcb, 0x0b, 0x5b, 0x54, 0x84, 0x09, 0x25, 0x98, 0xc8, 0x4e, 0xad, 0xaa, - 0xca, 0xa1, 0xb1, 0x4b, 0x28, 0xaa, 0xca, 0x05, 0x11, 0x24, 0xd4, 0x1c, 0xa2, 0x46, 0x3e, 0xf6, - 0x12, 0x39, 0xeb, 0x89, 0xd9, 0x36, 0xf1, 0x5a, 0xbb, 0x9b, 0xa8, 0xfe, 0x02, 0xa8, 0x47, 0x6e, - 0xed, 0x91, 0x6b, 0xbf, 0x09, 0x47, 0x8e, 0x3d, 0x45, 0x55, 0x72, 0xe9, 0x39, 0x9f, 0xa0, 0xb2, - 0x9d, 0x84, 0x84, 0xfc, 0x11, 0xed, 0xcd, 0xbb, 0xfb, 0x9b, 0x67, 0x66, 0x1e, 0x8f, 0x06, 0xe5, - 0x48, 0x1d, 0x5b, 0x4e, 0x10, 0x34, 0x09, 0x76, 0x04, 0xa1, 0x3e, 0xb7, 0x1a, 0x00, 0x56, 0xe7, - 0xd0, 0x12, 0x5f, 0xcc, 0x80, 0x51, 0x41, 0x95, 0x3d, 0x52, 0xc7, 0xe6, 0x24, 0x61, 0x36, 0x00, - 0xcc, 0xce, 0xa1, 0x9a, 0xf6, 0xa8, 0x47, 0x63, 0xc6, 0x8a, 0xbe, 0x12, 0x5c, 0x7d, 0xbe, 0x48, - 0x30, 0x8a, 0x8a, 0x11, 0xe3, 0xbb, 0x8c, 0xb4, 0x0a, 0xf7, 0x6c, 0xf0, 0x08, 0x17, 0xc0, 0xce, - 0x69, 0xdb, 0x17, 0xc0, 0x02, 0x87, 0x89, 0xf0, 0xcc, 0x75, 0x19, 0x70, 0xae, 0x64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1c, 0x59, 0x2d, 0xea, 0xb6, 0x9b, - 0xc0, 0xa3, 0x25, 0xc5, 0xad, 0xe2, 0xbb, 0x42, 0xb4, 0x9f, 0x44, 0x18, 0x00, 0xaf, 0xaf, 0xc5, - 0xfb, 0xe9, 0xe8, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x81, 0xea, 0x8a, 0x9a, 0x15, 0x05, 0x00, - 0x00, + // 594 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0x4d, 0x4f, 0xdb, 0x4c, + 0x10, 0xc7, 0x6d, 0xc2, 0xc3, 0x03, 0x5b, 0x54, 0x84, 0x81, 0x62, 0x4c, 0x64, 0x53, 0xab, 0xaa, + 0x72, 0x28, 0x76, 0x79, 0x53, 0x55, 0x2e, 0x88, 0x20, 0xa1, 0x72, 0x40, 0x8d, 0x7c, 0xec, 0x25, + 0x72, 0xd6, 0x13, 0xb3, 0x6d, 0xe2, 0xb5, 0xbc, 0x9b, 0xa8, 0xfe, 0x02, 0xa8, 0x47, 0x6e, 0xbd, + 0x72, 0xed, 0x37, 0xe1, 0x54, 0x71, 0xec, 0xc9, 0xaa, 0x92, 0x4b, 0xcf, 0xf9, 0x04, 0x95, 0xed, + 0xd8, 0x75, 0xc8, 0x8b, 0x68, 0x6f, 0x3b, 0x3b, 0xbf, 0xf9, 0xef, 0xcc, 0x7f, 0x57, 0x8b, 0x76, + 0x48, 0x03, 0x9b, 0xb6, 0xef, 0xb7, 0x08, 0xb6, 0x39, 0xa1, 0x1e, 0x33, 0x9b, 0x00, 0x66, 0x77, + 0xcf, 0xe4, 0x9f, 0x0d, 0x3f, 0xa0, 0x9c, 0x4a, 0x9b, 0xa4, 0x81, 0x8d, 0x22, 0x61, 0x34, 0x01, + 0x8c, 0xee, 0x9e, 0xb2, 0xee, 0x52, 0x97, 0x26, 0x8c, 0x19, 0xaf, 0x52, 0x5c, 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x34, 0xaf, 0x5b, 0xcb, 0xe9, 0x46, 0x8d, 0x06, 0xfc, 0xc2, 0x91, 0xde, 0xa1, 0xd5, + 0x21, 0x30, 0x36, 0x7b, 0x79, 0x10, 0x69, 0xf2, 0x88, 0x46, 0xd1, 0x82, 0x95, 0x74, 0xef, 0x2c, + 0x33, 0x42, 0x7a, 0x86, 0x16, 0x18, 0x71, 0x3d, 0x08, 0xe4, 0xf9, 0xe4, 0xae, 0x86, 0x91, 0xa4, + 0xa0, 0xc5, 0x00, 0x5a, 0x76, 0x08, 0x01, 0x93, 0xff, 0xdb, 0x29, 0x55, 0x96, 0xac, 0x3c, 0x2e, + 0x98, 0xb7, 0x85, 0x36, 0x1f, 0x38, 0x92, 0xbb, 0xf5, 0x4d, 0x44, 0xeb, 0x0f, 0x72, 0xa7, 0x2c, + 0xf4, 0xb0, 0x74, 0x2d, 0xa2, 0x0d, 0xe2, 0x80, 0xc7, 0x49, 0x93, 0x80, 0x53, 0xf7, 0x93, 0x6c, + 0xfd, 0x8f, 0x8b, 0xaf, 0xa6, 0xba, 0x78, 0x91, 0x57, 0xe5, 0x92, 0xd5, 0x17, 0xb1, 0xab, 0x83, + 0x48, 0x2b, 0xa7, 0x23, 0x4f, 0x14, 0xd6, 0xad, 0x35, 0x32, 0x5e, 0x5a, 0x18, 0x43, 0x45, 0xe5, + 0x49, 0xad, 0x66, 0xb3, 0xec, 0x5f, 0x97, 0x50, 0xe9, 0x92, 0xb9, 0xd2, 0x57, 0x11, 0x6d, 0xcf, + 0x7a, 0xf9, 0x6f, 0xa6, 0xb6, 0x3e, 0xfb, 0x89, 0x29, 0x27, 0xff, 0x58, 0x98, 0x75, 0x28, 0x7d, + 0x44, 0xcb, 0x23, 0xef, 0xb2, 0x32, 0x4b, 0xb0, 0x48, 0x2a, 0xaf, 0x1f, 0x4b, 0xe6, 0x67, 0x85, + 0x68, 0x75, 0xfc, 0x56, 0x77, 0x1f, 0x2b, 0x93, 0xe0, 0xca, 0xd1, 0x5f, 0xe1, 0xd9, 0xd1, 0xd5, + 0xf7, 0x77, 0x3d, 0x55, 0xbc, 0xef, 0xa9, 0xe2, 0xcf, 0x9e, 0x2a, 0xde, 0xf4, 0x55, 0xe1, 0xbe, + 0xaf, 0x0a, 0x3f, 0xfa, 0xaa, 0xf0, 0xe1, 0xc8, 0x25, 0xfc, 0xaa, 0xd3, 0x30, 0x30, 0x6d, 0x9b, + 0x98, 0xb2, 0x36, 0x65, 0x26, 0x69, 0xe0, 0x5d, 0x97, 0x9a, 0xdd, 0x03, 0xb3, 0x4d, 0x9d, 0x4e, + 0x0b, 0x58, 0xfc, 0xb5, 0x31, 0x73, 0xff, 0xed, 0x6e, 0xfc, 0xab, 0xf1, 0xd0, 0x07, 0xd6, 0x58, + 0x48, 0x7e, 0xb5, 0x83, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xcf, 0x27, 0xb3, 0x4f, 0x4b, 0x05, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -514,6 +516,13 @@ func (m *MsgRegisterCounterpartyAddress) MarshalToSizedBuffer(dAtA []byte) (int, _ = i var l int _ = l + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x1a + } if len(m.CounterpartyAddress) > 0 { i -= len(m.CounterpartyAddress) copy(dAtA[i:], m.CounterpartyAddress) @@ -721,6 +730,10 @@ func (m *MsgRegisterCounterpartyAddress) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } return n } @@ -890,6 +903,38 @@ func (m *MsgRegisterCounterpartyAddress) Unmarshal(dAtA []byte) error { } m.CounterpartyAddress = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/proto/ibc/applications/fee/v1/genesis.proto b/proto/ibc/applications/fee/v1/genesis.proto index 4780a68f72e..134a16be850 100644 --- a/proto/ibc/applications/fee/v1/genesis.proto +++ b/proto/ibc/applications/fee/v1/genesis.proto @@ -27,6 +27,7 @@ message FeeEnabledChannel { message RegisteredRelayerAddress { string address = 1; string counterparty_address = 2 [(gogoproto.moretags) = "yaml:\"counterparty_address\""]; + string channel_id = 3 [(gogoproto.moretags) = "yaml:\"channel_id\""]; } // ForwardRelayerAddress contains the forward relayer address and packetId used for async acknowledgements diff --git a/proto/ibc/applications/fee/v1/tx.proto b/proto/ibc/applications/fee/v1/tx.proto index 900764f9343..532524cd4b2 100644 --- a/proto/ibc/applications/fee/v1/tx.proto +++ b/proto/ibc/applications/fee/v1/tx.proto @@ -32,6 +32,7 @@ message MsgRegisterCounterpartyAddress { string address = 1; string counterparty_address = 2 [(gogoproto.moretags) = "yaml:\"counterparty_address\""]; + string channel_id = 3 [(gogoproto.moretags) = "yaml:\"channel_id\""]; } // MsgRegisterCounterpartyAddressResponse defines the Msg/RegisterCounterypartyAddress response type From 6999e107d321f2f1ba23643768ddfa583f8b5d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Tue, 22 Feb 2022 17:22:21 +0100 Subject: [PATCH 52/79] chore: fix err msg (#971) --- modules/apps/29-fee/ibc_module.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go index 3bd58fe8a75..e9d58ffb165 100644 --- a/modules/apps/29-fee/ibc_module.go +++ b/modules/apps/29-fee/ibc_module.go @@ -116,7 +116,7 @@ func (im IBCModule) OnChanOpenAck( } if versionMetadata.FeeVersion != types.Version { - return sdkerrors.Wrapf(types.ErrInvalidVersion, "expected counterparty version: %s, got: %s", types.Version, versionMetadata.FeeVersion) + return sdkerrors.Wrapf(types.ErrInvalidVersion, "expected counterparty fee version: %s, got: %s", types.Version, versionMetadata.FeeVersion) } // call underlying app's OnChanOpenAck callback with the counterparty app version. From 4fb6d18e515ba1140431ccfa17cab0f7574b51a5 Mon Sep 17 00:00:00 2001 From: Sean King Date: Wed, 23 Feb 2022 11:15:59 +0100 Subject: [PATCH 53/79] ics29:fix: store source address for query later on WriteAck (#912) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: for async WriteAck store source address for query later * ics29:fix: update genesis type (#913) * fix: adding ForwardRelayerAddresses to genesis * fix: trimspace on string check * nit: err + trimspace error case * refactor: updating WriteAck + keeper fn name * Update modules/apps/29-fee/keeper/relay.go Co-authored-by: Damian Nolan * chore: remove legacy testing functions (#954) * fix:ics29: WriteAck update + adding success bool to IncentivizedAck (#952) * fix: updating WriteAck & adding Success boolean to IncentivizedAcknowledgement * feat: adding check of is fee enabled * nit: change successful to underlying_application_success * test: adding seperate test for fee disabled write async * Update modules/apps/29-fee/ibc_module_test.go Co-authored-by: Aditya * test: adding check to compare hash of acks * fix: var name Co-authored-by: Aditya Co-authored-by: Damian Nolan Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> Co-authored-by: Aditya --- modules/apps/29-fee/ibc_module.go | 11 +++--- modules/apps/29-fee/keeper/genesis.go | 2 +- modules/apps/29-fee/keeper/genesis_test.go | 2 +- modules/apps/29-fee/keeper/keeper.go | 8 ++--- modules/apps/29-fee/keeper/relay.go | 15 ++++++-- modules/apps/29-fee/keeper/relay_test.go | 15 ++++---- modules/apps/29-fee/types/errors.go | 1 + modules/apps/29-fee/types/genesis.go | 22 +++++++++--- modules/apps/29-fee/types/genesis_test.go | 42 +++++++++++++++++----- 9 files changed, 84 insertions(+), 34 deletions(-) diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go index e9d58ffb165..a4c3cb5292e 100644 --- a/modules/apps/29-fee/ibc_module.go +++ b/modules/apps/29-fee/ibc_module.go @@ -196,14 +196,15 @@ func (im IBCModule) OnRecvPacket( ack := im.app.OnRecvPacket(ctx, packet, relayer) - forwardRelayer, found := im.keeper.GetCounterpartyAddress(ctx, relayer.String(), packet.DestinationChannel) - - // incase of async aknowledgement (ack == nil) store the ForwardRelayer address for use later - if ack == nil && found { - im.keeper.SetForwardRelayerAddress(ctx, channeltypes.NewPacketId(packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence()), forwardRelayer) + // incase of async aknowledgement (ack == nil) store the relayer address for use later during async WriteAcknowledgement + if ack == nil { + im.keeper.SetRelayerAddressForAsyncAck(ctx, channeltypes.NewPacketId(packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence()), relayer.String()) return nil } + // if forwardRelayer is not found we refund recv_fee + forwardRelayer, _ := im.keeper.GetCounterpartyAddress(ctx, relayer.String(), packet.GetSourceChannel()) + return types.NewIncentivizedAcknowledgement(forwardRelayer, ack.Acknowledgement(), ack.Success()) } diff --git a/modules/apps/29-fee/keeper/genesis.go b/modules/apps/29-fee/keeper/genesis.go index aff999ec8aa..5cf26a52ac3 100644 --- a/modules/apps/29-fee/keeper/genesis.go +++ b/modules/apps/29-fee/keeper/genesis.go @@ -17,7 +17,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) { } for _, forwardAddr := range state.ForwardRelayers { - k.SetForwardRelayerAddress(ctx, forwardAddr.PacketId, forwardAddr.Address) + k.SetRelayerAddressForAsyncAck(ctx, forwardAddr.PacketId, forwardAddr.Address) } for _, enabledChan := range state.FeeEnabledChannels { diff --git a/modules/apps/29-fee/keeper/genesis_test.go b/modules/apps/29-fee/keeper/genesis_test.go index 76990303312..0b3dcb4bad6 100644 --- a/modules/apps/29-fee/keeper/genesis_test.go +++ b/modules/apps/29-fee/keeper/genesis_test.go @@ -88,7 +88,7 @@ func (suite *KeeperTestSuite) TestExportGenesis() { suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainA.GetContext(), sender, counterparty, ibctesting.FirstChannelID) // set forward relayer address - suite.chainA.GetSimApp().IBCFeeKeeper.SetForwardRelayerAddress(suite.chainA.GetContext(), packetID, sender) + suite.chainA.GetSimApp().IBCFeeKeeper.SetRelayerAddressForAsyncAck(suite.chainA.GetContext(), packetID, sender) // export genesis genesisState := suite.chainA.GetSimApp().IBCFeeKeeper.ExportGenesis(suite.chainA.GetContext()) diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index 390d2f5e51c..b867d05a2c2 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -175,14 +175,14 @@ func (k Keeper) GetAllRelayerAddresses(ctx sdk.Context) []types.RegisteredRelaye return registeredAddrArr } -// SetForwardRelayerAddress sets the forward relayer address during OnRecvPacket in case of async acknowledgement -func (k Keeper) SetForwardRelayerAddress(ctx sdk.Context, packetId channeltypes.PacketId, address string) { +// SetRelayerAddressForAsyncAck sets the forward relayer address during OnRecvPacket in case of async acknowledgement +func (k Keeper) SetRelayerAddressForAsyncAck(ctx sdk.Context, packetId channeltypes.PacketId, address string) { store := ctx.KVStore(k.storeKey) store.Set(types.KeyForwardRelayerAddress(packetId), []byte(address)) } -// GetForwardRelayerAddress gets forward relayer address for a particular packet -func (k Keeper) GetForwardRelayerAddress(ctx sdk.Context, packetId channeltypes.PacketId) (string, bool) { +// GetRelayerAddressForAsyncAck gets forward relayer address for a particular packet +func (k Keeper) GetRelayerAddressForAsyncAck(ctx sdk.Context, packetId channeltypes.PacketId) (string, bool) { store := ctx.KVStore(k.storeKey) key := types.KeyForwardRelayerAddress(packetId) if !store.Has(key) { diff --git a/modules/apps/29-fee/keeper/relay.go b/modules/apps/29-fee/keeper/relay.go index 983c9163815..76b410bb09e 100644 --- a/modules/apps/29-fee/keeper/relay.go +++ b/modules/apps/29-fee/keeper/relay.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" @@ -24,11 +25,19 @@ func (k Keeper) WriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.C // retrieve the forward relayer that was stored in `onRecvPacket` packetId := channeltypes.NewPacketId(packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence()) - relayer, _ := k.GetForwardRelayerAddress(ctx, packetId) - k.DeleteForwardRelayerAddress(ctx, packetId) + relayer, found := k.GetRelayerAddressForAsyncAck(ctx, packetId) + if !found { + return sdkerrors.Wrapf(types.ErrRelayerNotFoundForAsyncAck, "no relayer address stored for async acknowledgement for packet with portID: %s, channelID: %s, sequence: %d", packetId.PortId, packetId.ChannelId, packetId.Sequence) + } + + // it is possible that a relayer has not registered a counterparty address. + // if there is no registered counterparty address then write acknowledgement with empty relayer address and refund recv_fee. + forwardRelayer, _ := k.GetCounterpartyAddress(ctx, relayer, packet.GetSourceChannel()) - ack := types.NewIncentivizedAcknowledgement(relayer, acknowledgement.Acknowledgement(), acknowledgement.Success()) + ack := types.NewIncentivizedAcknowledgement(forwardRelayer, acknowledgement.Acknowledgement(), acknowledgement.Success()) + + k.DeleteForwardRelayerAddress(ctx, packetId) // ics4Wrapper may be core IBC or higher-level middleware return k.ics4Wrapper.WriteAcknowledgement(ctx, chanCap, packet, ack) diff --git a/modules/apps/29-fee/keeper/relay_test.go b/modules/apps/29-fee/keeper/relay_test.go index 69633bb8ee8..4f366b8682a 100644 --- a/modules/apps/29-fee/keeper/relay_test.go +++ b/modules/apps/29-fee/keeper/relay_test.go @@ -13,16 +13,17 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgementAsync() { }{ { "success", - func() {}, - true, - }, - { - "forward relayer address is successfully deleted", func() { - suite.chainB.GetSimApp().IBCFeeKeeper.SetForwardRelayerAddress(suite.chainB.GetContext(), channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 1), suite.chainA.SenderAccount.GetAddress().String()) + suite.chainB.GetSimApp().IBCFeeKeeper.SetRelayerAddressForAsyncAck(suite.chainB.GetContext(), channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 1), suite.chainA.SenderAccount.GetAddress().String()) + suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), suite.path.EndpointA.ChannelID) }, true, }, + { + "relayer address not set for async WriteAcknowledgement", + func() {}, + false, + }, } for _, tc := range testCases { @@ -56,7 +57,7 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgementAsync() { if tc.expPass { suite.Require().NoError(err) - _, found := suite.chainB.GetSimApp().IBCFeeKeeper.GetForwardRelayerAddress(suite.chainB.GetContext(), channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 1)) + _, found := suite.chainB.GetSimApp().IBCFeeKeeper.GetRelayerAddressForAsyncAck(suite.chainB.GetContext(), channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 1)) suite.Require().False(found) } else { suite.Require().Error(err) diff --git a/modules/apps/29-fee/types/errors.go b/modules/apps/29-fee/types/errors.go index 55ce843e92c..75fdd436c91 100644 --- a/modules/apps/29-fee/types/errors.go +++ b/modules/apps/29-fee/types/errors.go @@ -14,4 +14,5 @@ var ( ErrCounterpartyAddressEmpty = sdkerrors.Register(ModuleName, 7, "counterparty address must not be empty") ErrForwardRelayerAddressNotFound = sdkerrors.Register(ModuleName, 8, "forward relayer address not found") ErrFeeNotEnabled = sdkerrors.Register(ModuleName, 9, "fee module is not enabled for this channel. If this error occurs after channel setup, fee module may not be enabled") + ErrRelayerNotFoundForAsyncAck = sdkerrors.Register(ModuleName, 10, "relayer address must be stored for async WriteAcknowledgement") ) diff --git a/modules/apps/29-fee/types/genesis.go b/modules/apps/29-fee/types/genesis.go index dbeb71c1285..33319feb984 100644 --- a/modules/apps/29-fee/types/genesis.go +++ b/modules/apps/29-fee/types/genesis.go @@ -1,6 +1,8 @@ package types import ( + "strings" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -8,11 +10,12 @@ import ( ) // NewGenesisState creates a 29-fee GenesisState instance. -func NewGenesisState(identifiedFees []IdentifiedPacketFee, feeEnabledChannels []FeeEnabledChannel, registeredRelayers []RegisteredRelayerAddress) *GenesisState { +func NewGenesisState(identifiedFees []IdentifiedPacketFee, feeEnabledChannels []FeeEnabledChannel, registeredRelayers []RegisteredRelayerAddress, forwardRelayers []ForwardRelayerAddress) *GenesisState { return &GenesisState{ IdentifiedFees: identifiedFees, FeeEnabledChannels: feeEnabledChannels, RegisteredRelayers: registeredRelayers, + ForwardRelayers: forwardRelayers, } } @@ -20,6 +23,7 @@ func NewGenesisState(identifiedFees []IdentifiedPacketFee, feeEnabledChannels [] func DefaultGenesisState() *GenesisState { return &GenesisState{ IdentifiedFees: []IdentifiedPacketFee{}, + ForwardRelayers: []ForwardRelayerAddress{}, FeeEnabledChannels: []FeeEnabledChannel{}, RegisteredRelayers: []RegisteredRelayerAddress{}, } @@ -48,15 +52,25 @@ func (gs GenesisState) Validate() error { // Validate RegisteredRelayers for _, rel := range gs.RegisteredRelayers { - _, err := sdk.AccAddressFromBech32(rel.Address) - if err != nil { + if _, err := sdk.AccAddressFromBech32(rel.Address); err != nil { return sdkerrors.Wrap(err, "failed to convert source relayer address into sdk.AccAddress") } - if rel.CounterpartyAddress == "" { + if strings.TrimSpace(rel.CounterpartyAddress) == "" { return ErrCounterpartyAddressEmpty } } + // Validate ForwardRelayers + for _, rel := range gs.ForwardRelayers { + if _, err := sdk.AccAddressFromBech32(rel.Address); err != nil { + return sdkerrors.Wrap(err, "failed to convert forward relayer address into sdk.AccAddress") + } + + if err := rel.PacketId.Validate(); err != nil { + return err + } + } + return nil } diff --git a/modules/apps/29-fee/types/genesis_test.go b/modules/apps/29-fee/types/genesis_test.go index b26fbe27b38..711e9ebb142 100644 --- a/modules/apps/29-fee/types/genesis_test.go +++ b/modules/apps/29-fee/types/genesis_test.go @@ -23,14 +23,16 @@ var ( func TestValidateGenesis(t *testing.T) { var ( - packetId channeltypes.PacketId - fee types.Fee - refundAcc string - sender string - counterparty string - portID string - channelID string - seq uint64 + packetId channeltypes.PacketId + fee types.Fee + refundAcc string + sender string + forwardAddr string + counterparty string + portID string + channelID string + packetChannelID string + seq uint64 ) testCases := []struct { @@ -118,7 +120,21 @@ func TestValidateGenesis(t *testing.T) { { "invalid RegisteredRelayers: invalid counterparty", func() { - counterparty = "" + counterparty = " " + }, + false, + }, + { + "invalid ForwardRelayerAddress: invalid forwardAddr", + func() { + forwardAddr = "" + }, + false, + }, + { + "invalid ForwardRelayerAddress: invalid packet", + func() { + packetChannelID = "1" }, false, }, @@ -127,6 +143,7 @@ func TestValidateGenesis(t *testing.T) { for _, tc := range testCases { portID = transfertypes.PortID channelID = ibctesting.FirstChannelID + packetChannelID = ibctesting.FirstChannelID seq = uint64(1) // build PacketId & Fee @@ -146,6 +163,7 @@ func TestValidateGenesis(t *testing.T) { // relayer addresses sender = addr1 counterparty = addr2 + forwardAddr = addr2 tc.malleate() @@ -170,6 +188,12 @@ func TestValidateGenesis(t *testing.T) { CounterpartyAddress: counterparty, }, }, + ForwardRelayers: []types.ForwardRelayerAddress{ + { + Address: forwardAddr, + PacketId: channeltypes.NewPacketId(packetChannelID, portID, 1), + }, + }, } err := genState.Validate() From b02d193dbc9a420e019968a960c1dfe1ad66bdc9 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 23 Feb 2022 13:51:19 +0000 Subject: [PATCH 54/79] refactor: make fee storage more efficient (#956) * adding new proto types and codegen * refactoring ics29 fees for more efficient storage * updating tests * fixing typo in protodoc comments --- docs/ibc/proto-docs.md | 40 +- modules/apps/29-fee/ibc_module.go | 8 +- modules/apps/29-fee/ibc_module_test.go | 46 +- modules/apps/29-fee/keeper/escrow.go | 24 +- modules/apps/29-fee/keeper/escrow_test.go | 44 +- modules/apps/29-fee/keeper/events.go | 14 +- modules/apps/29-fee/keeper/keeper.go | 32 +- modules/apps/29-fee/keeper/msg_server.go | 8 +- modules/apps/29-fee/types/fee.go | 24 +- modules/apps/29-fee/types/fee.pb.go | 597 ++++++++++++++++++-- proto/ibc/applications/fee/v1/fee.proto | 22 +- proto/ibc/applications/fee/v1/genesis.proto | 9 +- 12 files changed, 724 insertions(+), 144 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 164017ca3b2..9bf131b1b56 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -32,6 +32,8 @@ - [Fee](#ibc.applications.fee.v1.Fee) - [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) - [IdentifiedPacketFees](#ibc.applications.fee.v1.IdentifiedPacketFees) + - [PacketFee](#ibc.applications.fee.v1.PacketFee) + - [PacketFees](#ibc.applications.fee.v1.PacketFees) - [ibc/applications/fee/v1/genesis.proto](#ibc/applications/fee/v1/genesis.proto) - [FeeEnabledChannel](#ibc.applications.fee.v1.FeeEnabledChannel) @@ -742,12 +744,46 @@ and an optional list of relayers that are permitted to receive the fee. ### IdentifiedPacketFees -IdentifiedPacketFees contains a list of packet fees +IdentifiedPacketFees contains a list of type PacketFee and associated PacketId | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `packet_fees` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | repeated | | +| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | | +| `packet_fees` | [PacketFee](#ibc.applications.fee.v1.PacketFee) | repeated | | + + + + + + + + +### PacketFee +PacketFee contains the relayer fee, refund address and an optional list of relayers that are permitted to receive the +fee + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | +| `refund_address` | [string](#string) | | | +| `relayers` | [string](#string) | repeated | | + + + + + + + + +### PacketFees +PacketFees contains a list of type PacketFee + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `packet_fees` | [PacketFee](#ibc.applications.fee.v1.PacketFee) | repeated | | diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go index a4c3cb5292e..c7a73d56e74 100644 --- a/modules/apps/29-fee/ibc_module.go +++ b/modules/apps/29-fee/ibc_module.go @@ -226,13 +226,13 @@ func (im IBCModule) OnAcknowledgementPacket( } packetID := channeltypes.NewPacketId(packet.SourceChannel, packet.SourcePort, packet.Sequence) - identifiedPacketFees, found := im.keeper.GetFeesInEscrow(ctx, packetID) + feesInEscrow, found := im.keeper.GetFeesInEscrow(ctx, packetID) if !found { // return underlying callback if no fee found for given packetID return im.app.OnAcknowledgementPacket(ctx, packet, ack.Result, relayer) } - im.keeper.DistributePacketFees(ctx, ack.ForwardRelayerAddress, relayer, identifiedPacketFees.PacketFees) + im.keeper.DistributePacketFees(ctx, ack.ForwardRelayerAddress, relayer, feesInEscrow.PacketFees) // removes the fees from the store as fees are now paid im.keeper.DeleteFeesInEscrow(ctx, packetID) @@ -253,13 +253,13 @@ func (im IBCModule) OnTimeoutPacket( } packetID := channeltypes.NewPacketId(packet.SourceChannel, packet.SourcePort, packet.Sequence) - identifiedPacketFees, found := im.keeper.GetFeesInEscrow(ctx, packetID) + feesInEscrow, found := im.keeper.GetFeesInEscrow(ctx, packetID) if !found { // return underlying callback if fee not found for given packetID return im.app.OnTimeoutPacket(ctx, packet, relayer) } - im.keeper.DistributePacketFeesOnTimeout(ctx, relayer, identifiedPacketFees.PacketFees) + im.keeper.DistributePacketFeesOnTimeout(ctx, relayer, feesInEscrow.PacketFees) // removes the fee from the store as fee is now paid im.keeper.DeleteFeesInEscrow(ctx, packetID) diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index 8d6ebb8fcc9..214c171d72a 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -307,8 +307,8 @@ func (suite *FeeTestSuite) TestOnChanCloseInit() { 1, ) refundAcc := suite.chainA.SenderAccount.GetAddress() - identifiedFee := types.NewIdentifiedPacketFee(packetID, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedFee) + packetFee := types.NewPacketFee(types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) suite.Require().NoError(err) }, false, @@ -322,8 +322,8 @@ func (suite *FeeTestSuite) TestOnChanCloseInit() { Sequence: 1, } refundAcc := suite.chainA.SenderAccount.GetAddress() - identifiedFee := types.NewIdentifiedPacketFee(packetID, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedFee) + packetFee := types.NewPacketFee(types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) suite.Require().NoError(err) suite.chainA.GetSimApp().BankKeeper.SendCoinsFromModuleToAccount(suite.chainA.GetContext(), types.ModuleName, refundAcc, validCoins3) @@ -385,8 +385,8 @@ func (suite *FeeTestSuite) TestOnChanCloseConfirm() { Sequence: 1, } refundAcc := suite.chainA.SenderAccount.GetAddress() - identifiedFee := types.NewIdentifiedPacketFee(packetID, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedFee) + packetFee := types.NewPacketFee(types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) suite.Require().NoError(err) }, false, @@ -400,8 +400,8 @@ func (suite *FeeTestSuite) TestOnChanCloseConfirm() { Sequence: 1, } refundAcc := suite.chainA.SenderAccount.GetAddress() - identifiedFee := types.NewIdentifiedPacketFee(packetID, types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedFee) + packetFee := types.NewPacketFee(types.Fee{validCoins, validCoins2, validCoins3}, refundAcc.String(), []string{}) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) suite.Require().NoError(err) suite.chainA.GetSimApp().BankKeeper.SendCoinsFromModuleToAccount(suite.chainA.GetContext(), types.ModuleName, refundAcc, validCoins3) @@ -544,7 +544,7 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { var ( ack []byte - identifiedFee types.IdentifiedPacketFee + packetFee types.PacketFee originalBalance sdk.Coins expectedBalance sdk.Coins expectedRelayerBalance sdk.Coins @@ -558,7 +558,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { { "success", func() { - expectedRelayerBalance = identifiedFee.Fee.RecvFee.Add(identifiedFee.Fee.AckFee[0]) + expectedRelayerBalance = packetFee.Fee.RecvFee.Add(packetFee.Fee.AckFee[0]) }, true, }, @@ -606,7 +606,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { ForwardRelayerAddress: blockedAddr.String(), }.Acknowledgement() - expectedRelayerBalance = identifiedFee.Fee.AckFee + expectedRelayerBalance = packetFee.Fee.AckFee }, true, }, @@ -630,8 +630,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { // escrow the packet fee packetID := channeltypes.NewPacketId(packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence()) - identifiedFee = types.NewIdentifiedPacketFee( - packetID, + packetFee = types.NewPacketFee( types.Fee{ RecvFee: validCoins, AckFee: validCoins2, @@ -640,7 +639,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { suite.chainA.SenderAccount.GetAddress().String(), []string{}, ) - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedFee) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) suite.Require().NoError(err) relayerAddr := suite.chainB.SenderAccount.GetAddress() @@ -656,7 +655,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { originalBalance = sdk.NewCoins(suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), ibctesting.TestCoin.Denom)) // default to success case - expectedBalance = originalBalance.Add(identifiedFee.Fee.TimeoutFee[0]) + expectedBalance = originalBalance.Add(packetFee.Fee.TimeoutFee[0]) // malleate test case tc.malleate() @@ -687,7 +686,7 @@ func (suite *FeeTestSuite) TestOnAcknowledgementPacket() { func (suite *FeeTestSuite) TestOnTimeoutPacket() { var ( relayerAddr sdk.AccAddress - identifiedFee types.IdentifiedPacketFee + packetFee types.PacketFee originalBalance sdk.Coins expectedBalance sdk.Coins ) @@ -727,8 +726,8 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { relayerAddr = suite.chainA.GetSimApp().AccountKeeper.GetModuleAccount(suite.chainA.GetContext(), transfertypes.ModuleName).GetAddress() expectedBalance = originalBalance. - Add(identifiedFee.Fee.RecvFee[0]). - Add(identifiedFee.Fee.AckFee[0]) + Add(packetFee.Fee.RecvFee[0]). + Add(packetFee.Fee.AckFee[0]) }, false, }, @@ -753,8 +752,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { // must be explicitly changed relayerAddr = suite.chainB.SenderAccount.GetAddress() - identifiedFee = types.NewIdentifiedPacketFee( - packetID, + packetFee = types.NewPacketFee( types.Fee{ RecvFee: validCoins, AckFee: validCoins2, @@ -764,7 +762,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { []string{}, ) - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedFee) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) suite.Require().NoError(err) // log original sender balance @@ -773,8 +771,8 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { // default to success case expectedBalance = originalBalance. - Add(identifiedFee.Fee.RecvFee[0]). - Add(identifiedFee.Fee.AckFee[0]) + Add(packetFee.Fee.RecvFee[0]). + Add(packetFee.Fee.AckFee[0]) // malleate test case tc.malleate() @@ -793,7 +791,7 @@ func (suite *FeeTestSuite) TestOnTimeoutPacket() { found := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeesInEscrow(suite.chainA.GetContext(), packetID) suite.Require().False(found) - suite.Require().Equal(identifiedFee.Fee.TimeoutFee, relayerBalance) + suite.Require().Equal(packetFee.Fee.TimeoutFee, relayerBalance) } else { suite.Require().Empty(relayerBalance) } diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index ec62156855b..d3e96bad312 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -11,13 +11,13 @@ import ( ) // EscrowPacketFee sends the packet fee to the 29-fee module account to hold in escrow -func (k Keeper) EscrowPacketFee(ctx sdk.Context, packetID channeltypes.PacketId, identifiedFee types.IdentifiedPacketFee) error { +func (k Keeper) EscrowPacketFee(ctx sdk.Context, packetID channeltypes.PacketId, packetFee types.PacketFee) error { if !k.IsFeeEnabled(ctx, packetID.PortId, packetID.ChannelId) { // users may not escrow fees on this channel. Must send packets without a fee message return sdkerrors.Wrap(types.ErrFeeNotEnabled, "cannot escrow fee for packet") } // check if the refund account exists - refundAcc, err := sdk.AccAddressFromBech32(identifiedFee.RefundAddress) + refundAcc, err := sdk.AccAddressFromBech32(packetFee.RefundAddress) if err != nil { return err } @@ -27,26 +27,26 @@ func (k Keeper) EscrowPacketFee(ctx sdk.Context, packetID channeltypes.PacketId, return sdkerrors.Wrapf(types.ErrRefundAccNotFound, "account with address: %s not found", refundAcc) } - coins := identifiedFee.Fee.Total() + coins := packetFee.Fee.Total() if err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, refundAcc, types.ModuleName, coins); err != nil { return err } - packetFees := []types.IdentifiedPacketFee{identifiedFee} + fees := []types.PacketFee{packetFee} if feesInEscrow, found := k.GetFeesInEscrow(ctx, packetID); found { - packetFees = append(packetFees, feesInEscrow.PacketFees...) + fees = append(fees, feesInEscrow.PacketFees...) } - identifiedFees := types.NewIdentifiedPacketFees(packetFees) - k.SetFeesInEscrow(ctx, packetID, identifiedFees) + packetFees := types.NewPacketFees(fees) + k.SetFeesInEscrow(ctx, packetID, packetFees) - EmitIncentivizedPacket(ctx, identifiedFee) + EmitIncentivizedPacket(ctx, packetID, packetFee) return nil } // DistributePacketFees pays the acknowledgement fee & receive fee for a given packetId while refunding the timeout fee to the refund account associated with the Fee. -func (k Keeper) DistributePacketFees(ctx sdk.Context, forwardRelayer string, reverseRelayer sdk.AccAddress, feesInEscrow []types.IdentifiedPacketFee) { +func (k Keeper) DistributePacketFees(ctx sdk.Context, forwardRelayer string, reverseRelayer sdk.AccAddress, feesInEscrow []types.PacketFee) { forwardAddr, _ := sdk.AccAddressFromBech32(forwardRelayer) for _, packetFee := range feesInEscrow { @@ -73,7 +73,7 @@ func (k Keeper) DistributePacketFees(ctx sdk.Context, forwardRelayer string, rev } // DistributePacketsFeesTimeout pays the timeout fee for a given packetId while refunding the acknowledgement fee & receive fee to the refund account associated with the Fee -func (k Keeper) DistributePacketFeesOnTimeout(ctx sdk.Context, timeoutRelayer sdk.AccAddress, feesInEscrow []types.IdentifiedPacketFee) { +func (k Keeper) DistributePacketFeesOnTimeout(ctx sdk.Context, timeoutRelayer sdk.AccAddress, feesInEscrow []types.PacketFee) { for _, feeInEscrow := range feesInEscrow { // check if refundAcc address works refundAddr, err := sdk.AccAddressFromBech32(feeInEscrow.RefundAddress) @@ -113,8 +113,8 @@ func (k Keeper) RefundFeesOnChannel(ctx sdk.Context, portID, channelID string) e var refundErr error - k.IterateIdentifiedChannelFeesInEscrow(ctx, portID, channelID, func(identifiedFees types.IdentifiedPacketFees) (stop bool) { - for _, identifiedFee := range identifiedFees.PacketFees { + k.IteratePacketFeesInEscrow(ctx, portID, channelID, func(packetFees types.PacketFees) (stop bool) { + for _, identifiedFee := range packetFees.PacketFees { refundAccAddr, err := sdk.AccAddressFromBech32(identifiedFee.RefundAddress) if err != nil { refundErr = err diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go index fe582aa4335..81103197aa5 100644 --- a/modules/apps/29-fee/keeper/escrow_test.go +++ b/modules/apps/29-fee/keeper/escrow_test.go @@ -35,11 +35,8 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { TimeoutFee: timeoutFee, } - identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) - - feesInEscrow := types.IdentifiedPacketFees{ - PacketFees: []types.IdentifiedPacketFee{identifiedPacketFee}, - } + packetFee := types.NewPacketFee(fee, refundAcc.String(), []string{}) + feesInEscrow := types.NewPacketFees([]types.PacketFee{packetFee}) suite.chainA.GetSimApp().IBCFeeKeeper.SetFeesInEscrow(suite.chainA.GetContext(), packetID, feesInEscrow) }, true, @@ -92,13 +89,13 @@ func (suite *KeeperTestSuite) TestEscrowPacketFee() { AckFee: ackFee, TimeoutFee: timeoutFee, } - identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) + packetFee := types.NewPacketFee(fee, refundAcc.String(), []string{}) // refundAcc balance before escrow originalBal := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom) // escrow the packet fee - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) if tc.expPass { feesInEscrow, found := suite.chainA.GetSimApp().IBCFeeKeeper.GetFeesInEscrow(suite.chainA.GetContext(), packetID) @@ -166,12 +163,12 @@ func (suite *KeeperTestSuite) TestDistributeFee() { } // escrow the packet fee & store the fee in state - identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) + packetFee := types.NewPacketFee(fee, refundAcc.String(), []string{}) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) suite.Require().NoError(err) // escrow a second packet fee to test with multiple fees distributed - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) suite.Require().NoError(err) tc.malleate() @@ -179,7 +176,7 @@ func (suite *KeeperTestSuite) TestDistributeFee() { // refundAcc balance after escrow refundAccBal := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom) - suite.chainA.GetSimApp().IBCFeeKeeper.DistributePacketFees(suite.chainA.GetContext(), forwardRelayer, reverseRelayer, []types.IdentifiedPacketFee{identifiedPacketFee, identifiedPacketFee}) + suite.chainA.GetSimApp().IBCFeeKeeper.DistributePacketFees(suite.chainA.GetContext(), forwardRelayer, reverseRelayer, []types.PacketFee{packetFee, packetFee}) if tc.expPass { // there should no longer be a fee in escrow for this packet @@ -234,23 +231,18 @@ func (suite *KeeperTestSuite) TestDistributeTimeoutFee() { } // escrow the packet fee & store the fee in state - identifiedPacketFee := types.NewIdentifiedPacketFee( - packetID, - fee, - refundAcc.String(), - []string{}, - ) + packetFee := types.NewPacketFee(fee, refundAcc.String(), []string{}) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) suite.Require().NoError(err) // escrow a second packet fee to test with multiple fees distributed - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) suite.Require().NoError(err) // refundAcc balance after escrow refundAccBal := suite.chainA.GetSimApp().BankKeeper.GetBalance(suite.chainA.GetContext(), refundAcc, sdk.DefaultBondDenom) - suite.chainA.GetSimApp().IBCFeeKeeper.DistributePacketFeesOnTimeout(suite.chainA.GetContext(), timeoutRelayer, []types.IdentifiedPacketFee{identifiedPacketFee, identifiedPacketFee}) + suite.chainA.GetSimApp().IBCFeeKeeper.DistributePacketFeesOnTimeout(suite.chainA.GetContext(), timeoutRelayer, []types.PacketFee{packetFee, packetFee}) // check if the timeoutRelayer has been paid hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), timeoutRelayer, fee.TimeoutFee[0]) @@ -284,9 +276,9 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { TimeoutFee: defaultTimeoutFee, } - identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) + packetFee := types.NewPacketFee(fee, refundAcc.String(), []string{}) suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) suite.Require().NoError(err) } @@ -298,9 +290,9 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { TimeoutFee: defaultTimeoutFee, } - identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) + packetFee := types.NewPacketFee(fee, refundAcc.String(), []string{}) suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, "channel-1") - err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) suite.Require().NoError(err) // check that refunding all fees on channel-0 refunds all fees except for fee on channel-1 @@ -314,8 +306,8 @@ func (suite *KeeperTestSuite) TestRefundFeesOnChannel() { // create escrow and then change module account balance to cause error on refund packetID = channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, uint64(6)) - identifiedPacketFee = types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) - err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, identifiedPacketFee) + packetFee = types.NewPacketFee(fee, refundAcc.String(), []string{}) + err = suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) suite.Require().NoError(err) suite.chainA.GetSimApp().BankKeeper.SendCoinsFromModuleToAccount(suite.chainA.GetContext(), types.ModuleName, refundAcc, fee.TimeoutFee) diff --git a/modules/apps/29-fee/keeper/events.go b/modules/apps/29-fee/keeper/events.go index 64c44a34ea0..9ff6f320ffc 100644 --- a/modules/apps/29-fee/keeper/events.go +++ b/modules/apps/29-fee/keeper/events.go @@ -10,16 +10,16 @@ import ( ) // EmitIncentivizedPacket emits an event so that relayers know an incentivized packet is ready to be relayed -func EmitIncentivizedPacket(ctx sdk.Context, identifiedFee types.IdentifiedPacketFee) { +func EmitIncentivizedPacket(ctx sdk.Context, packetID channeltypes.PacketId, packetFee types.PacketFee) { ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTypeIncentivizedPacket, - sdk.NewAttribute(channeltypes.AttributeKeyPortID, identifiedFee.PacketId.PortId), - sdk.NewAttribute(channeltypes.AttributeKeyChannelID, identifiedFee.PacketId.ChannelId), - sdk.NewAttribute(channeltypes.AttributeKeySequence, fmt.Sprint(identifiedFee.PacketId.Sequence)), - sdk.NewAttribute(types.AttributeKeyRecvFee, identifiedFee.Fee.RecvFee.String()), - sdk.NewAttribute(types.AttributeKeyAckFee, identifiedFee.Fee.AckFee.String()), - sdk.NewAttribute(types.AttributeKeyTimeoutFee, identifiedFee.Fee.TimeoutFee.String()), + sdk.NewAttribute(channeltypes.AttributeKeyPortID, packetID.PortId), + sdk.NewAttribute(channeltypes.AttributeKeyChannelID, packetID.ChannelId), + sdk.NewAttribute(channeltypes.AttributeKeySequence, fmt.Sprint(packetID.Sequence)), + sdk.NewAttribute(types.AttributeKeyRecvFee, packetFee.Fee.RecvFee.String()), + sdk.NewAttribute(types.AttributeKeyAckFee, packetFee.Fee.AckFee.String()), + sdk.NewAttribute(types.AttributeKeyTimeoutFee, packetFee.Fee.TimeoutFee.String()), ), ) } diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index b867d05a2c2..cc7bff64bdb 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -249,12 +249,12 @@ func (k Keeper) GetFeeInEscrow(ctx sdk.Context, packetId channeltypes.PacketId) } // GetFeesInEscrow returns all escrowed packet fees for a given packetID -func (k Keeper) GetFeesInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) (types.IdentifiedPacketFees, bool) { +func (k Keeper) GetFeesInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) (types.PacketFees, bool) { store := ctx.KVStore(k.storeKey) key := types.KeyFeesInEscrow(packetID) bz := store.Get(key) if bz == nil { - return types.IdentifiedPacketFees{}, false + return types.PacketFees{}, false } return k.MustUnmarshalFees(bz), true @@ -269,7 +269,7 @@ func (k Keeper) HasFeesInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) } // SetFeesInEscrow sets the given packet fees in escrow keyed by the packet identifier -func (k Keeper) SetFeesInEscrow(ctx sdk.Context, packetID channeltypes.PacketId, fees types.IdentifiedPacketFees) { +func (k Keeper) SetFeesInEscrow(ctx sdk.Context, packetID channeltypes.PacketId, fees types.PacketFees) { store := ctx.KVStore(k.storeKey) bz := k.MustMarshalFees(fees) store.Set(types.KeyFeesInEscrow(packetID), bz) @@ -282,31 +282,31 @@ func (k Keeper) DeleteFeesInEscrow(ctx sdk.Context, packetID channeltypes.Packet store.Delete(key) } -// IterateChannelFeesInEscrow iterates over all the fees on the given channel currently escrowed and calls the provided callback +// IteratePacketFeesInEscrow iterates over all the fees on the given channel currently escrowed and calls the provided callback // if the callback returns true, then iteration is stopped. -func (k Keeper) IterateChannelFeesInEscrow(ctx sdk.Context, portID, channelID string, cb func(identifiedFee types.IdentifiedPacketFee) (stop bool)) { +func (k Keeper) IteratePacketFeesInEscrow(ctx sdk.Context, portID, channelID string, cb func(packetFees types.PacketFees) (stop bool)) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.KeyFeeInEscrowChannelPrefix(portID, channelID)) + iterator := sdk.KVStorePrefixIterator(store, types.KeyFeesInEscrowChannelPrefix(portID, channelID)) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - identifiedFee := k.MustUnmarshalFee(iterator.Value()) - if cb(identifiedFee) { + packetFees := k.MustUnmarshalFees(iterator.Value()) + if cb(packetFees) { break } } } -// IterateIdentifiedChannelFeesInEscrow iterates over all the fees on the given channel currently escrowed and calls the provided callback +// IterateChannelFeesInEscrow iterates over all the fees on the given channel currently escrowed and calls the provided callback // if the callback returns true, then iteration is stopped. -func (k Keeper) IterateIdentifiedChannelFeesInEscrow(ctx sdk.Context, portID, channelID string, cb func(identifiedFees types.IdentifiedPacketFees) (stop bool)) { +func (k Keeper) IterateChannelFeesInEscrow(ctx sdk.Context, portID, channelID string, cb func(identifiedFee types.IdentifiedPacketFee) (stop bool)) { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.KeyFeesInEscrowChannelPrefix(portID, channelID)) + iterator := sdk.KVStorePrefixIterator(store, types.KeyFeeInEscrowChannelPrefix(portID, channelID)) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - identifiedFees := k.MustUnmarshalFees(iterator.Value()) - if cb(identifiedFees) { + identifiedFee := k.MustUnmarshalFee(iterator.Value()) + if cb(identifiedFee) { break } } @@ -358,14 +358,14 @@ func (k Keeper) MustUnmarshalFee(bz []byte) types.IdentifiedPacketFee { // MustMarshalFees attempts to encode a Fee object and returns the // raw encoded bytes. It panics on error. -func (k Keeper) MustMarshalFees(fees types.IdentifiedPacketFees) []byte { +func (k Keeper) MustMarshalFees(fees types.PacketFees) []byte { return k.cdc.MustMarshal(&fees) } // MustUnmarshalFees attempts to decode and return a Fee object from // raw encoded bytes. It panics on error. -func (k Keeper) MustUnmarshalFees(bz []byte) types.IdentifiedPacketFees { - var fees types.IdentifiedPacketFees +func (k Keeper) MustUnmarshalFees(bz []byte) types.PacketFees { + var fees types.PacketFees k.cdc.MustUnmarshal(bz, &fees) return fees } diff --git a/modules/apps/29-fee/keeper/msg_server.go b/modules/apps/29-fee/keeper/msg_server.go index ef918905c8b..2f0004be150 100644 --- a/modules/apps/29-fee/keeper/msg_server.go +++ b/modules/apps/29-fee/keeper/msg_server.go @@ -43,8 +43,8 @@ func (k Keeper) PayPacketFee(goCtx context.Context, msg *types.MsgPayPacketFee) sequence, ) - identifiedPacket := types.NewIdentifiedPacketFee(packetID, msg.Fee, msg.Signer, msg.Relayers) - if err := k.EscrowPacketFee(ctx, packetID, identifiedPacket); err != nil { + packetFee := types.NewPacketFee(msg.Fee, msg.Signer, msg.Relayers) + if err := k.EscrowPacketFee(ctx, packetID, packetFee); err != nil { return nil, err } @@ -57,7 +57,9 @@ func (k Keeper) PayPacketFee(goCtx context.Context, msg *types.MsgPayPacketFee) func (k Keeper) PayPacketFeeAsync(goCtx context.Context, msg *types.MsgPayPacketFeeAsync) (*types.MsgPayPacketFeeAsyncResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - if err := k.EscrowPacketFee(ctx, msg.IdentifiedPacketFee.PacketId, msg.IdentifiedPacketFee); err != nil { + // TODO: Update MsgPayPacketFeeAsync to include PacketFee in favour of IdentifiedPacketFee + packetFee := types.NewPacketFee(msg.IdentifiedPacketFee.Fee, msg.IdentifiedPacketFee.RefundAddress, msg.IdentifiedPacketFee.Relayers) + if err := k.EscrowPacketFee(ctx, msg.IdentifiedPacketFee.PacketId, packetFee); err != nil { return nil, err } diff --git a/modules/apps/29-fee/types/fee.go b/modules/apps/29-fee/types/fee.go index 7453c88e50e..54dd9ee1435 100644 --- a/modules/apps/29-fee/types/fee.go +++ b/modules/apps/29-fee/types/fee.go @@ -7,13 +7,31 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -// NewIdentifiedPacketFees creates and returns a new IdentifiedPacketFees struct -func NewIdentifiedPacketFees(packetFees []IdentifiedPacketFee) IdentifiedPacketFees { - return IdentifiedPacketFees{ +// NewPacketFee creates and returns a new PacketFee struct including the incentivization fees, refund addres and relayers +func NewPacketFee(fee Fee, refundAddr string, relayers []string) PacketFee { + return PacketFee{ + Fee: fee, + RefundAddress: refundAddr, + Relayers: relayers, + } +} + +// NewPacketFees creates and returns a new PacketFees struct including a list of type PacketFee +func NewPacketFees(packetFees []PacketFee) PacketFees { + return PacketFees{ PacketFees: packetFees, } } +// NewFee creates and returns a new Fee struct encapsulating the receive, acknowledgement and timeout fees as sdk.Coins +func NewFee(recvFee, ackFee, timeoutFee sdk.Coins) Fee { + return Fee{ + RecvFee: recvFee, + AckFee: ackFee, + TimeoutFee: timeoutFee, + } +} + // Total returns the total amount for a given Fee func (f Fee) Total() sdk.Coins { return f.RecvFee.Add(f.AckFee...).Add(f.TimeoutFee...) diff --git a/modules/apps/29-fee/types/fee.pb.go b/modules/apps/29-fee/types/fee.pb.go index 8be56939659..ad74e0b2d86 100644 --- a/modules/apps/29-fee/types/fee.pb.go +++ b/modules/apps/29-fee/types/fee.pb.go @@ -161,16 +161,124 @@ func (m *IdentifiedPacketFee) GetRelayers() []string { return nil } -// IdentifiedPacketFees contains a list of packet fees +// PacketFee contains the relayer fee, refund address and an optional list of relayers that are permitted to receive the +// fee +type PacketFee struct { + Fee Fee `protobuf:"bytes,1,opt,name=fee,proto3" json:"fee"` + RefundAddress string `protobuf:"bytes,2,opt,name=refund_address,json=refundAddress,proto3" json:"refund_address,omitempty" yaml:"refund_address"` + Relayers []string `protobuf:"bytes,3,rep,name=relayers,proto3" json:"relayers,omitempty"` +} + +func (m *PacketFee) Reset() { *m = PacketFee{} } +func (m *PacketFee) String() string { return proto.CompactTextString(m) } +func (*PacketFee) ProtoMessage() {} +func (*PacketFee) Descriptor() ([]byte, []int) { + return fileDescriptor_cb3319f1af2a53e5, []int{2} +} +func (m *PacketFee) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PacketFee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PacketFee.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PacketFee) XXX_Merge(src proto.Message) { + xxx_messageInfo_PacketFee.Merge(m, src) +} +func (m *PacketFee) XXX_Size() int { + return m.Size() +} +func (m *PacketFee) XXX_DiscardUnknown() { + xxx_messageInfo_PacketFee.DiscardUnknown(m) +} + +var xxx_messageInfo_PacketFee proto.InternalMessageInfo + +func (m *PacketFee) GetFee() Fee { + if m != nil { + return m.Fee + } + return Fee{} +} + +func (m *PacketFee) GetRefundAddress() string { + if m != nil { + return m.RefundAddress + } + return "" +} + +func (m *PacketFee) GetRelayers() []string { + if m != nil { + return m.Relayers + } + return nil +} + +// PacketFees contains a list of type PacketFee +type PacketFees struct { + PacketFees []PacketFee `protobuf:"bytes,1,rep,name=packet_fees,json=packetFees,proto3" json:"packet_fees" yaml:"packet_fees"` +} + +func (m *PacketFees) Reset() { *m = PacketFees{} } +func (m *PacketFees) String() string { return proto.CompactTextString(m) } +func (*PacketFees) ProtoMessage() {} +func (*PacketFees) Descriptor() ([]byte, []int) { + return fileDescriptor_cb3319f1af2a53e5, []int{3} +} +func (m *PacketFees) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PacketFees) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PacketFees.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PacketFees) XXX_Merge(src proto.Message) { + xxx_messageInfo_PacketFees.Merge(m, src) +} +func (m *PacketFees) XXX_Size() int { + return m.Size() +} +func (m *PacketFees) XXX_DiscardUnknown() { + xxx_messageInfo_PacketFees.DiscardUnknown(m) +} + +var xxx_messageInfo_PacketFees proto.InternalMessageInfo + +func (m *PacketFees) GetPacketFees() []PacketFee { + if m != nil { + return m.PacketFees + } + return nil +} + +// IdentifiedPacketFees contains a list of type PacketFee and associated PacketId type IdentifiedPacketFees struct { - PacketFees []IdentifiedPacketFee `protobuf:"bytes,1,rep,name=packet_fees,json=packetFees,proto3" json:"packet_fees" yaml:"packet_fees"` + PacketId types1.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id" yaml:"packet_id"` + PacketFees []PacketFee `protobuf:"bytes,2,rep,name=packet_fees,json=packetFees,proto3" json:"packet_fees" yaml:"packet_fees"` } func (m *IdentifiedPacketFees) Reset() { *m = IdentifiedPacketFees{} } func (m *IdentifiedPacketFees) String() string { return proto.CompactTextString(m) } func (*IdentifiedPacketFees) ProtoMessage() {} func (*IdentifiedPacketFees) Descriptor() ([]byte, []int) { - return fileDescriptor_cb3319f1af2a53e5, []int{2} + return fileDescriptor_cb3319f1af2a53e5, []int{4} } func (m *IdentifiedPacketFees) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -199,7 +307,14 @@ func (m *IdentifiedPacketFees) XXX_DiscardUnknown() { var xxx_messageInfo_IdentifiedPacketFees proto.InternalMessageInfo -func (m *IdentifiedPacketFees) GetPacketFees() []IdentifiedPacketFee { +func (m *IdentifiedPacketFees) GetPacketId() types1.PacketId { + if m != nil { + return m.PacketId + } + return types1.PacketId{} +} + +func (m *IdentifiedPacketFees) GetPacketFees() []PacketFee { if m != nil { return m.PacketFees } @@ -209,46 +324,50 @@ func (m *IdentifiedPacketFees) GetPacketFees() []IdentifiedPacketFee { func init() { proto.RegisterType((*Fee)(nil), "ibc.applications.fee.v1.Fee") proto.RegisterType((*IdentifiedPacketFee)(nil), "ibc.applications.fee.v1.IdentifiedPacketFee") + proto.RegisterType((*PacketFee)(nil), "ibc.applications.fee.v1.PacketFee") + proto.RegisterType((*PacketFees)(nil), "ibc.applications.fee.v1.PacketFees") proto.RegisterType((*IdentifiedPacketFees)(nil), "ibc.applications.fee.v1.IdentifiedPacketFees") } func init() { proto.RegisterFile("ibc/applications/fee/v1/fee.proto", fileDescriptor_cb3319f1af2a53e5) } var fileDescriptor_cb3319f1af2a53e5 = []byte{ - // 523 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0xc7, 0x6b, 0x32, 0x6d, 0xab, 0x2b, 0x26, 0x14, 0x86, 0xe8, 0x2a, 0x48, 0x4b, 0x4e, 0x3d, - 0x50, 0x5b, 0xed, 0xe0, 0x00, 0x27, 0x08, 0x52, 0xa5, 0x9d, 0x40, 0x11, 0x27, 0x2e, 0x95, 0xe3, - 0xbc, 0x76, 0x56, 0x9b, 0x38, 0x8a, 0xd3, 0x48, 0x95, 0x38, 0x00, 0x9f, 0x80, 0xcf, 0xc1, 0x27, - 0xd9, 0x71, 0x47, 0x4e, 0x05, 0xb5, 0xdf, 0x60, 0x5f, 0x00, 0xe4, 0xd8, 0xab, 0x8a, 0xd8, 0x34, - 0xf5, 0x64, 0xfb, 0xf9, 0xfd, 0xdf, 0xef, 0xd9, 0xef, 0x3d, 0xfc, 0x4c, 0x44, 0x9c, 0xb2, 0x2c, - 0x9b, 0x09, 0xce, 0x0a, 0x21, 0x53, 0x45, 0xc7, 0x00, 0xb4, 0xec, 0xeb, 0x85, 0x64, 0xb9, 0x2c, - 0xa4, 0xfb, 0x58, 0x44, 0x9c, 0x6c, 0xbb, 0x10, 0x7d, 0x57, 0xf6, 0x5b, 0x1e, 0x97, 0x2a, 0x91, - 0x8a, 0x46, 0x4c, 0x69, 0x49, 0x04, 0x05, 0xeb, 0x53, 0x2e, 0x45, 0x6a, 0x84, 0xad, 0xe3, 0x89, - 0x9c, 0xc8, 0x6a, 0x4b, 0xf5, 0xce, 0x5a, 0x2b, 0x22, 0x97, 0x39, 0x50, 0x7e, 0xce, 0xd2, 0x14, - 0x66, 0x9a, 0x66, 0xb7, 0xc6, 0xc5, 0xff, 0xe2, 0x60, 0x67, 0x08, 0xe0, 0x7e, 0xc6, 0x87, 0x39, - 0xf0, 0x72, 0x34, 0x06, 0x68, 0xa2, 0x8e, 0xd3, 0x6d, 0x0c, 0x4e, 0x88, 0x61, 0x12, 0xcd, 0x24, - 0x96, 0x49, 0xde, 0x49, 0x91, 0x06, 0xc3, 0x8b, 0x65, 0xbb, 0x76, 0xb5, 0x6c, 0xbb, 0x0b, 0x96, - 0xcc, 0x5e, 0xfb, 0x39, 0x70, 0x10, 0x25, 0x68, 0xad, 0xff, 0xe3, 0x57, 0xbb, 0x3b, 0x11, 0xc5, - 0xf9, 0x3c, 0x22, 0x5c, 0x26, 0xd4, 0xa6, 0x6d, 0x96, 0x9e, 0x8a, 0xa7, 0xb4, 0x58, 0x64, 0xa0, - 0xaa, 0x30, 0x2a, 0x3c, 0xd0, 0x48, 0x4d, 0x2f, 0xf1, 0x01, 0xe3, 0xd3, 0x0a, 0x7e, 0xef, 0x2e, - 0x78, 0x60, 0xe1, 0x47, 0x06, 0x6e, 0x75, 0xbb, 0x81, 0xf7, 0x19, 0x9f, 0x6a, 0xee, 0x37, 0x84, - 0x1b, 0x85, 0x48, 0x40, 0xce, 0x8b, 0x0a, 0xee, 0xec, 0xf8, 0xf2, 0x2d, 0xed, 0x6e, 0x09, 0x60, - 0xab, 0x1c, 0x02, 0xf8, 0x7f, 0x10, 0x7e, 0x78, 0x16, 0x43, 0x5a, 0x88, 0xb1, 0x80, 0xf8, 0x03, - 0xe3, 0x53, 0xd0, 0x76, 0xf7, 0x23, 0xae, 0x67, 0xd5, 0x61, 0x24, 0xe2, 0x26, 0xea, 0xa0, 0x6e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a, 0x7a, 0xa4, 0xab, 0x42, 0x47, 0xfb, 0xd5, 0x80, 0x9d, 0xfe, 0x0d, 0x00, - 0x00, 0xff, 0xff, 0x0e, 0xeb, 0xd3, 0x29, 0xf7, 0x03, 0x00, 0x00, + // 560 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0xc1, 0x6e, 0xd3, 0x30, + 0x18, 0xc7, 0xeb, 0x66, 0xda, 0x56, 0x57, 0x4c, 0x28, 0x0c, 0xd1, 0x55, 0x90, 0x96, 0x9c, 0x7a, + 0xa9, 0xad, 0x76, 0x70, 0x80, 0x13, 0x04, 0xa9, 0xd2, 0x4e, 0xa0, 0x88, 0x13, 0x97, 0xca, 0x71, + 0xbe, 0x76, 0x56, 0x9b, 0x38, 0x8a, 0xd3, 0x48, 0x95, 0x38, 0x20, 0x9e, 0x80, 0x37, 0xe0, 0xce, + 0x93, 0xec, 0x82, 0xb4, 0x23, 0xa7, 0x82, 0xda, 0x37, 0xd8, 0x0b, 0x80, 0x9c, 0x78, 0xa5, 0x0c, + 0x26, 0x54, 0x0d, 0x4e, 0xb1, 0x9d, 0xef, 0xff, 0xfd, 0xfe, 0x9f, 0xfd, 0xd9, 0xf8, 0xa1, 0x08, + 0x38, 0x65, 0x49, 0x32, 0x15, 0x9c, 0x65, 0x42, 0xc6, 0x8a, 0x8e, 0x00, 0x68, 0xde, 0xd3, 0x1f, + 0x92, 0xa4, 0x32, 0x93, 0xf6, 0x3d, 0x11, 0x70, 0xb2, 0x19, 0x42, 0xf4, 0xbf, 0xbc, 0xd7, 0x74, + 0xb8, 0x54, 0x91, 0x54, 0x34, 0x60, 0x4a, 0x4b, 0x02, 0xc8, 0x58, 0x8f, 0x72, 0x29, 0xe2, 0x52, + 0xd8, 0x3c, 0x1c, 0xcb, 0xb1, 0x2c, 0x86, 0x54, 0x8f, 0xcc, 0x6a, 0x41, 0xe4, 0x32, 0x05, 0xca, + 0x4f, 0x59, 0x1c, 0xc3, 0x54, 0xd3, 0xcc, 0xb0, 0x0c, 0x71, 0xdf, 0x59, 0xd8, 0x1a, 0x00, 0xd8, + 0x6f, 0xf1, 0x7e, 0x0a, 0x3c, 0x1f, 0x8e, 0x00, 0x1a, 0xa8, 0x6d, 0x75, 0xea, 0xfd, 0x23, 0x52, + 0x32, 0x89, 0x66, 0x12, 0xc3, 0x24, 0x2f, 0xa4, 0x88, 0xbd, 0xc1, 0xd9, 0xa2, 0x55, 0xb9, 0x58, + 0xb4, 0xec, 0x39, 0x8b, 0xa6, 0x4f, 0xdd, 0x14, 0x38, 0x88, 0x1c, 0xb4, 0xd6, 0xfd, 0xf4, 0xb5, + 0xd5, 0x19, 0x8b, 0xec, 0x74, 0x16, 0x10, 0x2e, 0x23, 0x6a, 0x6c, 0x97, 0x9f, 0xae, 0x0a, 0x27, + 0x34, 0x9b, 0x27, 0xa0, 0x8a, 0x34, 0xca, 0xdf, 0xd3, 0x48, 0x4d, 0xcf, 0xf1, 0x1e, 0xe3, 0x93, + 0x02, 0x5e, 0xfd, 0x1b, 0xdc, 0x33, 0xf0, 0x83, 0x12, 0x6e, 0x74, 0xdb, 0x81, 0x77, 0x19, 0x9f, + 0x68, 0xee, 0x7b, 0x84, 0xeb, 0x99, 0x88, 0x40, 0xce, 0xb2, 0x02, 0x6e, 0x6d, 0x59, 0xf9, 0x86, + 0x76, 0x3b, 0x03, 0xd8, 0x28, 0x07, 0x00, 0xee, 0x77, 0x84, 0xef, 0x9c, 0x84, 0x10, 0x67, 0x62, + 0x24, 0x20, 0x7c, 0xc5, 0xf8, 0x04, 0xf4, 0xba, 0xfd, 0x1a, 0xd7, 0x92, 0x62, 0x32, 0x14, 0x61, + 0x03, 0xb5, 0x51, 0xa7, 0xde, 0x7f, 0x40, 0x74, 0x83, 0xe8, 0x13, 0x25, 0x97, 0xc7, 0x98, 0xf7, + 0x48, 0x29, 0x39, 0x09, 0xbd, 0x86, 0x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, 0xd3, 0x48, 0x86, 0xb3, + 0x29, 0x28, 0xfd, 0x68, 0x2a, 0xda, 0x7f, 0xd2, 0xd5, 0xef, 0x65, 0x71, 0x8b, 0x82, 0xdd, 0xe2, + 0xf5, 0x3a, 0xfe, 0x11, 0x00, 0x00, 0xff, 0xff, 0x6b, 0xd4, 0x49, 0x04, 0x54, 0x05, 0x00, 0x00, } func (m *Fee) Marshal() (dAtA []byte, err error) { @@ -375,6 +494,92 @@ func (m *IdentifiedPacketFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *PacketFee) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PacketFee) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PacketFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Relayers) > 0 { + for iNdEx := len(m.Relayers) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Relayers[iNdEx]) + copy(dAtA[i:], m.Relayers[iNdEx]) + i = encodeVarintFee(dAtA, i, uint64(len(m.Relayers[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.RefundAddress) > 0 { + i -= len(m.RefundAddress) + copy(dAtA[i:], m.RefundAddress) + i = encodeVarintFee(dAtA, i, uint64(len(m.RefundAddress))) + i-- + dAtA[i] = 0x12 + } + { + size, err := m.Fee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFee(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *PacketFees) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PacketFees) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PacketFees) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PacketFees) > 0 { + for iNdEx := len(m.PacketFees) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PacketFees[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintFee(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *IdentifiedPacketFees) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -406,9 +611,19 @@ func (m *IdentifiedPacketFees) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintFee(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 + } + } + { + size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintFee(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -473,12 +688,50 @@ func (m *IdentifiedPacketFee) Size() (n int) { return n } +func (m *PacketFee) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Fee.Size() + n += 1 + l + sovFee(uint64(l)) + l = len(m.RefundAddress) + if l > 0 { + n += 1 + l + sovFee(uint64(l)) + } + if len(m.Relayers) > 0 { + for _, s := range m.Relayers { + l = len(s) + n += 1 + l + sovFee(uint64(l)) + } + } + return n +} + +func (m *PacketFees) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.PacketFees) > 0 { + for _, e := range m.PacketFees { + l = e.Size() + n += 1 + l + sovFee(uint64(l)) + } + } + return n +} + func (m *IdentifiedPacketFees) Size() (n int) { if m == nil { return 0 } var l int _ = l + l = m.PacketId.Size() + n += 1 + l + sovFee(uint64(l)) if len(m.PacketFees) > 0 { for _, e := range m.PacketFees { l = e.Size() @@ -826,6 +1079,237 @@ func (m *IdentifiedPacketFee) Unmarshal(dAtA []byte) error { } return nil } +func (m *PacketFee) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFee + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PacketFee: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PacketFee: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFee + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFee + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFee + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Fee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RefundAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFee + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFee + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFee + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RefundAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Relayers", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFee + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthFee + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthFee + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Relayers = append(m.Relayers, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFee(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFee + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PacketFees) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFee + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PacketFees: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PacketFees: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PacketFees", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFee + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFee + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFee + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PacketFees = append(m.PacketFees, PacketFee{}) + if err := m.PacketFees[len(m.PacketFees)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipFee(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthFee + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *IdentifiedPacketFees) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -856,6 +1340,39 @@ func (m *IdentifiedPacketFees) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowFee + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthFee + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthFee + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PacketFees", wireType) } @@ -884,7 +1401,7 @@ func (m *IdentifiedPacketFees) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.PacketFees = append(m.PacketFees, IdentifiedPacketFee{}) + m.PacketFees = append(m.PacketFees, PacketFee{}) if err := m.PacketFees[len(m.PacketFees)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/proto/ibc/applications/fee/v1/fee.proto b/proto/ibc/applications/fee/v1/fee.proto index 3a58f093e06..4d39ad3786c 100644 --- a/proto/ibc/applications/fee/v1/fee.proto +++ b/proto/ibc/applications/fee/v1/fee.proto @@ -41,8 +41,22 @@ message IdentifiedPacketFee { repeated string relayers = 4; } -// IdentifiedPacketFees contains a list of packet fees +// PacketFee contains the relayer fee, refund address and an optional list of relayers that are permitted to receive the +// fee +message PacketFee { + Fee fee = 1 [(gogoproto.nullable) = false]; + string refund_address = 2 [(gogoproto.moretags) = "yaml:\"refund_address\""]; + repeated string relayers = 3; +} + +// PacketFees contains a list of type PacketFee +message PacketFees { + repeated PacketFee packet_fees = 1 [(gogoproto.moretags) = "yaml:\"packet_fees\"", (gogoproto.nullable) = false]; +} + +// IdentifiedPacketFees contains a list of type PacketFee and associated PacketId message IdentifiedPacketFees { - repeated IdentifiedPacketFee packet_fees = 1 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"packet_fees\""]; -} \ No newline at end of file + ibc.core.channel.v1.PacketId packet_id = 1 + [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"packet_id\""]; + repeated PacketFee packet_fees = 2 [(gogoproto.moretags) = "yaml:\"packet_fees\"", (gogoproto.nullable) = false]; +} diff --git a/proto/ibc/applications/fee/v1/genesis.proto b/proto/ibc/applications/fee/v1/genesis.proto index 134a16be850..b832a4bcd4a 100644 --- a/proto/ibc/applications/fee/v1/genesis.proto +++ b/proto/ibc/applications/fee/v1/genesis.proto @@ -12,9 +12,12 @@ import "ibc/core/channel/v1/channel.proto"; message GenesisState { repeated IdentifiedPacketFee identified_fees = 1 [(gogoproto.moretags) = "yaml:\"identified_fees\"", (gogoproto.nullable) = false]; - repeated FeeEnabledChannel fee_enabled_channels = 2 [(gogoproto.moretags) = "yaml:\"fee_enabled_channels\"", (gogoproto.nullable) = false]; - repeated RegisteredRelayerAddress registered_relayers = 3 [(gogoproto.moretags) = "yaml:\"registered_relayers\"", (gogoproto.nullable) = false]; - repeated ForwardRelayerAddress forward_relayers = 4 [(gogoproto.moretags) = "yaml:\"forward_relayers\"", (gogoproto.nullable) = false]; + repeated FeeEnabledChannel fee_enabled_channels = 2 + [(gogoproto.moretags) = "yaml:\"fee_enabled_channels\"", (gogoproto.nullable) = false]; + repeated RegisteredRelayerAddress registered_relayers = 3 + [(gogoproto.moretags) = "yaml:\"registered_relayers\"", (gogoproto.nullable) = false]; + repeated ForwardRelayerAddress forward_relayers = 4 + [(gogoproto.moretags) = "yaml:\"forward_relayers\"", (gogoproto.nullable) = false]; } // FeeEnabledChannel contains the PortID & ChannelID for a fee enabled channel From 15fa37bd65ff49c9e5013db580b5b26e2d36606f Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 23 Feb 2022 14:26:40 +0000 Subject: [PATCH 55/79] chore: update ics29 genesis state to support multiple packet fees (#957) * adding new proto types and codegen * refactoring ics29 fees for more efficient storage * updating tests * updating genesis protos to use IdentifiedPacketFees * updating init/export genesis state functionality and tests --- docs/ibc/proto-docs.md | 2 +- modules/apps/29-fee/keeper/genesis.go | 4 +- modules/apps/29-fee/keeper/genesis_test.go | 34 ++++----- modules/apps/29-fee/keeper/keeper.go | 24 ++++-- modules/apps/29-fee/keeper/keeper_test.go | 24 +++--- modules/apps/29-fee/types/fee.go | 19 +++++ modules/apps/29-fee/types/genesis.go | 15 ++-- modules/apps/29-fee/types/genesis.pb.go | 82 ++++++++++----------- modules/apps/29-fee/types/genesis_test.go | 14 ++-- proto/ibc/applications/fee/v1/ack.proto | 2 +- proto/ibc/applications/fee/v1/genesis.proto | 4 +- proto/ibc/applications/fee/v1/tx.proto | 2 +- 12 files changed, 136 insertions(+), 90 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 9bf131b1b56..ddeba3e5cb6 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -846,7 +846,7 @@ GenesisState defines the fee middleware genesis state | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `identified_fees` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | repeated | | +| `identified_fees` | [IdentifiedPacketFees](#ibc.applications.fee.v1.IdentifiedPacketFees) | repeated | | | `fee_enabled_channels` | [FeeEnabledChannel](#ibc.applications.fee.v1.FeeEnabledChannel) | repeated | | | `registered_relayers` | [RegisteredRelayerAddress](#ibc.applications.fee.v1.RegisteredRelayerAddress) | repeated | | | `forward_relayers` | [ForwardRelayerAddress](#ibc.applications.fee.v1.ForwardRelayerAddress) | repeated | | diff --git a/modules/apps/29-fee/keeper/genesis.go b/modules/apps/29-fee/keeper/genesis.go index 5cf26a52ac3..70b6a5012a2 100644 --- a/modules/apps/29-fee/keeper/genesis.go +++ b/modules/apps/29-fee/keeper/genesis.go @@ -8,8 +8,8 @@ import ( // InitGenesis initializes the fee middleware application state from a provided genesis state func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) { - for _, fee := range state.IdentifiedFees { - k.SetFeeInEscrow(ctx, fee) + for _, identifiedFees := range state.IdentifiedFees { + k.SetFeesInEscrow(ctx, identifiedFees.PacketId, types.NewPacketFees(identifiedFees.PacketFees)) } for _, relayer := range state.RegisteredRelayers { diff --git a/modules/apps/29-fee/keeper/genesis_test.go b/modules/apps/29-fee/keeper/genesis_test.go index 0b3dcb4bad6..f2824120a82 100644 --- a/modules/apps/29-fee/keeper/genesis_test.go +++ b/modules/apps/29-fee/keeper/genesis_test.go @@ -9,11 +9,7 @@ import ( func (suite *KeeperTestSuite) TestInitGenesis() { // build PacketId & Fee refundAcc := suite.chainA.SenderAccount.GetAddress() - packetId := channeltypes.NewPacketId( - ibctesting.FirstChannelID, - ibctesting.MockFeePort, - uint64(1), - ) + packetID := channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1) fee := types.Fee{ RecvFee: defaultReceiveFee, AckFee: defaultAckFee, @@ -25,12 +21,16 @@ func (suite *KeeperTestSuite) TestInitGenesis() { counterparty := suite.chainB.SenderAccount.GetAddress().String() genesisState := types.GenesisState{ - IdentifiedFees: []types.IdentifiedPacketFee{ + IdentifiedFees: []types.IdentifiedPacketFees{ { - PacketId: packetId, - Fee: fee, - RefundAddress: refundAcc.String(), - Relayers: nil, + PacketId: packetID, + PacketFees: []types.PacketFee{ + { + Fee: fee, + RefundAddress: refundAcc.String(), + Relayers: nil, + }, + }, }, }, FeeEnabledChannels: []types.FeeEnabledChannel{ @@ -51,9 +51,9 @@ func (suite *KeeperTestSuite) TestInitGenesis() { suite.chainA.GetSimApp().IBCFeeKeeper.InitGenesis(suite.chainA.GetContext(), genesisState) // check fee - identifiedFee, found := suite.chainA.GetSimApp().IBCFeeKeeper.GetFeeInEscrow(suite.chainA.GetContext(), packetId) + feesInEscrow, found := suite.chainA.GetSimApp().IBCFeeKeeper.GetFeesInEscrow(suite.chainA.GetContext(), packetID) suite.Require().True(found) - suite.Require().Equal(genesisState.IdentifiedFees[0], identifiedFee) + suite.Require().Equal(genesisState.IdentifiedFees[0].PacketFees, feesInEscrow.PacketFees) // check fee is enabled isEnabled := suite.chainA.GetSimApp().IBCFeeKeeper.IsFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) @@ -78,8 +78,8 @@ func (suite *KeeperTestSuite) TestExportGenesis() { TimeoutFee: defaultTimeoutFee, } - identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeInEscrow(suite.chainA.GetContext(), identifiedPacketFee) + packetFee := types.NewPacketFee(fee, refundAcc.String(), []string{}) + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeesInEscrow(suite.chainA.GetContext(), packetID, types.NewPacketFees([]types.PacketFee{packetFee})) // relayer addresses sender := suite.chainA.SenderAccount.GetAddress().String() @@ -99,9 +99,9 @@ func (suite *KeeperTestSuite) TestExportGenesis() { // check fee suite.Require().Equal(packetID, genesisState.IdentifiedFees[0].PacketId) - suite.Require().Equal(fee, genesisState.IdentifiedFees[0].Fee) - suite.Require().Equal(refundAcc.String(), genesisState.IdentifiedFees[0].RefundAddress) - suite.Require().Equal([]string(nil), genesisState.IdentifiedFees[0].Relayers) + suite.Require().Equal(fee, genesisState.IdentifiedFees[0].PacketFees[0].Fee) + suite.Require().Equal(refundAcc.String(), genesisState.IdentifiedFees[0].PacketFees[0].RefundAddress) + suite.Require().Equal([]string(nil), genesisState.IdentifiedFees[0].PacketFees[0].Relayers) // check registered relayer addresses suite.Require().Equal(sender, genesisState.RegisteredRelayers[0].Address) diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index cc7bff64bdb..48ff7c935b0 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -328,15 +328,29 @@ func (k Keeper) HasFeeInEscrow(ctx sdk.Context, packetId channeltypes.PacketId) } // GetAllIdentifiedPacketFees returns a list of all IdentifiedPacketFees that are stored in state -func (k Keeper) GetAllIdentifiedPacketFees(ctx sdk.Context) []types.IdentifiedPacketFee { +func (k Keeper) GetAllIdentifiedPacketFees(ctx sdk.Context) []types.IdentifiedPacketFees { store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, []byte(types.FeeInEscrowPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte(types.FeesInEscrowPrefix)) defer iterator.Close() - var identifiedFees []types.IdentifiedPacketFee + var identifiedFees []types.IdentifiedPacketFees for ; iterator.Valid(); iterator.Next() { - fee := k.MustUnmarshalFee(iterator.Value()) - identifiedFees = append(identifiedFees, fee) + keySplit := strings.Split(string(iterator.Key()), "/") + + feesInEscrow := k.MustUnmarshalFees(iterator.Value()) + + channelID, portID := keySplit[2], keySplit[1] + seq, err := strconv.ParseUint(keySplit[3], 10, 64) + if err != nil { + panic(err) + } + + identifiedFee := types.IdentifiedPacketFees{ + PacketId: channeltypes.NewPacketId(channelID, portID, seq), + PacketFees: feesInEscrow.PacketFees, + } + + identifiedFees = append(identifiedFees, identifiedFee) } return identifiedFees diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index 103fad7968c..65132c243e1 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -109,21 +109,25 @@ func (suite *KeeperTestSuite) TestGetAllIdentifiedPacketFees() { } // escrow the packet fee - identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, refundAcc.String(), []string{}) - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeInEscrow(suite.chainA.GetContext(), identifiedPacketFee) + packetFee := types.NewPacketFee(fee, refundAcc.String(), []string{}) + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeesInEscrow(suite.chainA.GetContext(), packetID, types.NewPacketFees([]types.PacketFee{packetFee})) - expectedFees := []types.IdentifiedPacketFee{ + expectedFees := []types.IdentifiedPacketFees{ { - PacketId: packetID, - Fee: fee, - RefundAddress: refundAcc.String(), - Relayers: nil, + PacketId: packetID, + PacketFees: []types.PacketFee{ + { + Fee: fee, + RefundAddress: refundAcc.String(), + Relayers: nil, + }, + }, }, } - fees := suite.chainA.GetSimApp().IBCFeeKeeper.GetAllIdentifiedPacketFees(suite.chainA.GetContext()) - suite.Require().Len(fees, len(expectedFees)) - suite.Require().Equal(fees, expectedFees) + identifiedFees := suite.chainA.GetSimApp().IBCFeeKeeper.GetAllIdentifiedPacketFees(suite.chainA.GetContext()) + suite.Require().Len(identifiedFees, len(expectedFees)) + suite.Require().Equal(identifiedFees, expectedFees) } func (suite *KeeperTestSuite) TestGetAllFeeEnabledChannels() { diff --git a/modules/apps/29-fee/types/fee.go b/modules/apps/29-fee/types/fee.go index 54dd9ee1435..4dd73893888 100644 --- a/modules/apps/29-fee/types/fee.go +++ b/modules/apps/29-fee/types/fee.go @@ -16,6 +16,25 @@ func NewPacketFee(fee Fee, refundAddr string, relayers []string) PacketFee { } } +// Validate performs basic stateless validation of the associated PacketFee +func (p PacketFee) Validate() error { + _, err := sdk.AccAddressFromBech32(p.RefundAddress) + if err != nil { + return sdkerrors.Wrap(err, "failed to convert RefundAddress into sdk.AccAddress") + } + + // enforce relayer is nil + if p.Relayers != nil { + return ErrRelayersNotNil + } + + if err := p.Fee.Validate(); err != nil { + return err + } + + return nil +} + // NewPacketFees creates and returns a new PacketFees struct including a list of type PacketFee func NewPacketFees(packetFees []PacketFee) PacketFees { return PacketFees{ diff --git a/modules/apps/29-fee/types/genesis.go b/modules/apps/29-fee/types/genesis.go index 33319feb984..be9299fcd94 100644 --- a/modules/apps/29-fee/types/genesis.go +++ b/modules/apps/29-fee/types/genesis.go @@ -10,7 +10,7 @@ import ( ) // NewGenesisState creates a 29-fee GenesisState instance. -func NewGenesisState(identifiedFees []IdentifiedPacketFee, feeEnabledChannels []FeeEnabledChannel, registeredRelayers []RegisteredRelayerAddress, forwardRelayers []ForwardRelayerAddress) *GenesisState { +func NewGenesisState(identifiedFees []IdentifiedPacketFees, feeEnabledChannels []FeeEnabledChannel, registeredRelayers []RegisteredRelayerAddress, forwardRelayers []ForwardRelayerAddress) *GenesisState { return &GenesisState{ IdentifiedFees: identifiedFees, FeeEnabledChannels: feeEnabledChannels, @@ -22,7 +22,7 @@ func NewGenesisState(identifiedFees []IdentifiedPacketFee, feeEnabledChannels [] // DefaultGenesisState returns a GenesisState with "transfer" as the default PortID. func DefaultGenesisState() *GenesisState { return &GenesisState{ - IdentifiedFees: []IdentifiedPacketFee{}, + IdentifiedFees: []IdentifiedPacketFees{}, ForwardRelayers: []ForwardRelayerAddress{}, FeeEnabledChannels: []FeeEnabledChannel{}, RegisteredRelayers: []RegisteredRelayerAddress{}, @@ -33,11 +33,16 @@ func DefaultGenesisState() *GenesisState { // failure. func (gs GenesisState) Validate() error { // Validate IdentifiedPacketFees - for _, fee := range gs.IdentifiedFees { - err := fee.Validate() - if err != nil { + for _, identifiedFees := range gs.IdentifiedFees { + if err := identifiedFees.PacketId.Validate(); err != nil { return err } + + for _, packetFee := range identifiedFees.PacketFees { + if err := packetFee.Validate(); err != nil { + return err + } + } } // Validate FeeEnabledChannels diff --git a/modules/apps/29-fee/types/genesis.pb.go b/modules/apps/29-fee/types/genesis.pb.go index 1ae5e9b195d..84a946a6d43 100644 --- a/modules/apps/29-fee/types/genesis.pb.go +++ b/modules/apps/29-fee/types/genesis.pb.go @@ -26,7 +26,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the fee middleware genesis state type GenesisState struct { - IdentifiedFees []IdentifiedPacketFee `protobuf:"bytes,1,rep,name=identified_fees,json=identifiedFees,proto3" json:"identified_fees" yaml:"identified_fees"` + IdentifiedFees []IdentifiedPacketFees `protobuf:"bytes,1,rep,name=identified_fees,json=identifiedFees,proto3" json:"identified_fees" yaml:"identified_fees"` FeeEnabledChannels []FeeEnabledChannel `protobuf:"bytes,2,rep,name=fee_enabled_channels,json=feeEnabledChannels,proto3" json:"fee_enabled_channels" yaml:"fee_enabled_channels"` RegisteredRelayers []RegisteredRelayerAddress `protobuf:"bytes,3,rep,name=registered_relayers,json=registeredRelayers,proto3" json:"registered_relayers" yaml:"registered_relayers"` ForwardRelayers []ForwardRelayerAddress `protobuf:"bytes,4,rep,name=forward_relayers,json=forwardRelayers,proto3" json:"forward_relayers" yaml:"forward_relayers"` @@ -65,7 +65,7 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetIdentifiedFees() []IdentifiedPacketFee { +func (m *GenesisState) GetIdentifiedFees() []IdentifiedPacketFees { if m != nil { return m.IdentifiedFees } @@ -272,44 +272,44 @@ func init() { } var fileDescriptor_7191992e856dff95 = []byte{ - // 581 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xcd, 0x6e, 0xd4, 0x3c, - 0x14, 0x9d, 0xb4, 0x55, 0xfb, 0xd5, 0xfd, 0xd4, 0x1f, 0xb7, 0xa5, 0x51, 0x11, 0x49, 0x31, 0x42, - 0xaa, 0x80, 0x26, 0x9a, 0x16, 0x16, 0xb0, 0x63, 0x10, 0x45, 0xb3, 0x02, 0x19, 0x56, 0x6c, 0xa2, - 0xfc, 0xdc, 0xa4, 0x16, 0x99, 0x38, 0xb2, 0x3d, 0x83, 0x86, 0x1d, 0x1b, 0xd8, 0x21, 0x9e, 0x88, - 0x75, 0x97, 0x5d, 0xb2, 0x1a, 0xa1, 0xf6, 0x0d, 0xe6, 0x09, 0x50, 0xe2, 0xa4, 0x33, 0x1d, 0x26, - 0x88, 0xdd, 0x8d, 0x7d, 0xce, 0x3d, 0xc7, 0xc7, 0xb9, 0x46, 0xf7, 0x59, 0x10, 0xba, 0x7e, 0x9e, - 0xa7, 0x2c, 0xf4, 0x15, 0xe3, 0x99, 0x74, 0x63, 0x00, 0x77, 0xd0, 0x76, 0x13, 0xc8, 0x40, 0x32, - 0xe9, 0xe4, 0x82, 0x2b, 0x8e, 0xf7, 0x58, 0x10, 0x3a, 0xd3, 0x30, 0x27, 0x06, 0x70, 0x06, 0xed, - 0xfd, 0x9d, 0x84, 0x27, 0xbc, 0xc4, 0xb8, 0x45, 0xa5, 0xe1, 0xfb, 0x77, 0x9b, 0xba, 0x16, 0xac, - 0x29, 0x48, 0xc8, 0x05, 0xb8, 0xe1, 0x99, 0x9f, 0x65, 0x90, 0x16, 0xdb, 0x55, 0xa9, 0x21, 0xe4, - 0xdb, 0x12, 0xfa, 0xff, 0x95, 0xb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xf2, 0x9e, 0x1b, 0x72, 0xd9, 0xe3, 0xd2, 0x65, 0x41, 0x78, 0x94, 0x70, 0x77, 0x70, 0xe2, - 0xf6, 0x78, 0xd4, 0x4f, 0x41, 0x16, 0x6f, 0x8a, 0x74, 0x8f, 0x9f, 0x1e, 0x15, 0xcf, 0x89, 0x1a, - 0xe6, 0x20, 0x83, 0xe5, 0xf2, 0xad, 0x38, 0xf9, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x19, 0xed, 0x5e, - 0x39, 0xc9, 0x04, 0x00, 0x00, + // 579 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x4d, 0x6f, 0xd4, 0x30, + 0x14, 0xdc, 0xb4, 0x55, 0x4b, 0x5d, 0xd4, 0x0f, 0xb7, 0xa5, 0x51, 0x11, 0x49, 0x31, 0x42, 0xaa, + 0x40, 0x4d, 0xb4, 0x2d, 0x1c, 0xe0, 0xc6, 0x22, 0x8a, 0xf6, 0x04, 0x32, 0x9c, 0xb8, 0x44, 0xf9, + 0x78, 0x49, 0x2d, 0xb2, 0x71, 0x64, 0xbb, 0x41, 0xcb, 0x8d, 0x0b, 0x1c, 0xe1, 0x17, 0x71, 0xee, + 0xb1, 0x47, 0x4e, 0x2b, 0xd4, 0xfe, 0x83, 0xfe, 0x02, 0x94, 0x38, 0xe9, 0x6e, 0x97, 0x0d, 0xe2, + 0xf6, 0x62, 0xcf, 0xbc, 0x19, 0x8f, 0xf3, 0x8c, 0x1e, 0xb2, 0x20, 0x74, 0xfd, 0x3c, 0x4f, 0x59, + 0xe8, 0x2b, 0xc6, 0x33, 0xe9, 0xc6, 0x00, 0x6e, 0xd1, 0x75, 0x13, 0xc8, 0x40, 0x32, 0xe9, 0xe4, + 0x82, 0x2b, 0x8e, 0x77, 0x58, 0x10, 0x3a, 0x93, 0x30, 0x27, 0x06, 0x70, 0x8a, 0xee, 0xee, 0x56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 0xad, 0xbc, 0xc1, 0xbc, + 0x39, 0xbb, 0xb0, 0x8c, 0xf3, 0x0b, 0xcb, 0xf8, 0x7d, 0x61, 0x19, 0x3f, 0x2e, 0xad, 0xce, 0xf9, + 0xa5, 0xd5, 0xf9, 0x75, 0x69, 0x75, 0x3e, 0x3c, 0x4d, 0x98, 0x3a, 0x39, 0x0d, 0x9c, 0x90, 0x0f, + 0xdc, 0x90, 0xcb, 0x01, 0x97, 0x2e, 0x0b, 0xc2, 0x83, 0x84, 0xbb, 0xc5, 0x91, 0x3b, 0xe0, 0xd1, + 0x69, 0x0a, 0xb2, 0x7c, 0x54, 0xa4, 0x7b, 0xf8, 0xec, 0xa0, 0x7c, 0x4f, 0xd4, 0x30, 0x07, 0x19, + 0x2c, 0x56, 0x8f, 0xc5, 0xd1, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe9, 0x33, 0x0f, 0x78, 0xca, + 0x04, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -673,7 +673,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.IdentifiedFees = append(m.IdentifiedFees, IdentifiedPacketFee{}) + m.IdentifiedFees = append(m.IdentifiedFees, IdentifiedPacketFees{}) if err := m.IdentifiedFees[len(m.IdentifiedFees)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/modules/apps/29-fee/types/genesis_test.go b/modules/apps/29-fee/types/genesis_test.go index 711e9ebb142..75c754cc7c9 100644 --- a/modules/apps/29-fee/types/genesis_test.go +++ b/modules/apps/29-fee/types/genesis_test.go @@ -168,12 +168,16 @@ func TestValidateGenesis(t *testing.T) { tc.malleate() genState := types.GenesisState{ - IdentifiedFees: []types.IdentifiedPacketFee{ + IdentifiedFees: []types.IdentifiedPacketFees{ { - PacketId: packetId, - Fee: fee, - RefundAddress: refundAcc, - Relayers: nil, + PacketId: packetId, + PacketFees: []types.PacketFee{ + { + Fee: fee, + RefundAddress: refundAcc, + Relayers: nil, + }, + }, }, }, FeeEnabledChannels: []types.FeeEnabledChannel{ diff --git a/proto/ibc/applications/fee/v1/ack.proto b/proto/ibc/applications/fee/v1/ack.proto index 1a0c5e3f404..6a77e4fce45 100644 --- a/proto/ibc/applications/fee/v1/ack.proto +++ b/proto/ibc/applications/fee/v1/ack.proto @@ -11,5 +11,5 @@ import "gogoproto/gogo.proto"; message IncentivizedAcknowledgement { bytes result = 1; string forward_relayer_address = 2 [(gogoproto.moretags) = "yaml:\"forward_relayer_address\""]; - bool underlying_app_success = 3 [(gogoproto.moretags) = "yaml:\"underlying_app_successl\""]; + bool underlying_app_success = 3 [(gogoproto.moretags) = "yaml:\"underlying_app_successl\""]; } diff --git a/proto/ibc/applications/fee/v1/genesis.proto b/proto/ibc/applications/fee/v1/genesis.proto index b832a4bcd4a..0e76fa3a168 100644 --- a/proto/ibc/applications/fee/v1/genesis.proto +++ b/proto/ibc/applications/fee/v1/genesis.proto @@ -10,7 +10,7 @@ import "ibc/core/channel/v1/channel.proto"; // GenesisState defines the fee middleware genesis state message GenesisState { - repeated IdentifiedPacketFee identified_fees = 1 + repeated IdentifiedPacketFees identified_fees = 1 [(gogoproto.moretags) = "yaml:\"identified_fees\"", (gogoproto.nullable) = false]; repeated FeeEnabledChannel fee_enabled_channels = 2 [(gogoproto.moretags) = "yaml:\"fee_enabled_channels\"", (gogoproto.nullable) = false]; @@ -30,7 +30,7 @@ message FeeEnabledChannel { message RegisteredRelayerAddress { string address = 1; string counterparty_address = 2 [(gogoproto.moretags) = "yaml:\"counterparty_address\""]; - string channel_id = 3 [(gogoproto.moretags) = "yaml:\"channel_id\""]; + string channel_id = 3 [(gogoproto.moretags) = "yaml:\"channel_id\""]; } // ForwardRelayerAddress contains the forward relayer address and packetId used for async acknowledgements diff --git a/proto/ibc/applications/fee/v1/tx.proto b/proto/ibc/applications/fee/v1/tx.proto index 532524cd4b2..8209e14d531 100644 --- a/proto/ibc/applications/fee/v1/tx.proto +++ b/proto/ibc/applications/fee/v1/tx.proto @@ -32,7 +32,7 @@ message MsgRegisterCounterpartyAddress { string address = 1; string counterparty_address = 2 [(gogoproto.moretags) = "yaml:\"counterparty_address\""]; - string channel_id = 3 [(gogoproto.moretags) = "yaml:\"channel_id\""]; + string channel_id = 3 [(gogoproto.moretags) = "yaml:\"channel_id\""]; } // MsgRegisterCounterpartyAddressResponse defines the Msg/RegisterCounterypartyAddress response type From 9350d53b58097faab324b327b1518b1a21efab46 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Thu, 24 Feb 2022 09:00:37 +0000 Subject: [PATCH 56/79] chore: update MsgPayPacketFeeAsync fields (#979) * adding new proto types and codegen * refactoring ics29 fees for more efficient storage * updating tests * fixing typo in protodoc comments * updating protos and codegen * updating MsgPayPacketFeeAsync handler and tests --- docs/ibc/proto-docs.md | 3 +- modules/apps/29-fee/client/cli/tx.go | 4 +- modules/apps/29-fee/keeper/msg_server.go | 4 +- modules/apps/29-fee/keeper/msg_server_test.go | 6 +- modules/apps/29-fee/types/msgs.go | 17 +-- modules/apps/29-fee/types/msgs_test.go | 47 +++--- modules/apps/29-fee/types/tx.pb.go | 141 ++++++++++++------ proto/ibc/applications/fee/v1/tx.proto | 10 +- 8 files changed, 140 insertions(+), 92 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index ddeba3e5cb6..0fe35525dc0 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -1041,7 +1041,8 @@ This Msg can be used to pay for a packet at a specified sequence (instead of the | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `identified_packet_fee` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | | identified packet to pay fee for identified fee must contain the refund address which is also signer of this message | +| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | unique packet identifier | +| `packet_fee` | [PacketFee](#ibc.applications.fee.v1.PacketFee) | | packet fee for incentivization | diff --git a/modules/apps/29-fee/client/cli/tx.go b/modules/apps/29-fee/client/cli/tx.go index a9f66a71007..d14c8313dca 100644 --- a/modules/apps/29-fee/client/cli/tx.go +++ b/modules/apps/29-fee/client/cli/tx.go @@ -83,9 +83,9 @@ func NewPayPacketFeeAsyncTxCmd() *cobra.Command { TimeoutFee: timeoutFee, } - identifiedPacketFee := types.NewIdentifiedPacketFee(packetID, fee, sender, relayers) + packetFee := types.NewPacketFee(fee, sender, relayers) + msg := types.NewMsgPayPacketFeeAsync(packetID, packetFee) - msg := types.NewMsgPayPacketFeeAsync(identifiedPacketFee) return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, } diff --git a/modules/apps/29-fee/keeper/msg_server.go b/modules/apps/29-fee/keeper/msg_server.go index 2f0004be150..fdac1d27874 100644 --- a/modules/apps/29-fee/keeper/msg_server.go +++ b/modules/apps/29-fee/keeper/msg_server.go @@ -57,9 +57,7 @@ func (k Keeper) PayPacketFee(goCtx context.Context, msg *types.MsgPayPacketFee) func (k Keeper) PayPacketFeeAsync(goCtx context.Context, msg *types.MsgPayPacketFeeAsync) (*types.MsgPayPacketFeeAsyncResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - // TODO: Update MsgPayPacketFeeAsync to include PacketFee in favour of IdentifiedPacketFee - packetFee := types.NewPacketFee(msg.IdentifiedPacketFee.Fee, msg.IdentifiedPacketFee.RefundAddress, msg.IdentifiedPacketFee.Relayers) - if err := k.EscrowPacketFee(ctx, msg.IdentifiedPacketFee.PacketId, packetFee); err != nil { + if err := k.EscrowPacketFee(ctx, msg.PacketId, msg.PacketFee); err != nil { return nil, err } diff --git a/modules/apps/29-fee/keeper/msg_server_test.go b/modules/apps/29-fee/keeper/msg_server_test.go index 0a8ad4b7d06..c6dc2f90856 100644 --- a/modules/apps/29-fee/keeper/msg_server_test.go +++ b/modules/apps/29-fee/keeper/msg_server_test.go @@ -119,12 +119,12 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() { seq, _ := suite.chainA.App.GetIBCKeeper().ChannelKeeper.GetNextSequenceSend(ctxA, suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID) // build fee - packetId := channeltypes.NewPacketId(channelID, suite.path.EndpointA.ChannelConfig.PortID, seq) - identifiedPacketFee := types.IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: refundAcc.String(), Relayers: []string{}} + packetID := channeltypes.NewPacketId(channelID, suite.path.EndpointA.ChannelConfig.PortID, seq) + packetFee := types.NewPacketFee(fee, refundAcc.String(), nil) tc.malleate() - msg := types.NewMsgPayPacketFeeAsync(identifiedPacketFee) + msg := types.NewMsgPayPacketFeeAsync(packetID, packetFee) _, err := suite.chainA.SendMsgs(msg) if tc.expPass { diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index 50e6584e26b..2c0d8a52e32 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -118,22 +118,21 @@ func (msg MsgPayPacketFee) GetSignBytes() []byte { } // NewMsgPayPacketAsync creates a new instance of MsgPayPacketFee -func NewMsgPayPacketFeeAsync(identifiedPacketFee IdentifiedPacketFee) *MsgPayPacketFeeAsync { +func NewMsgPayPacketFeeAsync(packetID channeltypes.PacketId, packetFee PacketFee) *MsgPayPacketFeeAsync { return &MsgPayPacketFeeAsync{ - IdentifiedPacketFee: identifiedPacketFee, + PacketId: packetID, + PacketFee: packetFee, } } // ValidateBasic performs a basic check of the MsgPayPacketFeeAsync fields func (msg MsgPayPacketFeeAsync) ValidateBasic() error { - // signer check - _, err := sdk.AccAddressFromBech32(msg.IdentifiedPacketFee.RefundAddress) - if err != nil { - return sdkerrors.Wrap(err, "failed to convert msg.Signer into sdk.AccAddress") + if err := msg.PacketId.Validate(); err != nil { + return err } - if err = msg.IdentifiedPacketFee.Validate(); err != nil { - return sdkerrors.Wrap(err, "Invalid IdentifiedPacketFee") + if err := msg.PacketFee.Validate(); err != nil { + return err } return nil @@ -142,7 +141,7 @@ func (msg MsgPayPacketFeeAsync) ValidateBasic() error { // GetSigners implements sdk.Msg // The signer of the fee message must be the refund address func (msg MsgPayPacketFeeAsync) GetSigners() []sdk.AccAddress { - signer, err := sdk.AccAddressFromBech32(msg.IdentifiedPacketFee.RefundAddress) + signer, err := sdk.AccAddressFromBech32(msg.PacketFee.RefundAddress) if err != nil { panic(err) } diff --git a/modules/apps/29-fee/types/msgs_test.go b/modules/apps/29-fee/types/msgs_test.go index c4ee1a477f1..6ded61d407f 100644 --- a/modules/apps/29-fee/types/msgs_test.go +++ b/modules/apps/29-fee/types/msgs_test.go @@ -319,9 +319,10 @@ func TestMsgPayPacketFeeAsyncValidation(t *testing.T) { tc.malleate() fee = Fee{receiveFee, ackFee, timeoutFee} - packetId := channeltypes.NewPacketId(channelID, portID, seq) - identifiedPacketFee := IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: signer, Relayers: relayers} - msg := NewMsgPayPacketFeeAsync(identifiedPacketFee) + packetID := channeltypes.NewPacketId(channelID, portID, seq) + packetFee := NewPacketFee(fee, signer, relayers) + + msg := NewMsgPayPacketFeeAsync(packetID, packetFee) err := msg.ValidateBasic() @@ -335,20 +336,15 @@ func TestMsgPayPacketFeeAsyncValidation(t *testing.T) { // TestRegisterCounterpartyAddressGetSigners tests GetSigners func TestPayPacketFeeAsyncGetSigners(t *testing.T) { - addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) - // build message - channelID := validChannelID - portID := validPortID - fee := Fee{validCoins, validCoins, validCoins} - seq := uint64(1) - packetId := channeltypes.NewPacketId(channelID, portID, seq) - identifiedPacketFee := IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: addr.String(), Relayers: nil} - msg := NewMsgPayPacketFeeAsync(identifiedPacketFee) + refundAddr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + fee := NewFee(validCoins, validCoins, validCoins) - // GetSigners - res := msg.GetSigners() + packetID := channeltypes.NewPacketId(validChannelID, validPortID, 1) + packetFee := NewPacketFee(fee, refundAddr.String(), nil) - require.Equal(t, []sdk.AccAddress{addr}, res) + msg := NewMsgPayPacketFeeAsync(packetID, packetFee) + + require.Equal(t, []sdk.AccAddress{refundAddr}, msg.GetSigners()) } // TestMsgPayPacketFeeAsyncRoute tests Route for MsgPayPacketFeeAsync @@ -360,9 +356,10 @@ func TestMsgPayPacketFeeAsyncRoute(t *testing.T) { portID := validPortID fee := Fee{validCoins, validCoins, validCoins} seq := uint64(1) - packetId := channeltypes.NewPacketId(channelID, portID, seq) - identifiedPacketFee := IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: addr.String(), Relayers: nil} - msg := NewMsgPayPacketFeeAsync(identifiedPacketFee) + packetID := channeltypes.NewPacketId(channelID, portID, seq) + packetFee := NewPacketFee(fee, addr.String(), nil) + + msg := NewMsgPayPacketFeeAsync(packetID, packetFee) require.Equal(t, RouterKey, msg.Route()) } @@ -376,9 +373,10 @@ func TestMsgPayPacketFeeAsyncType(t *testing.T) { portID := validPortID fee := Fee{validCoins, validCoins, validCoins} seq := uint64(1) - packetId := channeltypes.NewPacketId(channelID, portID, seq) - identifiedPacketFee := IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: addr.String(), Relayers: nil} - msg := NewMsgPayPacketFeeAsync(identifiedPacketFee) + packetID := channeltypes.NewPacketId(channelID, portID, seq) + packetFee := NewPacketFee(fee, addr.String(), nil) + + msg := NewMsgPayPacketFeeAsync(packetID, packetFee) require.Equal(t, "payPacketFeeAsync", msg.Type()) } @@ -392,9 +390,10 @@ func TestMsgPayPacketFeeAsyncGetSignBytes(t *testing.T) { portID := validPortID fee := Fee{validCoins, validCoins, validCoins} seq := uint64(1) - packetId := channeltypes.NewPacketId(channelID, portID, seq) - identifiedPacketFee := IdentifiedPacketFee{PacketId: packetId, Fee: fee, RefundAddress: addr.String(), Relayers: nil} - msg := NewMsgPayPacketFeeAsync(identifiedPacketFee) + packetID := channeltypes.NewPacketId(channelID, portID, seq) + packetFee := NewPacketFee(fee, addr.String(), nil) + + msg := NewMsgPayPacketFeeAsync(packetID, packetFee) require.NotPanics(t, func() { _ = msg.GetSignBytes() diff --git a/modules/apps/29-fee/types/tx.pb.go b/modules/apps/29-fee/types/tx.pb.go index a7f8e1d3bee..c30331992dd 100644 --- a/modules/apps/29-fee/types/tx.pb.go +++ b/modules/apps/29-fee/types/tx.pb.go @@ -6,6 +6,7 @@ package types import ( context "context" fmt "fmt" + types "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -194,9 +195,10 @@ var xxx_messageInfo_MsgPayPacketFeeResponse proto.InternalMessageInfo // MsgPayPacketFeeAsync defines the request type PayPacketFeeAsync RPC // This Msg can be used to pay for a packet at a specified sequence (instead of the next sequence send) type MsgPayPacketFeeAsync struct { - // identified packet to pay fee for - // identified fee must contain the refund address which is also signer of this message - IdentifiedPacketFee IdentifiedPacketFee `protobuf:"bytes,1,opt,name=identified_packet_fee,json=identifiedPacketFee,proto3" json:"identified_packet_fee" yaml:"identified_packet_fee"` + // unique packet identifier + PacketId types.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id" yaml:"packet_id"` + // packet fee for incentivization + PacketFee PacketFee `protobuf:"bytes,2,opt,name=packet_fee,json=packetFee,proto3" json:"packet_fee" yaml:"packet_fee"` } func (m *MsgPayPacketFeeAsync) Reset() { *m = MsgPayPacketFeeAsync{} } @@ -281,45 +283,47 @@ func init() { func init() { proto.RegisterFile("ibc/applications/fee/v1/tx.proto", fileDescriptor_05c93128649f1b96) } var fileDescriptor_05c93128649f1b96 = []byte{ - // 594 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0x4d, 0x4f, 0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0xfc, 0xb5, 0x31, 0x73, 0xff, 0xed, 0x6e, 0xfc, 0xab, 0xf1, 0xd0, 0x07, 0xd6, 0x58, - 0x48, 0x7e, 0xb5, 0x83, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xcf, 0x27, 0xb3, 0x4f, 0x4b, 0x05, - 0x00, 0x00, + // 630 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x4d, 0x4f, 0xdb, 0x40, + 0x10, 0x8d, 0x09, 0xa5, 0x64, 0x8b, 0x4a, 0xb3, 0x85, 0x62, 0x0c, 0xb5, 0xa9, 0x0f, 0x55, 0x2e, + 0xd8, 0xe5, 0x4b, 0x55, 0xb9, 0x20, 0x82, 0x84, 0xca, 0x01, 0x15, 0x59, 0x3d, 0x55, 0x95, 0x90, + 0xb3, 0x9e, 0x18, 0xb7, 0x89, 0xd7, 0xda, 0x75, 0xa2, 0xfa, 0x0f, 0x54, 0x3d, 0x72, 0xeb, 0x95, + 0x9f, 0xc3, 0xa9, 0xe2, 0xd0, 0x43, 0x4f, 0x56, 0x05, 0x97, 0x9e, 0xf3, 0x0b, 0xaa, 0xf5, 0x97, + 0x1c, 0x48, 0x22, 0xda, 0x9b, 0x77, 0xe6, 0xcd, 0xdb, 0x37, 0x6f, 0xc6, 0x8b, 0xd6, 0xbc, 0x16, + 0x31, 0xed, 0x20, 0xe8, 0x78, 0xc4, 0x0e, 0x3d, 0xea, 0x73, 0xb3, 0x0d, 0x60, 0xf6, 0x37, 0xcc, + 0xf0, 0x8b, 0x11, 0x30, 0x1a, 0x52, 0xbc, 0xe4, 0xb5, 0x88, 0x51, 0x46, 0x18, 0x6d, 0x00, 0xa3, + 0xbf, 0xa1, 0x2c, 0xb8, 0xd4, 0xa5, 0x09, 0xc6, 0x14, 0x5f, 0x29, 0x5c, 0x79, 0x31, 0x8e, 0x50, + 0x54, 0x95, 0x20, 0x84, 0x32, 0x30, 0xc9, 0x99, 0xed, 0xfb, 0xd0, 0x11, 0xe9, 0xec, 0x33, 0x85, + 0xe8, 0x3f, 0x24, 0xa4, 0x1e, 0x73, 0xd7, 0x02, 0xd7, 0xe3, 0x21, 0xb0, 0x03, 0xda, 0xf3, 0x43, + 0x60, 0x81, 0xcd, 0xc2, 0x68, 0xdf, 0x71, 0x18, 0x70, 0x8e, 0x65, 0xf4, 0xd0, 0x4e, 0x3f, 0x65, + 0x69, 0x4d, 0x6a, 0xd4, 0xac, 0xfc, 0x88, 0x2d, 0xb4, 0x40, 0x4a, 0x05, 0xa7, 0x39, 0x6c, 0x4a, + 0xc0, 0x9a, 0xda, 0x20, 0xd6, 0x56, 0x22, 0xbb, 0xdb, 0xd9, 0xd5, 0x47, 0xa1, 0x74, 0xeb, 0x29, + 0x19, 0x71, 0xdb, 0x36, 0x42, 0x99, 0xc2, 0x53, 0xcf, 0x91, 0xab, 0x09, 0xd3, 0xe2, 0x20, 0xd6, + 0xea, 0x19, 0x53, 0x91, 0xd3, 0xad, 0x5a, 0x76, 0x38, 0x72, 0x76, 0x67, 0xbf, 0x5d, 0x68, 0x95, + 0x3f, 0x17, 0x5a, 0x45, 0x6f, 0xa0, 0x97, 0x93, 0xfb, 0xb1, 0x80, 0x07, 0xd4, 0xe7, 0xa0, 0x9f, + 0x4f, 0xa1, 0xf9, 0x63, 0xee, 0x9e, 0xd8, 0xd1, 0x89, 0x4d, 0x3e, 0x43, 0x78, 0x08, 0x80, 0xb7, + 0x51, 0xb5, 0x0d, 0x90, 0xf4, 0xf9, 0x68, 0x73, 0xd5, 0x18, 0x33, 0x11, 0xe3, 0x10, 0xa0, 0x39, + 0x7d, 0x19, 0x6b, 0x15, 0x4b, 0xc0, 0xf1, 0x1e, 0x7a, 0xcc, 0x69, 0x8f, 0x11, 0x38, 0x0d, 0x28, + 0x0b, 0x85, 0xee, 0xd4, 0x81, 0xe5, 0x41, 0xac, 0x2d, 0xa6, 0xba, 0x87, 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09, 0xcd, 0x0d, 0xad, 0x70, 0x63, 0x12, 0x61, 0x19, 0xa9, 0xbc, 0xba, 0x2f, 0xb2, + 0xb8, 0x2b, 0x42, 0xf5, 0xbb, 0x0b, 0xb0, 0x7e, 0x5f, 0x9a, 0x04, 0xae, 0xec, 0xfc, 0x13, 0x3c, + 0xbf, 0xba, 0xf9, 0xee, 0xf2, 0x5a, 0x95, 0xae, 0xae, 0x55, 0xe9, 0xf7, 0xb5, 0x2a, 0x9d, 0xdf, + 0xa8, 0x95, 0xab, 0x1b, 0xb5, 0xf2, 0xeb, 0x46, 0xad, 0x7c, 0xd8, 0x71, 0xbd, 0xf0, 0xac, 0xd7, + 0x32, 0x08, 0xed, 0x9a, 0x84, 0xf2, 0x2e, 0xe5, 0xa6, 0xd7, 0x22, 0xeb, 0x2e, 0x35, 0xfb, 0x5b, + 0x66, 0x97, 0x3a, 0xbd, 0x0e, 0x70, 0xf1, 0x50, 0x72, 0x73, 0xf3, 0xcd, 0xba, 0x78, 0x23, 0xc3, + 0x28, 0x00, 0xde, 0x9a, 0x49, 0x1e, 0xc0, 0xad, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xcc, 0xf7, + 0x58, 0xab, 0x99, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -670,7 +674,17 @@ func (m *MsgPayPacketFeeAsync) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l { - size, err := m.IdentifiedPacketFee.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.PacketFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -790,7 +804,9 @@ func (m *MsgPayPacketFeeAsync) Size() (n int) { } var l int _ = l - l = m.IdentifiedPacketFee.Size() + l = m.PacketId.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.PacketFee.Size() n += 1 + l + sovTx(uint64(l)) return n } @@ -1298,7 +1314,40 @@ func (m *MsgPayPacketFeeAsync) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field IdentifiedPacketFee", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PacketFee", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1325,7 +1374,7 @@ func (m *MsgPayPacketFeeAsync) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.IdentifiedPacketFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.PacketFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/proto/ibc/applications/fee/v1/tx.proto b/proto/ibc/applications/fee/v1/tx.proto index 8209e14d531..ec2f2cc4f38 100644 --- a/proto/ibc/applications/fee/v1/tx.proto +++ b/proto/ibc/applications/fee/v1/tx.proto @@ -6,6 +6,7 @@ option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; import "gogoproto/gogo.proto"; import "ibc/applications/fee/v1/fee.proto"; +import "ibc/core/channel/v1/channel.proto"; // Msg defines the ibc/fee Msg service. service Msg { @@ -64,10 +65,11 @@ message MsgPayPacketFeeAsync { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - // identified packet to pay fee for - // identified fee must contain the refund address which is also signer of this message - ibc.applications.fee.v1.IdentifiedPacketFee identified_packet_fee = 1 - [(gogoproto.moretags) = "yaml:\"identified_packet_fee\"", (gogoproto.nullable) = false]; + // unique packet identifier + ibc.core.channel.v1.PacketId packet_id = 1 + [(gogoproto.moretags) = "yaml:\"packet_id\"", (gogoproto.nullable) = false]; + // packet fee for incentivization + PacketFee packet_fee = 2 [(gogoproto.moretags) = "yaml:\"packet_fee\"", (gogoproto.nullable) = false]; } // MsgPayPacketFeeAsyncResponse defines the response type for Msg/PayPacketFeeAsync From f1ba06f987f207501ac94cd71d462ba310d656d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 24 Feb 2022 12:50:08 +0100 Subject: [PATCH 57/79] chore: add ParseKeyFeesInEscrow helper function (#998) --- modules/apps/29-fee/keeper/keeper.go | 11 +++----- modules/apps/29-fee/types/keys.go | 22 +++++++++++++++ modules/apps/29-fee/types/keys_test.go | 39 ++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 7 deletions(-) diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index 48ff7c935b0..5b2e7810447 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -335,18 +335,15 @@ func (k Keeper) GetAllIdentifiedPacketFees(ctx sdk.Context) []types.IdentifiedPa var identifiedFees []types.IdentifiedPacketFees for ; iterator.Valid(); iterator.Next() { - keySplit := strings.Split(string(iterator.Key()), "/") - - feesInEscrow := k.MustUnmarshalFees(iterator.Value()) - - channelID, portID := keySplit[2], keySplit[1] - seq, err := strconv.ParseUint(keySplit[3], 10, 64) + packetID, err := types.ParseKeyFeesInEscrow(string(iterator.Key())) if err != nil { panic(err) } + feesInEscrow := k.MustUnmarshalFees(iterator.Value()) + identifiedFee := types.IdentifiedPacketFees{ - PacketId: channeltypes.NewPacketId(channelID, portID, seq), + PacketId: packetID, PacketFees: feesInEscrow.PacketFees, } diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index d65d8efcbef..8f23a4e7688 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -2,6 +2,10 @@ package types import ( "fmt" + "strconv" + "strings" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ) @@ -67,6 +71,24 @@ func KeyFeesInEscrow(packetID channeltypes.PacketId) []byte { return []byte(fmt.Sprintf("%s/%d", KeyFeesInEscrowChannelPrefix(packetID.PortId, packetID.ChannelId), packetID.Sequence)) } +// ParseKeyFeesInEscrow parses the key used to store fees in escrow and returns the packet id +func ParseKeyFeesInEscrow(key string) (channeltypes.PacketId, error) { + keySplit := strings.Split(key, "/") + if len(keySplit) != 4 { + return channeltypes.PacketId{}, sdkerrors.Wrapf( + sdkerrors.ErrLogic, "key provided is incorrect: the key split has incorrect length, expected %d, got %d", 4, len(keySplit), + ) + } + + seq, err := strconv.ParseUint(keySplit[3], 10, 64) + if err != nil { + return channeltypes.PacketId{}, err + } + + packetID := channeltypes.NewPacketId(keySplit[2], keySplit[1], seq) + return packetID, nil +} + // KeyFeeInEscrowChannelPrefix returns the key prefix for escrowed fees on the given channel func KeyFeeInEscrowChannelPrefix(portID, channelID string) []byte { return []byte(fmt.Sprintf("%s/%s/%s/packet", FeeInEscrowPrefix, portID, channelID)) diff --git a/modules/apps/29-fee/types/keys_test.go b/modules/apps/29-fee/types/keys_test.go index a49532b753b..ac60255955b 100644 --- a/modules/apps/29-fee/types/keys_test.go +++ b/modules/apps/29-fee/types/keys_test.go @@ -7,6 +7,8 @@ import ( "github.com/stretchr/testify/require" "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + ibctesting "github.com/cosmos/ibc-go/v3/testing" ) func TestKeyCounterpartyRelayer(t *testing.T) { @@ -18,3 +20,40 @@ func TestKeyCounterpartyRelayer(t *testing.T) { key := types.KeyCounterpartyRelayer(relayerAddress, channelID) require.Equal(t, string(key), fmt.Sprintf("%s/%s/%s", types.CounterpartyRelayerAddressKeyPrefix, relayerAddress, channelID)) } + +func TestParseKeyFeesInEscrow(t *testing.T) { + validPacketID := channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1) + + testCases := []struct { + name string + key string + expPass bool + }{ + { + "success", + string(types.KeyFeesInEscrow(validPacketID)), + true, + }, + { + "incorrect key - key split has incorrect length", + string(types.FeeEnabledKey(validPacketID.PortId, validPacketID.ChannelId)), + false, + }, + { + "incorrect key - sequence cannot be parsed", + fmt.Sprintf("%s/%s", types.KeyFeesInEscrowChannelPrefix(validPacketID.PortId, validPacketID.ChannelId), "sequence"), + false, + }, + } + + for _, tc := range testCases { + packetId, err := types.ParseKeyFeesInEscrow(tc.key) + + if tc.expPass { + require.NoError(t, err) + require.Equal(t, validPacketID, packetId) + } else { + require.Error(t, err) + } + } +} From fcea26d3eefd4d5e808481122664ca6c5a8f047d Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Thu, 24 Feb 2022 14:27:53 +0000 Subject: [PATCH 58/79] chore: update grpc queries to handle multiple fees (#967) * adding new proto types and codegen * refactoring ics29 fees for more efficient storage * updating tests * updating protos and existing queries * updating grpc queries and refactoring tests * format error correct in favour of proto string() method * leveraging ParseKeyFeesInEscrow to obtain packet id in query --- docs/ibc/proto-docs.md | 4 +- modules/apps/29-fee/keeper/grpc_query.go | 28 ++-- modules/apps/29-fee/keeper/grpc_query_test.go | 138 ++++++++---------- modules/apps/29-fee/types/fee.go | 9 ++ modules/apps/29-fee/types/query.pb.go | 109 +++++++------- proto/ibc/applications/fee/v1/query.proto | 4 +- 6 files changed, 139 insertions(+), 153 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 0fe35525dc0..eb2ddc97e3a 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -946,7 +946,7 @@ QueryIncentivizedPacketsResponse is the response type for the incentivized packe | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `incentivized_packet` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | | Incentivized_packet | +| `incentivized_packet` | [IdentifiedPacketFees](#ibc.applications.fee.v1.IdentifiedPacketFees) | | Incentivized_packet | @@ -977,7 +977,7 @@ QueryIncentivizedPacketsResponse is the response type for the incentivized packe | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `incentivized_packets` | [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) | repeated | Map of all incentivized_packets | +| `incentivized_packets` | [IdentifiedPacketFees](#ibc.applications.fee.v1.IdentifiedPacketFees) | repeated | Map of all incentivized_packets | diff --git a/modules/apps/29-fee/keeper/grpc_query.go b/modules/apps/29-fee/keeper/grpc_query.go index 1dae09d9265..3d4852831ad 100644 --- a/modules/apps/29-fee/keeper/grpc_query.go +++ b/modules/apps/29-fee/keeper/grpc_query.go @@ -24,22 +24,25 @@ func (k Keeper) IncentivizedPackets(c context.Context, req *types.QueryIncentivi ctx := sdk.UnwrapSDKContext(c).WithBlockHeight(int64(req.QueryHeight)) - var packets []*types.IdentifiedPacketFee - store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.FeeInEscrowPrefix)) - _, err := query.Paginate(store, req.Pagination, func(_, value []byte) error { - result := k.MustUnmarshalFee(value) - packets = append(packets, &result) + var identifiedPackets []types.IdentifiedPacketFees + store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.FeesInEscrowPrefix)) + _, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { + packetID, err := types.ParseKeyFeesInEscrow(types.FeesInEscrowPrefix + string(key)) + if err != nil { + return err + } + + packetFees := k.MustUnmarshalFees(value) + identifiedPackets = append(identifiedPackets, types.NewIdentifiedPacketFees(packetID, packetFees.PacketFees)) return nil }) if err != nil { - return nil, status.Error( - codes.NotFound, err.Error(), - ) + return nil, status.Error(codes.NotFound, err.Error()) } return &types.QueryIncentivizedPacketsResponse{ - IncentivizedPackets: packets, + IncentivizedPackets: identifiedPackets, }, nil } @@ -51,15 +54,14 @@ func (k Keeper) IncentivizedPacket(c context.Context, req *types.QueryIncentiviz ctx := sdk.UnwrapSDKContext(c).WithBlockHeight(int64(req.QueryHeight)) - fee, exists := k.GetFeeInEscrow(ctx, req.PacketId) + feesInEscrow, exists := k.GetFeesInEscrow(ctx, req.PacketId) if !exists { return nil, status.Error( codes.NotFound, - sdkerrors.Wrap(types.ErrFeeNotFound, req.PacketId.String()).Error(), - ) + sdkerrors.Wrapf(types.ErrFeeNotFound, "channel: %s, port: %s, sequence: %d", req.PacketId.ChannelId, req.PacketId.PortId, req.PacketId.Sequence).Error()) } return &types.QueryIncentivizedPacketResponse{ - IncentivizedPacket: &fee, + IncentivizedPacket: types.NewIdentifiedPacketFees(req.PacketId, feesInEscrow.PacketFees), }, nil } diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index 649ff89e6b9..37626b40bac 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -1,8 +1,6 @@ package keeper_test import ( - "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" @@ -11,25 +9,10 @@ import ( ibctesting "github.com/cosmos/ibc-go/v3/testing" ) -func (suite *KeeperTestSuite) TestQueryIncentivizedPacketI() { - +func (suite *KeeperTestSuite) TestQueryIncentivizedPackets() { var ( - req *types.QueryIncentivizedPacketRequest - ) - - // setup - suite.coordinator.Setup(suite.path) // setup channel - validPacketId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 1) - invalidPacketId := channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 2) - identifiedPacketFee := types.NewIdentifiedPacketFee( - validPacketId, - types.Fee{ - AckFee: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), - RecvFee: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), - TimeoutFee: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), - }, - "", // leave empty here and then populate on each testcase since suite resets - []string(nil), + req *types.QueryIncentivizedPacketsRequest + expectedPackets []types.IdentifiedPacketFees ) testCases := []struct { @@ -40,22 +23,36 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketI() { { "success", func() { - req = &types.QueryIncentivizedPacketRequest{ - PacketId: validPacketId, + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) + + fee := types.NewFee(defaultReceiveFee, defaultAckFee, defaultTimeoutFee) + packetFee := types.NewPacketFee(fee, suite.chainA.SenderAccount.GetAddress().String(), []string(nil)) + + for i := 0; i < 3; i++ { + // escrow packet fees for three different packets + packetID := channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, uint64(i+1)) + suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) + + expectedPackets = append(expectedPackets, types.NewIdentifiedPacketFees(packetID, []types.PacketFee{packetFee})) + } + + req = &types.QueryIncentivizedPacketsRequest{ + Pagination: &query.PageRequest{ + Limit: 5, + CountTotal: false, + }, QueryHeight: 0, } }, true, }, { - "packetId not found", + "empty pagination", func() { - req = &types.QueryIncentivizedPacketRequest{ - PacketId: invalidPacketId, - QueryHeight: 0, - } + expectedPackets = nil + req = &types.QueryIncentivizedPacketsRequest{} }, - false, + true, }, } @@ -63,22 +60,15 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketI() { suite.Run(tc.name, func() { suite.SetupTest() // reset - refundAcc := suite.chainA.SenderAccount.GetAddress() - // populate RefundAddress field - identifiedPacketFee.RefundAddress = refundAcc.String() - - tc.malleate() - - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), validPacketId.PortId, validPacketId.ChannelId) - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeInEscrow(suite.chainA.GetContext(), identifiedPacketFee) + tc.malleate() // malleate mutates test data ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) - res, err := suite.queryClient.IncentivizedPacket(ctx, req) + res, err := suite.queryClient.IncentivizedPackets(ctx, req) if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) - suite.Require().Equal(&identifiedPacketFee, res.IncentivizedPacket) + suite.Require().Equal(expectedPackets, res.IncentivizedPackets) } else { suite.Require().Error(err) } @@ -86,71 +76,63 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacketI() { } } -func (suite *KeeperTestSuite) TestQueryIncentivizedPackets() { +func (suite *KeeperTestSuite) TestQueryIncentivizedPacket() { var ( - req *types.QueryIncentivizedPacketsRequest - expPackets []*types.IdentifiedPacketFee + req *types.QueryIncentivizedPacketRequest ) - fee := types.Fee{ - AckFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}}, - RecvFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}}, - TimeoutFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}}, - } - testCases := []struct { - msg string + name string malleate func() expPass bool }{ { - "empty pagination", - func() { - req = &types.QueryIncentivizedPacketsRequest{} - }, + "success", + func() {}, true, }, { - "success", + "fees not found for packet id", func() { - refundAcc := suite.chainA.SenderAccount.GetAddress() - - fee1 := types.NewIdentifiedPacketFee(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1), fee, refundAcc.String(), []string(nil)) - fee2 := types.NewIdentifiedPacketFee(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 2), fee, refundAcc.String(), []string(nil)) - fee3 := types.NewIdentifiedPacketFee(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 3), fee, refundAcc.String(), []string(nil)) - - expPackets = []*types.IdentifiedPacketFee{} - expPackets = append(expPackets, &fee1, &fee2, &fee3) - - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) - for _, packetFee := range expPackets { - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeInEscrow(suite.chainA.GetContext(), *packetFee) - } - - req = &types.QueryIncentivizedPacketsRequest{ - Pagination: &query.PageRequest{ - Limit: 5, - CountTotal: false, - }, + req = &types.QueryIncentivizedPacketRequest{ + PacketId: channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 100), QueryHeight: 0, } }, - true, + false, }, } for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { + suite.Run(tc.name, func() { suite.SetupTest() // reset - tc.malleate() - ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) - res, err := suite.queryClient.IncentivizedPackets(ctx, req) + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) + + packetID := channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1) + fee := types.NewFee(defaultReceiveFee, defaultAckFee, defaultTimeoutFee) + packetFee := types.NewPacketFee(fee, suite.chainA.SenderAccount.GetAddress().String(), []string(nil)) + + for i := 0; i < 3; i++ { + // escrow three packet fees for the same packet + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) + suite.Require().NoError(err) + } + + req = &types.QueryIncentivizedPacketRequest{ + PacketId: packetID, + QueryHeight: 0, + } + + tc.malleate() // malleate mutates test data + + ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) + res, err := suite.queryClient.IncentivizedPacket(ctx, req) if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) - suite.Require().Equal(expPackets, res.IncentivizedPackets) + suite.Require().Equal(types.NewIdentifiedPacketFees(packetID, []types.PacketFee{packetFee, packetFee, packetFee}), res.IncentivizedPacket) } else { suite.Require().Error(err) } diff --git a/modules/apps/29-fee/types/fee.go b/modules/apps/29-fee/types/fee.go index 4dd73893888..bdcb2fc94ba 100644 --- a/modules/apps/29-fee/types/fee.go +++ b/modules/apps/29-fee/types/fee.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ) // NewPacketFee creates and returns a new PacketFee struct including the incentivization fees, refund addres and relayers @@ -42,6 +43,14 @@ func NewPacketFees(packetFees []PacketFee) PacketFees { } } +// NewIdentifiedPacketFees creates and returns a new IdentifiedPacketFees struct containing a packet ID and packet fees +func NewIdentifiedPacketFees(packetID channeltypes.PacketId, packetFees []PacketFee) IdentifiedPacketFees { + return IdentifiedPacketFees{ + PacketId: packetID, + PacketFees: packetFees, + } +} + // NewFee creates and returns a new Fee struct encapsulating the receive, acknowledgement and timeout fees as sdk.Coins func NewFee(recvFee, ackFee, timeoutFee sdk.Coins) Fee { return Fee{ diff --git a/modules/apps/29-fee/types/query.pb.go b/modules/apps/29-fee/types/query.pb.go index 3bbbbee7b17..ef1b0512d25 100644 --- a/modules/apps/29-fee/types/query.pb.go +++ b/modules/apps/29-fee/types/query.pb.go @@ -89,7 +89,7 @@ func (m *QueryIncentivizedPacketsRequest) GetQueryHeight() uint64 { // QueryIncentivizedPacketsResponse is the response type for the incentivized packets RPC type QueryIncentivizedPacketsResponse struct { // Map of all incentivized_packets - IncentivizedPackets []*IdentifiedPacketFee `protobuf:"bytes,1,rep,name=incentivized_packets,json=incentivizedPackets,proto3" json:"incentivized_packets,omitempty"` + IncentivizedPackets []IdentifiedPacketFees `protobuf:"bytes,1,rep,name=incentivized_packets,json=incentivizedPackets,proto3" json:"incentivized_packets"` } func (m *QueryIncentivizedPacketsResponse) Reset() { *m = QueryIncentivizedPacketsResponse{} } @@ -125,7 +125,7 @@ func (m *QueryIncentivizedPacketsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryIncentivizedPacketsResponse proto.InternalMessageInfo -func (m *QueryIncentivizedPacketsResponse) GetIncentivizedPackets() []*IdentifiedPacketFee { +func (m *QueryIncentivizedPacketsResponse) GetIncentivizedPackets() []IdentifiedPacketFees { if m != nil { return m.IncentivizedPackets } @@ -190,7 +190,7 @@ func (m *QueryIncentivizedPacketRequest) GetQueryHeight() uint64 { // QueryIncentivizedPacketsResponse is the response type for the incentivized packet RPC type QueryIncentivizedPacketResponse struct { // Incentivized_packet - IncentivizedPacket *IdentifiedPacketFee `protobuf:"bytes,1,opt,name=incentivized_packet,json=incentivizedPacket,proto3" json:"incentivized_packet,omitempty"` + IncentivizedPacket IdentifiedPacketFees `protobuf:"bytes,1,opt,name=incentivized_packet,json=incentivizedPacket,proto3" json:"incentivized_packet"` } func (m *QueryIncentivizedPacketResponse) Reset() { *m = QueryIncentivizedPacketResponse{} } @@ -226,11 +226,11 @@ func (m *QueryIncentivizedPacketResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryIncentivizedPacketResponse proto.InternalMessageInfo -func (m *QueryIncentivizedPacketResponse) GetIncentivizedPacket() *IdentifiedPacketFee { +func (m *QueryIncentivizedPacketResponse) GetIncentivizedPacket() IdentifiedPacketFees { if m != nil { return m.IncentivizedPacket } - return nil + return IdentifiedPacketFees{} } func init() { @@ -246,41 +246,41 @@ func init() { var fileDescriptor_0638a8a78ca2503c = []byte{ // 554 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0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32, 0x05, 0x00, 0x00, + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x41, 0x6b, 0x13, 0x41, + 0x14, 0xce, 0xb4, 0x55, 0x74, 0xe2, 0x69, 0x52, 0x30, 0x04, 0xdd, 0xa6, 0x11, 0x35, 0x08, 0x99, + 0x21, 0x29, 0x62, 0x7b, 0x93, 0x1e, 0x8a, 0x39, 0x59, 0x73, 0xf4, 0x12, 0x76, 0x67, 0x5f, 0x36, + 0x83, 0xc9, 0xce, 0x36, 0x33, 0x59, 0x68, 0xb5, 0x97, 0x82, 0x08, 0xd2, 0x83, 0xe0, 0xaf, 0xf1, + 0x1f, 0xf4, 0x58, 0xf4, 0xe2, 0x49, 0x24, 0xf1, 0x87, 0xc8, 0xec, 0xce, 0xc6, 0x85, 0x64, 0xb1, + 0xed, 0x6d, 0xf7, 0xbd, 0xef, 0x7b, 0xdf, 0xb7, 0xdf, 0x9b, 0x1d, 0xfc, 0x48, 0x78, 0x9c, 0xb9, + 0x51, 0x34, 0x12, 0xdc, 0xd5, 0x42, 0x86, 0x8a, 0x0d, 0x00, 0x58, 0xdc, 0x66, 0x47, 0x53, 0x98, + 0x1c, 0xd3, 0x68, 0x22, 0xb5, 0x24, 0xf7, 0x85, 0xc7, 0x69, 0x1e, 0x44, 0x07, 0x00, 0x34, 0x6e, + 0xd7, 0x36, 0x03, 0x19, 0xc8, 0x04, 0xc3, 0xcc, 0x53, 0x0a, 0xaf, 0x6d, 0x17, 0xcd, 0x34, 0xac, + 0x14, 0xf2, 0x20, 0x90, 0x32, 0x18, 0x01, 0x73, 0x23, 0xc1, 0xdc, 0x30, 0x94, 0xda, 0xce, 0xcd, + 0x0d, 0xe0, 0x72, 0x02, 0x8c, 0x0f, 0xdd, 0x30, 0x84, 0x91, 0x21, 0xdb, 0x47, 0x0b, 0x79, 0xc6, + 0xa5, 0x1a, 0x4b, 0xc5, 0x3c, 0x57, 0x41, 0xea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0x55, 0x40, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -540,18 +540,16 @@ func (m *QueryIncentivizedPacketResponse) MarshalToSizedBuffer(dAtA []byte) (int _ = i var l int _ = l - if m.IncentivizedPacket != nil { - { - size, err := m.IncentivizedPacket.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) + { + size, err := m.IncentivizedPacket.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0xa + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -617,10 +615,8 @@ func (m *QueryIncentivizedPacketResponse) Size() (n int) { } var l int _ = l - if m.IncentivizedPacket != nil { - l = m.IncentivizedPacket.Size() - n += 1 + l + sovQuery(uint64(l)) - } + l = m.IncentivizedPacket.Size() + n += 1 + l + sovQuery(uint64(l)) return n } @@ -793,7 +789,7 @@ func (m *QueryIncentivizedPacketsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.IncentivizedPackets = append(m.IncentivizedPackets, &IdentifiedPacketFee{}) + m.IncentivizedPackets = append(m.IncentivizedPackets, IdentifiedPacketFees{}) if err := m.IncentivizedPackets[len(m.IncentivizedPackets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -979,9 +975,6 @@ func (m *QueryIncentivizedPacketResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.IncentivizedPacket == nil { - m.IncentivizedPacket = &IdentifiedPacketFee{} - } if err := m.IncentivizedPacket.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/proto/ibc/applications/fee/v1/query.proto b/proto/ibc/applications/fee/v1/query.proto index 47db939a512..a588240a285 100644 --- a/proto/ibc/applications/fee/v1/query.proto +++ b/proto/ibc/applications/fee/v1/query.proto @@ -37,7 +37,7 @@ message QueryIncentivizedPacketsRequest { // QueryIncentivizedPacketsResponse is the response type for the incentivized packets RPC message QueryIncentivizedPacketsResponse { // Map of all incentivized_packets - repeated ibc.applications.fee.v1.IdentifiedPacketFee incentivized_packets = 1; + repeated ibc.applications.fee.v1.IdentifiedPacketFees incentivized_packets = 1 [(gogoproto.nullable) = false]; } // QueryIncentivizedPacketRequest is the request type for querying for all incentivized packets @@ -51,5 +51,5 @@ message QueryIncentivizedPacketRequest { // QueryIncentivizedPacketsResponse is the response type for the incentivized packet RPC message QueryIncentivizedPacketResponse { // Incentivized_packet - ibc.applications.fee.v1.IdentifiedPacketFee incentivized_packet = 1; + ibc.applications.fee.v1.IdentifiedPacketFees incentivized_packet = 1 [(gogoproto.nullable) = false]; } From 9c508d2df0260f694cf0e48d0bf7affe0ff804f3 Mon Sep 17 00:00:00 2001 From: Sean King Date: Thu, 24 Feb 2022 21:40:22 +0100 Subject: [PATCH 59/79] feat: CLI cmd for MsgRegisterCounterpartyAddress (#987) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: CLI cmd for MsgRegisterCounterpartyAddress * fix: examples * Update modules/apps/29-fee/client/cli/tx.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * Update modules/apps/29-fee/client/cli/tx.go Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * chore: remove print * nit: update address for counterparty Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> --- modules/apps/29-fee/client/cli/cli.go | 1 + modules/apps/29-fee/client/cli/tx.go | 27 ++++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/modules/apps/29-fee/client/cli/cli.go b/modules/apps/29-fee/client/cli/cli.go index 9e18b088dc4..abb1d40c31b 100644 --- a/modules/apps/29-fee/client/cli/cli.go +++ b/modules/apps/29-fee/client/cli/cli.go @@ -33,6 +33,7 @@ func NewTxCmd() *cobra.Command { txCmd.AddCommand( NewPayPacketFeeAsyncTxCmd(), + NewRegisterCounterpartyAddress(), ) return txCmd diff --git a/modules/apps/29-fee/client/cli/tx.go b/modules/apps/29-fee/client/cli/tx.go index d14c8313dca..0a4436b0bc4 100644 --- a/modules/apps/29-fee/client/cli/tx.go +++ b/modules/apps/29-fee/client/cli/tx.go @@ -28,7 +28,7 @@ func NewPayPacketFeeAsyncTxCmd() *cobra.Command { Use: "pay-packet-fee [src-port] [src-channel] [sequence]", Short: "Pay a fee to incentivize an existing IBC packet", Long: strings.TrimSpace(`Pay a fee to incentivize an existing IBC packet.`), - Example: fmt.Sprintf("%s tx pay-packet-fee transfer channel-0 1 --recv-fee 10stake --ack-fee 10stake --timeout-fee 10stake", version.AppName), + Example: fmt.Sprintf("%s tx ibc-fee pay-packet-fee transfer channel-0 1 --recv-fee 10stake --ack-fee 10stake --timeout-fee 10stake", version.AppName), Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) @@ -97,3 +97,28 @@ func NewPayPacketFeeAsyncTxCmd() *cobra.Command { return cmd } + +// NewRegisterCounterpartyAddress returns the command to create a MsgRegisterCounterpartyAddress +func NewRegisterCounterpartyAddress() *cobra.Command { + cmd := &cobra.Command{ + Use: "register-counterparty [address] [counterparty-address] [channel-id]", + Short: "Register a counterparty relayer address on a given channel.", + Long: strings.TrimSpace(`Register a counterparty relayer address on a given channel.`), + Example: fmt.Sprintf("%s tx ibc-fee register-counterparty cosmos1rsp837a4kvtgp2m4uqzdge0zzu6efqgucm0qdh osmo1v5y0tz01llxzf4c2afml8s3awue0ymju22wxx2 channel-0", version.AppName), + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgRegisterCounterpartyAddress(args[0], args[1], args[2]) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} From 7991f79d7b732244cd489b16708cb1472d9753cb Mon Sep 17 00:00:00 2001 From: Sean King Date: Fri, 25 Feb 2022 14:41:34 +0100 Subject: [PATCH 60/79] fix: ics29: switch source with destintion for chan/port IDs (#961) * fix: switch source with destintion for chan/port IDs * fix: blunder * test: adding tests in case of incorrect channel/port id * test: moving check to WriteAcknowledgement * add test case for Get/Set counterparty address * nit: path name * Update modules/apps/29-fee/keeper/msg_server_test.go --- modules/apps/29-fee/fee_test.go | 14 +++++++++++-- modules/apps/29-fee/ibc_module.go | 4 ++-- modules/apps/29-fee/ibc_module_test.go | 21 ++++++++++++++++--- modules/apps/29-fee/keeper/keeper_test.go | 15 +++++++++++-- modules/apps/29-fee/keeper/msg_server_test.go | 2 +- modules/apps/29-fee/keeper/relay.go | 6 +++--- modules/apps/29-fee/keeper/relay_test.go | 14 ++++++++++--- 7 files changed, 60 insertions(+), 16 deletions(-) diff --git a/modules/apps/29-fee/fee_test.go b/modules/apps/29-fee/fee_test.go index 12d7e70a147..9369fc16743 100644 --- a/modules/apps/29-fee/fee_test.go +++ b/modules/apps/29-fee/fee_test.go @@ -19,14 +19,17 @@ type FeeTestSuite struct { chainA *ibctesting.TestChain chainB *ibctesting.TestChain + chainC *ibctesting.TestChain - path *ibctesting.Path + path *ibctesting.Path + pathAToC *ibctesting.Path } func (suite *FeeTestSuite) SetupTest() { - suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) + suite.coordinator = ibctesting.NewCoordinator(suite.T(), 3) suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) + suite.chainC = suite.coordinator.GetChain(ibctesting.GetChainID(3)) path := ibctesting.NewPath(suite.chainA, suite.chainB) mockFeeVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: ibcmock.Version})) @@ -35,6 +38,13 @@ func (suite *FeeTestSuite) SetupTest() { path.EndpointA.ChannelConfig.PortID = ibctesting.MockFeePort path.EndpointB.ChannelConfig.PortID = ibctesting.MockFeePort suite.path = path + + path = ibctesting.NewPath(suite.chainA, suite.chainC) + path.EndpointA.ChannelConfig.Version = mockFeeVersion + path.EndpointB.ChannelConfig.Version = mockFeeVersion + path.EndpointA.ChannelConfig.PortID = ibctesting.MockFeePort + path.EndpointB.ChannelConfig.PortID = ibctesting.MockFeePort + suite.pathAToC = path } func TestIBCFeeTestSuite(t *testing.T) { diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go index c7a73d56e74..e8a4a45fd40 100644 --- a/modules/apps/29-fee/ibc_module.go +++ b/modules/apps/29-fee/ibc_module.go @@ -198,12 +198,12 @@ func (im IBCModule) OnRecvPacket( // incase of async aknowledgement (ack == nil) store the relayer address for use later during async WriteAcknowledgement if ack == nil { - im.keeper.SetRelayerAddressForAsyncAck(ctx, channeltypes.NewPacketId(packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence()), relayer.String()) + im.keeper.SetRelayerAddressForAsyncAck(ctx, channeltypes.NewPacketId(packet.GetDestChannel(), packet.GetDestPort(), packet.GetSequence()), relayer.String()) return nil } // if forwardRelayer is not found we refund recv_fee - forwardRelayer, _ := im.keeper.GetCounterpartyAddress(ctx, relayer.String(), packet.GetSourceChannel()) + forwardRelayer, _ := im.keeper.GetCounterpartyAddress(ctx, relayer.String(), packet.GetDestChannel()) return types.NewIncentivizedAcknowledgement(forwardRelayer, ack.Acknowledgement(), ack.Success()) } diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index 214c171d72a..6e0202a887e 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -498,12 +498,12 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { tc := tc suite.Run(tc.name, func() { suite.SetupTest() + // setup pathAToC (chainA -> chainC) first in order to have different channel IDs for chainA & chainB + suite.coordinator.Setup(suite.pathAToC) + // setup path for chainA -> chainB suite.coordinator.Setup(suite.path) - // set up a different channel to make sure that the test will error if the destination channel of the packet is not fee enabled - suite.path.EndpointB.ChannelID = "channel-1" suite.chainB.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainB.GetContext(), suite.path.EndpointB.ChannelConfig.PortID, suite.path.EndpointB.ChannelID) - suite.chainB.GetSimApp().IBCFeeKeeper.DeleteFeeEnabled(suite.chainB.GetContext(), suite.path.EndpointB.ChannelConfig.PortID, "channel-0") packet := suite.CreateMockPacket() @@ -522,11 +522,26 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { result := cbs.OnRecvPacket(suite.chainB.GetContext(), packet, suite.chainA.SenderAccount.GetAddress()) switch { + case tc.name == "success": + forwardAddr, _ := suite.chainB.GetSimApp().IBCFeeKeeper.GetCounterpartyAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), suite.path.EndpointB.ChannelID) + + expectedAck := types.IncentivizedAcknowledgement{ + Result: ibcmock.MockAcknowledgement.Acknowledgement(), + ForwardRelayerAddress: forwardAddr, + UnderlyingAppSuccess: true, + } + suite.Require().Equal(expectedAck, result) + case !tc.feeEnabled: suite.Require().Equal(ibcmock.MockAcknowledgement, result) case tc.forwardRelayer && result == nil: suite.Require().Equal(nil, result) + packetId := channeltypes.NewPacketId(packet.GetDestChannel(), packet.GetDestPort(), packet.GetSequence()) + + // retrieve the forward relayer that was stored in `onRecvPacket` + relayer, _ := suite.chainB.GetSimApp().IBCFeeKeeper.GetRelayerAddressForAsyncAck(suite.chainB.GetContext(), packetId) + suite.Require().Equal(relayer, suite.chainA.SenderAccount.GetAddress().String()) case !tc.forwardRelayer: expectedAck := types.IncentivizedAcknowledgement{ diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index 65132c243e1..c9ad4a5f10b 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -28,15 +28,19 @@ type KeeperTestSuite struct { // testing chains used for convenience and readability chainA *ibctesting.TestChain chainB *ibctesting.TestChain + chainC *ibctesting.TestChain + + path *ibctesting.Path + pathAToC *ibctesting.Path - path *ibctesting.Path queryClient types.QueryClient } func (suite *KeeperTestSuite) SetupTest() { - suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) + suite.coordinator = ibctesting.NewCoordinator(suite.T(), 3) suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1)) suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2)) + suite.chainC = suite.coordinator.GetChain(ibctesting.GetChainID(3)) path := ibctesting.NewPath(suite.chainA, suite.chainB) mockFeeVersion := string(types.ModuleCdc.MustMarshalJSON(&types.Metadata{FeeVersion: types.Version, AppVersion: ibcmock.Version})) @@ -46,6 +50,13 @@ func (suite *KeeperTestSuite) SetupTest() { path.EndpointB.ChannelConfig.PortID = ibctesting.MockFeePort suite.path = path + path = ibctesting.NewPath(suite.chainA, suite.chainC) + path.EndpointA.ChannelConfig.Version = mockFeeVersion + path.EndpointB.ChannelConfig.Version = mockFeeVersion + path.EndpointA.ChannelConfig.PortID = ibctesting.MockFeePort + path.EndpointB.ChannelConfig.PortID = ibctesting.MockFeePort + suite.pathAToC = path + queryHelper := baseapp.NewQueryServerTestHelper(suite.chainA.GetContext(), suite.chainA.GetSimApp().InterfaceRegistry()) types.RegisterQueryServer(queryHelper, suite.chainA.GetSimApp().IBCFeeKeeper) suite.queryClient = types.NewQueryClient(queryHelper) diff --git a/modules/apps/29-fee/keeper/msg_server_test.go b/modules/apps/29-fee/keeper/msg_server_test.go index c6dc2f90856..1b371a2369f 100644 --- a/modules/apps/29-fee/keeper/msg_server_test.go +++ b/modules/apps/29-fee/keeper/msg_server_test.go @@ -23,7 +23,7 @@ func (suite *KeeperTestSuite) TestRegisterCounterpartyAddress() { func() {}, }, { - "success", + "counterparty is an arbitrary string", true, func() { counterparty = "arbitrary-string" }, }, diff --git a/modules/apps/29-fee/keeper/relay.go b/modules/apps/29-fee/keeper/relay.go index 76b410bb09e..e2d75c3a1f8 100644 --- a/modules/apps/29-fee/keeper/relay.go +++ b/modules/apps/29-fee/keeper/relay.go @@ -23,9 +23,9 @@ func (k Keeper) WriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.C return k.ics4Wrapper.WriteAcknowledgement(ctx, chanCap, packet, acknowledgement) } - // retrieve the forward relayer that was stored in `onRecvPacket` - packetId := channeltypes.NewPacketId(packet.GetSourceChannel(), packet.GetSourcePort(), packet.GetSequence()) + packetId := channeltypes.NewPacketId(packet.GetDestChannel(), packet.GetDestPort(), packet.GetSequence()) + // retrieve the forward relayer that was stored in `onRecvPacket` relayer, found := k.GetRelayerAddressForAsyncAck(ctx, packetId) if !found { return sdkerrors.Wrapf(types.ErrRelayerNotFoundForAsyncAck, "no relayer address stored for async acknowledgement for packet with portID: %s, channelID: %s, sequence: %d", packetId.PortId, packetId.ChannelId, packetId.Sequence) @@ -33,7 +33,7 @@ func (k Keeper) WriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.C // it is possible that a relayer has not registered a counterparty address. // if there is no registered counterparty address then write acknowledgement with empty relayer address and refund recv_fee. - forwardRelayer, _ := k.GetCounterpartyAddress(ctx, relayer, packet.GetSourceChannel()) + forwardRelayer, _ := k.GetCounterpartyAddress(ctx, relayer, packet.GetDestChannel()) ack := types.NewIncentivizedAcknowledgement(forwardRelayer, acknowledgement.Acknowledgement(), acknowledgement.Success()) diff --git a/modules/apps/29-fee/keeper/relay_test.go b/modules/apps/29-fee/keeper/relay_test.go index 4f366b8682a..3cfd627b520 100644 --- a/modules/apps/29-fee/keeper/relay_test.go +++ b/modules/apps/29-fee/keeper/relay_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ) @@ -14,8 +15,8 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgementAsync() { { "success", func() { - suite.chainB.GetSimApp().IBCFeeKeeper.SetRelayerAddressForAsyncAck(suite.chainB.GetContext(), channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 1), suite.chainA.SenderAccount.GetAddress().String()) - suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), suite.path.EndpointA.ChannelID) + suite.chainB.GetSimApp().IBCFeeKeeper.SetRelayerAddressForAsyncAck(suite.chainB.GetContext(), channeltypes.NewPacketId(suite.path.EndpointB.ChannelID, suite.path.EndpointB.ChannelConfig.PortID, 1), suite.chainA.SenderAccount.GetAddress().String()) + suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), suite.path.EndpointB.ChannelID) }, true, }, @@ -31,7 +32,10 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgementAsync() { suite.Run(tc.name, func() { suite.SetupTest() - // open incentivized channel + // open incentivized channels + // setup pathAToC (chainA -> chainC) first in order to have different channel IDs for chainA & chainB + suite.coordinator.Setup(suite.pathAToC) + // setup path for chainA -> chainB suite.coordinator.Setup(suite.path) // build packet @@ -59,6 +63,10 @@ func (suite *KeeperTestSuite) TestWriteAcknowledgementAsync() { suite.Require().NoError(err) _, found := suite.chainB.GetSimApp().IBCFeeKeeper.GetRelayerAddressForAsyncAck(suite.chainB.GetContext(), channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 1)) suite.Require().False(found) + + expectedAck := types.NewIncentivizedAcknowledgement(suite.chainB.SenderAccount.GetAddress().String(), ack.Acknowledgement(), ack.Success()) + commitedAck, _ := suite.chainB.GetSimApp().GetIBCKeeper().ChannelKeeper.GetPacketAcknowledgement(suite.chainB.GetContext(), packet.DestinationPort, packet.DestinationChannel, 1) + suite.Require().Equal(commitedAck, channeltypes.CommitAcknowledgement(expectedAck.Acknowledgement())) } else { suite.Require().Error(err) } From 9ece5da95e02aa5de1a42c68d79838d40a00936d Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Fri, 25 Feb 2022 16:00:43 +0000 Subject: [PATCH 61/79] test: cleanup 29-fee/types tests (#1006) --- modules/apps/29-fee/types/fee_test.go | 84 ++++--- modules/apps/29-fee/types/msgs_test.go | 298 +++++++++---------------- 2 files changed, 158 insertions(+), 224 deletions(-) diff --git a/modules/apps/29-fee/types/fee_test.go b/modules/apps/29-fee/types/fee_test.go index 349fe8dcf07..2b02e5b857b 100644 --- a/modules/apps/29-fee/types/fee_test.go +++ b/modules/apps/29-fee/types/fee_test.go @@ -1,30 +1,42 @@ -package types +package types_test import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/secp256k1" + + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" +) + +var ( + // defaultRecvFee is the default packet receive fee used for testing purposes + defaultRecvFee = sdk.NewCoins(sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}) + + // defaultAckFee is the default packet acknowledgement fee used for testing purposes + defaultAckFee = sdk.NewCoins(sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(200)}) + + // defaultTimeoutFee is the default packet timeout fee used for testing purposes + defaultTimeoutFee = sdk.NewCoins(sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(300)}) + + // invalidFee is an invalid coin set used to trigger error cases for testing purposes + invalidFee = sdk.Coins{sdk.Coin{Denom: "invalid-denom", Amount: sdk.NewInt(-2)}} + + // defaultAccAddress is the default account used for testing purposes + defaultAccAddress = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() ) func TestFeeTotal(t *testing.T) { - fee := Fee{ - AckFee: sdk.NewCoins(sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}), - RecvFee: sdk.NewCoins(sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}), - TimeoutFee: sdk.NewCoins(sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}), - } + fee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee) total := fee.Total() - require.Equal(t, sdk.NewInt(300), total.AmountOf(sdk.DefaultBondDenom)) + require.Equal(t, sdk.NewInt(600), total.AmountOf(sdk.DefaultBondDenom)) } -// TestFeeValidation tests Validate -func TestFeeValidation(t *testing.T) { +func TestPacketFeeValidation(t *testing.T) { var ( - fee Fee - ackFee sdk.Coins - receiveFee sdk.Coins - timeoutFee sdk.Coins + packetFee types.PacketFee ) testCases := []struct { @@ -37,66 +49,70 @@ func TestFeeValidation(t *testing.T) { func() {}, true, }, + { + "should fail when refund address is invalid", + func() { + packetFee.RefundAddress = "invalid-address" + }, + false, + }, { "should fail when all fees are invalid", func() { - ackFee = invalidCoins - receiveFee = invalidCoins - timeoutFee = invalidCoins + packetFee.Fee.AckFee = invalidFee + packetFee.Fee.RecvFee = invalidFee + packetFee.Fee.TimeoutFee = invalidFee }, false, }, { "should fail with single invalid fee", func() { - ackFee = invalidCoins + packetFee.Fee.AckFee = invalidFee }, false, }, { "should fail with two invalid fees", func() { - timeoutFee = invalidCoins - ackFee = invalidCoins + packetFee.Fee.TimeoutFee = invalidFee + packetFee.Fee.AckFee = invalidFee }, false, }, { "should pass with two empty fees", func() { - timeoutFee = sdk.Coins{} - ackFee = sdk.Coins{} + packetFee.Fee.TimeoutFee = sdk.Coins{} + packetFee.Fee.AckFee = sdk.Coins{} }, true, }, { "should pass with one empty fee", func() { - timeoutFee = sdk.Coins{} + packetFee.Fee.TimeoutFee = sdk.Coins{} }, true, }, { "should fail if all fees are empty", func() { - ackFee = sdk.Coins{} - receiveFee = sdk.Coins{} - timeoutFee = sdk.Coins{} + packetFee.Fee.AckFee = sdk.Coins{} + packetFee.Fee.RecvFee = sdk.Coins{} + packetFee.Fee.TimeoutFee = sdk.Coins{} }, false, }, } for _, tc := range testCases { - // build message - ackFee = validCoins - receiveFee = validCoins - timeoutFee = validCoins - - // malleate - tc.malleate() - fee = Fee{receiveFee, ackFee, timeoutFee} - err := fee.Validate() + fee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee) + packetFee = types.NewPacketFee(fee, defaultAccAddress, nil) + + tc.malleate() // malleate mutates test data + + err := packetFee.Validate() if tc.expPass { require.NoError(t, err) diff --git a/modules/apps/29-fee/types/msgs_test.go b/modules/apps/29-fee/types/msgs_test.go index 6ded61d407f..8a7ec915a31 100644 --- a/modules/apps/29-fee/types/msgs_test.go +++ b/modules/apps/29-fee/types/msgs_test.go @@ -1,42 +1,69 @@ -package types +package types_test import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + ibctesting "github.com/cosmos/ibc-go/v3/testing" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/secp256k1" ) -var ( - validChannelID = "channel-1" - invalidChannelID = "ch-1" - validPortID = "validPortId" - invalidID = "this identifier is too long to be used as a valid identifier" - validCoins = sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}} - invalidCoins = sdk.Coins{sdk.Coin{Denom: "invalid-denom", Amount: sdk.NewInt(-2)}} - validAddr = sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()).String() - invalidAddr = "invalid_address" -) - -// TestMsgTransferValidation tests ValidateBasic for MsgTransfer func TestMsgRegisterCountepartyAddressValidation(t *testing.T) { + var ( + msg *types.MsgRegisterCounterpartyAddress + ) + testCases := []struct { - name string - msg *MsgRegisterCounterpartyAddress - expPass bool + name string + malleate func() + expPass bool }{ - {"validate with correct sdk.AccAddress", NewMsgRegisterCounterpartyAddress(validAddr, validAddr, validChannelID), true}, - {"validate with incorrect destination relayer address", NewMsgRegisterCounterpartyAddress(invalidAddr, validAddr, validChannelID), false}, - {"invalid counterparty address", NewMsgRegisterCounterpartyAddress(validAddr, "", validChannelID), false}, - {"invalid counterparty address: whitespaced empty string", NewMsgRegisterCounterpartyAddress(validAddr, " ", validChannelID), false}, - {"invalid channelID", NewMsgRegisterCounterpartyAddress(validAddr, validAddr, invalidChannelID), false}, + { + "success", + func() {}, + true, + }, + { + "validate with incorrect destination relayer address", + func() { + msg.Address = "invalid-address" + }, + false, + }, + { + "invalid counterparty address", + func() { + msg.CounterpartyAddress = "" + }, + false, + }, + { + "invalid counterparty address: whitespaced empty string", + func() { + msg.CounterpartyAddress = " " + }, + false, + }, + { + "invalid channelID", + func() { + msg.ChannelId = "" + }, + false, + }, } for i, tc := range testCases { - err := tc.msg.ValidateBasic() + msg = types.NewMsgRegisterCounterpartyAddress(defaultAccAddress, defaultAccAddress, ibctesting.FirstChannelID) + + tc.malleate() + + err := msg.ValidateBasic() + if tc.expPass { require.NoError(t, err, "valid test case %d failed: %s", i, tc.name) } else { @@ -45,29 +72,15 @@ func TestMsgRegisterCountepartyAddressValidation(t *testing.T) { } } -// TestRegisterCounterpartyAddressGetSigners tests GetSigners func TestRegisterCountepartyAddressGetSigners(t *testing.T) { - addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) - // build message - msg := NewMsgRegisterCounterpartyAddress(addr.String(), "counterparty", validChannelID) - - // GetSigners - res := msg.GetSigners() - - require.Equal(t, []sdk.AccAddress{addr}, res) + accAddress := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + msg := types.NewMsgRegisterCounterpartyAddress(accAddress.String(), defaultAccAddress, ibctesting.FirstChannelID) + require.Equal(t, []sdk.AccAddress{sdk.AccAddress(accAddress)}, msg.GetSigners()) } -// TestMsgPayPacketFeeValidation tests ValidateBasic func TestMsgPayPacketFeeValidation(t *testing.T) { var ( - signer string - channelID string - portID string - fee Fee - relayers []string - ackFee sdk.Coins - receiveFee sdk.Coins - timeoutFee sdk.Coins + msg *types.MsgPayPacketFee ) testCases := []struct { @@ -83,47 +96,38 @@ func TestMsgPayPacketFeeValidation(t *testing.T) { { "invalid channelID", func() { - channelID = invalidID + msg.SourceChannelId = "" }, false, }, { "invalid portID", func() { - portID = invalidID + msg.SourcePortId = "" }, false, }, { "relayers is not nil", func() { - relayers = []string{validAddr} + msg.Relayers = []string{defaultAccAddress} }, false, }, { "invalid signer address", func() { - signer = "invalid-addr" + msg.Signer = "invalid-address" }, false, }, } for _, tc := range testCases { - // build message - signer = validAddr - channelID = validChannelID - portID = validPortID - ackFee = validCoins - receiveFee = validCoins - timeoutFee = validCoins - relayers = nil - - // malleate - tc.malleate() - fee = Fee{receiveFee, ackFee, timeoutFee} - msg := NewMsgPayPacketFee(fee, portID, channelID, signer, relayers) + fee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee) + msg = types.NewMsgPayPacketFee(fee, ibctesting.MockFeePort, ibctesting.FirstChannelID, defaultAccAddress, nil) + + tc.malleate() // malleate mutates test data err := msg.ValidateBasic() @@ -135,78 +139,36 @@ func TestMsgPayPacketFeeValidation(t *testing.T) { } } -// TestPayPacketFeeGetSigners tests GetSigners func TestPayPacketFeeGetSigners(t *testing.T) { - addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) - // build message - signer := addr.String() - channelID := validChannelID - portID := validPortID - fee := Fee{validCoins, validCoins, validCoins} - msg := NewMsgPayPacketFee(fee, portID, channelID, signer, nil) - - // GetSigners - res := msg.GetSigners() - - require.Equal(t, []sdk.AccAddress{addr}, res) + refundAddr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) + fee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee) + msg := types.NewMsgPayPacketFee(fee, ibctesting.MockFeePort, ibctesting.FirstChannelID, refundAddr.String(), nil) + + require.Equal(t, []sdk.AccAddress{refundAddr}, msg.GetSigners()) } -// TestMsgPayPacketFeeRoute tests Route for MsgPayPacketFee func TestMsgPayPacketFeeRoute(t *testing.T) { - addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) - - // build message - signer := addr.String() - channelID := validChannelID - portID := validPortID - fee := Fee{validCoins, validCoins, validCoins} - msg := NewMsgPayPacketFee(fee, portID, channelID, signer, nil) - - require.Equal(t, RouterKey, msg.Route()) + var msg types.MsgPayPacketFee + require.Equal(t, types.RouterKey, msg.Route()) } -// TestMsgPayPacketFeeType tests Type for MsgPayPacketFee func TestMsgPayPacketFeeType(t *testing.T) { - addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) - - // build message - signer := addr.String() - channelID := validChannelID - portID := validPortID - fee := Fee{validCoins, validCoins, validCoins} - msg := NewMsgPayPacketFee(fee, portID, channelID, signer, nil) - + var msg types.MsgPayPacketFee require.Equal(t, "payPacketFee", msg.Type()) } -// TestMsgPayPacketFeeGetSignBytes tests that GetSignBytes does not panic func TestMsgPayPacketFeeGetSignBytes(t *testing.T) { - addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) - - // build message - signer := addr.String() - channelID := validChannelID - portID := validPortID - fee := Fee{validCoins, validCoins, validCoins} - msg := NewMsgPayPacketFee(fee, portID, channelID, signer, nil) + fee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee) + msg := types.NewMsgPayPacketFee(fee, ibctesting.MockFeePort, ibctesting.FirstChannelID, defaultAccAddress, nil) require.NotPanics(t, func() { _ = msg.GetSignBytes() }) } -// TestMsgPayPacketFeeAsyncValidation tests ValidateBasic func TestMsgPayPacketFeeAsyncValidation(t *testing.T) { var ( - signer string - channelID string - portID string - fee Fee - relayers []string - seq uint64 - ackFee sdk.Coins - receiveFee sdk.Coins - timeoutFee sdk.Coins + msg *types.MsgPayPacketFeeAsync ) testCases := []struct { @@ -222,107 +184,96 @@ func TestMsgPayPacketFeeAsyncValidation(t *testing.T) { { "invalid channelID", func() { - channelID = invalidID + msg.PacketId.ChannelId = "" }, false, }, { "invalid portID", func() { - portID = invalidID + msg.PacketId.PortId = "" }, false, }, { - "relayers is not nil", + "invalid sequence", func() { - relayers = []string{validAddr} + msg.PacketId.Sequence = 0 }, false, }, { - "invalid signer address", + "relayers is not nil", func() { - signer = "invalid-addr" + msg.PacketFee.Relayers = []string{defaultAccAddress} }, false, }, { - "invalid sequence", + "invalid signer address", func() { - seq = 0 + msg.PacketFee.RefundAddress = "invalid-addr" }, false, }, { "should fail when all fees are invalid", func() { - ackFee = invalidCoins - receiveFee = invalidCoins - timeoutFee = invalidCoins + msg.PacketFee.Fee.AckFee = invalidFee + msg.PacketFee.Fee.RecvFee = invalidFee + msg.PacketFee.Fee.TimeoutFee = invalidFee }, false, }, { "should fail with single invalid fee", func() { - ackFee = invalidCoins + msg.PacketFee.Fee.AckFee = invalidFee }, false, }, { "should fail with two invalid fees", func() { - timeoutFee = invalidCoins - ackFee = invalidCoins + msg.PacketFee.Fee.AckFee = invalidFee + msg.PacketFee.Fee.TimeoutFee = invalidFee }, false, }, { "should pass with two empty fees", func() { - timeoutFee = sdk.Coins{} - ackFee = sdk.Coins{} + msg.PacketFee.Fee.AckFee = sdk.Coins{} + msg.PacketFee.Fee.TimeoutFee = sdk.Coins{} }, true, }, { "should pass with one empty fee", func() { - timeoutFee = sdk.Coins{} + msg.PacketFee.Fee.TimeoutFee = sdk.Coins{} }, true, }, { "should fail if all fees are empty", func() { - ackFee = sdk.Coins{} - receiveFee = sdk.Coins{} - timeoutFee = sdk.Coins{} + msg.PacketFee.Fee.AckFee = sdk.Coins{} + msg.PacketFee.Fee.RecvFee = sdk.Coins{} + msg.PacketFee.Fee.TimeoutFee = sdk.Coins{} }, false, }, } for _, tc := range testCases { - // build message - signer = validAddr - channelID = validChannelID - portID = validPortID - ackFee = validCoins - receiveFee = validCoins - timeoutFee = validCoins - relayers = nil - seq = 1 - - // malleate - tc.malleate() - fee = Fee{receiveFee, ackFee, timeoutFee} + packetID := channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1) + fee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee) + packetFee := types.NewPacketFee(fee, defaultAccAddress, nil) - packetID := channeltypes.NewPacketId(channelID, portID, seq) - packetFee := NewPacketFee(fee, signer, relayers) + msg = types.NewMsgPayPacketFeeAsync(packetID, packetFee) - msg := NewMsgPayPacketFeeAsync(packetID, packetFee) + tc.malleate() // malleate mutates test data err := msg.ValidateBasic() @@ -334,66 +285,33 @@ func TestMsgPayPacketFeeAsyncValidation(t *testing.T) { } } -// TestRegisterCounterpartyAddressGetSigners tests GetSigners func TestPayPacketFeeAsyncGetSigners(t *testing.T) { refundAddr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) - fee := NewFee(validCoins, validCoins, validCoins) + packetID := channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1) + fee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee) + packetFee := types.NewPacketFee(fee, refundAddr.String(), nil) - packetID := channeltypes.NewPacketId(validChannelID, validPortID, 1) - packetFee := NewPacketFee(fee, refundAddr.String(), nil) - - msg := NewMsgPayPacketFeeAsync(packetID, packetFee) + msg := types.NewMsgPayPacketFeeAsync(packetID, packetFee) require.Equal(t, []sdk.AccAddress{refundAddr}, msg.GetSigners()) } -// TestMsgPayPacketFeeAsyncRoute tests Route for MsgPayPacketFeeAsync func TestMsgPayPacketFeeAsyncRoute(t *testing.T) { - addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) - - // build message - channelID := validChannelID - portID := validPortID - fee := Fee{validCoins, validCoins, validCoins} - seq := uint64(1) - packetID := channeltypes.NewPacketId(channelID, portID, seq) - packetFee := NewPacketFee(fee, addr.String(), nil) - - msg := NewMsgPayPacketFeeAsync(packetID, packetFee) - - require.Equal(t, RouterKey, msg.Route()) + var msg types.MsgPayPacketFeeAsync + require.Equal(t, types.RouterKey, msg.Route()) } -// TestMsgPayPacketFeeAsyncType tests Type for MsgPayPacketFeeAsync func TestMsgPayPacketFeeAsyncType(t *testing.T) { - addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) - - // build message - channelID := validChannelID - portID := validPortID - fee := Fee{validCoins, validCoins, validCoins} - seq := uint64(1) - packetID := channeltypes.NewPacketId(channelID, portID, seq) - packetFee := NewPacketFee(fee, addr.String(), nil) - - msg := NewMsgPayPacketFeeAsync(packetID, packetFee) - + var msg types.MsgPayPacketFeeAsync require.Equal(t, "payPacketFeeAsync", msg.Type()) } -// TestMsgPayPacketFeeAsyncGetSignBytes tests that GetSignBytes does not panic func TestMsgPayPacketFeeAsyncGetSignBytes(t *testing.T) { - addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) - - // build message - channelID := validChannelID - portID := validPortID - fee := Fee{validCoins, validCoins, validCoins} - seq := uint64(1) - packetID := channeltypes.NewPacketId(channelID, portID, seq) - packetFee := NewPacketFee(fee, addr.String(), nil) + packetID := channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1) + fee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee) + packetFee := types.NewPacketFee(fee, defaultAccAddress, nil) - msg := NewMsgPayPacketFeeAsync(packetID, packetFee) + msg := types.NewMsgPayPacketFeeAsync(packetID, packetFee) require.NotPanics(t, func() { _ = msg.GetSignBytes() From f8b43454222afb4ef10f518f0f6540dd0d5f435d Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 1 Mar 2022 09:15:55 +0000 Subject: [PATCH 62/79] feat: grpc query total recv packet fees (#1015) * adding query for total packet recv fees to proto query server * adding total packet recv fee query impl and tests * updating doc comments --- docs/ibc/proto-docs.md | 33 ++ modules/apps/29-fee/keeper/grpc_query.go | 26 + modules/apps/29-fee/keeper/grpc_query_test.go | 64 +++ modules/apps/29-fee/types/query.pb.go | 478 ++++++++++++++++-- modules/apps/29-fee/types/query.pb.gw.go | 160 ++++++ proto/ibc/applications/fee/v1/query.proto | 27 +- 6 files changed, 750 insertions(+), 38 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index eb2ddc97e3a..eda1ca9bf69 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -49,6 +49,8 @@ - [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) - [QueryIncentivizedPacketsRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsRequest) - [QueryIncentivizedPacketsResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsResponse) + - [QueryTotalRecvFeesRequest](#ibc.applications.fee.v1.QueryTotalRecvFeesRequest) + - [QueryTotalRecvFeesResponse](#ibc.applications.fee.v1.QueryTotalRecvFeesResponse) - [Query](#ibc.applications.fee.v1.Query) @@ -983,6 +985,36 @@ QueryIncentivizedPacketsResponse is the response type for the incentivized packe + + + +### QueryTotalRecvFeesRequest +QueryTotalRecvFeesRequest defines the request type for the TotalRecvFees rpc + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | the packet identifier for the associated fees | + + + + + + + + +### QueryTotalRecvFeesResponse +QueryTotalRecvFeesResponse defines the response type for the TotalRecvFees rpc + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `recv_fees` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | the total packet receive fees | + + + + + @@ -999,6 +1031,7 @@ Query provides defines the gRPC querier service. | ----------- | ------------ | ------------- | ------------| ------- | -------- | | `IncentivizedPackets` | [QueryIncentivizedPacketsRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsRequest) | [QueryIncentivizedPacketsResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsResponse) | Gets all incentivized packets | GET|/ibc/apps/fee/v1/incentivized_packets| | `IncentivizedPacket` | [QueryIncentivizedPacketRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketRequest) | [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) | Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the given packet | GET|/ibc/apps/fee/v1/incentivized_packet/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| +| `TotalRecvFees` | [QueryTotalRecvFeesRequest](#ibc.applications.fee.v1.QueryTotalRecvFeesRequest) | [QueryTotalRecvFeesResponse](#ibc.applications.fee.v1.QueryTotalRecvFeesResponse) | TotalRecvFees returns the total receive fees for a packet given its identifier | GET|/ibc/apps/fee/v1/total_recv_fees/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| diff --git a/modules/apps/29-fee/keeper/grpc_query.go b/modules/apps/29-fee/keeper/grpc_query.go index 3d4852831ad..dfaa5d86a35 100644 --- a/modules/apps/29-fee/keeper/grpc_query.go +++ b/modules/apps/29-fee/keeper/grpc_query.go @@ -65,3 +65,29 @@ func (k Keeper) IncentivizedPacket(c context.Context, req *types.QueryIncentiviz IncentivizedPacket: types.NewIdentifiedPacketFees(req.PacketId, feesInEscrow.PacketFees), }, nil } + +// TotalRecvFees implements the Query/TotalRecvFees gRPC method +func (k Keeper) TotalRecvFees(goCtx context.Context, req *types.QueryTotalRecvFeesRequest) (*types.QueryTotalRecvFeesResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + feesInEscrow, found := k.GetFeesInEscrow(ctx, req.PacketId) + if !found { + return nil, status.Errorf( + codes.NotFound, + sdkerrors.Wrapf(types.ErrFeeNotFound, "channel: %s, port: %s, sequence: %d", req.PacketId.ChannelId, req.PacketId.PortId, req.PacketId.Sequence).Error(), + ) + } + + var recvFees sdk.Coins + for _, packetFee := range feesInEscrow.PacketFees { + recvFees = recvFees.Add(packetFee.Fee.RecvFee...) + } + + return &types.QueryTotalRecvFeesResponse{ + RecvFees: recvFees, + }, nil +} diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index 37626b40bac..c9df54665f0 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -139,3 +139,67 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacket() { }) } } + +func (suite *KeeperTestSuite) TestQueryTotalRecvFees() { + var ( + req *types.QueryTotalRecvFeesRequest + ) + + testCases := []struct { + name string + malleate func() + expPass bool + }{ + { + "success", + func() {}, + true, + }, + { + "packet not found", + func() { + req.PacketId = channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 100) + }, + false, + }, + } + + for _, tc := range testCases { + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) + + packetID := channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1) + + fee := types.NewFee(defaultReceiveFee, defaultAckFee, defaultTimeoutFee) + packetFee := types.NewPacketFee(fee, suite.chainA.SenderAccount.GetAddress().String(), []string(nil)) + + for i := 0; i < 3; i++ { + // escrow three packet fees for the same packet + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) + suite.Require().NoError(err) + } + + req = &types.QueryTotalRecvFeesRequest{ + PacketId: packetID, + } + + tc.malleate() + + ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) + res, err := suite.queryClient.TotalRecvFees(ctx, req) + + if tc.expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + + // expected total is three times the default recv fee + expectedFees := defaultReceiveFee.Add(defaultReceiveFee...).Add(defaultReceiveFee...) + suite.Require().Equal(expectedFees, res.RecvFees) + } else { + suite.Require().Error(err) + } + }) + } +} diff --git a/modules/apps/29-fee/types/query.pb.go b/modules/apps/29-fee/types/query.pb.go index ef1b0512d25..fdbaa9766c8 100644 --- a/modules/apps/29-fee/types/query.pb.go +++ b/modules/apps/29-fee/types/query.pb.go @@ -6,6 +6,8 @@ package types import ( context "context" fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types1 "github.com/cosmos/cosmos-sdk/types" query "github.com/cosmos/cosmos-sdk/types/query" types "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" _ "github.com/gogo/protobuf/gogoproto" @@ -233,11 +235,105 @@ func (m *QueryIncentivizedPacketResponse) GetIncentivizedPacket() IdentifiedPack return IdentifiedPacketFees{} } +// QueryTotalRecvFeesRequest defines the request type for the TotalRecvFees rpc +type QueryTotalRecvFeesRequest struct { + // the packet identifier for the associated fees + PacketId types.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id"` +} + +func (m *QueryTotalRecvFeesRequest) Reset() { *m = QueryTotalRecvFeesRequest{} } +func (m *QueryTotalRecvFeesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryTotalRecvFeesRequest) ProtoMessage() {} +func (*QueryTotalRecvFeesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{4} +} +func (m *QueryTotalRecvFeesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTotalRecvFeesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTotalRecvFeesRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryTotalRecvFeesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTotalRecvFeesRequest.Merge(m, src) +} +func (m *QueryTotalRecvFeesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryTotalRecvFeesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTotalRecvFeesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTotalRecvFeesRequest proto.InternalMessageInfo + +func (m *QueryTotalRecvFeesRequest) GetPacketId() types.PacketId { + if m != nil { + return m.PacketId + } + return types.PacketId{} +} + +// QueryTotalRecvFeesResponse defines the response type for the TotalRecvFees rpc +type QueryTotalRecvFeesResponse struct { + // the total packet receive fees + RecvFees github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=recv_fees,json=recvFees,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"recv_fees" yaml:"recv_fees"` +} + +func (m *QueryTotalRecvFeesResponse) Reset() { *m = QueryTotalRecvFeesResponse{} } +func (m *QueryTotalRecvFeesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryTotalRecvFeesResponse) ProtoMessage() {} +func (*QueryTotalRecvFeesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{5} +} +func (m *QueryTotalRecvFeesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTotalRecvFeesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTotalRecvFeesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryTotalRecvFeesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTotalRecvFeesResponse.Merge(m, src) +} +func (m *QueryTotalRecvFeesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryTotalRecvFeesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTotalRecvFeesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTotalRecvFeesResponse proto.InternalMessageInfo + +func (m *QueryTotalRecvFeesResponse) GetRecvFees() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.RecvFees + } + return nil +} + func init() { proto.RegisterType((*QueryIncentivizedPacketsRequest)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketsRequest") proto.RegisterType((*QueryIncentivizedPacketsResponse)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketsResponse") proto.RegisterType((*QueryIncentivizedPacketRequest)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketRequest") proto.RegisterType((*QueryIncentivizedPacketResponse)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketResponse") + proto.RegisterType((*QueryTotalRecvFeesRequest)(nil), "ibc.applications.fee.v1.QueryTotalRecvFeesRequest") + proto.RegisterType((*QueryTotalRecvFeesResponse)(nil), "ibc.applications.fee.v1.QueryTotalRecvFeesResponse") } func init() { @@ -245,42 +341,51 @@ func init() { } var fileDescriptor_0638a8a78ca2503c = []byte{ - // 554 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0x41, 0x6b, 0x13, 0x41, - 0x14, 0xce, 0xb4, 0x55, 0x74, 0xe2, 0x69, 0x52, 0x30, 0x04, 0xdd, 0xa6, 0x11, 0x35, 0x08, 0x99, - 0x21, 0x29, 0x62, 0x7b, 0x93, 0x1e, 0x8a, 0x39, 0x59, 0x73, 0xf4, 0x12, 0x76, 0x67, 0x5f, 0x36, - 0x83, 0xc9, 0xce, 0x36, 0x33, 0x59, 0x68, 0xb5, 0x97, 0x82, 0x08, 0xd2, 0x83, 0xe0, 0xaf, 0xf1, - 0x1f, 0xf4, 0x58, 0xf4, 0xe2, 0x49, 0x24, 0xf1, 0x87, 0xc8, 0xec, 0xce, 0xc6, 0x85, 0x64, 0xb1, - 0xed, 0x6d, 0xf7, 0xbd, 0xef, 0x7b, 0xdf, 0xb7, 0xdf, 0x9b, 0x1d, 0xfc, 0x48, 0x78, 0x9c, 0xb9, - 0x51, 0x34, 0x12, 0xdc, 0xd5, 0x42, 0x86, 0x8a, 0x0d, 0x00, 0x58, 0xdc, 0x66, 0x47, 0x53, 0x98, - 0x1c, 0xd3, 0x68, 0x22, 0xb5, 0x24, 0xf7, 0x85, 0xc7, 0x69, 0x1e, 0x44, 0x07, 0x00, 0x34, 0x6e, - 0xd7, 0x36, 0x03, 0x19, 0xc8, 0x04, 0xc3, 0xcc, 0x53, 0x0a, 0xaf, 0x6d, 0x17, 0xcd, 0x34, 0xac, - 0x14, 0xf2, 0x20, 0x90, 0x32, 0x18, 0x01, 0x73, 0x23, 0xc1, 0xdc, 0x30, 0x94, 0xda, 0xce, 0xcd, - 0x0d, 0xe0, 0x72, 0x02, 0x8c, 0x0f, 0xdd, 0x30, 0x84, 0x91, 0x21, 0xdb, 0x47, 0x0b, 0x79, 0xc6, - 0xa5, 0x1a, 0x4b, 0xc5, 0x3c, 0x57, 0x41, 0xea, 0x95, 0xc5, 0x6d, 0x0f, 0xb4, 0xdb, 0x66, 0x91, - 0x1b, 0x88, 0x30, 0x99, 0x97, 0x62, 0x1b, 0xe7, 0x08, 0x6f, 0xbd, 0x31, 0x90, 0x6e, 0xc8, 0x21, - 0xd4, 0x22, 0x16, 0x27, 0xe0, 0x1f, 0xba, 0xfc, 0x1d, 0x68, 0xd5, 0x83, 0xa3, 0x29, 0x28, 0x4d, - 0x0e, 0x30, 0xfe, 0xc7, 0xab, 0xa2, 0x3a, 0x6a, 0x96, 0x3b, 0x4f, 0x68, 0x2a, 0x42, 0x8d, 0x08, - 0x4d, 0x03, 0xb1, 0x22, 0xf4, 0xd0, 0x0d, 0xc0, 0x72, 0x7b, 0x39, 0x26, 0xd9, 0xc6, 0xf7, 0x12, - 0x60, 0x7f, 0x08, 0x22, 0x18, 0xea, 0xea, 0x5a, 0x1d, 0x35, 0x37, 0x7a, 0xe5, 0xa4, 0xf6, 0x2a, - 0x29, 0x35, 0x3e, 0x23, 0x5c, 0x2f, 0xb6, 0xa3, 0x22, 0x19,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xae, 0x67, 0x4b, 0x49, 0x5b, 0x19, 0xa3, 0x21, 0x87, 0x7c, 0x3f, 0xab, 0x9d, 0xee, 0xbf, 0xbe, - 0x98, 0x39, 0xe8, 0x72, 0xe6, 0xa0, 0xdf, 0x33, 0x07, 0x7d, 0x99, 0x3b, 0xa5, 0xcb, 0xb9, 0x53, - 0xfa, 0x39, 0x77, 0x4a, 0x6f, 0x9f, 0x07, 0x42, 0x0f, 0xa7, 0x1e, 0xe5, 0x72, 0xcc, 0xec, 0x9d, - 0x22, 0x3c, 0xde, 0x0a, 0x24, 0x8b, 0x77, 0xd8, 0x58, 0xfa, 0xd3, 0x11, 0xa8, 0xd4, 0x74, 0x67, - 0xaf, 0x65, 0x7c, 0xeb, 0xe3, 0x08, 0x94, 0x77, 0x3b, 0xb9, 0x5a, 0x76, 0xfe, 0x06, 0x00, 0x00, - 0xff, 0xff, 0xcd, 0x07, 0x8a, 0x55, 0x40, 0x05, 0x00, 0x00, + // 698 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x95, 0x41, 0x6b, 0x13, 0x4d, + 0x18, 0xc7, 0x33, 0x7d, 0xdb, 0x97, 0x76, 0xfa, 0xbe, 0x20, 0xd3, 0x82, 0x6d, 0xd0, 0x4d, 0xba, + 0xa2, 0x06, 0x21, 0x3b, 0x34, 0x45, 0x6c, 0x3d, 0x49, 0x95, 0x62, 0x4f, 0xd6, 0xe0, 0x49, 0x90, + 0xb0, 0x3b, 0x3b, 0xd9, 0x0c, 0x4d, 0x76, 0xb6, 0x99, 0xc9, 0x62, 0x6b, 0xeb, 0xa1, 0x20, 0x82, + 0xf4, 0x20, 0x78, 0xf3, 0x23, 0xf8, 0x0d, 0xfc, 0x06, 0xbd, 0x08, 0x05, 0x2f, 0x9e, 0xaa, 0xb4, + 0x7e, 0x02, 0x4f, 0x1e, 0x65, 0x66, 0x67, 0xd7, 0x2d, 0x49,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, 0xb2, 0xc0, 0x97, 0x23, + 0x0b, 0xbc, 0x3e, 0xb6, 0x0a, 0x07, 0xc7, 0x56, 0xe1, 0xd3, 0xb1, 0x55, 0x78, 0x7c, 0xb3, 0xff, + 0x74, 0x30, 0x8f, 0x54, 0x03, 0x8e, 0xe3, 0x05, 0xdc, 0xe1, 0x7e, 0xaf, 0x4d, 0x45, 0x02, 0x5c, + 0x5b, 0xaa, 0x2a, 0x66, 0x7d, 0x60, 0xbc, 0x7f, 0xf5, 0x3f, 0xca, 0xc2, 0x8f, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xdd, 0x79, 0x2b, 0x91, 0x57, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -300,6 +405,8 @@ type QueryClient interface { // Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the // given packet IncentivizedPacket(ctx context.Context, in *QueryIncentivizedPacketRequest, opts ...grpc.CallOption) (*QueryIncentivizedPacketResponse, error) + // TotalRecvFees returns the total receive fees for a packet given its identifier + TotalRecvFees(ctx context.Context, in *QueryTotalRecvFeesRequest, opts ...grpc.CallOption) (*QueryTotalRecvFeesResponse, error) } type queryClient struct { @@ -328,6 +435,15 @@ func (c *queryClient) IncentivizedPacket(ctx context.Context, in *QueryIncentivi return out, nil } +func (c *queryClient) TotalRecvFees(ctx context.Context, in *QueryTotalRecvFeesRequest, opts ...grpc.CallOption) (*QueryTotalRecvFeesResponse, error) { + out := new(QueryTotalRecvFeesResponse) + err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Query/TotalRecvFees", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Gets all incentivized packets @@ -335,6 +451,8 @@ type QueryServer interface { // Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the // given packet IncentivizedPacket(context.Context, *QueryIncentivizedPacketRequest) (*QueryIncentivizedPacketResponse, error) + // TotalRecvFees returns the total receive fees for a packet given its identifier + TotalRecvFees(context.Context, *QueryTotalRecvFeesRequest) (*QueryTotalRecvFeesResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -347,6 +465,9 @@ func (*UnimplementedQueryServer) IncentivizedPackets(ctx context.Context, req *Q func (*UnimplementedQueryServer) IncentivizedPacket(ctx context.Context, req *QueryIncentivizedPacketRequest) (*QueryIncentivizedPacketResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method IncentivizedPacket not implemented") } +func (*UnimplementedQueryServer) TotalRecvFees(ctx context.Context, req *QueryTotalRecvFeesRequest) (*QueryTotalRecvFeesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TotalRecvFees not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -388,6 +509,24 @@ func _Query_IncentivizedPacket_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Query_TotalRecvFees_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryTotalRecvFeesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).TotalRecvFees(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.applications.fee.v1.Query/TotalRecvFees", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).TotalRecvFees(ctx, req.(*QueryTotalRecvFeesRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.applications.fee.v1.Query", HandlerType: (*QueryServer)(nil), @@ -400,6 +539,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "IncentivizedPacket", Handler: _Query_IncentivizedPacket_Handler, }, + { + MethodName: "TotalRecvFees", + Handler: _Query_TotalRecvFees_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/applications/fee/v1/query.proto", @@ -553,6 +696,76 @@ func (m *QueryIncentivizedPacketResponse) MarshalToSizedBuffer(dAtA []byte) (int return len(dAtA) - i, nil } +func (m *QueryTotalRecvFeesRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryTotalRecvFeesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTotalRecvFeesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryTotalRecvFeesResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryTotalRecvFeesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTotalRecvFeesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RecvFees) > 0 { + for iNdEx := len(m.RecvFees) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.RecvFees[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -620,6 +833,32 @@ func (m *QueryIncentivizedPacketResponse) Size() (n int) { return n } +func (m *QueryTotalRecvFeesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.PacketId.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryTotalRecvFeesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.RecvFees) > 0 { + for _, e := range m.RecvFees { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1000,6 +1239,173 @@ func (m *QueryIncentivizedPacketResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryTotalRecvFeesRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryTotalRecvFeesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTotalRecvFeesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryTotalRecvFeesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryTotalRecvFeesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTotalRecvFeesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RecvFees", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RecvFees = append(m.RecvFees, types1.Coin{}) + if err := m.RecvFees[len(m.RecvFees)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/apps/29-fee/types/query.pb.gw.go b/modules/apps/29-fee/types/query.pb.gw.go index 3a9b3d581b2..e9626d2a08e 100644 --- a/modules/apps/29-fee/types/query.pb.gw.go +++ b/modules/apps/29-fee/types/query.pb.gw.go @@ -183,6 +183,122 @@ func local_request_Query_IncentivizedPacket_0(ctx context.Context, marshaler run } +var ( + filter_Query_TotalRecvFees_0 = &utilities.DoubleArray{Encoding: map[string]int{"packet_id": 0, "port_id": 1, "channel_id": 2, "sequence": 3}, Base: []int{1, 1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 2, 2, 2, 3, 4, 5}} +) + +func request_Query_TotalRecvFees_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTotalRecvFeesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["packet_id.port_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) + } + + val, ok = pathParams["packet_id.channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) + } + + val, ok = pathParams["packet_id.sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TotalRecvFees_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.TotalRecvFees(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_TotalRecvFees_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTotalRecvFeesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["packet_id.port_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) + } + + val, ok = pathParams["packet_id.channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) + } + + val, ok = pathParams["packet_id.sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TotalRecvFees_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.TotalRecvFees(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -229,6 +345,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_TotalRecvFees_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_TotalRecvFees_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TotalRecvFees_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -310,6 +446,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_TotalRecvFees_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_TotalRecvFees_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TotalRecvFees_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -317,10 +473,14 @@ var ( pattern_Query_IncentivizedPackets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"ibc", "apps", "fee", "v1", "incentivized_packets"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_IncentivizedPacket_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "incentivized_packet", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_TotalRecvFees_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "total_recv_fees", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( forward_Query_IncentivizedPackets_0 = runtime.ForwardResponseMessage forward_Query_IncentivizedPacket_0 = runtime.ForwardResponseMessage + + forward_Query_TotalRecvFees_0 = runtime.ForwardResponseMessage ) diff --git a/proto/ibc/applications/fee/v1/query.proto b/proto/ibc/applications/fee/v1/query.proto index a588240a285..65b677c2fdb 100644 --- a/proto/ibc/applications/fee/v1/query.proto +++ b/proto/ibc/applications/fee/v1/query.proto @@ -5,10 +5,11 @@ package ibc.applications.fee.v1; option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; import "gogoproto/gogo.proto"; -import "ibc/applications/fee/v1/fee.proto"; import "google/api/annotations.proto"; -import "ibc/core/channel/v1/channel.proto"; +import "cosmos/base/v1beta1/coin.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; +import "ibc/applications/fee/v1/fee.proto"; +import "ibc/core/channel/v1/channel.proto"; // Query provides defines the gRPC querier service. service Query { @@ -24,6 +25,12 @@ service Query { "/ibc/apps/fee/v1/incentivized_packet/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/" "{packet_id.sequence}"; } + + // TotalRecvFees returns the total receive fees for a packet given its identifier + rpc TotalRecvFees(QueryTotalRecvFeesRequest) returns (QueryTotalRecvFeesResponse) { + option (google.api.http).get = "/ibc/apps/fee/v1/total_recv_fees/port/{packet_id.port_id}/channel/" + "{packet_id.channel_id}/sequence/{packet_id.sequence}"; + } } // QueryIncentivizedPacketsRequest is the request type for querying for all incentivized packets @@ -53,3 +60,19 @@ message QueryIncentivizedPacketResponse { // Incentivized_packet ibc.applications.fee.v1.IdentifiedPacketFees incentivized_packet = 1 [(gogoproto.nullable) = false]; } + +// QueryTotalRecvFeesRequest defines the request type for the TotalRecvFees rpc +message QueryTotalRecvFeesRequest { + // the packet identifier for the associated fees + ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.nullable) = false]; +} + +// QueryTotalRecvFeesResponse defines the response type for the TotalRecvFees rpc +message QueryTotalRecvFeesResponse { + // the total packet receive fees + repeated cosmos.base.v1beta1.Coin recv_fees = 1 [ + (gogoproto.moretags) = "yaml:\"recv_fees\"", + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} From e51e2c9917c5786135414ba9fa32fd47efe61b3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Tue, 1 Mar 2022 14:57:47 +0100 Subject: [PATCH 63/79] chore: switch code ordering (#1025) --- modules/apps/29-fee/ibc_module.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go index e8a4a45fd40..bdb3bcadabd 100644 --- a/modules/apps/29-fee/ibc_module.go +++ b/modules/apps/29-fee/ibc_module.go @@ -143,6 +143,10 @@ func (im IBCModule) OnChanCloseInit( portID, channelID string, ) error { + if err := im.app.OnChanCloseInit(ctx, portID, channelID); err != nil { + return err + } + // delete fee enabled on channel // and refund any remaining fees escrowed on channel im.keeper.DeleteFeeEnabled(ctx, portID, channelID) @@ -157,7 +161,8 @@ func (im IBCModule) OnChanCloseInit( if err != nil { im.keeper.DisableAllChannels(ctx) } - return im.app.OnChanCloseInit(ctx, portID, channelID) + + return nil } // OnChanCloseConfirm implements the IBCModule interface From 5f8fc9fddb0101db591cc09325730dde66b853a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Tue, 1 Mar 2022 15:06:03 +0100 Subject: [PATCH 64/79] feat: Add ParseKeyFeeEnabled and rename FeeEnabledKey -> KeyFeeEnabled (#1023) * chore: add ParseKeyFeesInEscrow helper function * feat: add ParseKeyFeeEnabled function and rename FeeEnabledKey to KeyFeeEnabled --- modules/apps/29-fee/keeper/keeper.go | 16 +++++---- modules/apps/29-fee/types/keys.go | 24 ++++++++++++-- modules/apps/29-fee/types/keys_test.go | 45 ++++++++++++++++++++++++-- 3 files changed, 74 insertions(+), 11 deletions(-) diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index 5b2e7810447..9b7583ea055 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -81,20 +81,20 @@ func (k Keeper) GetFeeModuleAddress() sdk.AccAddress { // identified by channel and port identifiers. func (k Keeper) SetFeeEnabled(ctx sdk.Context, portID, channelID string) { store := ctx.KVStore(k.storeKey) - store.Set(types.FeeEnabledKey(portID, channelID), []byte{1}) + store.Set(types.KeyFeeEnabled(portID, channelID), []byte{1}) } // DeleteFeeEnabled deletes the fee enabled flag for a given portID and channelID func (k Keeper) DeleteFeeEnabled(ctx sdk.Context, portID, channelID string) { store := ctx.KVStore(k.storeKey) - store.Delete(types.FeeEnabledKey(portID, channelID)) + store.Delete(types.KeyFeeEnabled(portID, channelID)) } // IsFeeEnabled returns whether fee handling logic should be run for the given port. It will check the // fee enabled flag for the given port and channel identifiers func (k Keeper) IsFeeEnabled(ctx sdk.Context, portID, channelID string) bool { store := ctx.KVStore(k.storeKey) - return store.Get(types.FeeEnabledKey(portID, channelID)) != nil + return store.Get(types.KeyFeeEnabled(portID, channelID)) != nil } // GetAllFeeEnabledChannels returns a list of all ics29 enabled channels containing portID & channelID that are stored in state @@ -105,11 +105,13 @@ func (k Keeper) GetAllFeeEnabledChannels(ctx sdk.Context) []types.FeeEnabledChan var enabledChArr []types.FeeEnabledChannel for ; iterator.Valid(); iterator.Next() { - keySplit := strings.Split(string(iterator.Key()), "/") - + portID, channelID, err := types.ParseKeyFeeEnabled(string(iterator.Key())) + if err != nil { + panic(err) + } ch := types.FeeEnabledChannel{ - PortId: keySplit[1], - ChannelId: keySplit[2], + PortId: portID, + ChannelId: channelID, } enabledChArr = append(enabledChArr, ch) diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index 8f23a4e7688..f39cd9b5d44 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -45,12 +45,32 @@ const ( AttributeKeyTimeoutFee = "timeout_fee" ) -// FeeEnabledKey returns the key that stores a flag to determine if fee logic should +// KeyFeeEnabled returns the key that stores a flag to determine if fee logic should // be enabled for the given port and channel identifiers. -func FeeEnabledKey(portID, channelID string) []byte { +func KeyFeeEnabled(portID, channelID string) []byte { return []byte(fmt.Sprintf("%s/%s/%s", FeeEnabledKeyPrefix, portID, channelID)) } +// ParseKeyFeeEnabled parses the key used to indicate if the fee logic should be +// enabled for the given port and channel identifiers. +func ParseKeyFeeEnabled(key string) (portID, channelID string, err error) { + keySplit := strings.Split(key, "/") + if len(keySplit) != 3 { + return "", "", sdkerrors.Wrapf( + sdkerrors.ErrLogic, "key provided is incorrect: the key split has incorrect length, expected %d, got %d", 3, len(keySplit), + ) + } + + if keySplit[0] != FeeEnabledKeyPrefix { + return "", "", sdkerrors.Wrapf(sdkerrors.ErrLogic, "key prefix is incorrect: expected %s, got %s", FeeEnabledKeyPrefix, keySplit[0]) + } + + portID = keySplit[1] + channelID = keySplit[2] + + return portID, channelID, nil +} + // KeyCounterpartyRelayer returns the key for relayer address -> counteryparty address mapping func KeyCounterpartyRelayer(address, channelID string) []byte { return []byte(fmt.Sprintf("%s/%s/%s", CounterpartyRelayerAddressKeyPrefix, address, channelID)) diff --git a/modules/apps/29-fee/types/keys_test.go b/modules/apps/29-fee/types/keys_test.go index ac60255955b..f196f5de56b 100644 --- a/modules/apps/29-fee/types/keys_test.go +++ b/modules/apps/29-fee/types/keys_test.go @@ -11,6 +11,10 @@ import ( ibctesting "github.com/cosmos/ibc-go/v3/testing" ) +var ( + validPacketID = channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1) +) + func TestKeyCounterpartyRelayer(t *testing.T) { var ( relayerAddress = "relayer_address" @@ -21,8 +25,45 @@ func TestKeyCounterpartyRelayer(t *testing.T) { require.Equal(t, string(key), fmt.Sprintf("%s/%s/%s", types.CounterpartyRelayerAddressKeyPrefix, relayerAddress, channelID)) } +func TestParseKeyFeeEnabled(t *testing.T) { + testCases := []struct { + name string + key string + expPass bool + }{ + { + "success", + string(types.KeyFeeEnabled(ibctesting.MockPort, ibctesting.FirstChannelID)), + true, + }, + { + "incorrect key - key split has incorrect length", + string(types.KeyFeesInEscrow(validPacketID)), + false, + }, + { + "incorrect key - key split has incorrect length", + fmt.Sprintf("%s/%s/%s", "fee", ibctesting.MockPort, ibctesting.FirstChannelID), + false, + }, + } + + for _, tc := range testCases { + portID, channelID, err := types.ParseKeyFeeEnabled(tc.key) + + if tc.expPass { + require.NoError(t, err) + require.Equal(t, ibctesting.MockPort, portID) + require.Equal(t, ibctesting.FirstChannelID, channelID) + } else { + require.Error(t, err) + require.Empty(t, portID) + require.Empty(t, channelID) + } + } +} + func TestParseKeyFeesInEscrow(t *testing.T) { - validPacketID := channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1) testCases := []struct { name string @@ -36,7 +77,7 @@ func TestParseKeyFeesInEscrow(t *testing.T) { }, { "incorrect key - key split has incorrect length", - string(types.FeeEnabledKey(validPacketID.PortId, validPacketID.ChannelId)), + string(types.KeyFeeEnabled(validPacketID.PortId, validPacketID.ChannelId)), false, }, { From 4623772bb98f49dbd4401c50cd71194c0c1b772e Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 1 Mar 2022 16:50:52 +0000 Subject: [PATCH 65/79] feat: ics29 cli for query total recv fees (#1035) --- modules/apps/29-fee/client/cli/cli.go | 2 +- modules/apps/29-fee/client/cli/query.go | 58 ++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/modules/apps/29-fee/client/cli/cli.go b/modules/apps/29-fee/client/cli/cli.go index abb1d40c31b..a8caf155310 100644 --- a/modules/apps/29-fee/client/cli/cli.go +++ b/modules/apps/29-fee/client/cli/cli.go @@ -15,7 +15,7 @@ func GetQueryCmd() *cobra.Command { } queryCmd.AddCommand( - // TODO + GetCmdTotalRecvFees(), ) return queryCmd diff --git a/modules/apps/29-fee/client/cli/query.go b/modules/apps/29-fee/client/cli/query.go index e8878f3e042..1413ae001cb 100644 --- a/modules/apps/29-fee/client/cli/query.go +++ b/modules/apps/29-fee/client/cli/query.go @@ -1,3 +1,59 @@ package cli -// TODO +import ( + "fmt" + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/version" + "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + "github.com/spf13/cobra" +) + +// GetCmdTotalRecvFees returns the command handler for the Query/TotalRecvFees rpc. +func GetCmdTotalRecvFees() *cobra.Command { + cmd := &cobra.Command{ + Use: "total-recv-fees [port-id] [channel-id] [sequence]", + Short: "Query the total receive fees for a packet", + Long: "Query the total receive fees for a packet", + Args: cobra.ExactArgs(3), + Example: fmt.Sprintf("%s query ibc-fee transfer channel-5 100", version.AppName), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + portID, channelID := args[0], args[1] + seq, err := strconv.ParseUint(args[2], 10, 64) + if err != nil { + return err + } + + packetID := channeltypes.NewPacketId(channelID, portID, seq) + + if err := packetID.Validate(); err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + req := &types.QueryTotalRecvFeesRequest{ + PacketId: packetID, + } + + res, err := queryClient.TotalRecvFees(cmd.Context(), req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} From 8d380baad0eeb9febf58ba040ab3d75aefa12b9c Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 1 Mar 2022 17:11:37 +0000 Subject: [PATCH 66/79] feat: grpc query total ack fees (#1032) * adding query for total packet recv fees to proto query server * adding total packet recv fee query impl and tests * updating doc comments * adding protos and codegen * adding total ack fees query and tests * fixing protodoc comment --- docs/ibc/proto-docs.md | 33 ++ modules/apps/29-fee/keeper/grpc_query.go | 26 + modules/apps/29-fee/keeper/grpc_query_test.go | 64 +++ modules/apps/29-fee/types/query.pb.go | 490 ++++++++++++++++-- modules/apps/29-fee/types/query.pb.gw.go | 160 ++++++ proto/ibc/applications/fee/v1/query.proto | 22 + 6 files changed, 750 insertions(+), 45 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index eda1ca9bf69..d2093dd5c5d 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -49,6 +49,8 @@ - [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) - [QueryIncentivizedPacketsRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsRequest) - [QueryIncentivizedPacketsResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsResponse) + - [QueryTotalAckFeesRequest](#ibc.applications.fee.v1.QueryTotalAckFeesRequest) + - [QueryTotalAckFeesResponse](#ibc.applications.fee.v1.QueryTotalAckFeesResponse) - [QueryTotalRecvFeesRequest](#ibc.applications.fee.v1.QueryTotalRecvFeesRequest) - [QueryTotalRecvFeesResponse](#ibc.applications.fee.v1.QueryTotalRecvFeesResponse) @@ -986,6 +988,36 @@ QueryIncentivizedPacketsResponse is the response type for the incentivized packe + + +### QueryTotalAckFeesRequest +QueryTotalAckFeesRequest defines the request type for the TotalAckFees rpc + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | the packet identifier for the associated fees | + + + + + + + + +### QueryTotalAckFeesResponse +QueryTotalAckFeesResponse defines the response type for the TotalAckFees rpc + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `ack_fees` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | the total packet acknowledgement fees | + + + + + + ### QueryTotalRecvFeesRequest @@ -1032,6 +1064,7 @@ Query provides defines the gRPC querier service. | `IncentivizedPackets` | [QueryIncentivizedPacketsRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsRequest) | [QueryIncentivizedPacketsResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsResponse) | Gets all incentivized packets | GET|/ibc/apps/fee/v1/incentivized_packets| | `IncentivizedPacket` | [QueryIncentivizedPacketRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketRequest) | [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) | Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the given packet | GET|/ibc/apps/fee/v1/incentivized_packet/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| | `TotalRecvFees` | [QueryTotalRecvFeesRequest](#ibc.applications.fee.v1.QueryTotalRecvFeesRequest) | [QueryTotalRecvFeesResponse](#ibc.applications.fee.v1.QueryTotalRecvFeesResponse) | TotalRecvFees returns the total receive fees for a packet given its identifier | GET|/ibc/apps/fee/v1/total_recv_fees/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| +| `TotalAckFees` | [QueryTotalAckFeesRequest](#ibc.applications.fee.v1.QueryTotalAckFeesRequest) | [QueryTotalAckFeesResponse](#ibc.applications.fee.v1.QueryTotalAckFeesResponse) | TotalAckFees returns the total acknowledgement fees for a packet given its identifier | GET|/ibc/apps/fee/v1/total_ack_fees/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| diff --git a/modules/apps/29-fee/keeper/grpc_query.go b/modules/apps/29-fee/keeper/grpc_query.go index dfaa5d86a35..dd527f0fe59 100644 --- a/modules/apps/29-fee/keeper/grpc_query.go +++ b/modules/apps/29-fee/keeper/grpc_query.go @@ -91,3 +91,29 @@ func (k Keeper) TotalRecvFees(goCtx context.Context, req *types.QueryTotalRecvFe RecvFees: recvFees, }, nil } + +// TotalAckFees implements the Query/TotalAckFees gRPC method +func (k Keeper) TotalAckFees(goCtx context.Context, req *types.QueryTotalAckFeesRequest) (*types.QueryTotalAckFeesResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + feesInEscrow, found := k.GetFeesInEscrow(ctx, req.PacketId) + if !found { + return nil, status.Errorf( + codes.NotFound, + sdkerrors.Wrapf(types.ErrFeeNotFound, "channel: %s, port: %s, sequence: %d", req.PacketId.ChannelId, req.PacketId.PortId, req.PacketId.Sequence).Error(), + ) + } + + var ackFees sdk.Coins + for _, packetFee := range feesInEscrow.PacketFees { + ackFees = ackFees.Add(packetFee.Fee.AckFee...) + } + + return &types.QueryTotalAckFeesResponse{ + AckFees: ackFees, + }, nil +} diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index c9df54665f0..5bcb7d31416 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -203,3 +203,67 @@ func (suite *KeeperTestSuite) TestQueryTotalRecvFees() { }) } } + +func (suite *KeeperTestSuite) TestQueryTotalAckFees() { + var ( + req *types.QueryTotalAckFeesRequest + ) + + testCases := []struct { + name string + malleate func() + expPass bool + }{ + { + "success", + func() {}, + true, + }, + { + "packet not found", + func() { + req.PacketId = channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 100) + }, + false, + }, + } + + for _, tc := range testCases { + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) + + packetID := channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1) + + fee := types.NewFee(defaultReceiveFee, defaultAckFee, defaultTimeoutFee) + packetFee := types.NewPacketFee(fee, suite.chainA.SenderAccount.GetAddress().String(), []string(nil)) + + for i := 0; i < 3; i++ { + // escrow three packet fees for the same packet + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) + suite.Require().NoError(err) + } + + req = &types.QueryTotalAckFeesRequest{ + PacketId: packetID, + } + + tc.malleate() + + ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) + res, err := suite.queryClient.TotalAckFees(ctx, req) + + if tc.expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + + // expected total is three times the default acknowledgement fee + expectedFees := defaultAckFee.Add(defaultAckFee...).Add(defaultAckFee...) + suite.Require().Equal(expectedFees, res.AckFees) + } else { + suite.Require().Error(err) + } + }) + } +} diff --git a/modules/apps/29-fee/types/query.pb.go b/modules/apps/29-fee/types/query.pb.go index fdbaa9766c8..a4c5b0ee658 100644 --- a/modules/apps/29-fee/types/query.pb.go +++ b/modules/apps/29-fee/types/query.pb.go @@ -327,6 +327,98 @@ func (m *QueryTotalRecvFeesResponse) GetRecvFees() github_com_cosmos_cosmos_sdk_ return nil } +// QueryTotalAckFeesRequest defines the request type for the TotalAckFees rpc +type QueryTotalAckFeesRequest struct { + // the packet identifier for the associated fees + PacketId types.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id"` +} + +func (m *QueryTotalAckFeesRequest) Reset() { *m = QueryTotalAckFeesRequest{} } +func (m *QueryTotalAckFeesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryTotalAckFeesRequest) ProtoMessage() {} +func (*QueryTotalAckFeesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{6} +} +func (m *QueryTotalAckFeesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTotalAckFeesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTotalAckFeesRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryTotalAckFeesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTotalAckFeesRequest.Merge(m, src) +} +func (m *QueryTotalAckFeesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryTotalAckFeesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTotalAckFeesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTotalAckFeesRequest proto.InternalMessageInfo + +func (m *QueryTotalAckFeesRequest) GetPacketId() types.PacketId { + if m != nil { + return m.PacketId + } + return types.PacketId{} +} + +// QueryTotalAckFeesResponse defines the response type for the TotalAckFees rpc +type QueryTotalAckFeesResponse struct { + // the total packet acknowledgement fees + AckFees github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=ack_fees,json=ackFees,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"ack_fees" yaml:"ack_fees"` +} + +func (m *QueryTotalAckFeesResponse) Reset() { *m = QueryTotalAckFeesResponse{} } +func (m *QueryTotalAckFeesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryTotalAckFeesResponse) ProtoMessage() {} +func (*QueryTotalAckFeesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{7} +} +func (m *QueryTotalAckFeesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTotalAckFeesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTotalAckFeesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryTotalAckFeesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTotalAckFeesResponse.Merge(m, src) +} +func (m *QueryTotalAckFeesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryTotalAckFeesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTotalAckFeesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTotalAckFeesResponse proto.InternalMessageInfo + +func (m *QueryTotalAckFeesResponse) GetAckFees() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.AckFees + } + return nil +} + func init() { proto.RegisterType((*QueryIncentivizedPacketsRequest)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketsRequest") proto.RegisterType((*QueryIncentivizedPacketsResponse)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketsResponse") @@ -334,6 +426,8 @@ func init() { proto.RegisterType((*QueryIncentivizedPacketResponse)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketResponse") proto.RegisterType((*QueryTotalRecvFeesRequest)(nil), "ibc.applications.fee.v1.QueryTotalRecvFeesRequest") proto.RegisterType((*QueryTotalRecvFeesResponse)(nil), "ibc.applications.fee.v1.QueryTotalRecvFeesResponse") + proto.RegisterType((*QueryTotalAckFeesRequest)(nil), "ibc.applications.fee.v1.QueryTotalAckFeesRequest") + proto.RegisterType((*QueryTotalAckFeesResponse)(nil), "ibc.applications.fee.v1.QueryTotalAckFeesResponse") } func init() { @@ -341,51 +435,56 @@ func init() { } var fileDescriptor_0638a8a78ca2503c = []byte{ - // 698 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x95, 0x41, 0x6b, 0x13, 0x4d, - 0x18, 0xc7, 0x33, 0x7d, 0xdb, 0x97, 0x76, 0xfa, 0xbe, 0x20, 0xd3, 0x82, 0x6d, 0xd0, 0x4d, 0xba, - 0xa2, 0x06, 0x21, 0x3b, 0x34, 0x45, 0x6c, 0x3d, 0x49, 0x95, 0x62, 0x4f, 0xd6, 0xe0, 0x49, 0x90, - 0xb0, 0x3b, 0x3b, 0xd9, 0x0c, 0x4d, 0x76, 0xb6, 0x99, 0xc9, 0x62, 0x6b, 0xeb, 0xa1, 0x20, 0x82, - 0xf4, 0x20, 0x78, 0xf3, 0x23, 0xf8, 0x0d, 0xfc, 0x06, 0xbd, 0x08, 0x05, 0x2f, 0x9e, 0xaa, 0xb4, - 0x7e, 0x02, 0x4f, 0x1e, 0x65, 0x66, 0x67, 0xd7, 0x2d,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, 0x38, 0xb2, 0xc0, 0x97, 0x23, - 0x0b, 0xbc, 0x3e, 0xb6, 0x0a, 0x07, 0xc7, 0x56, 0xe1, 0xd3, 0xb1, 0x55, 0x78, 0x7c, 0xb3, 0xff, - 0x74, 0x30, 0x8f, 0x54, 0x03, 0x8e, 0xe3, 0x05, 0xdc, 0xe1, 0x7e, 0xaf, 0x4d, 0x45, 0x02, 0x5c, - 0x5b, 0xaa, 0x2a, 0x66, 0x7d, 0x60, 0xbc, 0x7f, 0xf5, 0x3f, 0xca, 0xc2, 0x8f, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xdd, 0x79, 0x2b, 0x91, 0x57, 0x07, 0x00, 0x00, + // 775 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x41, 0x6f, 0xd3, 0x48, + 0x14, 0xce, 0x74, 0xbb, 0xdb, 0x76, 0xda, 0xd5, 0xae, 0xa6, 0x95, 0x36, 0x8d, 0x76, 0x9d, 0xd4, + 0xab, 0x5d, 0x22, 0xa4, 0x78, 0x94, 0x54, 0x88, 0x96, 0x13, 0xb4, 0xa8, 0xa2, 0x27, 0x4a, 0xc4, + 0x09, 0x81, 0x22, 0x67, 0x3c, 0x71, 0x46, 0x49, 0x3c, 0x6e, 0xec, 0x18, 0x52, 0x5a, 0x0e, 0x95, + 0x10, 0x12, 0xea, 0x01, 0x09, 0x89, 0x03, 0x3f, 0x81, 0x7f, 0xc0, 0x9d, 0x43, 0x8f, 0x95, 0xb8, + 0x70, 0x2a, 0xa8, 0xe5, 0x17, 0x20, 0x0e, 0x1c, 0xd1, 0x8c, 0xc7, 0xae, 0xab, 0x24, 0x90, 0x54, + 0xed, 0x29, 0xf6, 0xbc, 0xef, 0xbd, 0xf7, 0x7d, 0x9f, 0xe7, 0x3d, 0x05, 0xfe, 0xcb, 0xaa, 0x04, + 0x9b, 0xae, 0xdb, 0x64, 0xc4, 0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, 0xa1, 0xa0, 0x47, 0xbe, 0x2f, 0xf0, 0x95, 0x78, 0x4e, + 0x2f, 0x48, 0xfa, 0x57, 0x00, 0x67, 0x92, 0x33, 0x86, 0x8a, 0x43, 0xa8, 0x38, 0x3d, 0xee, 0x99, + 0xd2, 0x28, 0x29, 0x4a, 0xf7, 0x8e, 0xd4, 0xfd, 0x10, 0x75, 0x06, 0xe8, 0x8e, 0xc6, 0xf4, 0x62, + 0x64, 0xaf, 0xdc, 0xde, 0x3f, 0xd2, 0xc0, 0xc1, 0x91, 0x06, 0x3e, 0x1d, 0x69, 0xe0, 0xc5, 0xb1, + 0x96, 0x3a, 0x38, 0xd6, 0x52, 0x1f, 0x8e, 0xb5, 0xd4, 0xbd, 0x2b, 0xbd, 0x3b, 0x81, 0x55, 0x49, + 0xc1, 0xe6, 0x38, 0x58, 0xc4, 0x2d, 0x6e, 0x75, 0x9a, 0xd4, 0x0b, 0xf9, 0x96, 0x96, 0x0b, 0x82, + 0xb2, 0x5c, 0x13, 0xd5, 0xdf, 0xe4, 0xff, 0x87, 0xc5, 0xef, 0x01, 0x00, 0x00, 0xff, 0xff, 0x2b, + 0xa4, 0xf4, 0xa9, 0x45, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -407,6 +506,8 @@ type QueryClient interface { IncentivizedPacket(ctx context.Context, in *QueryIncentivizedPacketRequest, opts ...grpc.CallOption) (*QueryIncentivizedPacketResponse, error) // TotalRecvFees returns the total receive fees for a packet given its identifier TotalRecvFees(ctx context.Context, in *QueryTotalRecvFeesRequest, opts ...grpc.CallOption) (*QueryTotalRecvFeesResponse, error) + // TotalAckFees returns the total acknowledgement fees for a packet given its identifier + TotalAckFees(ctx context.Context, in *QueryTotalAckFeesRequest, opts ...grpc.CallOption) (*QueryTotalAckFeesResponse, error) } type queryClient struct { @@ -444,6 +545,15 @@ func (c *queryClient) TotalRecvFees(ctx context.Context, in *QueryTotalRecvFeesR return out, nil } +func (c *queryClient) TotalAckFees(ctx context.Context, in *QueryTotalAckFeesRequest, opts ...grpc.CallOption) (*QueryTotalAckFeesResponse, error) { + out := new(QueryTotalAckFeesResponse) + err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Query/TotalAckFees", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Gets all incentivized packets @@ -453,6 +563,8 @@ type QueryServer interface { IncentivizedPacket(context.Context, *QueryIncentivizedPacketRequest) (*QueryIncentivizedPacketResponse, error) // TotalRecvFees returns the total receive fees for a packet given its identifier TotalRecvFees(context.Context, *QueryTotalRecvFeesRequest) (*QueryTotalRecvFeesResponse, error) + // TotalAckFees returns the total acknowledgement fees for a packet given its identifier + TotalAckFees(context.Context, *QueryTotalAckFeesRequest) (*QueryTotalAckFeesResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -468,6 +580,9 @@ func (*UnimplementedQueryServer) IncentivizedPacket(ctx context.Context, req *Qu func (*UnimplementedQueryServer) TotalRecvFees(ctx context.Context, req *QueryTotalRecvFeesRequest) (*QueryTotalRecvFeesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method TotalRecvFees not implemented") } +func (*UnimplementedQueryServer) TotalAckFees(ctx context.Context, req *QueryTotalAckFeesRequest) (*QueryTotalAckFeesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TotalAckFees not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -527,6 +642,24 @@ func _Query_TotalRecvFees_Handler(srv interface{}, ctx context.Context, dec func return interceptor(ctx, in, info, handler) } +func _Query_TotalAckFees_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryTotalAckFeesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).TotalAckFees(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.applications.fee.v1.Query/TotalAckFees", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).TotalAckFees(ctx, req.(*QueryTotalAckFeesRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.applications.fee.v1.Query", HandlerType: (*QueryServer)(nil), @@ -543,6 +676,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "TotalRecvFees", Handler: _Query_TotalRecvFees_Handler, }, + { + MethodName: "TotalAckFees", + Handler: _Query_TotalAckFees_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/applications/fee/v1/query.proto", @@ -766,6 +903,76 @@ func (m *QueryTotalRecvFeesResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } +func (m *QueryTotalAckFeesRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryTotalAckFeesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTotalAckFeesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryTotalAckFeesResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryTotalAckFeesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTotalAckFeesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.AckFees) > 0 { + for iNdEx := len(m.AckFees) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.AckFees[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -859,6 +1066,32 @@ func (m *QueryTotalRecvFeesResponse) Size() (n int) { return n } +func (m *QueryTotalAckFeesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.PacketId.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryTotalAckFeesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.AckFees) > 0 { + for _, e := range m.AckFees { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1406,6 +1639,173 @@ func (m *QueryTotalRecvFeesResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryTotalAckFeesRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryTotalAckFeesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTotalAckFeesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryTotalAckFeesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryTotalAckFeesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTotalAckFeesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AckFees", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AckFees = append(m.AckFees, types1.Coin{}) + if err := m.AckFees[len(m.AckFees)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/apps/29-fee/types/query.pb.gw.go b/modules/apps/29-fee/types/query.pb.gw.go index e9626d2a08e..b2e40834aa8 100644 --- a/modules/apps/29-fee/types/query.pb.gw.go +++ b/modules/apps/29-fee/types/query.pb.gw.go @@ -299,6 +299,122 @@ func local_request_Query_TotalRecvFees_0(ctx context.Context, marshaler runtime. } +var ( + filter_Query_TotalAckFees_0 = &utilities.DoubleArray{Encoding: map[string]int{"packet_id": 0, "port_id": 1, "channel_id": 2, "sequence": 3}, Base: []int{1, 1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 2, 2, 2, 3, 4, 5}} +) + +func request_Query_TotalAckFees_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTotalAckFeesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["packet_id.port_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) + } + + val, ok = pathParams["packet_id.channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) + } + + val, ok = pathParams["packet_id.sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TotalAckFees_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.TotalAckFees(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_TotalAckFees_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTotalAckFeesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["packet_id.port_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) + } + + val, ok = pathParams["packet_id.channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) + } + + val, ok = pathParams["packet_id.sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TotalAckFees_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.TotalAckFees(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -365,6 +481,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_TotalAckFees_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_TotalAckFees_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TotalAckFees_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -466,6 +602,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_TotalAckFees_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_TotalAckFees_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TotalAckFees_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -475,6 +631,8 @@ var ( pattern_Query_IncentivizedPacket_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "incentivized_packet", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_TotalRecvFees_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "total_recv_fees", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_TotalAckFees_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "total_ack_fees", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -483,4 +641,6 @@ var ( forward_Query_IncentivizedPacket_0 = runtime.ForwardResponseMessage forward_Query_TotalRecvFees_0 = runtime.ForwardResponseMessage + + forward_Query_TotalAckFees_0 = runtime.ForwardResponseMessage ) diff --git a/proto/ibc/applications/fee/v1/query.proto b/proto/ibc/applications/fee/v1/query.proto index 65b677c2fdb..e6ccb64fc77 100644 --- a/proto/ibc/applications/fee/v1/query.proto +++ b/proto/ibc/applications/fee/v1/query.proto @@ -31,6 +31,12 @@ service Query { option (google.api.http).get = "/ibc/apps/fee/v1/total_recv_fees/port/{packet_id.port_id}/channel/" "{packet_id.channel_id}/sequence/{packet_id.sequence}"; } + + // TotalAckFees returns the total acknowledgement fees for a packet given its identifier + rpc TotalAckFees(QueryTotalAckFeesRequest) returns (QueryTotalAckFeesResponse) { + option (google.api.http).get = "/ibc/apps/fee/v1/total_ack_fees/port/{packet_id.port_id}/channel/" + "{packet_id.channel_id}/sequence/{packet_id.sequence}"; + } } // QueryIncentivizedPacketsRequest is the request type for querying for all incentivized packets @@ -76,3 +82,19 @@ message QueryTotalRecvFeesResponse { (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; } + +// QueryTotalAckFeesRequest defines the request type for the TotalAckFees rpc +message QueryTotalAckFeesRequest { + // the packet identifier for the associated fees + ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.nullable) = false]; +} + +// QueryTotalAckFeesResponse defines the response type for the TotalAckFees rpc +message QueryTotalAckFeesResponse { + // the total packet acknowledgement fees + repeated cosmos.base.v1beta1.Coin ack_fees = 1 [ + (gogoproto.moretags) = "yaml:\"ack_fees\"", + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} From 91370849ee495023c93c4ed35b3d35bb29d317e2 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 2 Mar 2022 10:22:35 +0000 Subject: [PATCH 67/79] feat: grpc query total timeout fees (#1033) * adding query for total packet recv fees to proto query server * adding total packet recv fee query impl and tests * updating doc comments * adding protos and codegen * adding total ack fees query and tests * adding protos and codegen * adding query total timeout fees and tests * fixing protodoc comment * fixing protodoc comment --- docs/ibc/proto-docs.md | 33 ++ modules/apps/29-fee/keeper/grpc_query.go | 26 + modules/apps/29-fee/keeper/grpc_query_test.go | 64 +++ modules/apps/29-fee/types/query.pb.go | 500 ++++++++++++++++-- modules/apps/29-fee/types/query.pb.gw.go | 160 ++++++ proto/ibc/applications/fee/v1/query.proto | 22 + 6 files changed, 755 insertions(+), 50 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index d2093dd5c5d..e6bead7e83f 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -53,6 +53,8 @@ - [QueryTotalAckFeesResponse](#ibc.applications.fee.v1.QueryTotalAckFeesResponse) - [QueryTotalRecvFeesRequest](#ibc.applications.fee.v1.QueryTotalRecvFeesRequest) - [QueryTotalRecvFeesResponse](#ibc.applications.fee.v1.QueryTotalRecvFeesResponse) + - [QueryTotalTimeoutFeesRequest](#ibc.applications.fee.v1.QueryTotalTimeoutFeesRequest) + - [QueryTotalTimeoutFeesResponse](#ibc.applications.fee.v1.QueryTotalTimeoutFeesResponse) - [Query](#ibc.applications.fee.v1.Query) @@ -1047,6 +1049,36 @@ QueryTotalRecvFeesResponse defines the response type for the TotalRecvFees rpc + + + +### QueryTotalTimeoutFeesRequest +QueryTotalTimeoutFeesRequest defines the request type for the TotalTimeoutFees rpc + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | the packet identifier for the associated fees | + + + + + + + + +### QueryTotalTimeoutFeesResponse +QueryTotalTimeoutFeesResponse defines the response type for the TotalTimeoutFees rpc + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `timeout_fees` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | the total packet timeout fees | + + + + + @@ -1065,6 +1097,7 @@ Query provides defines the gRPC querier service. | `IncentivizedPacket` | [QueryIncentivizedPacketRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketRequest) | [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) | Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the given packet | GET|/ibc/apps/fee/v1/incentivized_packet/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| | `TotalRecvFees` | [QueryTotalRecvFeesRequest](#ibc.applications.fee.v1.QueryTotalRecvFeesRequest) | [QueryTotalRecvFeesResponse](#ibc.applications.fee.v1.QueryTotalRecvFeesResponse) | TotalRecvFees returns the total receive fees for a packet given its identifier | GET|/ibc/apps/fee/v1/total_recv_fees/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| | `TotalAckFees` | [QueryTotalAckFeesRequest](#ibc.applications.fee.v1.QueryTotalAckFeesRequest) | [QueryTotalAckFeesResponse](#ibc.applications.fee.v1.QueryTotalAckFeesResponse) | TotalAckFees returns the total acknowledgement fees for a packet given its identifier | GET|/ibc/apps/fee/v1/total_ack_fees/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| +| `TotalTimeoutFees` | [QueryTotalTimeoutFeesRequest](#ibc.applications.fee.v1.QueryTotalTimeoutFeesRequest) | [QueryTotalTimeoutFeesResponse](#ibc.applications.fee.v1.QueryTotalTimeoutFeesResponse) | TotalTimeoutFees returns the total timeout fees for a packet given its identifier | GET|/ibc/apps/fee/v1/total_timeout_fees/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| diff --git a/modules/apps/29-fee/keeper/grpc_query.go b/modules/apps/29-fee/keeper/grpc_query.go index dd527f0fe59..54969471086 100644 --- a/modules/apps/29-fee/keeper/grpc_query.go +++ b/modules/apps/29-fee/keeper/grpc_query.go @@ -117,3 +117,29 @@ func (k Keeper) TotalAckFees(goCtx context.Context, req *types.QueryTotalAckFees AckFees: ackFees, }, nil } + +// TotalTimeoutFees implements the Query/TotalTimeoutFees gRPC method +func (k Keeper) TotalTimeoutFees(goCtx context.Context, req *types.QueryTotalTimeoutFeesRequest) (*types.QueryTotalTimeoutFeesResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + feesInEscrow, found := k.GetFeesInEscrow(ctx, req.PacketId) + if !found { + return nil, status.Errorf( + codes.NotFound, + sdkerrors.Wrapf(types.ErrFeeNotFound, "channel: %s, port: %s, sequence: %d", req.PacketId.ChannelId, req.PacketId.PortId, req.PacketId.Sequence).Error(), + ) + } + + var timeoutFees sdk.Coins + for _, packetFee := range feesInEscrow.PacketFees { + timeoutFees = timeoutFees.Add(packetFee.Fee.TimeoutFee...) + } + + return &types.QueryTotalTimeoutFeesResponse{ + TimeoutFees: timeoutFees, + }, nil +} diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index 5bcb7d31416..fe06afdc5bd 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -267,3 +267,67 @@ func (suite *KeeperTestSuite) TestQueryTotalAckFees() { }) } } + +func (suite *KeeperTestSuite) TestQueryTotalTimeoutFees() { + var ( + req *types.QueryTotalTimeoutFeesRequest + ) + + testCases := []struct { + name string + malleate func() + expPass bool + }{ + { + "success", + func() {}, + true, + }, + { + "packet not found", + func() { + req.PacketId = channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 100) + }, + false, + }, + } + + for _, tc := range testCases { + suite.Run(tc.name, func() { + suite.SetupTest() // reset + + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) + + packetID := channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1) + + fee := types.NewFee(defaultReceiveFee, defaultAckFee, defaultTimeoutFee) + packetFee := types.NewPacketFee(fee, suite.chainA.SenderAccount.GetAddress().String(), []string(nil)) + + for i := 0; i < 3; i++ { + // escrow three packet fees for the same packet + err := suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) + suite.Require().NoError(err) + } + + req = &types.QueryTotalTimeoutFeesRequest{ + PacketId: packetID, + } + + tc.malleate() + + ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) + res, err := suite.queryClient.TotalTimeoutFees(ctx, req) + + if tc.expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + + // expected total is three times the default acknowledgement fee + expectedFees := defaultTimeoutFee.Add(defaultTimeoutFee...).Add(defaultTimeoutFee...) + suite.Require().Equal(expectedFees, res.TimeoutFees) + } else { + suite.Require().Error(err) + } + }) + } +} diff --git a/modules/apps/29-fee/types/query.pb.go b/modules/apps/29-fee/types/query.pb.go index a4c5b0ee658..b9f241000ab 100644 --- a/modules/apps/29-fee/types/query.pb.go +++ b/modules/apps/29-fee/types/query.pb.go @@ -419,6 +419,98 @@ func (m *QueryTotalAckFeesResponse) GetAckFees() github_com_cosmos_cosmos_sdk_ty return nil } +// QueryTotalTimeoutFeesRequest defines the request type for the TotalTimeoutFees rpc +type QueryTotalTimeoutFeesRequest struct { + // the packet identifier for the associated fees + PacketId types.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id"` +} + +func (m *QueryTotalTimeoutFeesRequest) Reset() { *m = QueryTotalTimeoutFeesRequest{} } +func (m *QueryTotalTimeoutFeesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryTotalTimeoutFeesRequest) ProtoMessage() {} +func (*QueryTotalTimeoutFeesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{8} +} +func (m *QueryTotalTimeoutFeesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTotalTimeoutFeesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTotalTimeoutFeesRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryTotalTimeoutFeesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTotalTimeoutFeesRequest.Merge(m, src) +} +func (m *QueryTotalTimeoutFeesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryTotalTimeoutFeesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTotalTimeoutFeesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTotalTimeoutFeesRequest proto.InternalMessageInfo + +func (m *QueryTotalTimeoutFeesRequest) GetPacketId() types.PacketId { + if m != nil { + return m.PacketId + } + return types.PacketId{} +} + +// QueryTotalTimeoutFeesResponse defines the response type for the TotalTimeoutFees rpc +type QueryTotalTimeoutFeesResponse struct { + // the total packet timeout fees + TimeoutFees github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=timeout_fees,json=timeoutFees,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"timeout_fees" yaml:"timeout_fees"` +} + +func (m *QueryTotalTimeoutFeesResponse) Reset() { *m = QueryTotalTimeoutFeesResponse{} } +func (m *QueryTotalTimeoutFeesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryTotalTimeoutFeesResponse) ProtoMessage() {} +func (*QueryTotalTimeoutFeesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{9} +} +func (m *QueryTotalTimeoutFeesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryTotalTimeoutFeesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryTotalTimeoutFeesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryTotalTimeoutFeesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryTotalTimeoutFeesResponse.Merge(m, src) +} +func (m *QueryTotalTimeoutFeesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryTotalTimeoutFeesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryTotalTimeoutFeesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryTotalTimeoutFeesResponse proto.InternalMessageInfo + +func (m *QueryTotalTimeoutFeesResponse) GetTimeoutFees() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.TimeoutFees + } + return nil +} + func init() { proto.RegisterType((*QueryIncentivizedPacketsRequest)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketsRequest") proto.RegisterType((*QueryIncentivizedPacketsResponse)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketsResponse") @@ -428,6 +520,8 @@ func init() { proto.RegisterType((*QueryTotalRecvFeesResponse)(nil), "ibc.applications.fee.v1.QueryTotalRecvFeesResponse") proto.RegisterType((*QueryTotalAckFeesRequest)(nil), "ibc.applications.fee.v1.QueryTotalAckFeesRequest") proto.RegisterType((*QueryTotalAckFeesResponse)(nil), "ibc.applications.fee.v1.QueryTotalAckFeesResponse") + proto.RegisterType((*QueryTotalTimeoutFeesRequest)(nil), "ibc.applications.fee.v1.QueryTotalTimeoutFeesRequest") + proto.RegisterType((*QueryTotalTimeoutFeesResponse)(nil), "ibc.applications.fee.v1.QueryTotalTimeoutFeesResponse") } func init() { @@ -435,56 +529,61 @@ func init() { } var fileDescriptor_0638a8a78ca2503c = []byte{ - // 775 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x41, 0x6f, 0xd3, 0x48, - 0x14, 0xce, 0x74, 0xbb, 0xdb, 0x76, 0xda, 0xd5, 0xae, 0xa6, 0x95, 0x36, 0x8d, 0x76, 0x9d, 0xd4, - 0xab, 0x5d, 0x22, 0xa4, 0x78, 0x94, 0x54, 0x88, 0x96, 0x13, 0xb4, 0xa8, 0xa2, 0x27, 0x4a, 0xc4, - 0x09, 0x81, 0x22, 0x67, 0x3c, 0x71, 0x46, 0x49, 0x3c, 0x6e, 0xec, 0x18, 0x52, 0x5a, 0x0e, 0x95, - 0x10, 0x12, 0xea, 0x01, 0x09, 0x89, 0x03, 0x3f, 0x81, 0x7f, 0xc0, 0x9d, 0x43, 0x8f, 0x95, 0xb8, - 0x70, 0x2a, 0xa8, 0xe5, 0x17, 0x20, 0x0e, 0x1c, 0xd1, 0x8c, 0xc7, 0xae, 0xab, 0x24, 0x90, 0x54, - 0xed, 0x29, 0xf6, 0xbc, 0xef, 0xbd, 0xf7, 0x7d, 0x9f, 0xe7, 0x3d, 0x05, 0xfe, 0xcb, 0xaa, 0x04, - 0x9b, 0xae, 0xdb, 0x64, 0xc4, 0xf4, 0x19, 0x77, 0x3c, 0x5c, 0xa3, 0x14, 0x07, 0x45, 0xbc, 0xd9, - 0xa1, 0xed, 0xae, 0xe1, 0xb6, 0xb9, 0xcf, 0xd1, 0x5f, 0xac, 0x4a, 0x8c, 0x24, 0xc8, 0xa8, 0x51, - 0x6a, 0x04, 0xc5, 0xcc, 0x9c, 0xcd, 0x6d, 0x2e, 0x31, 0x58, 0x3c, 0x85, 0xf0, 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62, - 0x64, 0xaf, 0xdc, 0xde, 0x3f, 0xd2, 0xc0, 0xc1, 0x91, 0x06, 0x3e, 0x1d, 0x69, 0xe0, 0xc5, 0xb1, - 0x96, 0x3a, 0x38, 0xd6, 0x52, 0x1f, 0x8e, 0xb5, 0xd4, 0xbd, 0x2b, 0xbd, 0x3b, 0x81, 0x55, 0x49, - 0xc1, 0xe6, 0x38, 0x58, 0xc4, 0x2d, 0x6e, 0x75, 0x9a, 0xd4, 0x0b, 0xf9, 0x96, 0x96, 0x0b, 0x82, - 0xb2, 0x5c, 0x13, 0xd5, 0xdf, 0xe4, 0xff, 0x87, 0xc5, 0xef, 0x01, 0x00, 0x00, 0xff, 0xff, 0x2b, - 0xa4, 0xf4, 0xa9, 0x45, 0x09, 0x00, 0x00, + // 853 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xcf, 0x6e, 0xe3, 0x44, + 0x1c, 0xce, 0x84, 0x05, 0xda, 0x49, 0x11, 0xab, 0xc9, 0x4a, 0x64, 0xa3, 0x5d, 0x27, 0x6b, 0x04, + 0x44, 0x48, 0xf1, 0x28, 0xa9, 0x16, 0x76, 0x39, 0x41, 0x17, 0x2d, 0xf4, 0x44, 0x89, 0x7a, 0x42, + 0xa0, 0xe0, 0x8c, 0x27, 0xce, 0x28, 0x89, 0xc7, 0x8d, 0x27, 0x86, 0xf4, 0x0f, 0x12, 0x95, 0x2a, + 0x24, 0xd4, 0x03, 0x12, 0x12, 0x07, 0x5e, 0x00, 0x89, 0x37, 0xe0, 0x0d, 0x7a, 0xe0, 0x50, 0x89, + 0x0b, 0xa7, 0x82, 0x5a, 0x9e, 0x00, 0x71, 0xe0, 0x88, 0x66, 0x3c, 0x76, 0x5c, 0x12, 0x43, 0x52, + 0xb5, 0xa7, 0xd8, 0xf3, 0xfb, 0xf7, 0x7d, 0xdf, 0x8c, 0xbf, 0x09, 0x7c, 0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 0x3c, 0xa7, 0xfe, 0x53, 0xae, 0xff, 0x13, 0x00, 0x00, 0xff, 0xff, 0x9b, 0xa6, 0xbd, + 0x0f, 0x59, 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -508,6 +607,8 @@ type QueryClient interface { TotalRecvFees(ctx context.Context, in *QueryTotalRecvFeesRequest, opts ...grpc.CallOption) (*QueryTotalRecvFeesResponse, error) // TotalAckFees returns the total acknowledgement fees for a packet given its identifier TotalAckFees(ctx context.Context, in *QueryTotalAckFeesRequest, opts ...grpc.CallOption) (*QueryTotalAckFeesResponse, error) + // TotalTimeoutFees returns the total timeout fees for a packet given its identifier + TotalTimeoutFees(ctx context.Context, in *QueryTotalTimeoutFeesRequest, opts ...grpc.CallOption) (*QueryTotalTimeoutFeesResponse, error) } type queryClient struct { @@ -554,6 +655,15 @@ func (c *queryClient) TotalAckFees(ctx context.Context, in *QueryTotalAckFeesReq return out, nil } +func (c *queryClient) TotalTimeoutFees(ctx context.Context, in *QueryTotalTimeoutFeesRequest, opts ...grpc.CallOption) (*QueryTotalTimeoutFeesResponse, error) { + out := new(QueryTotalTimeoutFeesResponse) + err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Query/TotalTimeoutFees", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Gets all incentivized packets @@ -565,6 +675,8 @@ type QueryServer interface { TotalRecvFees(context.Context, *QueryTotalRecvFeesRequest) (*QueryTotalRecvFeesResponse, error) // TotalAckFees returns the total acknowledgement fees for a packet given its identifier TotalAckFees(context.Context, *QueryTotalAckFeesRequest) (*QueryTotalAckFeesResponse, error) + // TotalTimeoutFees returns the total timeout fees for a packet given its identifier + TotalTimeoutFees(context.Context, *QueryTotalTimeoutFeesRequest) (*QueryTotalTimeoutFeesResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -583,6 +695,9 @@ func (*UnimplementedQueryServer) TotalRecvFees(ctx context.Context, req *QueryTo func (*UnimplementedQueryServer) TotalAckFees(ctx context.Context, req *QueryTotalAckFeesRequest) (*QueryTotalAckFeesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method TotalAckFees not implemented") } +func (*UnimplementedQueryServer) TotalTimeoutFees(ctx context.Context, req *QueryTotalTimeoutFeesRequest) (*QueryTotalTimeoutFeesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TotalTimeoutFees not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -660,6 +775,24 @@ func _Query_TotalAckFees_Handler(srv interface{}, ctx context.Context, dec func( return interceptor(ctx, in, info, handler) } +func _Query_TotalTimeoutFees_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryTotalTimeoutFeesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).TotalTimeoutFees(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.applications.fee.v1.Query/TotalTimeoutFees", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).TotalTimeoutFees(ctx, req.(*QueryTotalTimeoutFeesRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "ibc.applications.fee.v1.Query", HandlerType: (*QueryServer)(nil), @@ -680,6 +813,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "TotalAckFees", Handler: _Query_TotalAckFees_Handler, }, + { + MethodName: "TotalTimeoutFees", + Handler: _Query_TotalTimeoutFees_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "ibc/applications/fee/v1/query.proto", @@ -973,6 +1110,76 @@ func (m *QueryTotalAckFeesResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } +func (m *QueryTotalTimeoutFeesRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryTotalTimeoutFeesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTotalTimeoutFeesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryTotalTimeoutFeesResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryTotalTimeoutFeesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryTotalTimeoutFeesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TimeoutFees) > 0 { + for iNdEx := len(m.TimeoutFees) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TimeoutFees[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1092,6 +1299,32 @@ func (m *QueryTotalAckFeesResponse) Size() (n int) { return n } +func (m *QueryTotalTimeoutFeesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.PacketId.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryTotalTimeoutFeesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.TimeoutFees) > 0 { + for _, e := range m.TimeoutFees { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1806,6 +2039,173 @@ func (m *QueryTotalAckFeesResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryTotalTimeoutFeesRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryTotalTimeoutFeesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTotalTimeoutFeesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryTotalTimeoutFeesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryTotalTimeoutFeesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryTotalTimeoutFeesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TimeoutFees", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TimeoutFees = append(m.TimeoutFees, types1.Coin{}) + if err := m.TimeoutFees[len(m.TimeoutFees)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/modules/apps/29-fee/types/query.pb.gw.go b/modules/apps/29-fee/types/query.pb.gw.go index b2e40834aa8..172967a9625 100644 --- a/modules/apps/29-fee/types/query.pb.gw.go +++ b/modules/apps/29-fee/types/query.pb.gw.go @@ -415,6 +415,122 @@ func local_request_Query_TotalAckFees_0(ctx context.Context, marshaler runtime.M } +var ( + filter_Query_TotalTimeoutFees_0 = &utilities.DoubleArray{Encoding: map[string]int{"packet_id": 0, "port_id": 1, "channel_id": 2, "sequence": 3}, Base: []int{1, 1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 2, 2, 2, 3, 4, 5}} +) + +func request_Query_TotalTimeoutFees_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTotalTimeoutFeesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["packet_id.port_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) + } + + val, ok = pathParams["packet_id.channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) + } + + val, ok = pathParams["packet_id.sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TotalTimeoutFees_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.TotalTimeoutFees(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_TotalTimeoutFees_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryTotalTimeoutFeesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["packet_id.port_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.port_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.port_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.port_id", err) + } + + val, ok = pathParams["packet_id.channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.channel_id") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.channel_id", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.channel_id", err) + } + + val, ok = pathParams["packet_id.sequence"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "packet_id.sequence") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "packet_id.sequence", val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "packet_id.sequence", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TotalTimeoutFees_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.TotalTimeoutFees(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -501,6 +617,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_TotalTimeoutFees_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_TotalTimeoutFees_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TotalTimeoutFees_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -622,6 +758,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_TotalTimeoutFees_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_TotalTimeoutFees_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_TotalTimeoutFees_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -633,6 +789,8 @@ var ( pattern_Query_TotalRecvFees_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "total_recv_fees", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_TotalAckFees_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "total_ack_fees", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_TotalTimeoutFees_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "total_timeout_fees", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -643,4 +801,6 @@ var ( forward_Query_TotalRecvFees_0 = runtime.ForwardResponseMessage forward_Query_TotalAckFees_0 = runtime.ForwardResponseMessage + + forward_Query_TotalTimeoutFees_0 = runtime.ForwardResponseMessage ) diff --git a/proto/ibc/applications/fee/v1/query.proto b/proto/ibc/applications/fee/v1/query.proto index e6ccb64fc77..8cbb51859a3 100644 --- a/proto/ibc/applications/fee/v1/query.proto +++ b/proto/ibc/applications/fee/v1/query.proto @@ -37,6 +37,12 @@ service Query { option (google.api.http).get = "/ibc/apps/fee/v1/total_ack_fees/port/{packet_id.port_id}/channel/" "{packet_id.channel_id}/sequence/{packet_id.sequence}"; } + + // TotalTimeoutFees returns the total timeout fees for a packet given its identifier + rpc TotalTimeoutFees(QueryTotalTimeoutFeesRequest) returns (QueryTotalTimeoutFeesResponse) { + option (google.api.http).get = "/ibc/apps/fee/v1/total_timeout_fees/port/{packet_id.port_id}/channel/" + "{packet_id.channel_id}/sequence/{packet_id.sequence}"; + } } // QueryIncentivizedPacketsRequest is the request type for querying for all incentivized packets @@ -98,3 +104,19 @@ message QueryTotalAckFeesResponse { (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; } + +// QueryTotalTimeoutFeesRequest defines the request type for the TotalTimeoutFees rpc +message QueryTotalTimeoutFeesRequest { + // the packet identifier for the associated fees + ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.nullable) = false]; +} + +// QueryTotalTimeoutFeesResponse defines the response type for the TotalTimeoutFees rpc +message QueryTotalTimeoutFeesResponse { + // the total packet timeout fees + repeated cosmos.base.v1beta1.Coin timeout_fees = 1 [ + (gogoproto.moretags) = "yaml:\"timeout_fees\"", + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} From d788adf967634a33a2324ad7b9f45dc865e4028c Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Wed, 2 Mar 2022 15:14:23 +0000 Subject: [PATCH 68/79] feat: adding clis for total ack and timeout queries (#1043) --- modules/apps/29-fee/client/cli/query.go | 94 ++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) diff --git a/modules/apps/29-fee/client/cli/query.go b/modules/apps/29-fee/client/cli/query.go index 1413ae001cb..95bb0959ba7 100644 --- a/modules/apps/29-fee/client/cli/query.go +++ b/modules/apps/29-fee/client/cli/query.go @@ -19,7 +19,7 @@ func GetCmdTotalRecvFees() *cobra.Command { Short: "Query the total receive fees for a packet", Long: "Query the total receive fees for a packet", Args: cobra.ExactArgs(3), - Example: fmt.Sprintf("%s query ibc-fee transfer channel-5 100", version.AppName), + Example: fmt.Sprintf("%s query ibc-fee total-recv-fees transfer channel-5 100", version.AppName), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -57,3 +57,95 @@ func GetCmdTotalRecvFees() *cobra.Command { return cmd } + +// GetCmdTotalAckFees returns the command handler for the Query/TotalAckFees rpc. +func GetCmdTotalAckFees() *cobra.Command { + cmd := &cobra.Command{ + Use: "total-ack-fees [port-id] [channel-id] [sequence]", + Short: "Query the total acknowledgement fees for a packet", + Long: "Query the total acknowledgement fees for a packet", + Args: cobra.ExactArgs(3), + Example: fmt.Sprintf("%s query ibc-fee total-ack-fees transfer channel-5 100", version.AppName), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + portID, channelID := args[0], args[1] + seq, err := strconv.ParseUint(args[2], 10, 64) + if err != nil { + return err + } + + packetID := channeltypes.NewPacketId(channelID, portID, seq) + + if err := packetID.Validate(); err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + req := &types.QueryTotalAckFeesRequest{ + PacketId: packetID, + } + + res, err := queryClient.TotalAckFees(cmd.Context(), req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +// GetCmdTotalTimeoutFees returns the command handler for the Query/TotalTimeoutFees rpc. +func GetCmdTotalTimeoutFees() *cobra.Command { + cmd := &cobra.Command{ + Use: "total-timeout-fees [port-id] [channel-id] [sequence]", + Short: "Query the total timeout fees for a packet", + Long: "Query the total timeout fees for a packet", + Args: cobra.ExactArgs(3), + Example: fmt.Sprintf("%s query ibc-fee total-timeout-fees transfer channel-5 100", version.AppName), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + portID, channelID := args[0], args[1] + seq, err := strconv.ParseUint(args[2], 10, 64) + if err != nil { + return err + } + + packetID := channeltypes.NewPacketId(channelID, portID, seq) + + if err := packetID.Validate(); err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + req := &types.QueryTotalTimeoutFeesRequest{ + PacketId: packetID, + } + + res, err := queryClient.TotalTimeoutFees(cmd.Context(), req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} From 478db4ffdb54de8ffe0e7257c1f5475204faff69 Mon Sep 17 00:00:00 2001 From: Charly Date: Wed, 2 Mar 2022 16:49:40 +0100 Subject: [PATCH 69/79] add ParseKeyForwardRelayerAddress function + test (#1046) --- modules/apps/29-fee/keeper/keeper.go | 41 +++++++++++--------------- modules/apps/29-fee/types/keys.go | 20 ++++++++++++- modules/apps/29-fee/types/keys_test.go | 40 +++++++++++++++++++++++-- 3 files changed, 75 insertions(+), 26 deletions(-) diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index 9b7583ea055..4a3dfbdeb4a 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -1,7 +1,6 @@ package keeper import ( - "strconv" "strings" "github.com/cosmos/cosmos-sdk/codec" @@ -178,15 +177,15 @@ func (k Keeper) GetAllRelayerAddresses(ctx sdk.Context) []types.RegisteredRelaye } // SetRelayerAddressForAsyncAck sets the forward relayer address during OnRecvPacket in case of async acknowledgement -func (k Keeper) SetRelayerAddressForAsyncAck(ctx sdk.Context, packetId channeltypes.PacketId, address string) { +func (k Keeper) SetRelayerAddressForAsyncAck(ctx sdk.Context, packetID channeltypes.PacketId, address string) { store := ctx.KVStore(k.storeKey) - store.Set(types.KeyForwardRelayerAddress(packetId), []byte(address)) + store.Set(types.KeyForwardRelayerAddress(packetID), []byte(address)) } // GetRelayerAddressForAsyncAck gets forward relayer address for a particular packet -func (k Keeper) GetRelayerAddressForAsyncAck(ctx sdk.Context, packetId channeltypes.PacketId) (string, bool) { +func (k Keeper) GetRelayerAddressForAsyncAck(ctx sdk.Context, packetID channeltypes.PacketId) (string, bool) { store := ctx.KVStore(k.storeKey) - key := types.KeyForwardRelayerAddress(packetId) + key := types.KeyForwardRelayerAddress(packetID) if !store.Has(key) { return "", false } @@ -203,18 +202,14 @@ func (k Keeper) GetAllForwardRelayerAddresses(ctx sdk.Context) []types.ForwardRe var forwardRelayerAddr []types.ForwardRelayerAddress for ; iterator.Valid(); iterator.Next() { - keySplit := strings.Split(string(iterator.Key()), "/") - - seq, err := strconv.ParseUint(keySplit[3], 0, 64) + packetID, err := types.ParseKeyForwardRelayerAddress(string(iterator.Key())) if err != nil { - panic("failed to parse packet sequence in forward relayer address mapping") + panic(err) } - packetId := channeltypes.NewPacketId(keySplit[2], keySplit[1], seq) - addr := types.ForwardRelayerAddress{ Address: string(iterator.Value()), - PacketId: packetId, + PacketId: packetID, } forwardRelayerAddr = append(forwardRelayerAddr, addr) @@ -223,10 +218,10 @@ func (k Keeper) GetAllForwardRelayerAddresses(ctx sdk.Context) []types.ForwardRe return forwardRelayerAddr } -// Deletes the forwardRelayerAddr associated with the packetId -func (k Keeper) DeleteForwardRelayerAddress(ctx sdk.Context, packetId channeltypes.PacketId) { +// Deletes the forwardRelayerAddr associated with the packetID +func (k Keeper) DeleteForwardRelayerAddress(ctx sdk.Context, packetID channeltypes.PacketId) { store := ctx.KVStore(k.storeKey) - key := types.KeyForwardRelayerAddress(packetId) + key := types.KeyForwardRelayerAddress(packetID) store.Delete(key) } @@ -238,9 +233,9 @@ func (k Keeper) SetFeeInEscrow(ctx sdk.Context, fee types.IdentifiedPacketFee) { } // Gets a Fee for a given packet -func (k Keeper) GetFeeInEscrow(ctx sdk.Context, packetId channeltypes.PacketId) (types.IdentifiedPacketFee, bool) { +func (k Keeper) GetFeeInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) (types.IdentifiedPacketFee, bool) { store := ctx.KVStore(k.storeKey) - key := types.KeyFeeInEscrow(packetId) + key := types.KeyFeeInEscrow(packetID) bz := store.Get(key) if bz == nil { return types.IdentifiedPacketFee{}, false @@ -270,7 +265,7 @@ func (k Keeper) HasFeesInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) return store.Has(key) } -// SetFeesInEscrow sets the given packet fees in escrow keyed by the packet identifier +// SetFeesInEscrow sets the given packet fees in escrow keyed by the packetID func (k Keeper) SetFeesInEscrow(ctx sdk.Context, packetID channeltypes.PacketId, fees types.PacketFees) { store := ctx.KVStore(k.storeKey) bz := k.MustMarshalFees(fees) @@ -314,17 +309,17 @@ func (k Keeper) IterateChannelFeesInEscrow(ctx sdk.Context, portID, channelID st } } -// Deletes the fee associated with the given packetId -func (k Keeper) DeleteFeeInEscrow(ctx sdk.Context, packetId channeltypes.PacketId) { +// Deletes the fee associated with the given packetID +func (k Keeper) DeleteFeeInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) { store := ctx.KVStore(k.storeKey) - key := types.KeyFeeInEscrow(packetId) + key := types.KeyFeeInEscrow(packetID) store.Delete(key) } // HasFeeInEscrow returns true if there is a Fee still to be escrowed for a given packet -func (k Keeper) HasFeeInEscrow(ctx sdk.Context, packetId channeltypes.PacketId) bool { +func (k Keeper) HasFeeInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) bool { store := ctx.KVStore(k.storeKey) - key := types.KeyFeeInEscrow(packetId) + key := types.KeyFeeInEscrow(packetID) return store.Has(key) } diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index f39cd9b5d44..e619bde8806 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -78,7 +78,25 @@ func KeyCounterpartyRelayer(address, channelID string) []byte { // KeyForwardRelayerAddress returns the key for packetID -> forwardAddress mapping func KeyForwardRelayerAddress(packetId channeltypes.PacketId) []byte { - return []byte(fmt.Sprintf("%s/%s/%s/%d/", ForwardRelayerPrefix, packetId.PortId, packetId.ChannelId, packetId.Sequence)) + return []byte(fmt.Sprintf("%s/%s/%s/%d", ForwardRelayerPrefix, packetId.PortId, packetId.ChannelId, packetId.Sequence)) +} + +// ParseKeyForwardRelayerAddress parses the key used to store the forward relayer address and returns the packetID +func ParseKeyForwardRelayerAddress(key string) (channeltypes.PacketId, error) { + keySplit := strings.Split(key, "/") + if len(keySplit) != 4 { + return channeltypes.PacketId{}, sdkerrors.Wrapf( + sdkerrors.ErrLogic, "key provided is incorrect: the key split has incorrect length, expected %d, got %d", 4, len(keySplit), + ) + } + + seq, err := strconv.ParseUint(keySplit[3], 10, 64) + if err != nil { + return channeltypes.PacketId{}, err + } + + packetID := channeltypes.NewPacketId(keySplit[2], keySplit[1], seq) + return packetID, nil } // KeyFeeInEscrow returns the key for escrowed fees diff --git a/modules/apps/29-fee/types/keys_test.go b/modules/apps/29-fee/types/keys_test.go index f196f5de56b..85c6b107f5f 100644 --- a/modules/apps/29-fee/types/keys_test.go +++ b/modules/apps/29-fee/types/keys_test.go @@ -88,11 +88,47 @@ func TestParseKeyFeesInEscrow(t *testing.T) { } for _, tc := range testCases { - packetId, err := types.ParseKeyFeesInEscrow(tc.key) + packetID, err := types.ParseKeyFeesInEscrow(tc.key) if tc.expPass { require.NoError(t, err) - require.Equal(t, validPacketID, packetId) + require.Equal(t, validPacketID, packetID) + } else { + require.Error(t, err) + } + } +} + +func TestParseKeyForwardRelayerAddress(t *testing.T) { + + testCases := []struct { + name string + key string + expPass bool + }{ + { + "success", + string(types.KeyForwardRelayerAddress(validPacketID)), + true, + }, + { + "incorrect key - key split has incorrect length", + "forwardRelayer/transfer/channel-0", + false, + }, + { + "incorrect key - sequence is not correct", + "forwardRelayer/transfer/channel-0/sequence", + false, + }, + } + + for _, tc := range testCases { + packetID, err := types.ParseKeyForwardRelayerAddress(tc.key) + + if tc.expPass { + require.NoError(t, err) + require.Equal(t, validPacketID, packetID) } else { require.Error(t, err) } From 71167c45394ea025e5577a9545ef020187ccba94 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Thu, 3 Mar 2022 10:29:06 +0000 Subject: [PATCH 70/79] chore: remove unused ics29 keeper funcs (#1044) * removing keys, adding additional test, moving event attribute keys * removing unused code and updating tests * removing unused IdentifiedPacketFee type --- docs/ibc/proto-docs.md | 22 -- modules/apps/29-fee/keeper/escrow_test.go | 4 - modules/apps/29-fee/keeper/keeper.go | 66 +--- modules/apps/29-fee/keeper/keeper_test.go | 34 +- modules/apps/29-fee/types/events.go | 4 + modules/apps/29-fee/types/fee.pb.go | 411 ++-------------------- modules/apps/29-fee/types/keys.go | 17 - modules/apps/29-fee/types/keys_test.go | 5 + modules/apps/29-fee/types/msgs.go | 33 -- proto/ibc/applications/fee/v1/fee.proto | 12 - 10 files changed, 63 insertions(+), 545 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index e6bead7e83f..96963202d20 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -30,7 +30,6 @@ - [ibc/applications/fee/v1/fee.proto](#ibc/applications/fee/v1/fee.proto) - [Fee](#ibc.applications.fee.v1.Fee) - - [IdentifiedPacketFee](#ibc.applications.fee.v1.IdentifiedPacketFee) - [IdentifiedPacketFees](#ibc.applications.fee.v1.IdentifiedPacketFees) - [PacketFee](#ibc.applications.fee.v1.PacketFee) - [PacketFees](#ibc.applications.fee.v1.PacketFees) @@ -726,27 +725,6 @@ https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middl - - -### IdentifiedPacketFee -IdentifiedPacketFee contains the relayer fee along with the associated metadata needed to process it. -This includes the PacketId identifying the packet the fee is paying for, -the refund address to which any unused funds are refunded, -and an optional list of relayers that are permitted to receive the fee. - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | | -| `fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | -| `refund_address` | [string](#string) | | | -| `relayers` | [string](#string) | repeated | | - - - - - - ### IdentifiedPacketFees diff --git a/modules/apps/29-fee/keeper/escrow_test.go b/modules/apps/29-fee/keeper/escrow_test.go index 81103197aa5..647b968f56d 100644 --- a/modules/apps/29-fee/keeper/escrow_test.go +++ b/modules/apps/29-fee/keeper/escrow_test.go @@ -179,10 +179,6 @@ func (suite *KeeperTestSuite) TestDistributeFee() { suite.chainA.GetSimApp().IBCFeeKeeper.DistributePacketFees(suite.chainA.GetContext(), forwardRelayer, reverseRelayer, []types.PacketFee{packetFee, packetFee}) if tc.expPass { - // there should no longer be a fee in escrow for this packet - found := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeeInEscrow(suite.chainA.GetContext(), packetID) - suite.Require().False(found) - // check if the reverse relayer is paid hasBalance := suite.chainA.GetSimApp().BankKeeper.HasBalance(suite.chainA.GetContext(), reverseRelayer, fee.AckFee[0].Add(fee.AckFee[0])) suite.Require().True(hasBalance) diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index 4a3dfbdeb4a..4caa0579846 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -225,26 +225,6 @@ func (k Keeper) DeleteForwardRelayerAddress(ctx sdk.Context, packetID channeltyp store.Delete(key) } -// Stores a Fee for a given packet in state -func (k Keeper) SetFeeInEscrow(ctx sdk.Context, fee types.IdentifiedPacketFee) { - store := ctx.KVStore(k.storeKey) - bz := k.MustMarshalFee(&fee) - store.Set(types.KeyFeeInEscrow(fee.PacketId), bz) -} - -// Gets a Fee for a given packet -func (k Keeper) GetFeeInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) (types.IdentifiedPacketFee, bool) { - store := ctx.KVStore(k.storeKey) - key := types.KeyFeeInEscrow(packetID) - bz := store.Get(key) - if bz == nil { - return types.IdentifiedPacketFee{}, false - } - fee := k.MustUnmarshalFee(bz) - - return fee, true -} - // GetFeesInEscrow returns all escrowed packet fees for a given packetID func (k Keeper) GetFeesInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) (types.PacketFees, bool) { store := ctx.KVStore(k.storeKey) @@ -265,7 +245,7 @@ func (k Keeper) HasFeesInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) return store.Has(key) } -// SetFeesInEscrow sets the given packet fees in escrow keyed by the packetID +// SetFeesInEscrow sets the given packet fees in escrow keyed by the packetID func (k Keeper) SetFeesInEscrow(ctx sdk.Context, packetID channeltypes.PacketId, fees types.PacketFees) { store := ctx.KVStore(k.storeKey) bz := k.MustMarshalFees(fees) @@ -294,36 +274,6 @@ func (k Keeper) IteratePacketFeesInEscrow(ctx sdk.Context, portID, channelID str } } -// IterateChannelFeesInEscrow iterates over all the fees on the given channel currently escrowed and calls the provided callback -// if the callback returns true, then iteration is stopped. -func (k Keeper) IterateChannelFeesInEscrow(ctx sdk.Context, portID, channelID string, cb func(identifiedFee types.IdentifiedPacketFee) (stop bool)) { - store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.KeyFeeInEscrowChannelPrefix(portID, channelID)) - - defer iterator.Close() - for ; iterator.Valid(); iterator.Next() { - identifiedFee := k.MustUnmarshalFee(iterator.Value()) - if cb(identifiedFee) { - break - } - } -} - -// Deletes the fee associated with the given packetID -func (k Keeper) DeleteFeeInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) { - store := ctx.KVStore(k.storeKey) - key := types.KeyFeeInEscrow(packetID) - store.Delete(key) -} - -// HasFeeInEscrow returns true if there is a Fee still to be escrowed for a given packet -func (k Keeper) HasFeeInEscrow(ctx sdk.Context, packetID channeltypes.PacketId) bool { - store := ctx.KVStore(k.storeKey) - key := types.KeyFeeInEscrow(packetID) - - return store.Has(key) -} - // GetAllIdentifiedPacketFees returns a list of all IdentifiedPacketFees that are stored in state func (k Keeper) GetAllIdentifiedPacketFees(ctx sdk.Context) []types.IdentifiedPacketFees { store := ctx.KVStore(k.storeKey) @@ -350,20 +300,6 @@ func (k Keeper) GetAllIdentifiedPacketFees(ctx sdk.Context) []types.IdentifiedPa return identifiedFees } -// MustMarshalFee attempts to encode a Fee object and returns the -// raw encoded bytes. It panics on error. -func (k Keeper) MustMarshalFee(fee *types.IdentifiedPacketFee) []byte { - return k.cdc.MustMarshal(fee) -} - -// MustUnmarshalFee attempts to decode and return a Fee object from -// raw encoded bytes. It panics on error. -func (k Keeper) MustUnmarshalFee(bz []byte) types.IdentifiedPacketFee { - var fee types.IdentifiedPacketFee - k.cdc.MustUnmarshal(bz, &fee) - return fee -} - // MustMarshalFees attempts to encode a Fee object and returns the // raw encoded bytes. It panics on error. func (k Keeper) MustMarshalFees(fees types.PacketFees) []byte { diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index c9ad4a5f10b..92705c9c7cc 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "fmt" "testing" "github.com/cosmos/cosmos-sdk/baseapp" @@ -66,30 +67,27 @@ func TestKeeperTestSuite(t *testing.T) { suite.Run(t, new(KeeperTestSuite)) } -func (suite *KeeperTestSuite) TestFeeInEscrow() { +func (suite *KeeperTestSuite) TestFeesInEscrow() { suite.coordinator.Setup(suite.path) - fee := types.Fee{RecvFee: defaultReceiveFee, AckFee: defaultAckFee, TimeoutFee: defaultTimeoutFee} + // escrow five fees for packet sequence 1 + packetID := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 1) + fee := types.NewFee(defaultReceiveFee, defaultAckFee, defaultTimeoutFee) - // set some fees for i := 1; i < 6; i++ { - packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, uint64(i)) - fee := types.NewIdentifiedPacketFee(packetId, fee, suite.chainA.SenderAccount.GetAddress().String(), []string{}) - suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeInEscrow(suite.chainA.GetContext(), fee) + packetFee := types.NewPacketFee(fee, suite.chainA.SenderAccount.GetAddress().String(), nil) + suite.chainA.GetSimApp().IBCFeeKeeper.EscrowPacketFee(suite.chainA.GetContext(), packetID, packetFee) } - // delete 1 fee - packetId := channeltypes.NewPacketId(suite.path.EndpointA.ChannelID, suite.path.EndpointA.ChannelConfig.PortID, 3) - suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeeInEscrow(suite.chainA.GetContext(), packetId) - - // iterate over remaining fees - arr := []int64{} - expectedArr := []int64{1, 2, 4, 5} - suite.chainA.GetSimApp().IBCFeeKeeper.IterateChannelFeesInEscrow(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, func(identifiedFee types.IdentifiedPacketFee) (stop bool) { - arr = append(arr, int64(identifiedFee.PacketId.Sequence)) - return false - }) - suite.Require().Equal(expectedArr, arr, "did not retrieve expected fees during iteration") + // retrieve the fees in escrow and assert the length of PacketFees + feesInEscrow, found := suite.chainA.GetSimApp().IBCFeeKeeper.GetFeesInEscrow(suite.chainA.GetContext(), packetID) + suite.Require().True(found) + suite.Require().Len(feesInEscrow.PacketFees, 5, fmt.Sprintf("expected length 5, but got %d", len(feesInEscrow.PacketFees))) + + // delete fees for packet sequence 1 + suite.chainA.GetSimApp().IBCFeeKeeper.DeleteFeesInEscrow(suite.chainA.GetContext(), packetID) + hasFeesInEscrow := suite.chainA.GetSimApp().IBCFeeKeeper.HasFeesInEscrow(suite.chainA.GetContext(), packetID) + suite.Require().False(hasFeesInEscrow) } func (suite *KeeperTestSuite) TestDisableAllChannels() { diff --git a/modules/apps/29-fee/types/events.go b/modules/apps/29-fee/types/events.go index 2c63bc0dcc8..cac882d98d3 100644 --- a/modules/apps/29-fee/types/events.go +++ b/modules/apps/29-fee/types/events.go @@ -3,4 +3,8 @@ package types // 29-fee events const ( EventTypeIncentivizedPacket = "incentivized_ibc_packet" + + AttributeKeyRecvFee = "recv_fee" + AttributeKeyAckFee = "ack_fee" + AttributeKeyTimeoutFee = "timeout_fee" ) diff --git a/modules/apps/29-fee/types/fee.pb.go b/modules/apps/29-fee/types/fee.pb.go index ad74e0b2d86..8c95fd11176 100644 --- a/modules/apps/29-fee/types/fee.pb.go +++ b/modules/apps/29-fee/types/fee.pb.go @@ -89,78 +89,6 @@ func (m *Fee) GetTimeoutFee() github_com_cosmos_cosmos_sdk_types.Coins { return nil } -// IdentifiedPacketFee contains the relayer fee along with the associated metadata needed to process it. -// This includes the PacketId identifying the packet the fee is paying for, -// the refund address to which any unused funds are refunded, -// and an optional list of relayers that are permitted to receive the fee. -type IdentifiedPacketFee struct { - PacketId types1.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id" yaml:"packet_id"` - Fee Fee `protobuf:"bytes,2,opt,name=fee,proto3" json:"fee"` - RefundAddress string `protobuf:"bytes,3,opt,name=refund_address,json=refundAddress,proto3" json:"refund_address,omitempty" yaml:"refund_address"` - Relayers []string `protobuf:"bytes,4,rep,name=relayers,proto3" json:"relayers,omitempty"` -} - -func (m *IdentifiedPacketFee) Reset() { *m = IdentifiedPacketFee{} } -func (m *IdentifiedPacketFee) String() string { return proto.CompactTextString(m) } -func (*IdentifiedPacketFee) ProtoMessage() {} -func (*IdentifiedPacketFee) Descriptor() ([]byte, []int) { - return fileDescriptor_cb3319f1af2a53e5, []int{1} -} -func (m *IdentifiedPacketFee) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *IdentifiedPacketFee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_IdentifiedPacketFee.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *IdentifiedPacketFee) XXX_Merge(src proto.Message) { - xxx_messageInfo_IdentifiedPacketFee.Merge(m, src) -} -func (m *IdentifiedPacketFee) XXX_Size() int { - return m.Size() -} -func (m *IdentifiedPacketFee) XXX_DiscardUnknown() { - xxx_messageInfo_IdentifiedPacketFee.DiscardUnknown(m) -} - -var xxx_messageInfo_IdentifiedPacketFee proto.InternalMessageInfo - -func (m *IdentifiedPacketFee) GetPacketId() types1.PacketId { - if m != nil { - return m.PacketId - } - return types1.PacketId{} -} - -func (m *IdentifiedPacketFee) GetFee() Fee { - if m != nil { - return m.Fee - } - return Fee{} -} - -func (m *IdentifiedPacketFee) GetRefundAddress() string { - if m != nil { - return m.RefundAddress - } - return "" -} - -func (m *IdentifiedPacketFee) GetRelayers() []string { - if m != nil { - return m.Relayers - } - return nil -} - // PacketFee contains the relayer fee, refund address and an optional list of relayers that are permitted to receive the // fee type PacketFee struct { @@ -173,7 +101,7 @@ func (m *PacketFee) Reset() { *m = PacketFee{} } func (m *PacketFee) String() string { return proto.CompactTextString(m) } func (*PacketFee) ProtoMessage() {} func (*PacketFee) Descriptor() ([]byte, []int) { - return fileDescriptor_cb3319f1af2a53e5, []int{2} + return fileDescriptor_cb3319f1af2a53e5, []int{1} } func (m *PacketFee) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -232,7 +160,7 @@ func (m *PacketFees) Reset() { *m = PacketFees{} } func (m *PacketFees) String() string { return proto.CompactTextString(m) } func (*PacketFees) ProtoMessage() {} func (*PacketFees) Descriptor() ([]byte, []int) { - return fileDescriptor_cb3319f1af2a53e5, []int{3} + return fileDescriptor_cb3319f1af2a53e5, []int{2} } func (m *PacketFees) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -278,7 +206,7 @@ func (m *IdentifiedPacketFees) Reset() { *m = IdentifiedPacketFees{} } func (m *IdentifiedPacketFees) String() string { return proto.CompactTextString(m) } func (*IdentifiedPacketFees) ProtoMessage() {} func (*IdentifiedPacketFees) Descriptor() ([]byte, []int) { - return fileDescriptor_cb3319f1af2a53e5, []int{4} + return fileDescriptor_cb3319f1af2a53e5, []int{3} } func (m *IdentifiedPacketFees) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -323,7 +251,6 @@ func (m *IdentifiedPacketFees) GetPacketFees() []PacketFee { func init() { proto.RegisterType((*Fee)(nil), "ibc.applications.fee.v1.Fee") - proto.RegisterType((*IdentifiedPacketFee)(nil), "ibc.applications.fee.v1.IdentifiedPacketFee") proto.RegisterType((*PacketFee)(nil), "ibc.applications.fee.v1.PacketFee") proto.RegisterType((*PacketFees)(nil), "ibc.applications.fee.v1.PacketFees") proto.RegisterType((*IdentifiedPacketFees)(nil), "ibc.applications.fee.v1.IdentifiedPacketFees") @@ -332,42 +259,40 @@ func init() { func init() { proto.RegisterFile("ibc/applications/fee/v1/fee.proto", fileDescriptor_cb3319f1af2a53e5) } var fileDescriptor_cb3319f1af2a53e5 = []byte{ - // 560 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0xc1, 0x6e, 0xd3, 0x30, - 0x18, 0xc7, 0xeb, 0x66, 0xda, 0x56, 0x57, 0x4c, 0x28, 0x0c, 0xd1, 0x55, 0x90, 0x96, 0x9c, 0x7a, - 0xa9, 0xad, 0x76, 0x70, 0x80, 0x13, 0x04, 0xa9, 0xd2, 0x4e, 0xa0, 0x88, 0x13, 0x97, 0xca, 0x71, - 0xbe, 0x76, 0x56, 0x9b, 0x38, 0x8a, 0xd3, 0x48, 0x95, 0x38, 0x20, 0x9e, 0x80, 0x37, 0xe0, 0xce, - 0x93, 0xec, 0x82, 0xb4, 0x23, 0xa7, 0x82, 0xda, 0x37, 0xd8, 0x0b, 0x80, 0x9c, 0x78, 0xa5, 0x0c, - 0x26, 0x54, 0x0d, 0x4e, 0xb1, 0x9d, 0xef, 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x77, 0x19, 0x9f, - 0x68, 0xee, 0x7b, 0x84, 0xeb, 0x99, 0x88, 0x40, 0xce, 0xb2, 0x02, 0x6e, 0x6d, 0x59, 0xf9, 0x86, - 0x76, 0x3b, 0x03, 0xd8, 0x28, 0x07, 0x00, 0xee, 0x77, 0x84, 0xef, 0x9c, 0x84, 0x10, 0x67, 0x62, - 0x24, 0x20, 0x7c, 0xc5, 0xf8, 0x04, 0xf4, 0xba, 0xfd, 0x1a, 0xd7, 0x92, 0x62, 0x32, 0x14, 0x61, - 0x03, 0xb5, 0x51, 0xa7, 0xde, 0x7f, 0x40, 0x74, 0x83, 0xe8, 0x13, 0x25, 0x97, 0xc7, 0x98, 0xf7, - 0x48, 0x29, 0x39, 0x09, 0xbd, 0x86, 0x71, 0x77, 0xbb, 0x74, 0xb7, 0x56, 0xbb, 0xfe, 0x7e, 0x62, - 0x62, 0xec, 0x47, 0xd8, 0x2a, 0xb7, 0x59, 0xe7, 0xbb, 0x4f, 0xae, 0x69, 0x38, 0x32, 0x00, 0xf0, - 0x76, 0x74, 0x3a, 0x5f, 0x87, 0xdb, 0xcf, 0xf0, 0x41, 0x0a, 0xa3, 0x59, 0x1c, 0x0e, 0x59, 0x18, - 0xa6, 0xa0, 0x54, 0xc3, 0x6a, 0xa3, 0x4e, 0xcd, 0x3b, 0xba, 0x58, 0xb4, 0xee, 0x5e, 0x76, 0xc1, - 0xe6, 0x7f, 0xd7, 0xbf, 0x55, 0x2e, 0x3c, 0x2f, 0xe7, 0x76, 0x53, 0x37, 0xd8, 0x94, 0xcd, 0x21, - 0x55, 0x8d, 0x9d, 0xb6, 0xd5, 0xa9, 0xf9, 0xeb, 0xb9, 0xfb, 0x11, 0xe1, 0xda, 0xcf, 0xba, 0x8d, - 0x43, 0x74, 0x53, 0x87, 0xd5, 0x1b, 0x38, 0xb4, 0xae, 0x38, 0x8c, 0x30, 0x5e, 0x1b, 0x54, 0xf6, - 0x10, 0xd7, 0xcd, 0xde, 0x8e, 0x00, 0x94, 0xb9, 0x2f, 0xee, 0xb5, 0x4e, 0xd7, 0x4a, 0xaf, 0xf9, - 0x6b, 0xfb, 0x6c, 0x24, 0x71, 0x7d, 0x9c, 0xac, 0x01, 0xee, 0x67, 0x84, 0x0f, 0xff, 0xd0, 0x12, - 0xea, 0x3f, 0xf5, 0xc4, 0x95, 0x7a, 0xaa, 0xff, 0xba, 0x1e, 0xef, 0xe5, 0xd9, 0xd2, 0x41, 0xe7, - 0x4b, 0x07, 0x7d, 0x5b, 0x3a, 0xe8, 0xc3, 0xca, 0xa9, 0x9c, 0xaf, 0x9c, 0xca, 0x97, 0x95, 0x53, - 0x79, 0xf3, 0xf8, 0xf7, 0x2b, 0x23, 0x02, 0xde, 0x1d, 0x4b, 0x9a, 0x1f, 0xd3, 0x48, 0x86, 0xb3, - 0x29, 0x28, 0xfd, 0x68, 0x2a, 0xda, 0x7f, 0xd2, 0xd5, 0xef, 0x65, 0x71, 0x8b, 0x82, 0xdd, 0xe2, - 0xf5, 0x3a, 0xfe, 0x11, 0x00, 0x00, 0xff, 0xff, 0x6b, 0xd4, 0x49, 0x04, 0x54, 0x05, 0x00, 0x00, + // 526 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xc1, 0x8a, 0x13, 0x31, + 0x18, 0xc7, 0x3b, 0x5b, 0xd9, 0xdd, 0xa6, 0xb8, 0xc8, 0xb0, 0x62, 0xb7, 0xe8, 0x74, 0xcd, 0xa9, + 0x97, 0x26, 0xb4, 0xab, 0x07, 0x3d, 0xe9, 0x08, 0x85, 0x3d, 0x29, 0x83, 0x27, 0x2f, 0x25, 0x93, + 0x7c, 0xed, 0x86, 0x76, 0x26, 0xc3, 0x64, 0x3a, 0x50, 0xf0, 0x20, 0x3e, 0x81, 0x6f, 0xe0, 0xdd, + 0x27, 0xd9, 0x8b, 0xb0, 0x47, 0x4f, 0x55, 0xda, 0x37, 0xd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0x3e, 0xb8, 0x85, 0x94, 0x02, 0x47, 0x87, 0x99, + 0xcb, 0xf9, 0xb3, 0x9f, 0xbd, 0xff, 0xdd, 0x4f, 0xf8, 0xf6, 0x72, 0x15, 0x78, 0x57, 0xab, 0xc0, + 0xfb, 0xb5, 0x0a, 0xbc, 0x2f, 0xeb, 0xa0, 0x76, 0xb5, 0x0e, 0x6a, 0x3f, 0xd6, 0x41, 0xed, 0xc3, + 0xf3, 0xbf, 0x0d, 0x23, 0x63, 0xde, 0x9b, 0x28, 0x5a, 0x9e, 0xd1, 0x44, 0x89, 0xf9, 0x0c, 0xb4, + 0x79, 0x32, 0x34, 0x1d, 0xbc, 0xe8, 0x99, 0xd7, 0xc2, 0x7a, 0x28, 0xde, 0xb7, 0xff, 0xee, 0xd9, + 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xdf, 0x70, 0xf8, 0xe7, 0x52, 0x04, 0x00, 0x00, } func (m *Fee) Marshal() (dAtA []byte, err error) { @@ -435,65 +360,6 @@ func (m *Fee) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *IdentifiedPacketFee) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *IdentifiedPacketFee) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *IdentifiedPacketFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Relayers) > 0 { - for iNdEx := len(m.Relayers) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Relayers[iNdEx]) - copy(dAtA[i:], m.Relayers[iNdEx]) - i = encodeVarintFee(dAtA, i, uint64(len(m.Relayers[iNdEx]))) - i-- - dAtA[i] = 0x22 - } - } - if len(m.RefundAddress) > 0 { - i -= len(m.RefundAddress) - copy(dAtA[i:], m.RefundAddress) - i = encodeVarintFee(dAtA, i, uint64(len(m.RefundAddress))) - i-- - dAtA[i] = 0x1a - } - { - size, err := m.Fee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintFee(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size, err := m.PacketId.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintFee(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - func (m *PacketFee) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -665,29 +531,6 @@ func (m *Fee) Size() (n int) { return n } -func (m *IdentifiedPacketFee) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.PacketId.Size() - n += 1 + l + sovFee(uint64(l)) - l = m.Fee.Size() - n += 1 + l + sovFee(uint64(l)) - l = len(m.RefundAddress) - if l > 0 { - n += 1 + l + sovFee(uint64(l)) - } - if len(m.Relayers) > 0 { - for _, s := range m.Relayers { - l = len(s) - n += 1 + l + sovFee(uint64(l)) - } - } - return n -} - func (m *PacketFee) Size() (n int) { if m == nil { return 0 @@ -899,186 +742,6 @@ func (m *Fee) Unmarshal(dAtA []byte) error { } return nil } -func (m *IdentifiedPacketFee) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowFee - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: IdentifiedPacketFee: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: IdentifiedPacketFee: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PacketId", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowFee - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthFee - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthFee - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.PacketId.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Fee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowFee - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthFee - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthFee - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Fee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RefundAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowFee - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthFee - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthFee - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RefundAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Relayers", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowFee - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthFee - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthFee - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Relayers = append(m.Relayers, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipFee(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthFee - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *PacketFee) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index e619bde8806..c9fab858919 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -31,18 +31,11 @@ const ( // CounterpartyRelayerAddressKeyPrefix is the key prefix for relayer address mapping CounterpartyRelayerAddressKeyPrefix = "relayerAddress" - // FeeInEscrowPrefix is the key prefix for fee in escrow mapping - FeeInEscrowPrefix = "feeInEscrow" - // FeesInEscrowPrefix is the key prefix for fee in escrow mapping FeesInEscrowPrefix = "feesInEscrow" // ForwardRelayerPrefix is the key prefix for forward relayer addresses stored in state for async acknowledgements ForwardRelayerPrefix = "forwardRelayer" - - AttributeKeyRecvFee = "recv_fee" - AttributeKeyAckFee = "ack_fee" - AttributeKeyTimeoutFee = "timeout_fee" ) // KeyFeeEnabled returns the key that stores a flag to determine if fee logic should @@ -99,11 +92,6 @@ func ParseKeyForwardRelayerAddress(key string) (channeltypes.PacketId, error) { return packetID, nil } -// KeyFeeInEscrow returns the key for escrowed fees -func KeyFeeInEscrow(packetID channeltypes.PacketId) []byte { - return []byte(fmt.Sprintf("%s/%d", KeyFeeInEscrowChannelPrefix(packetID.PortId, packetID.ChannelId), packetID.Sequence)) -} - // KeyFeesInEscrow returns the key for escrowed fees func KeyFeesInEscrow(packetID channeltypes.PacketId) []byte { return []byte(fmt.Sprintf("%s/%d", KeyFeesInEscrowChannelPrefix(packetID.PortId, packetID.ChannelId), packetID.Sequence)) @@ -127,11 +115,6 @@ func ParseKeyFeesInEscrow(key string) (channeltypes.PacketId, error) { return packetID, nil } -// KeyFeeInEscrowChannelPrefix returns the key prefix for escrowed fees on the given channel -func KeyFeeInEscrowChannelPrefix(portID, channelID string) []byte { - return []byte(fmt.Sprintf("%s/%s/%s/packet", FeeInEscrowPrefix, portID, channelID)) -} - // KeyFeesInEscrowChannelPrefix returns the key prefix for escrowed fees on the given channel func KeyFeesInEscrowChannelPrefix(portID, channelID string) []byte { return []byte(fmt.Sprintf("%s/%s/%s", FeesInEscrowPrefix, portID, channelID)) diff --git a/modules/apps/29-fee/types/keys_test.go b/modules/apps/29-fee/types/keys_test.go index 85c6b107f5f..e6ef922b757 100644 --- a/modules/apps/29-fee/types/keys_test.go +++ b/modules/apps/29-fee/types/keys_test.go @@ -25,6 +25,11 @@ func TestKeyCounterpartyRelayer(t *testing.T) { require.Equal(t, string(key), fmt.Sprintf("%s/%s/%s", types.CounterpartyRelayerAddressKeyPrefix, relayerAddress, channelID)) } +func TestKeyFeesInEscrow(t *testing.T) { + key := types.KeyFeesInEscrow(validPacketID) + require.Equal(t, string(key), fmt.Sprintf("%s/%s/%s/%d", types.FeesInEscrowPrefix, ibctesting.MockFeePort, ibctesting.FirstChannelID, 1)) +} + func TestParseKeyFeeEnabled(t *testing.T) { testCases := []struct { name string diff --git a/modules/apps/29-fee/types/msgs.go b/modules/apps/29-fee/types/msgs.go index 2c0d8a52e32..d2fec3e542f 100644 --- a/modules/apps/29-fee/types/msgs.go +++ b/modules/apps/29-fee/types/msgs.go @@ -162,36 +162,3 @@ func (msg MsgPayPacketFeeAsync) Type() string { func (msg MsgPayPacketFeeAsync) GetSignBytes() []byte { return sdk.MustSortJSON(AminoCdc.MustMarshalJSON(&msg)) } - -func NewIdentifiedPacketFee(packetId channeltypes.PacketId, fee Fee, refundAddr string, relayers []string) IdentifiedPacketFee { - return IdentifiedPacketFee{ - PacketId: packetId, - Fee: fee, - RefundAddress: refundAddr, - Relayers: relayers, - } -} - -// Validate performs a stateless check of the IdentifiedPacketFee fields -func (fee IdentifiedPacketFee) Validate() error { - // validate PacketId - if err := fee.PacketId.Validate(); err != nil { - return sdkerrors.Wrap(err, "Invalid PacketId") - } - - _, err := sdk.AccAddressFromBech32(fee.RefundAddress) - if err != nil { - return sdkerrors.Wrap(err, "failed to convert RefundAddress into sdk.AccAddress") - } - - // enforce relayer is nil - if fee.Relayers != nil { - return ErrRelayersNotNil - } - - if err := fee.Fee.Validate(); err != nil { - return err - } - - return nil -} diff --git a/proto/ibc/applications/fee/v1/fee.proto b/proto/ibc/applications/fee/v1/fee.proto index 4d39ad3786c..b1ebd7008ad 100644 --- a/proto/ibc/applications/fee/v1/fee.proto +++ b/proto/ibc/applications/fee/v1/fee.proto @@ -29,18 +29,6 @@ message Fee { ]; } -// IdentifiedPacketFee contains the relayer fee along with the associated metadata needed to process it. -// This includes the PacketId identifying the packet the fee is paying for, -// the refund address to which any unused funds are refunded, -// and an optional list of relayers that are permitted to receive the fee. -message IdentifiedPacketFee { - ibc.core.channel.v1.PacketId packet_id = 1 - [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"packet_id\""]; - Fee fee = 2 [(gogoproto.nullable) = false]; - string refund_address = 3 [(gogoproto.moretags) = "yaml:\"refund_address\""]; - repeated string relayers = 4; -} - // PacketFee contains the relayer fee, refund address and an optional list of relayers that are permitted to receive the // fee message PacketFee { From 4bf859a3299ec68fbdf7cb4474b807b638465c50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 3 Mar 2022 12:00:24 +0100 Subject: [PATCH 71/79] chore: add gRPC for querying incentivized packets for a specific channel (#983) * generate proto files * feat: add gRPC for querying incentivized packets for a specific channel * test: add gRPC test for incentivized packets for channel query * fix build * partially fix tests * chore: fix tests * deduplicate code * chore: code cleanup * fix build * remove changes from merge conflict * nit: rename c to goCtx --- docs/ibc/proto-docs.md | 37 + modules/apps/29-fee/keeper/grpc_query.go | 40 +- modules/apps/29-fee/keeper/grpc_query_test.go | 95 +++ modules/apps/29-fee/types/fee.go | 1 + modules/apps/29-fee/types/query.pb.go | 677 ++++++++++++++++-- modules/apps/29-fee/types/query.pb.gw.go | 138 ++++ proto/ibc/applications/fee/v1/query.proto | 23 + 7 files changed, 945 insertions(+), 66 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 96963202d20..0d50531b2e0 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -46,6 +46,8 @@ - [ibc/applications/fee/v1/query.proto](#ibc/applications/fee/v1/query.proto) - [QueryIncentivizedPacketRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketRequest) - [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) + - [QueryIncentivizedPacketsForChannelRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsForChannelRequest) + - [QueryIncentivizedPacketsForChannelResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsForChannelResponse) - [QueryIncentivizedPacketsRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsRequest) - [QueryIncentivizedPacketsResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsResponse) - [QueryTotalAckFeesRequest](#ibc.applications.fee.v1.QueryTotalAckFeesRequest) @@ -937,6 +939,40 @@ QueryIncentivizedPacketsResponse is the response type for the incentivized packe + + +### QueryIncentivizedPacketsForChannelRequest +QueryIncentivizedPacketsForChannelRequest is the request type for querying for all incentivized packets +for a specific channel + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | +| `port_id` | [string](#string) | | | +| `channel_id` | [string](#string) | | | +| `query_height` | [uint64](#uint64) | | Height to query at | + + + + + + + + +### QueryIncentivizedPacketsForChannelResponse +QueryIncentivizedPacketsResponse is the response type for the incentivized packets RPC + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `incentivized_packets` | [IdentifiedPacketFees](#ibc.applications.fee.v1.IdentifiedPacketFees) | repeated | Map of all incentivized_packets | + + + + + + ### QueryIncentivizedPacketsRequest @@ -1073,6 +1109,7 @@ Query provides defines the gRPC querier service. | ----------- | ------------ | ------------- | ------------| ------- | -------- | | `IncentivizedPackets` | [QueryIncentivizedPacketsRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsRequest) | [QueryIncentivizedPacketsResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsResponse) | Gets all incentivized packets | GET|/ibc/apps/fee/v1/incentivized_packets| | `IncentivizedPacket` | [QueryIncentivizedPacketRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketRequest) | [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) | Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the given packet | GET|/ibc/apps/fee/v1/incentivized_packet/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| +| `IncentivizedPacketsForChannel` | [QueryIncentivizedPacketsForChannelRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsForChannelRequest) | [QueryIncentivizedPacketsForChannelResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsForChannelResponse) | Gets all incentivized packets for a specific channel | GET|/ibc/apps/fee/v1/incentivized_packets/{port_id}/{channel_id}| | `TotalRecvFees` | [QueryTotalRecvFeesRequest](#ibc.applications.fee.v1.QueryTotalRecvFeesRequest) | [QueryTotalRecvFeesResponse](#ibc.applications.fee.v1.QueryTotalRecvFeesResponse) | TotalRecvFees returns the total receive fees for a packet given its identifier | GET|/ibc/apps/fee/v1/total_recv_fees/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| | `TotalAckFees` | [QueryTotalAckFeesRequest](#ibc.applications.fee.v1.QueryTotalAckFeesRequest) | [QueryTotalAckFeesResponse](#ibc.applications.fee.v1.QueryTotalAckFeesResponse) | TotalAckFees returns the total acknowledgement fees for a packet given its identifier | GET|/ibc/apps/fee/v1/total_ack_fees/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| | `TotalTimeoutFees` | [QueryTotalTimeoutFeesRequest](#ibc.applications.fee.v1.QueryTotalTimeoutFeesRequest) | [QueryTotalTimeoutFeesResponse](#ibc.applications.fee.v1.QueryTotalTimeoutFeesResponse) | TotalTimeoutFees returns the total timeout fees for a packet given its identifier | GET|/ibc/apps/fee/v1/total_timeout_fees/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| diff --git a/modules/apps/29-fee/keeper/grpc_query.go b/modules/apps/29-fee/keeper/grpc_query.go index 54969471086..68f2cb332ca 100644 --- a/modules/apps/29-fee/keeper/grpc_query.go +++ b/modules/apps/29-fee/keeper/grpc_query.go @@ -3,13 +3,12 @@ package keeper import ( "context" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/query" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types" ) @@ -66,12 +65,43 @@ func (k Keeper) IncentivizedPacket(c context.Context, req *types.QueryIncentiviz }, nil } -// TotalRecvFees implements the Query/TotalRecvFees gRPC method -func (k Keeper) TotalRecvFees(goCtx context.Context, req *types.QueryTotalRecvFeesRequest) (*types.QueryTotalRecvFeesResponse, error) { +// IncentivizedPacketsForChannel implements the IncentivizedPacketsForChannel gRPC method +func (k Keeper) IncentivizedPacketsForChannel(goCtx context.Context, req *types.QueryIncentivizedPacketsForChannelRequest) (*types.QueryIncentivizedPacketsForChannelResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } + ctx := sdk.UnwrapSDKContext(goCtx).WithBlockHeight(int64(req.QueryHeight)) + + var packets []*types.IdentifiedPacketFees + keyPrefix := types.KeyFeesInEscrowChannelPrefix(req.PortId, req.ChannelId) + store := prefix.NewStore(ctx.KVStore(k.storeKey), keyPrefix) + _, err := query.Paginate(store, req.Pagination, func(key, value []byte) error { + packetID, err := types.ParseKeyFeesInEscrow(string(keyPrefix) + string(key)) + if err != nil { + return err + } + + packetFees := k.MustUnmarshalFees(value) + + identifiedPacketFees := types.NewIdentifiedPacketFees(packetID, packetFees.PacketFees) + packets = append(packets, &identifiedPacketFees) + + return nil + }) + + if err != nil { + return nil, status.Error(codes.NotFound, err.Error()) + } + + return &types.QueryIncentivizedPacketsForChannelResponse{ + IncentivizedPackets: packets, + }, nil +} + +// TotalRecvFees implements the Query/TotalRecvFees gRPC method +func (k Keeper) TotalRecvFees(goCtx context.Context, req *types.QueryTotalRecvFeesRequest) (*types.QueryTotalRecvFeesResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) feesInEscrow, found := k.GetFeesInEscrow(ctx, req.PacketId) diff --git a/modules/apps/29-fee/keeper/grpc_query_test.go b/modules/apps/29-fee/keeper/grpc_query_test.go index fe06afdc5bd..4bd55b92903 100644 --- a/modules/apps/29-fee/keeper/grpc_query_test.go +++ b/modules/apps/29-fee/keeper/grpc_query_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "fmt" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" @@ -140,6 +141,100 @@ func (suite *KeeperTestSuite) TestQueryIncentivizedPacket() { } } +func (suite *KeeperTestSuite) TestQueryIncentivizedPacketsForChannel() { + var ( + req *types.QueryIncentivizedPacketsForChannelRequest + expIdentifiedPacketFees []*types.IdentifiedPacketFees + ) + + fee := types.Fee{ + AckFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}}, + RecvFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}}, + TimeoutFee: sdk.Coins{sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: sdk.NewInt(100)}}, + } + + testCases := []struct { + msg string + malleate func() + expPass bool + }{ + { + "empty pagination", + func() { + expIdentifiedPacketFees = nil + req = &types.QueryIncentivizedPacketsForChannelRequest{} + }, + true, + }, + { + "success", + func() { + req = &types.QueryIncentivizedPacketsForChannelRequest{ + Pagination: &query.PageRequest{ + Limit: 5, + CountTotal: false, + }, + PortId: ibctesting.MockFeePort, + ChannelId: ibctesting.FirstChannelID, + QueryHeight: 0, + } + }, + true, + }, + { + "no packets for specified channel", + func() { + expIdentifiedPacketFees = nil + req = &types.QueryIncentivizedPacketsForChannelRequest{ + Pagination: &query.PageRequest{ + Limit: 5, + CountTotal: false, + }, + PortId: ibctesting.MockFeePort, + ChannelId: "channel-10", + QueryHeight: 0, + } + }, + true, + }, + } + + for _, tc := range testCases { + suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { + suite.SetupTest() // reset + + // setup + refundAcc := suite.chainA.SenderAccount.GetAddress() + packetFee := types.NewPacketFee(fee, refundAcc.String(), nil) + packetFees := types.NewPacketFees([]types.PacketFee{packetFee, packetFee, packetFee}) + + identifiedFees1 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 1), packetFees.PacketFees) + identifiedFees2 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 2), packetFees.PacketFees) + identifiedFees3 := types.NewIdentifiedPacketFees(channeltypes.NewPacketId(ibctesting.FirstChannelID, ibctesting.MockFeePort, 3), packetFees.PacketFees) + + expIdentifiedPacketFees = append(expIdentifiedPacketFees, &identifiedFees1, &identifiedFees2, &identifiedFees3) + + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeeEnabled(suite.chainA.GetContext(), ibctesting.MockFeePort, ibctesting.FirstChannelID) + for _, identifiedPacketFees := range expIdentifiedPacketFees { + suite.chainA.GetSimApp().IBCFeeKeeper.SetFeesInEscrow(suite.chainA.GetContext(), identifiedPacketFees.PacketId, types.NewPacketFees(identifiedPacketFees.PacketFees)) + } + + tc.malleate() + ctx := sdk.WrapSDKContext(suite.chainA.GetContext()) + + res, err := suite.queryClient.IncentivizedPacketsForChannel(ctx, req) + + if tc.expPass { + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Require().Equal(expIdentifiedPacketFees, res.IncentivizedPackets) + } else { + suite.Require().Error(err) + } + }) + } +} + func (suite *KeeperTestSuite) TestQueryTotalRecvFees() { var ( req *types.QueryTotalRecvFeesRequest diff --git a/modules/apps/29-fee/types/fee.go b/modules/apps/29-fee/types/fee.go index bdcb2fc94ba..1f979c732d8 100644 --- a/modules/apps/29-fee/types/fee.go +++ b/modules/apps/29-fee/types/fee.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" ) diff --git a/modules/apps/29-fee/types/query.pb.go b/modules/apps/29-fee/types/query.pb.go index b9f241000ab..5421eda2fff 100644 --- a/modules/apps/29-fee/types/query.pb.go +++ b/modules/apps/29-fee/types/query.pb.go @@ -235,6 +235,132 @@ func (m *QueryIncentivizedPacketResponse) GetIncentivizedPacket() IdentifiedPack return IdentifiedPacketFees{} } +// QueryIncentivizedPacketsForChannelRequest is the request type for querying for all incentivized packets +// for a specific channel +type QueryIncentivizedPacketsForChannelRequest struct { + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` + PortId string `protobuf:"bytes,2,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"` + ChannelId string `protobuf:"bytes,3,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // Height to query at + QueryHeight uint64 `protobuf:"varint,4,opt,name=query_height,json=queryHeight,proto3" json:"query_height,omitempty"` +} + +func (m *QueryIncentivizedPacketsForChannelRequest) Reset() { + *m = QueryIncentivizedPacketsForChannelRequest{} +} +func (m *QueryIncentivizedPacketsForChannelRequest) String() string { + return proto.CompactTextString(m) +} +func (*QueryIncentivizedPacketsForChannelRequest) ProtoMessage() {} +func (*QueryIncentivizedPacketsForChannelRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{4} +} +func (m *QueryIncentivizedPacketsForChannelRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryIncentivizedPacketsForChannelRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryIncentivizedPacketsForChannelRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryIncentivizedPacketsForChannelRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryIncentivizedPacketsForChannelRequest.Merge(m, src) +} +func (m *QueryIncentivizedPacketsForChannelRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryIncentivizedPacketsForChannelRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryIncentivizedPacketsForChannelRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryIncentivizedPacketsForChannelRequest proto.InternalMessageInfo + +func (m *QueryIncentivizedPacketsForChannelRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +func (m *QueryIncentivizedPacketsForChannelRequest) GetPortId() string { + if m != nil { + return m.PortId + } + return "" +} + +func (m *QueryIncentivizedPacketsForChannelRequest) GetChannelId() string { + if m != nil { + return m.ChannelId + } + return "" +} + +func (m *QueryIncentivizedPacketsForChannelRequest) GetQueryHeight() uint64 { + if m != nil { + return m.QueryHeight + } + return 0 +} + +// QueryIncentivizedPacketsResponse is the response type for the incentivized packets RPC +type QueryIncentivizedPacketsForChannelResponse struct { + // Map of all incentivized_packets + IncentivizedPackets []*IdentifiedPacketFees `protobuf:"bytes,1,rep,name=incentivized_packets,json=incentivizedPackets,proto3" json:"incentivized_packets,omitempty"` +} + +func (m *QueryIncentivizedPacketsForChannelResponse) Reset() { + *m = QueryIncentivizedPacketsForChannelResponse{} +} +func (m *QueryIncentivizedPacketsForChannelResponse) String() string { + return proto.CompactTextString(m) +} +func (*QueryIncentivizedPacketsForChannelResponse) ProtoMessage() {} +func (*QueryIncentivizedPacketsForChannelResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_0638a8a78ca2503c, []int{5} +} +func (m *QueryIncentivizedPacketsForChannelResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryIncentivizedPacketsForChannelResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryIncentivizedPacketsForChannelResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryIncentivizedPacketsForChannelResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryIncentivizedPacketsForChannelResponse.Merge(m, src) +} +func (m *QueryIncentivizedPacketsForChannelResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryIncentivizedPacketsForChannelResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryIncentivizedPacketsForChannelResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryIncentivizedPacketsForChannelResponse proto.InternalMessageInfo + +func (m *QueryIncentivizedPacketsForChannelResponse) GetIncentivizedPackets() []*IdentifiedPacketFees { + if m != nil { + return m.IncentivizedPackets + } + return nil +} + // QueryTotalRecvFeesRequest defines the request type for the TotalRecvFees rpc type QueryTotalRecvFeesRequest struct { // the packet identifier for the associated fees @@ -245,7 +371,7 @@ func (m *QueryTotalRecvFeesRequest) Reset() { *m = QueryTotalRecvFeesReq func (m *QueryTotalRecvFeesRequest) String() string { return proto.CompactTextString(m) } func (*QueryTotalRecvFeesRequest) ProtoMessage() {} func (*QueryTotalRecvFeesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_0638a8a78ca2503c, []int{4} + return fileDescriptor_0638a8a78ca2503c, []int{6} } func (m *QueryTotalRecvFeesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -291,7 +417,7 @@ func (m *QueryTotalRecvFeesResponse) Reset() { *m = QueryTotalRecvFeesRe func (m *QueryTotalRecvFeesResponse) String() string { return proto.CompactTextString(m) } func (*QueryTotalRecvFeesResponse) ProtoMessage() {} func (*QueryTotalRecvFeesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_0638a8a78ca2503c, []int{5} + return fileDescriptor_0638a8a78ca2503c, []int{7} } func (m *QueryTotalRecvFeesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -337,7 +463,7 @@ func (m *QueryTotalAckFeesRequest) Reset() { *m = QueryTotalAckFeesReque func (m *QueryTotalAckFeesRequest) String() string { return proto.CompactTextString(m) } func (*QueryTotalAckFeesRequest) ProtoMessage() {} func (*QueryTotalAckFeesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_0638a8a78ca2503c, []int{6} + return fileDescriptor_0638a8a78ca2503c, []int{8} } func (m *QueryTotalAckFeesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -383,7 +509,7 @@ func (m *QueryTotalAckFeesResponse) Reset() { *m = QueryTotalAckFeesResp func (m *QueryTotalAckFeesResponse) String() string { return proto.CompactTextString(m) } func (*QueryTotalAckFeesResponse) ProtoMessage() {} func (*QueryTotalAckFeesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_0638a8a78ca2503c, []int{7} + return fileDescriptor_0638a8a78ca2503c, []int{9} } func (m *QueryTotalAckFeesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -429,7 +555,7 @@ func (m *QueryTotalTimeoutFeesRequest) Reset() { *m = QueryTotalTimeoutF func (m *QueryTotalTimeoutFeesRequest) String() string { return proto.CompactTextString(m) } func (*QueryTotalTimeoutFeesRequest) ProtoMessage() {} func (*QueryTotalTimeoutFeesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_0638a8a78ca2503c, []int{8} + return fileDescriptor_0638a8a78ca2503c, []int{10} } func (m *QueryTotalTimeoutFeesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -475,7 +601,7 @@ func (m *QueryTotalTimeoutFeesResponse) Reset() { *m = QueryTotalTimeout func (m *QueryTotalTimeoutFeesResponse) String() string { return proto.CompactTextString(m) } func (*QueryTotalTimeoutFeesResponse) ProtoMessage() {} func (*QueryTotalTimeoutFeesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_0638a8a78ca2503c, []int{9} + return fileDescriptor_0638a8a78ca2503c, []int{11} } func (m *QueryTotalTimeoutFeesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -516,6 +642,8 @@ func init() { proto.RegisterType((*QueryIncentivizedPacketsResponse)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketsResponse") proto.RegisterType((*QueryIncentivizedPacketRequest)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketRequest") proto.RegisterType((*QueryIncentivizedPacketResponse)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketResponse") + proto.RegisterType((*QueryIncentivizedPacketsForChannelRequest)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketsForChannelRequest") + proto.RegisterType((*QueryIncentivizedPacketsForChannelResponse)(nil), "ibc.applications.fee.v1.QueryIncentivizedPacketsForChannelResponse") proto.RegisterType((*QueryTotalRecvFeesRequest)(nil), "ibc.applications.fee.v1.QueryTotalRecvFeesRequest") proto.RegisterType((*QueryTotalRecvFeesResponse)(nil), "ibc.applications.fee.v1.QueryTotalRecvFeesResponse") proto.RegisterType((*QueryTotalAckFeesRequest)(nil), "ibc.applications.fee.v1.QueryTotalAckFeesRequest") @@ -529,61 +657,67 @@ func init() { } var fileDescriptor_0638a8a78ca2503c = []byte{ - // 853 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xcf, 0x6e, 0xe3, 0x44, - 0x1c, 0xce, 0x84, 0x05, 0xda, 0x49, 0x11, 0xab, 0xc9, 0x4a, 0x64, 0xa3, 0x5d, 0x27, 0x6b, 0x04, - 0x44, 0x48, 0xf1, 0x28, 0xa9, 0x16, 0x76, 0x39, 0x41, 0x17, 0x2d, 0xf4, 0x44, 0x89, 0x7a, 0x42, - 0xa0, 0xe0, 0x8c, 0x27, 0xce, 0x28, 0x89, 0xc7, 0x8d, 0x27, 0x86, 0xf4, 0x0f, 0x12, 0x95, 0x2a, - 0x24, 0xd4, 0x03, 0x12, 0x12, 0x07, 0x5e, 0x00, 0x89, 0x37, 0xe0, 0x0d, 0x7a, 0xe0, 0x50, 0x89, - 0x0b, 0xa7, 0x82, 0x5a, 0x9e, 0x00, 0x71, 0xe0, 0x88, 0x66, 0x3c, 0x76, 0x5c, 0x12, 0x43, 0x52, - 0xb5, 0xa7, 0xd8, 0xf3, 0xfb, 0xf7, 0x7d, 0xdf, 0x8c, 0xbf, 0x09, 0x7c, 0x99, 0x75, 0x08, 0xb6, - 0x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 0xae, 0xff, 0x13, 0x00, 0x00, 0xff, 0xff, 0x9b, 0xa6, 0xbd, - 0x0f, 0x59, 0x0b, 0x00, 0x00, + // 956 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0xcf, 0x6f, 0xdc, 0x44, + 0x14, 0xce, 0xa4, 0xa1, 0x4d, 0x66, 0x83, 0xa8, 0x26, 0x95, 0x9a, 0x5a, 0x8d, 0x93, 0x1a, 0x01, + 0xa1, 0xd2, 0x7a, 0x94, 0x8d, 0x0a, 0x2d, 0x42, 0x08, 0x92, 0x2a, 0x90, 0x13, 0x65, 0xd5, 0x13, + 0x02, 0x6d, 0xbd, 0xe3, 0x59, 0x67, 0x94, 0x5d, 0x8f, 0xbb, 0xf6, 0x1a, 0xb6, 0x69, 0x90, 0xa8, + 0x14, 0x21, 0xa1, 0x0a, 0x21, 0x21, 0x71, 0xe0, 0x1f, 0x40, 0xe2, 0x3f, 0xe0, 0xc0, 0xbd, 0x27, + 0x54, 0x89, 0x0b, 0xa7, 0x82, 0x12, 0xce, 0x1c, 0x10, 0x07, 0x8e, 0x68, 0x7e, 0xd8, 0xeb, 0xe0, + 0x75, 0xb1, 0xd3, 0xcd, 0x29, 0xf6, 0xbc, 0xf7, 0xe6, 0x7d, 0xdf, 0xf7, 0xc6, 0xdf, 0x64, 0xe1, + 0x8b, 0xac, 0x4d, 0xb0, 0x13, 0x04, 0x5d, 0x46, 0x9c, 0x88, 0x71, 0x3f, 0xc4, 0x1d, 0x4a, 0x71, + 0xbc, 0x86, 0xef, 0x0e, 0x68, 0x7f, 0x68, 0x07, 0x7d, 0x1e, 0x71, 0x74, 0x91, 0xb5, 0x89, 0x9d, + 0x4d, 0xb2, 0x3b, 0x94, 0xda, 0xf1, 0x9a, 0x71, 0xc1, 0xe3, 0x1e, 0x97, 0x39, 0x58, 0x3c, 0xa9, + 0x74, 0xe3, 0xb2, 0xc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x1f, 0x9a, 0xe0, 0xf7, + 0x43, 0x13, 0x7c, 0x7d, 0x64, 0x4e, 0x3d, 0x3e, 0x32, 0xa7, 0x7e, 0x3d, 0x32, 0xa7, 0x3e, 0xbc, + 0x96, 0xbf, 0x10, 0x58, 0x9b, 0xd4, 0x3d, 0x8e, 0xe3, 0x75, 0xdc, 0xe3, 0xee, 0xa0, 0x4b, 0x43, + 0x85, 0xb9, 0x71, 0xa3, 0x2e, 0x60, 0xcb, 0x3b, 0xa2, 0x7d, 0x56, 0xfe, 0x4c, 0x59, 0xff, 0x37, + 0x00, 0x00, 0xff, 0xff, 0x54, 0xbb, 0x0e, 0x52, 0xac, 0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -603,6 +737,8 @@ type QueryClient interface { // Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the // given packet IncentivizedPacket(ctx context.Context, in *QueryIncentivizedPacketRequest, opts ...grpc.CallOption) (*QueryIncentivizedPacketResponse, error) + // Gets all incentivized packets for a specific channel + IncentivizedPacketsForChannel(ctx context.Context, in *QueryIncentivizedPacketsForChannelRequest, opts ...grpc.CallOption) (*QueryIncentivizedPacketsForChannelResponse, error) // TotalRecvFees returns the total receive fees for a packet given its identifier TotalRecvFees(ctx context.Context, in *QueryTotalRecvFeesRequest, opts ...grpc.CallOption) (*QueryTotalRecvFeesResponse, error) // TotalAckFees returns the total acknowledgement fees for a packet given its identifier @@ -637,6 +773,15 @@ func (c *queryClient) IncentivizedPacket(ctx context.Context, in *QueryIncentivi return out, nil } +func (c *queryClient) IncentivizedPacketsForChannel(ctx context.Context, in *QueryIncentivizedPacketsForChannelRequest, opts ...grpc.CallOption) (*QueryIncentivizedPacketsForChannelResponse, error) { + out := new(QueryIncentivizedPacketsForChannelResponse) + err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Query/IncentivizedPacketsForChannel", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) TotalRecvFees(ctx context.Context, in *QueryTotalRecvFeesRequest, opts ...grpc.CallOption) (*QueryTotalRecvFeesResponse, error) { out := new(QueryTotalRecvFeesResponse) err := c.cc.Invoke(ctx, "/ibc.applications.fee.v1.Query/TotalRecvFees", in, out, opts...) @@ -671,6 +816,8 @@ type QueryServer interface { // Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the // given packet IncentivizedPacket(context.Context, *QueryIncentivizedPacketRequest) (*QueryIncentivizedPacketResponse, error) + // Gets all incentivized packets for a specific channel + IncentivizedPacketsForChannel(context.Context, *QueryIncentivizedPacketsForChannelRequest) (*QueryIncentivizedPacketsForChannelResponse, error) // TotalRecvFees returns the total receive fees for a packet given its identifier TotalRecvFees(context.Context, *QueryTotalRecvFeesRequest) (*QueryTotalRecvFeesResponse, error) // TotalAckFees returns the total acknowledgement fees for a packet given its identifier @@ -689,6 +836,9 @@ func (*UnimplementedQueryServer) IncentivizedPackets(ctx context.Context, req *Q func (*UnimplementedQueryServer) IncentivizedPacket(ctx context.Context, req *QueryIncentivizedPacketRequest) (*QueryIncentivizedPacketResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method IncentivizedPacket not implemented") } +func (*UnimplementedQueryServer) IncentivizedPacketsForChannel(ctx context.Context, req *QueryIncentivizedPacketsForChannelRequest) (*QueryIncentivizedPacketsForChannelResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method IncentivizedPacketsForChannel not implemented") +} func (*UnimplementedQueryServer) TotalRecvFees(ctx context.Context, req *QueryTotalRecvFeesRequest) (*QueryTotalRecvFeesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method TotalRecvFees not implemented") } @@ -739,6 +889,24 @@ func _Query_IncentivizedPacket_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Query_IncentivizedPacketsForChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryIncentivizedPacketsForChannelRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).IncentivizedPacketsForChannel(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/ibc.applications.fee.v1.Query/IncentivizedPacketsForChannel", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).IncentivizedPacketsForChannel(ctx, req.(*QueryIncentivizedPacketsForChannelRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_TotalRecvFees_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryTotalRecvFeesRequest) if err := dec(in); err != nil { @@ -805,6 +973,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "IncentivizedPacket", Handler: _Query_IncentivizedPacket_Handler, }, + { + MethodName: "IncentivizedPacketsForChannel", + Handler: _Query_IncentivizedPacketsForChannel_Handler, + }, { MethodName: "TotalRecvFees", Handler: _Query_TotalRecvFees_Handler, @@ -970,6 +1142,97 @@ func (m *QueryIncentivizedPacketResponse) MarshalToSizedBuffer(dAtA []byte) (int return len(dAtA) - i, nil } +func (m *QueryIncentivizedPacketsForChannelRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryIncentivizedPacketsForChannelRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryIncentivizedPacketsForChannelRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.QueryHeight != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.QueryHeight)) + i-- + dAtA[i] = 0x20 + } + if len(m.ChannelId) > 0 { + i -= len(m.ChannelId) + copy(dAtA[i:], m.ChannelId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + i-- + dAtA[i] = 0x1a + } + if len(m.PortId) > 0 { + i -= len(m.PortId) + copy(dAtA[i:], m.PortId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.PortId))) + i-- + dAtA[i] = 0x12 + } + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryIncentivizedPacketsForChannelResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryIncentivizedPacketsForChannelResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryIncentivizedPacketsForChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.IncentivizedPackets) > 0 { + for iNdEx := len(m.IncentivizedPackets) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.IncentivizedPackets[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *QueryTotalRecvFeesRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1247,6 +1510,45 @@ func (m *QueryIncentivizedPacketResponse) Size() (n int) { return n } +func (m *QueryIncentivizedPacketsForChannelRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.PortId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.ChannelId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.QueryHeight != 0 { + n += 1 + sovQuery(uint64(m.QueryHeight)) + } + return n +} + +func (m *QueryIncentivizedPacketsForChannelResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.IncentivizedPackets) > 0 { + for _, e := range m.IncentivizedPackets { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func (m *QueryTotalRecvFeesRequest) Size() (n int) { if m == nil { return 0 @@ -1705,6 +2007,259 @@ func (m *QueryIncentivizedPacketResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryIncentivizedPacketsForChannelRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryIncentivizedPacketsForChannelRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryIncentivizedPacketsForChannelRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PortId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PortId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChannelId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field QueryHeight", wireType) + } + m.QueryHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.QueryHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryIncentivizedPacketsForChannelResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: QueryIncentivizedPacketsForChannelResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryIncentivizedPacketsForChannelResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IncentivizedPackets", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.IncentivizedPackets = append(m.IncentivizedPackets, &IdentifiedPacketFees{}) + if err := m.IncentivizedPackets[len(m.IncentivizedPackets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryTotalRecvFeesRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/modules/apps/29-fee/types/query.pb.gw.go b/modules/apps/29-fee/types/query.pb.gw.go index 172967a9625..8775f7404fd 100644 --- a/modules/apps/29-fee/types/query.pb.gw.go +++ b/modules/apps/29-fee/types/query.pb.gw.go @@ -183,6 +183,100 @@ func local_request_Query_IncentivizedPacket_0(ctx context.Context, marshaler run } +var ( + filter_Query_IncentivizedPacketsForChannel_0 = &utilities.DoubleArray{Encoding: map[string]int{"port_id": 0, "channel_id": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} +) + +func request_Query_IncentivizedPacketsForChannel_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryIncentivizedPacketsForChannelRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["port_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port_id") + } + + protoReq.PortId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err) + } + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_IncentivizedPacketsForChannel_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.IncentivizedPacketsForChannel(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_IncentivizedPacketsForChannel_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryIncentivizedPacketsForChannelRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["port_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "port_id") + } + + protoReq.PortId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "port_id", err) + } + + val, ok = pathParams["channel_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") + } + + protoReq.ChannelId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_IncentivizedPacketsForChannel_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.IncentivizedPacketsForChannel(ctx, &protoReq) + return msg, metadata, err + +} + var ( filter_Query_TotalRecvFees_0 = &utilities.DoubleArray{Encoding: map[string]int{"packet_id": 0, "port_id": 1, "channel_id": 2, "sequence": 3}, Base: []int{1, 1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 2, 2, 2, 3, 4, 5}} ) @@ -577,6 +671,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_IncentivizedPacketsForChannel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_IncentivizedPacketsForChannel_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_IncentivizedPacketsForChannel_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_TotalRecvFees_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -718,6 +832,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_IncentivizedPacketsForChannel_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_IncentivizedPacketsForChannel_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_IncentivizedPacketsForChannel_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_TotalRecvFees_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -786,6 +920,8 @@ var ( pattern_Query_IncentivizedPacket_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "incentivized_packet", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_IncentivizedPacketsForChannel_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5, 1, 0, 4, 1, 5, 6}, []string{"ibc", "apps", "fee", "v1", "incentivized_packets", "port_id", "channel_id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_TotalRecvFees_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "total_recv_fees", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_TotalAckFees_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 1, 0, 4, 1, 5, 6, 2, 7, 1, 0, 4, 1, 5, 8, 2, 9, 1, 0, 4, 1, 5, 10}, []string{"ibc", "apps", "fee", "v1", "total_ack_fees", "port", "packet_id.port_id", "channel", "packet_id.channel_id", "sequence", "packet_id.sequence"}, "", runtime.AssumeColonVerbOpt(true))) @@ -798,6 +934,8 @@ var ( forward_Query_IncentivizedPacket_0 = runtime.ForwardResponseMessage + forward_Query_IncentivizedPacketsForChannel_0 = runtime.ForwardResponseMessage + forward_Query_TotalRecvFees_0 = runtime.ForwardResponseMessage forward_Query_TotalAckFees_0 = runtime.ForwardResponseMessage diff --git a/proto/ibc/applications/fee/v1/query.proto b/proto/ibc/applications/fee/v1/query.proto index 8cbb51859a3..8f2f7188839 100644 --- a/proto/ibc/applications/fee/v1/query.proto +++ b/proto/ibc/applications/fee/v1/query.proto @@ -26,6 +26,12 @@ service Query { "{packet_id.sequence}"; } + // Gets all incentivized packets for a specific channel + rpc IncentivizedPacketsForChannel(QueryIncentivizedPacketsForChannelRequest) + returns (QueryIncentivizedPacketsForChannelResponse) { + option (google.api.http).get = "/ibc/apps/fee/v1/incentivized_packets/{port_id}/{channel_id}"; + } + // TotalRecvFees returns the total receive fees for a packet given its identifier rpc TotalRecvFees(QueryTotalRecvFeesRequest) returns (QueryTotalRecvFeesResponse) { option (google.api.http).get = "/ibc/apps/fee/v1/total_recv_fees/port/{packet_id.port_id}/channel/" @@ -73,6 +79,23 @@ message QueryIncentivizedPacketResponse { ibc.applications.fee.v1.IdentifiedPacketFees incentivized_packet = 1 [(gogoproto.nullable) = false]; } +// QueryIncentivizedPacketsForChannelRequest is the request type for querying for all incentivized packets +// for a specific channel +message QueryIncentivizedPacketsForChannelRequest { + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; + string port_id = 2; + string channel_id = 3; + // Height to query at + uint64 query_height = 4; +} + +// QueryIncentivizedPacketsResponse is the response type for the incentivized packets RPC +message QueryIncentivizedPacketsForChannelResponse { + // Map of all incentivized_packets + repeated ibc.applications.fee.v1.IdentifiedPacketFees incentivized_packets = 1; +} + // QueryTotalRecvFeesRequest defines the request type for the TotalRecvFees rpc message QueryTotalRecvFeesRequest { // the packet identifier for the associated fees From b33b0a77018aca6070d5158b58887db17f8dd7e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Thu, 3 Mar 2022 12:08:34 +0100 Subject: [PATCH 72/79] add function EscrowAccountHasBalance (#1042) * add function EscrowAccountHasBalance * change API to use sdk.Coins --- modules/apps/29-fee/keeper/keeper.go | 11 +++++++++++ modules/apps/29-fee/keeper/keeper_test.go | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index 4caa0579846..cb481543a23 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -76,6 +76,17 @@ func (k Keeper) GetFeeModuleAddress() sdk.AccAddress { return k.authKeeper.GetModuleAddress(types.ModuleName) } +// EscrowAccountHasBalance verifies if the escrow account has the provided fee. +func (k Keeper) EscrowAccountHasBalance(ctx sdk.Context, coins sdk.Coins) bool { + for _, coin := range coins { + if !k.bankKeeper.HasBalance(ctx, k.GetFeeModuleAddress(), coin) { + return false + } + } + + return true +} + // SetFeeEnabled sets a flag to determine if fee handling logic should run for the given channel // identified by channel and port identifiers. func (k Keeper) SetFeeEnabled(ctx sdk.Context, portID, channelID string) { diff --git a/modules/apps/29-fee/keeper/keeper_test.go b/modules/apps/29-fee/keeper/keeper_test.go index 92705c9c7cc..1f29a8872d5 100644 --- a/modules/apps/29-fee/keeper/keeper_test.go +++ b/modules/apps/29-fee/keeper/keeper_test.go @@ -67,6 +67,27 @@ func TestKeeperTestSuite(t *testing.T) { suite.Run(t, new(KeeperTestSuite)) } +func (suite *KeeperTestSuite) TestEscrowAccountHasBalance() { + fee := types.Fee{ + AckFee: defaultAckFee, + RecvFee: defaultReceiveFee, + TimeoutFee: defaultTimeoutFee, + } + + suite.Require().False(suite.chainA.GetSimApp().IBCFeeKeeper.EscrowAccountHasBalance(suite.chainA.GetContext(), fee.Total())) + + // set fee in escrow account + err := suite.chainA.GetSimApp().BankKeeper.SendCoinsFromAccountToModule(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress(), types.ModuleName, fee.Total()) + suite.Require().Nil(err) + + suite.Require().True(suite.chainA.GetSimApp().IBCFeeKeeper.EscrowAccountHasBalance(suite.chainA.GetContext(), fee.Total())) + + // increase ack fee + fee.AckFee = fee.AckFee.Add(defaultAckFee...) + suite.Require().False(suite.chainA.GetSimApp().IBCFeeKeeper.EscrowAccountHasBalance(suite.chainA.GetContext(), fee.Total())) + +} + func (suite *KeeperTestSuite) TestFeesInEscrow() { suite.coordinator.Setup(suite.path) From f3ee8decabdd5b45c4f08ece096f9e04e0c22689 Mon Sep 17 00:00:00 2001 From: Charly Date: Thu, 3 Mar 2022 17:17:29 +0100 Subject: [PATCH 73/79] feat: ParseKeyCounterpartyRelayer function (#1047) --- modules/apps/29-fee/keeper/keeper.go | 11 ++++---- modules/apps/29-fee/types/keys.go | 14 ++++++++++- modules/apps/29-fee/types/keys_test.go | 35 ++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 6 deletions(-) diff --git a/modules/apps/29-fee/keeper/keeper.go b/modules/apps/29-fee/keeper/keeper.go index cb481543a23..c0c43dbecc6 100644 --- a/modules/apps/29-fee/keeper/keeper.go +++ b/modules/apps/29-fee/keeper/keeper.go @@ -1,8 +1,6 @@ package keeper import ( - "strings" - "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" @@ -173,12 +171,15 @@ func (k Keeper) GetAllRelayerAddresses(ctx sdk.Context) []types.RegisteredRelaye var registeredAddrArr []types.RegisteredRelayerAddress for ; iterator.Valid(); iterator.Next() { - keySplit := strings.Split(string(iterator.Key()), "/") + address, channelID, err := types.ParseKeyCounterpartyRelayer(string(iterator.Key())) + if err != nil { + panic(err) + } addr := types.RegisteredRelayerAddress{ - Address: keySplit[1], + Address: address, CounterpartyAddress: string(iterator.Value()), - ChannelId: keySplit[2], + ChannelId: channelID, } registeredAddrArr = append(registeredAddrArr, addr) diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index c9fab858919..68154661d6e 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -64,11 +64,23 @@ func ParseKeyFeeEnabled(key string) (portID, channelID string, err error) { return portID, channelID, nil } -// KeyCounterpartyRelayer returns the key for relayer address -> counteryparty address mapping +// KeyCounterpartyRelayer returns the key for relayer address -> counterparty address mapping func KeyCounterpartyRelayer(address, channelID string) []byte { return []byte(fmt.Sprintf("%s/%s/%s", CounterpartyRelayerAddressKeyPrefix, address, channelID)) } +// ParseKeyCounterpartyRelayer returns the registered relayer address and channelID used to store the counterpartyrelayer address +func ParseKeyCounterpartyRelayer(key string) (address string, channelID string, error error) { + keySplit := strings.Split(key, "/") + if len(keySplit) != 3 { + return "", "", sdkerrors.Wrapf( + sdkerrors.ErrLogic, "key provided is incorrect: the key split has incorrect length, expected %d, got %d", 3, len(keySplit), + ) + } + + return keySplit[1], keySplit[2], nil +} + // KeyForwardRelayerAddress returns the key for packetID -> forwardAddress mapping func KeyForwardRelayerAddress(packetId channeltypes.PacketId) []byte { return []byte(fmt.Sprintf("%s/%s/%s/%d", ForwardRelayerPrefix, packetId.PortId, packetId.ChannelId, packetId.Sequence)) diff --git a/modules/apps/29-fee/types/keys_test.go b/modules/apps/29-fee/types/keys_test.go index e6ef922b757..518b2d65604 100644 --- a/modules/apps/29-fee/types/keys_test.go +++ b/modules/apps/29-fee/types/keys_test.go @@ -139,3 +139,38 @@ func TestParseKeyForwardRelayerAddress(t *testing.T) { } } } + +func TestParseKeyCounterpartyRelayer(t *testing.T) { + var ( + relayerAddress = "relayer_address" + ) + + testCases := []struct { + name string + key string + expPass bool + }{ + { + "success", + string(types.KeyCounterpartyRelayer(relayerAddress, ibctesting.FirstChannelID)), + true, + }, + { + "incorrect key - key split has incorrect length", + "relayerAddress/relayer_address/transfer/channel-0", + false, + }, + } + + for _, tc := range testCases { + address, channelID, err := types.ParseKeyCounterpartyRelayer(tc.key) + + if tc.expPass { + require.NoError(t, err) + require.Equal(t, relayerAddress, address) + require.Equal(t, ibctesting.FirstChannelID, channelID) + } else { + require.Error(t, err) + } + } +} From db88c8462353fb816ee96ae6660b354974be195a Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Thu, 3 Mar 2022 17:45:03 +0000 Subject: [PATCH 74/79] chore: adding queries to cmd builder (#1057) --- modules/apps/29-fee/client/cli/cli.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/apps/29-fee/client/cli/cli.go b/modules/apps/29-fee/client/cli/cli.go index a8caf155310..292f1d7b3d8 100644 --- a/modules/apps/29-fee/client/cli/cli.go +++ b/modules/apps/29-fee/client/cli/cli.go @@ -16,6 +16,8 @@ func GetQueryCmd() *cobra.Command { queryCmd.AddCommand( GetCmdTotalRecvFees(), + GetCmdTotalAckFees(), + GetCmdTotalTimeoutFees(), ) return queryCmd From 637652d033347e67df3d4a4ed97b72a74b85ddc8 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Fri, 4 Mar 2022 15:57:17 +0000 Subject: [PATCH 75/79] chore: update ics29 protodocs (#1055) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * updating protodocs comments and regen code/docs * Update proto/ibc/applications/fee/v1/tx.proto Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> * updating incentivized ack doc Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> --- docs/ibc/proto-docs.md | 122 ++++++++++---------- modules/apps/29-fee/types/ack.pb.go | 8 +- modules/apps/29-fee/types/fee.pb.go | 98 ++++++++-------- modules/apps/29-fee/types/genesis.pb.go | 29 +++-- modules/apps/29-fee/types/query.pb.go | 32 +++-- modules/apps/29-fee/types/tx.pb.go | 39 ++++--- proto/ibc/applications/fee/v1/ack.proto | 8 +- proto/ibc/applications/fee/v1/fee.proto | 24 ++-- proto/ibc/applications/fee/v1/genesis.proto | 23 +++- proto/ibc/applications/fee/v1/query.proto | 29 +++-- proto/ibc/applications/fee/v1/tx.proto | 39 ++++--- 11 files changed, 250 insertions(+), 201 deletions(-) diff --git a/docs/ibc/proto-docs.md b/docs/ibc/proto-docs.md index 0d50531b2e0..573ca53088b 100644 --- a/docs/ibc/proto-docs.md +++ b/docs/ibc/proto-docs.md @@ -343,14 +343,13 @@ ### IncentivizedAcknowledgement IncentivizedAcknowledgement is the acknowledgement format to be used by applications wrapped in the fee middleware -It contains the raw acknowledgement bytes, as well as the forward relayer address | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `result` | [bytes](#bytes) | | | -| `forward_relayer_address` | [string](#string) | | | -| `underlying_app_success` | [bool](#bool) | | | +| `result` | [bytes](#bytes) | | the underlying app acknowledgement result bytes | +| `forward_relayer_address` | [string](#string) | | the relayer address which submits the recv packet message | +| `underlying_app_success` | [bool](#bool) | | success flag of the base application callback | @@ -711,16 +710,14 @@ CLOSED, INIT, TRYOPEN, OPEN or UNINITIALIZED. ### Fee -Fee implements the ics29 Fee interface -See Fee Payment Middleware spec: -https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middleware-contract +Fee defines the ICS29 receive, acknowledgement and timeout fees | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `recv_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | -| `ack_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | -| `timeout_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | | +| `recv_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | the packet receive fee | +| `ack_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | the packet acknowledgement fee | +| `timeout_fee` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | the packet timeout fee | @@ -735,8 +732,8 @@ IdentifiedPacketFees contains a list of type PacketFee and associated PacketId | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | | -| `packet_fees` | [PacketFee](#ibc.applications.fee.v1.PacketFee) | repeated | | +| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | unique packet identifier comprised of the channel ID, port ID and sequence | +| `packet_fees` | [PacketFee](#ibc.applications.fee.v1.PacketFee) | repeated | list of packet fees | @@ -746,15 +743,14 @@ IdentifiedPacketFees contains a list of type PacketFee and associated PacketId ### PacketFee -PacketFee contains the relayer fee, refund address and an optional list of relayers that are permitted to receive the -fee +PacketFee contains ICS29 relayer fees, refund address and optional list of permitted relayers | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | -| `refund_address` | [string](#string) | | | -| `relayers` | [string](#string) | repeated | | +| `fee` | [Fee](#ibc.applications.fee.v1.Fee) | | fee encapsulates the recv, ack and timeout fees associated with an IBC packet | +| `refund_address` | [string](#string) | | the refund address for unspent fees | +| `relayers` | [string](#string) | repeated | optional list of relayers permitted to receive fees | @@ -769,7 +765,7 @@ PacketFees contains a list of type PacketFee | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `packet_fees` | [PacketFee](#ibc.applications.fee.v1.PacketFee) | repeated | | +| `packet_fees` | [PacketFee](#ibc.applications.fee.v1.PacketFee) | repeated | list of packet fees | @@ -800,8 +796,8 @@ FeeEnabledChannel contains the PortID & ChannelID for a fee enabled channel | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `port_id` | [string](#string) | | | -| `channel_id` | [string](#string) | | | +| `port_id` | [string](#string) | | unique port identifier | +| `channel_id` | [string](#string) | | unique channel identifier | @@ -811,13 +807,13 @@ FeeEnabledChannel contains the PortID & ChannelID for a fee enabled channel ### ForwardRelayerAddress -ForwardRelayerAddress contains the forward relayer address and packetId used for async acknowledgements +ForwardRelayerAddress contains the forward relayer address and PacketId used for async acknowledgements | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | | -| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | | +| `address` | [string](#string) | | the forward relayer address | +| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | unique packet identifer comprised of the channel ID, port ID and sequence | @@ -827,15 +823,15 @@ ForwardRelayerAddress contains the forward relayer address and packetId used for ### GenesisState -GenesisState defines the fee middleware genesis state +GenesisState defines the ICS29 fee middleware genesis state | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `identified_fees` | [IdentifiedPacketFees](#ibc.applications.fee.v1.IdentifiedPacketFees) | repeated | | -| `fee_enabled_channels` | [FeeEnabledChannel](#ibc.applications.fee.v1.FeeEnabledChannel) | repeated | | -| `registered_relayers` | [RegisteredRelayerAddress](#ibc.applications.fee.v1.RegisteredRelayerAddress) | repeated | | -| `forward_relayers` | [ForwardRelayerAddress](#ibc.applications.fee.v1.ForwardRelayerAddress) | repeated | | +| `identified_fees` | [IdentifiedPacketFees](#ibc.applications.fee.v1.IdentifiedPacketFees) | repeated | list of identified packet fees | +| `fee_enabled_channels` | [FeeEnabledChannel](#ibc.applications.fee.v1.FeeEnabledChannel) | repeated | list of fee enabled channels | +| `registered_relayers` | [RegisteredRelayerAddress](#ibc.applications.fee.v1.RegisteredRelayerAddress) | repeated | list of registered relayer addresses | +| `forward_relayers` | [ForwardRelayerAddress](#ibc.applications.fee.v1.ForwardRelayerAddress) | repeated | list of forward relayer addresses | @@ -850,9 +846,9 @@ RegisteredRelayerAddress contains the address and counterparty address for a spe | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | | -| `counterparty_address` | [string](#string) | | | -| `channel_id` | [string](#string) | | | +| `address` | [string](#string) | | the relayer address | +| `counterparty_address` | [string](#string) | | the counterparty relayer address | +| `channel_id` | [string](#string) | | unique channel identifier | @@ -911,13 +907,13 @@ See ICS004: https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel- ### QueryIncentivizedPacketRequest -QueryIncentivizedPacketRequest is the request type for querying for all incentivized packets +QueryIncentivizedPacketRequest defines the request type for the IncentivizedPacket rpc | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | PacketID | -| `query_height` | [uint64](#uint64) | | Height to query at | +| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | unique packet identifier comprised of channel ID, port ID and sequence | +| `query_height` | [uint64](#uint64) | | block height at which to query | @@ -927,12 +923,12 @@ QueryIncentivizedPacketRequest is the request type for querying for all incentiv ### QueryIncentivizedPacketResponse -QueryIncentivizedPacketsResponse is the response type for the incentivized packet RPC +QueryIncentivizedPacketsResponse defines the response type for the IncentivizedPacket rpc | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `incentivized_packet` | [IdentifiedPacketFees](#ibc.applications.fee.v1.IdentifiedPacketFees) | | Incentivized_packet | +| `incentivized_packet` | [IdentifiedPacketFees](#ibc.applications.fee.v1.IdentifiedPacketFees) | | the identified fees for the incentivized packet | @@ -942,7 +938,7 @@ QueryIncentivizedPacketsResponse is the response type for the incentivized packe ### QueryIncentivizedPacketsForChannelRequest -QueryIncentivizedPacketsForChannelRequest is the request type for querying for all incentivized packets +QueryIncentivizedPacketsForChannelRequest defines the request type for querying for all incentivized packets for a specific channel @@ -961,7 +957,7 @@ for a specific channel ### QueryIncentivizedPacketsForChannelResponse -QueryIncentivizedPacketsResponse is the response type for the incentivized packets RPC +QueryIncentivizedPacketsResponse defines the response type for the incentivized packets RPC | Field | Type | Label | Description | @@ -976,13 +972,13 @@ QueryIncentivizedPacketsResponse is the response type for the incentivized packe ### QueryIncentivizedPacketsRequest -QueryIncentivizedPacketsRequest is the request type for querying for all incentivized packets +QueryIncentivizedPacketsRequest defines the request type for the IncentivizedPackets rpc | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | -| `query_height` | [uint64](#uint64) | | Height to query at | +| `query_height` | [uint64](#uint64) | | block height at which to query | @@ -992,12 +988,12 @@ QueryIncentivizedPacketsRequest is the request type for querying for all incenti ### QueryIncentivizedPacketsResponse -QueryIncentivizedPacketsResponse is the response type for the incentivized packets RPC +QueryIncentivizedPacketsResponse defines the response type for the IncentivizedPackets rpc | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `incentivized_packets` | [IdentifiedPacketFees](#ibc.applications.fee.v1.IdentifiedPacketFees) | repeated | Map of all incentivized_packets | +| `incentivized_packets` | [IdentifiedPacketFees](#ibc.applications.fee.v1.IdentifiedPacketFees) | repeated | list of identified fees for incentivized packets | @@ -1103,12 +1099,12 @@ QueryTotalTimeoutFeesResponse defines the response type for the TotalTimeoutFees ### Query -Query provides defines the gRPC querier service. +Query defines the ICS29 gRPC querier service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `IncentivizedPackets` | [QueryIncentivizedPacketsRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsRequest) | [QueryIncentivizedPacketsResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsResponse) | Gets all incentivized packets | GET|/ibc/apps/fee/v1/incentivized_packets| -| `IncentivizedPacket` | [QueryIncentivizedPacketRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketRequest) | [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) | Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the given packet | GET|/ibc/apps/fee/v1/incentivized_packet/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| +| `IncentivizedPackets` | [QueryIncentivizedPacketsRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsRequest) | [QueryIncentivizedPacketsResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsResponse) | IncentivizedPackets returns all incentivized packets and their associated fees | GET|/ibc/apps/fee/v1/incentivized_packets| +| `IncentivizedPacket` | [QueryIncentivizedPacketRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketRequest) | [QueryIncentivizedPacketResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketResponse) | IncentivizedPacket returns all packet fees for a packet given its identifier | GET|/ibc/apps/fee/v1/incentivized_packet/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| | `IncentivizedPacketsForChannel` | [QueryIncentivizedPacketsForChannelRequest](#ibc.applications.fee.v1.QueryIncentivizedPacketsForChannelRequest) | [QueryIncentivizedPacketsForChannelResponse](#ibc.applications.fee.v1.QueryIncentivizedPacketsForChannelResponse) | Gets all incentivized packets for a specific channel | GET|/ibc/apps/fee/v1/incentivized_packets/{port_id}/{channel_id}| | `TotalRecvFees` | [QueryTotalRecvFeesRequest](#ibc.applications.fee.v1.QueryTotalRecvFeesRequest) | [QueryTotalRecvFeesResponse](#ibc.applications.fee.v1.QueryTotalRecvFeesResponse) | TotalRecvFees returns the total receive fees for a packet given its identifier | GET|/ibc/apps/fee/v1/total_recv_fees/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| | `TotalAckFees` | [QueryTotalAckFeesRequest](#ibc.applications.fee.v1.QueryTotalAckFeesRequest) | [QueryTotalAckFeesResponse](#ibc.applications.fee.v1.QueryTotalAckFeesResponse) | TotalAckFees returns the total acknowledgement fees for a packet given its identifier | GET|/ibc/apps/fee/v1/total_ack_fees/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/{packet_id.sequence}| @@ -1128,18 +1124,18 @@ Query provides defines the gRPC querier service. ### MsgPayPacketFee -MsgPayPacketFee defines the request type PayPacketFee RPC +MsgPayPacketFee defines the request type for the PayPacketFee rpc This Msg can be used to pay for a packet at the next sequence send & should be combined with the Msg that will be paid for | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `fee` | [Fee](#ibc.applications.fee.v1.Fee) | | | -| `source_port_id` | [string](#string) | | source channel port identifier | -| `source_channel_id` | [string](#string) | | source channel unique identifier | +| `fee` | [Fee](#ibc.applications.fee.v1.Fee) | | fee encapsulates the recv, ack and timeout fees associated with an IBC packet | +| `source_port_id` | [string](#string) | | the source port unique identifier | +| `source_channel_id` | [string](#string) | | the source channel unique identifer | | `signer` | [string](#string) | | account address to refund fee if necessary | -| `relayers` | [string](#string) | repeated | | +| `relayers` | [string](#string) | repeated | optional list of relayers permitted to the receive packet fees | @@ -1149,14 +1145,14 @@ paid for ### MsgPayPacketFeeAsync -MsgPayPacketFeeAsync defines the request type PayPacketFeeAsync RPC +MsgPayPacketFeeAsync defines the request type for the PayPacketFeeAsync rpc This Msg can be used to pay for a packet at a specified sequence (instead of the next sequence send) | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | unique packet identifier | -| `packet_fee` | [PacketFee](#ibc.applications.fee.v1.PacketFee) | | packet fee for incentivization | +| `packet_id` | [ibc.core.channel.v1.PacketId](#ibc.core.channel.v1.PacketId) | | unique packet identifier comprised of the channel ID, port ID and sequence | +| `packet_fee` | [PacketFee](#ibc.applications.fee.v1.PacketFee) | | the packet fee associated with a particular IBC packet | @@ -1166,7 +1162,7 @@ This Msg can be used to pay for a packet at a specified sequence (instead of the ### MsgPayPacketFeeAsyncResponse -MsgPayPacketFeeAsyncResponse defines the response type for Msg/PayPacketFeeAsync +MsgPayPacketFeeAsyncResponse defines the response type for the PayPacketFeeAsync rpc @@ -1176,7 +1172,7 @@ MsgPayPacketFeeAsyncResponse defines the response type for Msg/PayPacketFeeAsync ### MsgPayPacketFeeResponse -MsgPayPacketFeeResponse defines the response type for Msg/PayPacketFee +MsgPayPacketFeeResponse defines the response type for the PayPacketFee rpc @@ -1186,14 +1182,14 @@ MsgPayPacketFeeResponse defines the response type for Msg/PayPacketFee ### MsgRegisterCounterpartyAddress -MsgRegisterCounterpartyAddress is the request type for registering the counterparty address +MsgRegisterCounterpartyAddress defines the request type for the RegisterCounterpartyAddress rpc | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | | -| `counterparty_address` | [string](#string) | | | -| `channel_id` | [string](#string) | | | +| `address` | [string](#string) | | the relayer address | +| `counterparty_address` | [string](#string) | | the counterparty relayer address | +| `channel_id` | [string](#string) | | unique channel identifier | @@ -1203,7 +1199,7 @@ MsgRegisterCounterpartyAddress is the request type for registering the counterpa ### MsgRegisterCounterpartyAddressResponse -MsgRegisterCounterpartyAddressResponse defines the Msg/RegisterCounterypartyAddress response type +MsgRegisterCounterpartyAddressResponse defines the response type for the RegisterCounterpartyAddress rpc @@ -1219,13 +1215,13 @@ MsgRegisterCounterpartyAddressResponse defines the Msg/RegisterCounterypartyAddr ### Msg -Msg defines the ibc/fee Msg service. +Msg defines the ICS29 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. | | -| `PayPacketFee` | [MsgPayPacketFee](#ibc.applications.fee.v1.MsgPayPacketFee) | [MsgPayPacketFeeResponse](#ibc.applications.fee.v1.MsgPayPacketFeeResponse) | PayPacketFee defines a rpc handler method for MsgPayPacketFee PayPacketFee 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 packet at the next sequence | | -| `PayPacketFeeAsync` | [MsgPayPacketFeeAsync](#ibc.applications.fee.v1.MsgPayPacketFeeAsync) | [MsgPayPacketFeeAsyncResponse](#ibc.applications.fee.v1.MsgPayPacketFeeAsyncResponse) | PayPacketFeeAsync defines a rpc handler method for MsgPayPacketFeeAsync PayPacketFeeAsync is an open callback that may be called by any module/user that wishes to escrow funds in order to incentivize the relaying of a known packet | | +| `PayPacketFee` | [MsgPayPacketFee](#ibc.applications.fee.v1.MsgPayPacketFee) | [MsgPayPacketFeeResponse](#ibc.applications.fee.v1.MsgPayPacketFeeResponse) | PayPacketFee defines a rpc handler method for MsgPayPacketFee PayPacketFee 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 packet at the next sequence NOTE: This method is intended to be used within a multi msg transaction, where the subsequent msg that follows initiates the lifecycle of the incentivized packet | | +| `PayPacketFeeAsync` | [MsgPayPacketFeeAsync](#ibc.applications.fee.v1.MsgPayPacketFeeAsync) | [MsgPayPacketFeeAsyncResponse](#ibc.applications.fee.v1.MsgPayPacketFeeAsyncResponse) | PayPacketFeeAsync defines a rpc handler method for MsgPayPacketFeeAsync PayPacketFeeAsync is an open callback that may be called by any module/user that wishes to escrow funds in order to incentivize the relaying of a known packet (i.e. at a particular sequence) | | diff --git a/modules/apps/29-fee/types/ack.pb.go b/modules/apps/29-fee/types/ack.pb.go index dfcc0e1041c..4f6437da224 100644 --- a/modules/apps/29-fee/types/ack.pb.go +++ b/modules/apps/29-fee/types/ack.pb.go @@ -24,11 +24,13 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // IncentivizedAcknowledgement is the acknowledgement format to be used by applications wrapped in the fee middleware -// It contains the raw acknowledgement bytes, as well as the forward relayer address type IncentivizedAcknowledgement struct { - Result []byte `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` + // the underlying app acknowledgement result bytes + Result []byte `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"` + // the relayer address which submits the recv packet message ForwardRelayerAddress string `protobuf:"bytes,2,opt,name=forward_relayer_address,json=forwardRelayerAddress,proto3" json:"forward_relayer_address,omitempty" yaml:"forward_relayer_address"` - UnderlyingAppSuccess bool `protobuf:"varint,3,opt,name=underlying_app_success,json=underlyingAppSuccess,proto3" json:"underlying_app_success,omitempty" yaml:"underlying_app_successl"` + // success flag of the base application callback + UnderlyingAppSuccess bool `protobuf:"varint,3,opt,name=underlying_app_success,json=underlyingAppSuccess,proto3" json:"underlying_app_success,omitempty" yaml:"underlying_app_successl"` } func (m *IncentivizedAcknowledgement) Reset() { *m = IncentivizedAcknowledgement{} } diff --git a/modules/apps/29-fee/types/fee.pb.go b/modules/apps/29-fee/types/fee.pb.go index 8c95fd11176..1867eb351e5 100644 --- a/modules/apps/29-fee/types/fee.pb.go +++ b/modules/apps/29-fee/types/fee.pb.go @@ -26,12 +26,13 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// Fee implements the ics29 Fee interface -// See Fee Payment Middleware spec: -// https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middleware-contract +// Fee defines the ICS29 receive, acknowledgement and timeout fees type Fee struct { - RecvFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=recv_fee,json=recvFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"recv_fee" yaml:"receive_fee"` - AckFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=ack_fee,json=ackFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"ack_fee" yaml:"ack_fee"` + // the packet receive fee + RecvFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=recv_fee,json=recvFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"recv_fee" yaml:"recv_fee"` + // the packet acknowledgement fee + AckFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=ack_fee,json=ackFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"ack_fee" yaml:"ack_fee"` + // the packet timeout fee TimeoutFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,3,rep,name=timeout_fee,json=timeoutFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"timeout_fee" yaml:"timeout_fee"` } @@ -89,12 +90,14 @@ func (m *Fee) GetTimeoutFee() github_com_cosmos_cosmos_sdk_types.Coins { return nil } -// PacketFee contains the relayer fee, refund address and an optional list of relayers that are permitted to receive the -// fee +// PacketFee contains ICS29 relayer fees, refund address and optional list of permitted relayers type PacketFee struct { - Fee Fee `protobuf:"bytes,1,opt,name=fee,proto3" json:"fee"` - RefundAddress string `protobuf:"bytes,2,opt,name=refund_address,json=refundAddress,proto3" json:"refund_address,omitempty" yaml:"refund_address"` - Relayers []string `protobuf:"bytes,3,rep,name=relayers,proto3" json:"relayers,omitempty"` + // fee encapsulates the recv, ack and timeout fees associated with an IBC packet + Fee Fee `protobuf:"bytes,1,opt,name=fee,proto3" json:"fee"` + // the refund address for unspent fees + RefundAddress string `protobuf:"bytes,2,opt,name=refund_address,json=refundAddress,proto3" json:"refund_address,omitempty" yaml:"refund_address"` + // optional list of relayers permitted to receive fees + Relayers []string `protobuf:"bytes,3,rep,name=relayers,proto3" json:"relayers,omitempty"` } func (m *PacketFee) Reset() { *m = PacketFee{} } @@ -153,6 +156,7 @@ func (m *PacketFee) GetRelayers() []string { // PacketFees contains a list of type PacketFee type PacketFees struct { + // list of packet fees PacketFees []PacketFee `protobuf:"bytes,1,rep,name=packet_fees,json=packetFees,proto3" json:"packet_fees" yaml:"packet_fees"` } @@ -198,8 +202,10 @@ func (m *PacketFees) GetPacketFees() []PacketFee { // IdentifiedPacketFees contains a list of type PacketFee and associated PacketId type IdentifiedPacketFees struct { - PacketId types1.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id" yaml:"packet_id"` - PacketFees []PacketFee `protobuf:"bytes,2,rep,name=packet_fees,json=packetFees,proto3" json:"packet_fees" yaml:"packet_fees"` + // unique packet identifier comprised of the channel ID, port ID and sequence + PacketId types1.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id" yaml:"packet_id"` + // list of packet fees + PacketFees []PacketFee `protobuf:"bytes,2,rep,name=packet_fees,json=packetFees,proto3" json:"packet_fees" yaml:"packet_fees"` } func (m *IdentifiedPacketFees) Reset() { *m = IdentifiedPacketFees{} } @@ -259,40 +265,40 @@ func init() { func init() { proto.RegisterFile("ibc/applications/fee/v1/fee.proto", fileDescriptor_cb3319f1af2a53e5) } var fileDescriptor_cb3319f1af2a53e5 = []byte{ - // 526 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xc1, 0x8a, 0x13, 0x31, - 0x18, 0xc7, 0x3b, 0x5b, 0xd9, 0xdd, 0xa6, 0xb8, 0xc8, 0xb0, 0x62, 0xb7, 0xe8, 0x74, 0xcd, 0xa9, - 0x97, 0x26, 0xb4, 0xab, 0x07, 0x3d, 0xe9, 0x08, 0x85, 0x3d, 0x29, 0x83, 0x27, 0x2f, 0x25, 0x93, - 0x7c, 0xed, 0x86, 0x76, 0x26, 0xc3, 0x64, 0x3a, 0x50, 0xf0, 0x20, 0x3e, 0x81, 0x6f, 0xe0, 0xdd, - 0x27, 0xd9, 0x8b, 0xb0, 0x47, 0x4f, 0x55, 0xda, 0x37, 0xd8, 0x27, 0x90, 0x64, 0xb2, 0xa5, 0xab, - 0x2c, 0x52, 0xf0, 0x34, 0xf9, 0x92, 0xef, 0x9f, 0xdf, 0xf7, 0x25, 0xff, 0x09, 0x7a, 0x2a, 0x63, - 0x4e, 0x59, 0x96, 0xcd, 0x24, 0x67, 0x85, 0x54, 0xa9, 0xa6, 0x63, 0x00, 0x5a, 0xf6, 0xcd, 0x87, - 0x64, 0xb9, 0x2a, 0x94, 0xff, 0x48, 0xc6, 0x9c, 0x6c, 0xa7, 0x10, 0xb3, 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9e, 0xd1, 0x44, 0x89, 0xf9, 0x0c, 0xb4, - 0x79, 0x32, 0x34, 0x1d, 0xbc, 0xe8, 0x99, 0xd7, 0xc2, 0x7a, 0x28, 0xde, 0xb7, 0xff, 0xee, 0xd9, - 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0xdf, 0x70, 0xf8, 0xe7, 0x52, 0x04, 0x00, 0x00, + // 525 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x31, 0x6f, 0x13, 0x31, + 0x14, 0xc7, 0x73, 0x09, 0x6a, 0x1b, 0x47, 0x14, 0x74, 0x2a, 0x22, 0x8d, 0xe0, 0x52, 0x3c, 0x65, + 0x89, 0xad, 0xa4, 0x30, 0xc0, 0x04, 0x57, 0x29, 0x52, 0x27, 0xd0, 0x89, 0x89, 0x25, 0xf2, 0xd9, + 0x2f, 0xa9, 0x95, 0xdc, 0xf9, 0x74, 0xbe, 0x44, 0xca, 0xca, 0x27, 0xe0, 0x1b, 0xb0, 0xf3, 0x49, + 0xba, 0x20, 0x75, 0x64, 0x0a, 0x28, 0xf9, 0x06, 0xdd, 0x91, 0x90, 0x7d, 0x4e, 0x94, 0x82, 0xaa, + 0xaa, 0x12, 0xd3, 0xf9, 0xd9, 0xef, 0xef, 0xdf, 0xb3, 0xdf, 0xff, 0x8c, 0x5e, 0xc8, 0x98, 0x53, + 0x96, 0x65, 0x53, 0xc9, 0x59, 0x21, 0x55, 0xaa, 0xe9, 0x08, 0x80, 0xce, 0x7b, 0xe6, 0x43, 0xb2, + 0x5c, 0x15, 0xca, 0x7f, 0x2a, 0x63, 0x4e, 0x76, 0x53, 0x88, 0x59, 0x9b, 0xf7, 0x5a, 0x01, 0x57, + 0x3a, 0x51, 0x9a, 0xc6, 0x4c, 0x1b, 0x49, 0x0c, 0x05, 0xeb, 0x51, 0xae, 0x64, 0x5a, 0x0a, 0x5b, + 0x47, 0x63, 0x35, 0x56, 0x76, 0x48, 0xcd, 0xc8, 0xcd, 0x5a, 0x22, 0x57, 0x39, 0x50, 0x7e, 0xc1, + 0xd2, 0x14, 0xa6, 0x86, 0xe6, 0x86, 0x65, 0x0a, 0xfe, 0x5d, 0x45, 0xb5, 0x01, 0x80, 0xbf, 0x40, + 0x07, 0x39, 0xf0, 0xf9, 0x70, 0x04, 0xd0, 0xf4, 0x4e, 0x6a, 0x9d, 0x46, 0xff, 0x98, 0x94, 0x4c, + 0x62, 0x98, 0xc4, 0x31, 0xc9, 0x99, 0x92, 0x69, 0x78, 0x76, 0xb9, 0x6c, 0x57, 0xae, 0x97, 0xed, + 0x47, 0x0b, 0x96, 0x4c, 0xdf, 0xe0, 0x8d, 0x10, 0x7f, 0xfb, 0xd9, 0xee, 0x8c, 0x65, 0x71, 0x31, + 0x8b, 0x09, 0x57, 0x09, 0x75, 0x35, 0x97, 0x9f, 0xae, 0x16, 0x13, 0x5a, 0x2c, 0x32, 0xd0, 0x76, + 0x0f, 0x1d, 0xed, 0x1b, 0x99, 0x41, 0xcf, 0xd1, 0x3e, 0xe3, 0x13, 0x4b, 0xae, 0xde, 0x45, 0x0e, + 0x1d, 0xf9, 0xb0, 0x24, 0x3b, 0xdd, 0xfd, 0xc0, 0x7b, 0x8c, 0x4f, 0x0c, 0xf7, 0xb3, 0x87, 0x1a, + 0x85, 0x4c, 0x40, 0xcd, 0x0a, 0x0b, 0xaf, 0xdd, 0x05, 0x1f, 0x38, 0xb8, 0x5f, 0xc2, 0x77, 0xb4, + 0xf7, 0x2b, 0x00, 0x39, 0xe5, 0x00, 0x00, 0x7f, 0xf5, 0x50, 0xfd, 0x03, 0xe3, 0x13, 0x30, 0x91, + 0xff, 0x12, 0xd5, 0xca, 0x06, 0x78, 0x9d, 0x46, 0xff, 0x19, 0xb9, 0xc5, 0x0d, 0x64, 0x00, 0x10, + 0x3e, 0x30, 0xc5, 0x44, 0x26, 0xdd, 0x7f, 0x8b, 0x0e, 0x73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9e, 0xfe, + 0x09, 0x00, 0x00, 0xff, 0xff, 0xc1, 0x6c, 0xa2, 0x41, 0x4f, 0x04, 0x00, 0x00, } func (m *Fee) Marshal() (dAtA []byte, err error) { diff --git a/modules/apps/29-fee/types/genesis.pb.go b/modules/apps/29-fee/types/genesis.pb.go index 84a946a6d43..af78add463e 100644 --- a/modules/apps/29-fee/types/genesis.pb.go +++ b/modules/apps/29-fee/types/genesis.pb.go @@ -24,12 +24,16 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// GenesisState defines the fee middleware genesis state +// GenesisState defines the ICS29 fee middleware genesis state type GenesisState struct { - IdentifiedFees []IdentifiedPacketFees `protobuf:"bytes,1,rep,name=identified_fees,json=identifiedFees,proto3" json:"identified_fees" yaml:"identified_fees"` - FeeEnabledChannels []FeeEnabledChannel `protobuf:"bytes,2,rep,name=fee_enabled_channels,json=feeEnabledChannels,proto3" json:"fee_enabled_channels" yaml:"fee_enabled_channels"` + // list of identified packet fees + IdentifiedFees []IdentifiedPacketFees `protobuf:"bytes,1,rep,name=identified_fees,json=identifiedFees,proto3" json:"identified_fees" yaml:"identified_fees"` + // list of fee enabled channels + FeeEnabledChannels []FeeEnabledChannel `protobuf:"bytes,2,rep,name=fee_enabled_channels,json=feeEnabledChannels,proto3" json:"fee_enabled_channels" yaml:"fee_enabled_channels"` + // list of registered relayer addresses RegisteredRelayers []RegisteredRelayerAddress `protobuf:"bytes,3,rep,name=registered_relayers,json=registeredRelayers,proto3" json:"registered_relayers" yaml:"registered_relayers"` - ForwardRelayers []ForwardRelayerAddress `protobuf:"bytes,4,rep,name=forward_relayers,json=forwardRelayers,proto3" json:"forward_relayers" yaml:"forward_relayers"` + // list of forward relayer addresses + ForwardRelayers []ForwardRelayerAddress `protobuf:"bytes,4,rep,name=forward_relayers,json=forwardRelayers,proto3" json:"forward_relayers" yaml:"forward_relayers"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -95,7 +99,9 @@ func (m *GenesisState) GetForwardRelayers() []ForwardRelayerAddress { // FeeEnabledChannel contains the PortID & ChannelID for a fee enabled channel type FeeEnabledChannel struct { - PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty" yaml:"port_id"` + // unique port identifier + PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty" yaml:"port_id"` + // unique channel identifier ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` } @@ -148,9 +154,12 @@ func (m *FeeEnabledChannel) GetChannelId() string { // RegisteredRelayerAddress contains the address and counterparty address for a specific relayer (for distributing fees) type RegisteredRelayerAddress struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // the relayer address + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // the counterparty relayer address CounterpartyAddress string `protobuf:"bytes,2,opt,name=counterparty_address,json=counterpartyAddress,proto3" json:"counterparty_address,omitempty" yaml:"counterparty_address"` - ChannelId string `protobuf:"bytes,3,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` + // unique channel identifier + ChannelId string `protobuf:"bytes,3,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` } func (m *RegisteredRelayerAddress) Reset() { *m = RegisteredRelayerAddress{} } @@ -207,9 +216,11 @@ func (m *RegisteredRelayerAddress) GetChannelId() string { return "" } -// ForwardRelayerAddress contains the forward relayer address and packetId used for async acknowledgements +// ForwardRelayerAddress contains the forward relayer address and PacketId used for async acknowledgements type ForwardRelayerAddress struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // the forward relayer address + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // unique packet identifer comprised of the channel ID, port ID and sequence PacketId types.PacketId `protobuf:"bytes,2,opt,name=packet_id,json=packetId,proto3" json:"packet_id" yaml:"packet_id"` } diff --git a/modules/apps/29-fee/types/query.pb.go b/modules/apps/29-fee/types/query.pb.go index 5421eda2fff..dd130bcc3fd 100644 --- a/modules/apps/29-fee/types/query.pb.go +++ b/modules/apps/29-fee/types/query.pb.go @@ -33,11 +33,11 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// QueryIncentivizedPacketsRequest is the request type for querying for all incentivized packets +// QueryIncentivizedPacketsRequest defines the request type for the IncentivizedPackets rpc type QueryIncentivizedPacketsRequest struct { // pagination defines an optional pagination for the request. Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` - // Height to query at + // block height at which to query QueryHeight uint64 `protobuf:"varint,2,opt,name=query_height,json=queryHeight,proto3" json:"query_height,omitempty"` } @@ -88,9 +88,9 @@ func (m *QueryIncentivizedPacketsRequest) GetQueryHeight() uint64 { return 0 } -// QueryIncentivizedPacketsResponse is the response type for the incentivized packets RPC +// QueryIncentivizedPacketsResponse defines the response type for the IncentivizedPackets rpc type QueryIncentivizedPacketsResponse struct { - // Map of all incentivized_packets + // list of identified fees for incentivized packets IncentivizedPackets []IdentifiedPacketFees `protobuf:"bytes,1,rep,name=incentivized_packets,json=incentivizedPackets,proto3" json:"incentivized_packets"` } @@ -134,11 +134,11 @@ func (m *QueryIncentivizedPacketsResponse) GetIncentivizedPackets() []Identified return nil } -// QueryIncentivizedPacketRequest is the request type for querying for all incentivized packets +// QueryIncentivizedPacketRequest defines the request type for the IncentivizedPacket rpc type QueryIncentivizedPacketRequest struct { - // PacketID + // unique packet identifier comprised of channel ID, port ID and sequence PacketId types.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id"` - // Height to query at + // block height at which to query QueryHeight uint64 `protobuf:"varint,2,opt,name=query_height,json=queryHeight,proto3" json:"query_height,omitempty"` } @@ -189,9 +189,9 @@ func (m *QueryIncentivizedPacketRequest) GetQueryHeight() uint64 { return 0 } -// QueryIncentivizedPacketsResponse is the response type for the incentivized packet RPC +// QueryIncentivizedPacketsResponse defines the response type for the IncentivizedPacket rpc type QueryIncentivizedPacketResponse struct { - // Incentivized_packet + // the identified fees for the incentivized packet IncentivizedPacket IdentifiedPacketFees `protobuf:"bytes,1,opt,name=incentivized_packet,json=incentivizedPacket,proto3" json:"incentivized_packet"` } @@ -235,7 +235,7 @@ func (m *QueryIncentivizedPacketResponse) GetIncentivizedPacket() IdentifiedPack return IdentifiedPacketFees{} } -// QueryIncentivizedPacketsForChannelRequest is the request type for querying for all incentivized packets +// QueryIncentivizedPacketsForChannelRequest defines the request type for querying for all incentivized packets // for a specific channel type QueryIncentivizedPacketsForChannelRequest struct { // pagination defines an optional pagination for the request. @@ -311,7 +311,7 @@ func (m *QueryIncentivizedPacketsForChannelRequest) GetQueryHeight() uint64 { return 0 } -// QueryIncentivizedPacketsResponse is the response type for the incentivized packets RPC +// QueryIncentivizedPacketsResponse defines the response type for the incentivized packets RPC type QueryIncentivizedPacketsForChannelResponse struct { // Map of all incentivized_packets IncentivizedPackets []*IdentifiedPacketFees `protobuf:"bytes,1,rep,name=incentivized_packets,json=incentivizedPackets,proto3" json:"incentivized_packets,omitempty"` @@ -732,10 +732,9 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { - // Gets all incentivized packets + // IncentivizedPackets returns all incentivized packets and their associated fees IncentivizedPackets(ctx context.Context, in *QueryIncentivizedPacketsRequest, opts ...grpc.CallOption) (*QueryIncentivizedPacketsResponse, error) - // Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the - // given packet + // IncentivizedPacket returns all packet fees for a packet given its identifier IncentivizedPacket(ctx context.Context, in *QueryIncentivizedPacketRequest, opts ...grpc.CallOption) (*QueryIncentivizedPacketResponse, error) // Gets all incentivized packets for a specific channel IncentivizedPacketsForChannel(ctx context.Context, in *QueryIncentivizedPacketsForChannelRequest, opts ...grpc.CallOption) (*QueryIncentivizedPacketsForChannelResponse, error) @@ -811,10 +810,9 @@ func (c *queryClient) TotalTimeoutFees(ctx context.Context, in *QueryTotalTimeou // QueryServer is the server API for Query service. type QueryServer interface { - // Gets all incentivized packets + // IncentivizedPackets returns all incentivized packets and their associated fees IncentivizedPackets(context.Context, *QueryIncentivizedPacketsRequest) (*QueryIncentivizedPacketsResponse, error) - // Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the - // given packet + // IncentivizedPacket returns all packet fees for a packet given its identifier IncentivizedPacket(context.Context, *QueryIncentivizedPacketRequest) (*QueryIncentivizedPacketResponse, error) // Gets all incentivized packets for a specific channel IncentivizedPacketsForChannel(context.Context, *QueryIncentivizedPacketsForChannelRequest) (*QueryIncentivizedPacketsForChannelResponse, error) diff --git a/modules/apps/29-fee/types/tx.pb.go b/modules/apps/29-fee/types/tx.pb.go index c30331992dd..1cecc607dc9 100644 --- a/modules/apps/29-fee/types/tx.pb.go +++ b/modules/apps/29-fee/types/tx.pb.go @@ -29,11 +29,14 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgRegisterCounterpartyAddress is the request type for registering the counterparty address +// MsgRegisterCounterpartyAddress defines the request type for the RegisterCounterpartyAddress rpc type MsgRegisterCounterpartyAddress struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // the relayer address + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // the counterparty relayer address CounterpartyAddress string `protobuf:"bytes,2,opt,name=counterparty_address,json=counterpartyAddress,proto3" json:"counterparty_address,omitempty" yaml:"counterparty_address"` - ChannelId string `protobuf:"bytes,3,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` + // unique channel identifier + ChannelId string `protobuf:"bytes,3,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` } func (m *MsgRegisterCounterpartyAddress) Reset() { *m = MsgRegisterCounterpartyAddress{} } @@ -69,7 +72,7 @@ func (m *MsgRegisterCounterpartyAddress) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRegisterCounterpartyAddress proto.InternalMessageInfo -// MsgRegisterCounterpartyAddressResponse defines the Msg/RegisterCounterypartyAddress response type +// MsgRegisterCounterpartyAddressResponse defines the response type for the RegisterCounterpartyAddress rpc type MsgRegisterCounterpartyAddressResponse struct { } @@ -108,17 +111,19 @@ func (m *MsgRegisterCounterpartyAddressResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRegisterCounterpartyAddressResponse proto.InternalMessageInfo -// MsgPayPacketFee defines the request type PayPacketFee RPC +// MsgPayPacketFee defines the request type for the PayPacketFee rpc // This Msg can be used to pay for a packet at the next sequence send & should be combined with the Msg that will be // paid for type MsgPayPacketFee struct { + // fee encapsulates the recv, ack and timeout fees associated with an IBC packet Fee Fee `protobuf:"bytes,1,opt,name=fee,proto3" json:"fee"` - // source channel port identifier + // the source port unique identifier SourcePortId string `protobuf:"bytes,2,opt,name=source_port_id,json=sourcePortId,proto3" json:"source_port_id,omitempty" yaml:"source_port_id"` - // source channel unique identifier + // the source channel unique identifer SourceChannelId string `protobuf:"bytes,3,opt,name=source_channel_id,json=sourceChannelId,proto3" json:"source_channel_id,omitempty" yaml:"source_channel_id"` // account address to refund fee if necessary - Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` + Signer string `protobuf:"bytes,4,opt,name=signer,proto3" json:"signer,omitempty"` + // optional list of relayers permitted to the receive packet fees Relayers []string `protobuf:"bytes,5,rep,name=relayers,proto3" json:"relayers,omitempty"` } @@ -155,7 +160,7 @@ func (m *MsgPayPacketFee) XXX_DiscardUnknown() { var xxx_messageInfo_MsgPayPacketFee proto.InternalMessageInfo -// MsgPayPacketFeeResponse defines the response type for Msg/PayPacketFee +// MsgPayPacketFeeResponse defines the response type for the PayPacketFee rpc type MsgPayPacketFeeResponse struct { } @@ -192,12 +197,12 @@ func (m *MsgPayPacketFeeResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgPayPacketFeeResponse proto.InternalMessageInfo -// MsgPayPacketFeeAsync defines the request type PayPacketFeeAsync RPC +// MsgPayPacketFeeAsync defines the request type for the PayPacketFeeAsync rpc // This Msg can be used to pay for a packet at a specified sequence (instead of the next sequence send) type MsgPayPacketFeeAsync struct { - // unique packet identifier + // unique packet identifier comprised of the channel ID, port ID and sequence PacketId types.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id" yaml:"packet_id"` - // packet fee for incentivization + // the packet fee associated with a particular IBC packet PacketFee PacketFee `protobuf:"bytes,2,opt,name=packet_fee,json=packetFee,proto3" json:"packet_fee" yaml:"packet_fee"` } @@ -234,7 +239,7 @@ func (m *MsgPayPacketFeeAsync) XXX_DiscardUnknown() { var xxx_messageInfo_MsgPayPacketFeeAsync proto.InternalMessageInfo -// MsgPayPacketFeeAsyncResponse defines the response type for Msg/PayPacketFeeAsync +// MsgPayPacketFeeAsyncResponse defines the response type for the PayPacketFeeAsync rpc type MsgPayPacketFeeAsyncResponse struct { } @@ -347,10 +352,12 @@ type MsgClient interface { // PayPacketFee defines a rpc handler method for MsgPayPacketFee // PayPacketFee 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 packet at the next sequence + // NOTE: This method is intended to be used within a multi msg transaction, where the subsequent msg that follows + // initiates the lifecycle of the incentivized packet PayPacketFee(ctx context.Context, in *MsgPayPacketFee, opts ...grpc.CallOption) (*MsgPayPacketFeeResponse, error) // PayPacketFeeAsync defines a rpc handler method for MsgPayPacketFeeAsync // PayPacketFeeAsync is an open callback that may be called by any module/user that wishes to escrow funds in order to - // incentivize the relaying of a known packet + // incentivize the relaying of a known packet (i.e. at a particular sequence) PayPacketFeeAsync(ctx context.Context, in *MsgPayPacketFeeAsync, opts ...grpc.CallOption) (*MsgPayPacketFeeAsyncResponse, error) } @@ -400,10 +407,12 @@ type MsgServer interface { // PayPacketFee defines a rpc handler method for MsgPayPacketFee // PayPacketFee 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 packet at the next sequence + // NOTE: This method is intended to be used within a multi msg transaction, where the subsequent msg that follows + // initiates the lifecycle of the incentivized packet PayPacketFee(context.Context, *MsgPayPacketFee) (*MsgPayPacketFeeResponse, error) // PayPacketFeeAsync defines a rpc handler method for MsgPayPacketFeeAsync // PayPacketFeeAsync is an open callback that may be called by any module/user that wishes to escrow funds in order to - // incentivize the relaying of a known packet + // incentivize the relaying of a known packet (i.e. at a particular sequence) PayPacketFeeAsync(context.Context, *MsgPayPacketFeeAsync) (*MsgPayPacketFeeAsyncResponse, error) } diff --git a/proto/ibc/applications/fee/v1/ack.proto b/proto/ibc/applications/fee/v1/ack.proto index 6a77e4fce45..728c7536c6b 100644 --- a/proto/ibc/applications/fee/v1/ack.proto +++ b/proto/ibc/applications/fee/v1/ack.proto @@ -7,9 +7,11 @@ option go_package = "github.com/cosmos/ibc-go/v3/modules/apps/29-fee/types"; import "gogoproto/gogo.proto"; // IncentivizedAcknowledgement is the acknowledgement format to be used by applications wrapped in the fee middleware -// It contains the raw acknowledgement bytes, as well as the forward relayer address message IncentivizedAcknowledgement { - bytes result = 1; + // the underlying app acknowledgement result bytes + bytes result = 1; + // the relayer address which submits the recv packet message string forward_relayer_address = 2 [(gogoproto.moretags) = "yaml:\"forward_relayer_address\""]; - bool underlying_app_success = 3 [(gogoproto.moretags) = "yaml:\"underlying_app_successl\""]; + // success flag of the base application callback + bool underlying_app_success = 3 [(gogoproto.moretags) = "yaml:\"underlying_app_successl\""]; } diff --git a/proto/ibc/applications/fee/v1/fee.proto b/proto/ibc/applications/fee/v1/fee.proto index b1ebd7008ad..e7a1fa438df 100644 --- a/proto/ibc/applications/fee/v1/fee.proto +++ b/proto/ibc/applications/fee/v1/fee.proto @@ -8,20 +8,21 @@ import "cosmos/base/v1beta1/coin.proto"; import "gogoproto/gogo.proto"; import "ibc/core/channel/v1/channel.proto"; -// Fee implements the ics29 Fee interface -// See Fee Payment Middleware spec: -// https://github.com/cosmos/ibc/tree/master/spec/app/ics-029-fee-payment#fee-middleware-contract +// Fee defines the ICS29 receive, acknowledgement and timeout fees message Fee { + // the packet receive fee repeated cosmos.base.v1beta1.Coin recv_fee = 1 [ - (gogoproto.moretags) = "yaml:\"receive_fee\"", + (gogoproto.moretags) = "yaml:\"recv_fee\"", (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; + // the packet acknowledgement fee repeated cosmos.base.v1beta1.Coin ack_fee = 2 [ (gogoproto.moretags) = "yaml:\"ack_fee\"", (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; + // the packet timeout fee repeated cosmos.base.v1beta1.Coin timeout_fee = 3 [ (gogoproto.moretags) = "yaml:\"timeout_fee\"", (gogoproto.nullable) = false, @@ -29,22 +30,27 @@ message Fee { ]; } -// PacketFee contains the relayer fee, refund address and an optional list of relayers that are permitted to receive the -// fee +// PacketFee contains ICS29 relayer fees, refund address and optional list of permitted relayers message PacketFee { - Fee fee = 1 [(gogoproto.nullable) = false]; - string refund_address = 2 [(gogoproto.moretags) = "yaml:\"refund_address\""]; - repeated string relayers = 3; + // fee encapsulates the recv, ack and timeout fees associated with an IBC packet + Fee fee = 1 [(gogoproto.nullable) = false]; + // the refund address for unspent fees + string refund_address = 2 [(gogoproto.moretags) = "yaml:\"refund_address\""]; + // optional list of relayers permitted to receive fees + repeated string relayers = 3; } // PacketFees contains a list of type PacketFee message PacketFees { + // list of packet fees repeated PacketFee packet_fees = 1 [(gogoproto.moretags) = "yaml:\"packet_fees\"", (gogoproto.nullable) = false]; } // IdentifiedPacketFees contains a list of type PacketFee and associated PacketId message IdentifiedPacketFees { + // unique packet identifier comprised of the channel ID, port ID and sequence ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"packet_id\""]; + // list of packet fees repeated PacketFee packet_fees = 2 [(gogoproto.moretags) = "yaml:\"packet_fees\"", (gogoproto.nullable) = false]; } diff --git a/proto/ibc/applications/fee/v1/genesis.proto b/proto/ibc/applications/fee/v1/genesis.proto index 0e76fa3a168..cae132239d6 100644 --- a/proto/ibc/applications/fee/v1/genesis.proto +++ b/proto/ibc/applications/fee/v1/genesis.proto @@ -8,34 +8,45 @@ import "gogoproto/gogo.proto"; import "ibc/applications/fee/v1/fee.proto"; import "ibc/core/channel/v1/channel.proto"; -// GenesisState defines the fee middleware genesis state +// GenesisState defines the ICS29 fee middleware genesis state message GenesisState { + // list of identified packet fees repeated IdentifiedPacketFees identified_fees = 1 [(gogoproto.moretags) = "yaml:\"identified_fees\"", (gogoproto.nullable) = false]; + // list of fee enabled channels repeated FeeEnabledChannel fee_enabled_channels = 2 [(gogoproto.moretags) = "yaml:\"fee_enabled_channels\"", (gogoproto.nullable) = false]; + // list of registered relayer addresses repeated RegisteredRelayerAddress registered_relayers = 3 [(gogoproto.moretags) = "yaml:\"registered_relayers\"", (gogoproto.nullable) = false]; + // list of forward relayer addresses repeated ForwardRelayerAddress forward_relayers = 4 [(gogoproto.moretags) = "yaml:\"forward_relayers\"", (gogoproto.nullable) = false]; } // FeeEnabledChannel contains the PortID & ChannelID for a fee enabled channel message FeeEnabledChannel { - string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; + // unique port identifier + string port_id = 1 [(gogoproto.moretags) = "yaml:\"port_id\""]; + // unique channel identifier string channel_id = 2 [(gogoproto.moretags) = "yaml:\"channel_id\""]; } // RegisteredRelayerAddress contains the address and counterparty address for a specific relayer (for distributing fees) message RegisteredRelayerAddress { - string address = 1; + // the relayer address + string address = 1; + // the counterparty relayer address string counterparty_address = 2 [(gogoproto.moretags) = "yaml:\"counterparty_address\""]; - string channel_id = 3 [(gogoproto.moretags) = "yaml:\"channel_id\""]; + // unique channel identifier + string channel_id = 3 [(gogoproto.moretags) = "yaml:\"channel_id\""]; } -// ForwardRelayerAddress contains the forward relayer address and packetId used for async acknowledgements +// ForwardRelayerAddress contains the forward relayer address and PacketId used for async acknowledgements message ForwardRelayerAddress { - string address = 1; + // the forward relayer address + string address = 1; + // unique packet identifer comprised of the channel ID, port ID and sequence ibc.core.channel.v1.PacketId packet_id = 2 [(gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"packet_id\""]; } diff --git a/proto/ibc/applications/fee/v1/query.proto b/proto/ibc/applications/fee/v1/query.proto index 8f2f7188839..3e5d6b8740d 100644 --- a/proto/ibc/applications/fee/v1/query.proto +++ b/proto/ibc/applications/fee/v1/query.proto @@ -11,15 +11,14 @@ import "cosmos/base/query/v1beta1/pagination.proto"; import "ibc/applications/fee/v1/fee.proto"; import "ibc/core/channel/v1/channel.proto"; -// Query provides defines the gRPC querier service. +// Query defines the ICS29 gRPC querier service. service Query { - // Gets all incentivized packets + // IncentivizedPackets returns all incentivized packets and their associated fees rpc IncentivizedPackets(QueryIncentivizedPacketsRequest) returns (QueryIncentivizedPacketsResponse) { option (google.api.http).get = "/ibc/apps/fee/v1/incentivized_packets"; } - // Gets the fees expected for submitting the ReceivePacket, AcknowledgementPacket, and TimeoutPacket messages for the - // given packet + // IncentivizedPacket returns all packet fees for a packet given its identifier rpc IncentivizedPacket(QueryIncentivizedPacketRequest) returns (QueryIncentivizedPacketResponse) { option (google.api.http).get = "/ibc/apps/fee/v1/incentivized_packet/port/{packet_id.port_id}/channel/{packet_id.channel_id}/sequence/" @@ -51,35 +50,35 @@ service Query { } } -// QueryIncentivizedPacketsRequest is the request type for querying for all incentivized packets +// QueryIncentivizedPacketsRequest defines the request type for the IncentivizedPackets rpc message QueryIncentivizedPacketsRequest { // pagination defines an optional pagination for the request. cosmos.base.query.v1beta1.PageRequest pagination = 1; - // Height to query at + // block height at which to query uint64 query_height = 2; } -// QueryIncentivizedPacketsResponse is the response type for the incentivized packets RPC +// QueryIncentivizedPacketsResponse defines the response type for the IncentivizedPackets rpc message QueryIncentivizedPacketsResponse { - // Map of all incentivized_packets + // list of identified fees for incentivized packets repeated ibc.applications.fee.v1.IdentifiedPacketFees incentivized_packets = 1 [(gogoproto.nullable) = false]; } -// QueryIncentivizedPacketRequest is the request type for querying for all incentivized packets +// QueryIncentivizedPacketRequest defines the request type for the IncentivizedPacket rpc message QueryIncentivizedPacketRequest { - // PacketID + // unique packet identifier comprised of channel ID, port ID and sequence ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.nullable) = false]; - // Height to query at + // block height at which to query uint64 query_height = 2; } -// QueryIncentivizedPacketsResponse is the response type for the incentivized packet RPC +// QueryIncentivizedPacketsResponse defines the response type for the IncentivizedPacket rpc message QueryIncentivizedPacketResponse { - // Incentivized_packet + // the identified fees for the incentivized packet ibc.applications.fee.v1.IdentifiedPacketFees incentivized_packet = 1 [(gogoproto.nullable) = false]; } -// QueryIncentivizedPacketsForChannelRequest is the request type for querying for all incentivized packets +// QueryIncentivizedPacketsForChannelRequest defines the request type for querying for all incentivized packets // for a specific channel message QueryIncentivizedPacketsForChannelRequest { // pagination defines an optional pagination for the request. @@ -90,7 +89,7 @@ message QueryIncentivizedPacketsForChannelRequest { uint64 query_height = 4; } -// QueryIncentivizedPacketsResponse is the response type for the incentivized packets RPC +// QueryIncentivizedPacketsResponse defines the response type for the incentivized packets RPC message QueryIncentivizedPacketsForChannelResponse { // Map of all incentivized_packets repeated ibc.applications.fee.v1.IdentifiedPacketFees incentivized_packets = 1; diff --git a/proto/ibc/applications/fee/v1/tx.proto b/proto/ibc/applications/fee/v1/tx.proto index ec2f2cc4f38..7a0044cd363 100644 --- a/proto/ibc/applications/fee/v1/tx.proto +++ b/proto/ibc/applications/fee/v1/tx.proto @@ -8,7 +8,7 @@ import "gogoproto/gogo.proto"; import "ibc/applications/fee/v1/fee.proto"; import "ibc/core/channel/v1/channel.proto"; -// Msg defines the ibc/fee Msg service. +// Msg defines the ICS29 Msg service. service Msg { // RegisterCounterpartyAddress defines a rpc handler method for MsgRegisterCounterpartyAddress // RegisterCounterpartyAddress is called by the relayer on each channelEnd and allows them to specify their @@ -16,61 +16,70 @@ service Msg { // 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); + // PayPacketFee defines a rpc handler method for MsgPayPacketFee // PayPacketFee 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 packet at the next sequence + // NOTE: This method is intended to be used within a multi msg transaction, where the subsequent msg that follows + // initiates the lifecycle of the incentivized packet rpc PayPacketFee(MsgPayPacketFee) returns (MsgPayPacketFeeResponse); + // PayPacketFeeAsync defines a rpc handler method for MsgPayPacketFeeAsync // PayPacketFeeAsync is an open callback that may be called by any module/user that wishes to escrow funds in order to - // incentivize the relaying of a known packet + // incentivize the relaying of a known packet (i.e. at a particular sequence) rpc PayPacketFeeAsync(MsgPayPacketFeeAsync) returns (MsgPayPacketFeeAsyncResponse); } -// MsgRegisterCounterpartyAddress is the request type for registering the counterparty address +// MsgRegisterCounterpartyAddress defines the request type for the RegisterCounterpartyAddress rpc message MsgRegisterCounterpartyAddress { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - string address = 1; + // the relayer address + string address = 1; + // the counterparty relayer address string counterparty_address = 2 [(gogoproto.moretags) = "yaml:\"counterparty_address\""]; - string channel_id = 3 [(gogoproto.moretags) = "yaml:\"channel_id\""]; + // unique channel identifier + string channel_id = 3 [(gogoproto.moretags) = "yaml:\"channel_id\""]; } -// MsgRegisterCounterpartyAddressResponse defines the Msg/RegisterCounterypartyAddress response type +// MsgRegisterCounterpartyAddressResponse defines the response type for the RegisterCounterpartyAddress rpc message MsgRegisterCounterpartyAddressResponse {} -// MsgPayPacketFee defines the request type PayPacketFee RPC +// MsgPayPacketFee defines the request type for the PayPacketFee rpc // This Msg can be used to pay for a packet at the next sequence send & should be combined with the Msg that will be // paid for message MsgPayPacketFee { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; + // fee encapsulates the recv, ack and timeout fees associated with an IBC packet ibc.applications.fee.v1.Fee fee = 1 [(gogoproto.nullable) = false]; - // source channel port identifier + // the source port unique identifier string source_port_id = 2 [(gogoproto.moretags) = "yaml:\"source_port_id\""]; - // source channel unique identifier + // the source channel unique identifer string source_channel_id = 3 [(gogoproto.moretags) = "yaml:\"source_channel_id\""]; // account address to refund fee if necessary - string signer = 4; + string signer = 4; + // optional list of relayers permitted to the receive packet fees repeated string relayers = 5; } -// MsgPayPacketFeeResponse defines the response type for Msg/PayPacketFee +// MsgPayPacketFeeResponse defines the response type for the PayPacketFee rpc message MsgPayPacketFeeResponse {} -// MsgPayPacketFeeAsync defines the request type PayPacketFeeAsync RPC +// MsgPayPacketFeeAsync defines the request type for the PayPacketFeeAsync rpc // This Msg can be used to pay for a packet at a specified sequence (instead of the next sequence send) message MsgPayPacketFeeAsync { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; - // unique packet identifier + // unique packet identifier comprised of the channel ID, port ID and sequence ibc.core.channel.v1.PacketId packet_id = 1 [(gogoproto.moretags) = "yaml:\"packet_id\"", (gogoproto.nullable) = false]; - // packet fee for incentivization + // the packet fee associated with a particular IBC packet PacketFee packet_fee = 2 [(gogoproto.moretags) = "yaml:\"packet_fee\"", (gogoproto.nullable) = false]; } -// MsgPayPacketFeeAsyncResponse defines the response type for Msg/PayPacketFeeAsync +// MsgPayPacketFeeAsyncResponse defines the response type for the PayPacketFeeAsync rpc message MsgPayPacketFeeAsyncResponse {} From ab90f07e9a776a8aafe333a25f91fa43a0e42560 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Tue, 22 Mar 2022 15:22:47 +0100 Subject: [PATCH 76/79] add counter party channel ID to argument list of on channel open ack (#1159) Co-authored-by: Carlos Rodriguez --- modules/apps/29-fee/ibc_module.go | 5 +++-- modules/apps/29-fee/ibc_module_test.go | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/apps/29-fee/ibc_module.go b/modules/apps/29-fee/ibc_module.go index bdb3bcadabd..89d27b9f86f 100644 --- a/modules/apps/29-fee/ibc_module.go +++ b/modules/apps/29-fee/ibc_module.go @@ -105,6 +105,7 @@ func (im IBCModule) OnChanOpenAck( ctx sdk.Context, portID, channelID string, + counterpartyChannelID string, counterpartyVersion string, ) error { // If handshake was initialized with fee enabled it must complete with fee enabled. @@ -120,11 +121,11 @@ func (im IBCModule) OnChanOpenAck( } // call underlying app's OnChanOpenAck callback with the counterparty app version. - return im.app.OnChanOpenAck(ctx, portID, channelID, versionMetadata.AppVersion) + return im.app.OnChanOpenAck(ctx, portID, channelID, counterpartyChannelID, versionMetadata.AppVersion) } // call underlying app's OnChanOpenAck callback with the counterparty app version. - return im.app.OnChanOpenAck(ctx, portID, channelID, counterpartyVersion) + return im.app.OnChanOpenAck(ctx, portID, channelID, counterpartyChannelID, counterpartyVersion) } // OnChanOpenConfirm implements the IBCModule interface diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index 6e0202a887e..b520231a4f2 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -261,7 +261,7 @@ func (suite *FeeTestSuite) TestOnChanOpenAck() { // setup mock callback suite.chainA.GetSimApp().FeeMockModule.IBCApp.OnChanOpenAck = func( - ctx sdk.Context, portID, channelID string, counterpartyVersion string, + ctx sdk.Context, portID, channelID string, counterpartyChannelID string, counterpartyVersion string, ) error { if counterpartyVersion != ibcmock.Version { return fmt.Errorf("incorrect mock version") @@ -281,7 +281,7 @@ func (suite *FeeTestSuite) TestOnChanOpenAck() { cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module) suite.Require().True(ok) - err = cbs.OnChanOpenAck(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, tc.cpVersion) + err = cbs.OnChanOpenAck(suite.chainA.GetContext(), suite.path.EndpointA.ChannelConfig.PortID, suite.path.EndpointA.ChannelID, suite.path.EndpointA.Counterparty.ChannelID, tc.cpVersion) if tc.expPass { suite.Require().NoError(err, "unexpected error for case: %s", tc.name) } else { From 3ab22515f7f3026993724a4ea8ed9eb1c05ee65f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?colin=20axn=C3=A9r?= <25233464+colin-axner@users.noreply.github.com> Date: Tue, 29 Mar 2022 15:02:25 +0200 Subject: [PATCH 77/79] ADR 004: Fee module locking in the presence of severe bugs (#1060) * add adr 004 * add to README * Update docs/architecture/adr-004-ics29-lock-fee-module.md Co-authored-by: Aditya * Update docs/architecture/adr-004-ics29-lock-fee-module.md Co-authored-by: Aditya Co-authored-by: Carlos Rodriguez Co-authored-by: Aditya --- docs/architecture/README.md | 1 + .../adr-004-ics29-lock-fee-module.md | 55 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 docs/architecture/adr-004-ics29-lock-fee-module.md diff --git a/docs/architecture/README.md b/docs/architecture/README.md index 091ba899dc6..edfbea4f0c8 100644 --- a/docs/architecture/README.md +++ b/docs/architecture/README.md @@ -30,6 +30,7 @@ To suggest an ADR, please make use of the [ADR template](./adr-template.md) prov | [001](./adr-001-coin-source-tracing.md) | ICS-20 coin denomination format | Accepted, Implemented | | [002](./adr-002-go-module-versioning.md) | Go module versioning | Accepted | | [003](./adr-003-ics27-acknowledgement.md) | ICS27 acknowledgement format | Accepted | +| [004](./adr-004-ics29-lock-fee-module.md) | ICS29 module locking upon escrow out of balance | Accepted | | [015](./adr-015-ibc-packet-receiver.md) | IBC Packet Routing | Accepted | | [025](./adr-025-ibc-passive-channels.md) | IBC passive channels | Deprecated | | [026](./adr-026-ibc-client-recovery-mechanisms.md) | IBC client recovery mechansisms | Accepted | diff --git a/docs/architecture/adr-004-ics29-lock-fee-module.md b/docs/architecture/adr-004-ics29-lock-fee-module.md new file mode 100644 index 00000000000..5b17717e669 --- /dev/null +++ b/docs/architecture/adr-004-ics29-lock-fee-module.md @@ -0,0 +1,55 @@ +# ADR 004: Lock fee module upon escrow out of balance + +## Changelog +* 03/03/2022: initial draft + +## Status + +Accepted + +## Context + +The fee module maintains an escrow account for all fees escrowed to incentivize packet relays. +It also tracks each packet fee escrowed separately from the escrow account. This is because the escrow account only maintains a total balance. It has no reference for which coins belonged to which packet fee. +In the presence of a severe bug, it is possible the escrow balance will become out of sync with the packet fees marked as escrowed. +The ICS29 module should be capable of elegantly handling such a scenario. + +## Decision + +We will allow for the ICS29 module to become "locked" if the escrow balance is determined to be out of sync with the packet fees marked as escrowed. +A "locked" fee module will not allow for packet escrows to occur nor will it distribute fees. All IBC callbacks will skip performing fee logic, similar to fee disabled channels. + +Manual intervention will be needed to unlock the fee module. + +### Sending side + +Special behaviour will have to be accounted for in `OnAcknowledgementPacket`. Since the counterparty will continue to send incentivized acknowledgements for fee enabled channels, the acknowledgement will still need to be unmarshalled into an incentivized acknowledgement before calling the underlying application `OnAcknowledgePacket` callback. + +When distributing fees, a cached context should be used. If the escrow account balance would become negative, the current state changes should be discarded and the fee module should be locked using the uncached context. This prevents fees from being partially distributed for a given packetID. + +### Receiving side + +`OnRecvPacket` should remain unaffected by the fee module becoming locked since escrow accounts only affect the sending side. + +## Consequences + +### Positive + +The fee module can be elegantly disabled in the presence of severe bugs. + +### Negative + +Extra logic is added to account for edge cases which are only possible in the presence of bugs. + +### Neutral + +## References + +Issues: +- [#821](https://github.com/cosmos/ibc-go/issues/821) +- [#860](https://github.com/cosmos/ibc-go/issues/860) + +PR's: +- [#1031](https://github.com/cosmos/ibc-go/pull/1031) +- [#1029](https://github.com/cosmos/ibc-go/pull/1029) +- [#1056](https://github.com/cosmos/ibc-go/pull/1056) From e1cca36d7972d0dca65a8357a6cee53b8852735c Mon Sep 17 00:00:00 2001 From: Sean King Date: Tue, 5 Apr 2022 10:22:40 +0200 Subject: [PATCH 78/79] nit: packetID var name (#1214) --- modules/apps/29-fee/ibc_module_test.go | 4 ++-- modules/apps/29-fee/keeper/escrow.go | 4 ++-- modules/apps/29-fee/keeper/msg_server_test.go | 2 +- modules/apps/29-fee/keeper/relay.go | 8 +++---- modules/apps/29-fee/types/genesis_test.go | 22 +++++++++---------- modules/apps/29-fee/types/keys.go | 4 ++-- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/modules/apps/29-fee/ibc_module_test.go b/modules/apps/29-fee/ibc_module_test.go index b520231a4f2..8bdc92458f7 100644 --- a/modules/apps/29-fee/ibc_module_test.go +++ b/modules/apps/29-fee/ibc_module_test.go @@ -537,10 +537,10 @@ func (suite *FeeTestSuite) TestOnRecvPacket() { case tc.forwardRelayer && result == nil: suite.Require().Equal(nil, result) - packetId := channeltypes.NewPacketId(packet.GetDestChannel(), packet.GetDestPort(), packet.GetSequence()) + packetID := channeltypes.NewPacketId(packet.GetDestChannel(), packet.GetDestPort(), packet.GetSequence()) // retrieve the forward relayer that was stored in `onRecvPacket` - relayer, _ := suite.chainB.GetSimApp().IBCFeeKeeper.GetRelayerAddressForAsyncAck(suite.chainB.GetContext(), packetId) + relayer, _ := suite.chainB.GetSimApp().IBCFeeKeeper.GetRelayerAddressForAsyncAck(suite.chainB.GetContext(), packetID) suite.Require().Equal(relayer, suite.chainA.SenderAccount.GetAddress().String()) case !tc.forwardRelayer: diff --git a/modules/apps/29-fee/keeper/escrow.go b/modules/apps/29-fee/keeper/escrow.go index d3e96bad312..37c9dd7e624 100644 --- a/modules/apps/29-fee/keeper/escrow.go +++ b/modules/apps/29-fee/keeper/escrow.go @@ -45,7 +45,7 @@ func (k Keeper) EscrowPacketFee(ctx sdk.Context, packetID channeltypes.PacketId, return nil } -// DistributePacketFees pays the acknowledgement fee & receive fee for a given packetId while refunding the timeout fee to the refund account associated with the Fee. +// DistributePacketFees pays the acknowledgement fee & receive fee for a given packetID while refunding the timeout fee to the refund account associated with the Fee. func (k Keeper) DistributePacketFees(ctx sdk.Context, forwardRelayer string, reverseRelayer sdk.AccAddress, feesInEscrow []types.PacketFee) { forwardAddr, _ := sdk.AccAddressFromBech32(forwardRelayer) @@ -72,7 +72,7 @@ func (k Keeper) DistributePacketFees(ctx sdk.Context, forwardRelayer string, rev } } -// DistributePacketsFeesTimeout pays the timeout fee for a given packetId while refunding the acknowledgement fee & receive fee to the refund account associated with the Fee +// DistributePacketsFeesTimeout pays the timeout fee for a given packetID while refunding the acknowledgement fee & receive fee to the refund account associated with the Fee func (k Keeper) DistributePacketFeesOnTimeout(ctx sdk.Context, timeoutRelayer sdk.AccAddress, feesInEscrow []types.PacketFee) { for _, feeInEscrow := range feesInEscrow { // check if refundAcc address works diff --git a/modules/apps/29-fee/keeper/msg_server_test.go b/modules/apps/29-fee/keeper/msg_server_test.go index 1b371a2369f..26ce387b60e 100644 --- a/modules/apps/29-fee/keeper/msg_server_test.go +++ b/modules/apps/29-fee/keeper/msg_server_test.go @@ -109,7 +109,7 @@ func (suite *KeeperTestSuite) TestPayPacketFeeAsync() { refundAcc := suite.chainA.SenderAccount.GetAddress() - // build packetId + // build packetID channelID := suite.path.EndpointA.ChannelID fee := types.Fee{ RecvFee: defaultReceiveFee, diff --git a/modules/apps/29-fee/keeper/relay.go b/modules/apps/29-fee/keeper/relay.go index e2d75c3a1f8..a2ef8a7ca11 100644 --- a/modules/apps/29-fee/keeper/relay.go +++ b/modules/apps/29-fee/keeper/relay.go @@ -23,12 +23,12 @@ func (k Keeper) WriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.C return k.ics4Wrapper.WriteAcknowledgement(ctx, chanCap, packet, acknowledgement) } - packetId := channeltypes.NewPacketId(packet.GetDestChannel(), packet.GetDestPort(), packet.GetSequence()) + packetID := channeltypes.NewPacketId(packet.GetDestChannel(), packet.GetDestPort(), packet.GetSequence()) // retrieve the forward relayer that was stored in `onRecvPacket` - relayer, found := k.GetRelayerAddressForAsyncAck(ctx, packetId) + relayer, found := k.GetRelayerAddressForAsyncAck(ctx, packetID) if !found { - return sdkerrors.Wrapf(types.ErrRelayerNotFoundForAsyncAck, "no relayer address stored for async acknowledgement for packet with portID: %s, channelID: %s, sequence: %d", packetId.PortId, packetId.ChannelId, packetId.Sequence) + return sdkerrors.Wrapf(types.ErrRelayerNotFoundForAsyncAck, "no relayer address stored for async acknowledgement for packet with portID: %s, channelID: %s, sequence: %d", packetID.PortId, packetID.ChannelId, packetID.Sequence) } // it is possible that a relayer has not registered a counterparty address. @@ -37,7 +37,7 @@ func (k Keeper) WriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.C ack := types.NewIncentivizedAcknowledgement(forwardRelayer, acknowledgement.Acknowledgement(), acknowledgement.Success()) - k.DeleteForwardRelayerAddress(ctx, packetId) + k.DeleteForwardRelayerAddress(ctx, packetID) // ics4Wrapper may be core IBC or higher-level middleware return k.ics4Wrapper.WriteAcknowledgement(ctx, chanCap, packet, ack) diff --git a/modules/apps/29-fee/types/genesis_test.go b/modules/apps/29-fee/types/genesis_test.go index 75c754cc7c9..edcd91c6f9d 100644 --- a/modules/apps/29-fee/types/genesis_test.go +++ b/modules/apps/29-fee/types/genesis_test.go @@ -23,7 +23,7 @@ var ( func TestValidateGenesis(t *testing.T) { var ( - packetId channeltypes.PacketId + packetID channeltypes.PacketId fee types.Fee refundAcc string sender string @@ -46,9 +46,9 @@ func TestValidateGenesis(t *testing.T) { true, }, { - "invalid packetId: invalid channel", + "invalid packetID: invalid channel", func() { - packetId = channeltypes.NewPacketId( + packetID = channeltypes.NewPacketId( "", portID, seq, @@ -57,9 +57,9 @@ func TestValidateGenesis(t *testing.T) { false, }, { - "invalid packetId: invalid port", + "invalid packetID: invalid port", func() { - packetId = channeltypes.NewPacketId( + packetID = channeltypes.NewPacketId( channelID, "", seq, @@ -68,9 +68,9 @@ func TestValidateGenesis(t *testing.T) { false, }, { - "invalid packetId: invalid sequence", + "invalid packetID: invalid sequence", func() { - packetId = channeltypes.NewPacketId( + packetID = channeltypes.NewPacketId( channelID, portID, 0, @@ -79,7 +79,7 @@ func TestValidateGenesis(t *testing.T) { false, }, { - "invalid packetId: invalid fee", + "invalid packetID: invalid fee", func() { fee = types.Fee{ sdk.Coins{}, @@ -90,7 +90,7 @@ func TestValidateGenesis(t *testing.T) { false, }, { - "invalid packetId: invalid refundAcc", + "invalid packetID: invalid refundAcc", func() { refundAcc = "" }, @@ -147,7 +147,7 @@ func TestValidateGenesis(t *testing.T) { seq = uint64(1) // build PacketId & Fee - packetId = channeltypes.NewPacketId( + packetID = channeltypes.NewPacketId( portID, channelID, seq, @@ -170,7 +170,7 @@ func TestValidateGenesis(t *testing.T) { genState := types.GenesisState{ IdentifiedFees: []types.IdentifiedPacketFees{ { - PacketId: packetId, + PacketId: packetID, PacketFees: []types.PacketFee{ { Fee: fee, diff --git a/modules/apps/29-fee/types/keys.go b/modules/apps/29-fee/types/keys.go index 68154661d6e..f2dd3458e20 100644 --- a/modules/apps/29-fee/types/keys.go +++ b/modules/apps/29-fee/types/keys.go @@ -82,8 +82,8 @@ func ParseKeyCounterpartyRelayer(key string) (address string, channelID string, } // KeyForwardRelayerAddress returns the key for packetID -> forwardAddress mapping -func KeyForwardRelayerAddress(packetId channeltypes.PacketId) []byte { - return []byte(fmt.Sprintf("%s/%s/%s/%d", ForwardRelayerPrefix, packetId.PortId, packetId.ChannelId, packetId.Sequence)) +func KeyForwardRelayerAddress(packetID channeltypes.PacketId) []byte { + return []byte(fmt.Sprintf("%s/%s/%s/%d", ForwardRelayerPrefix, packetID.PortId, packetID.ChannelId, packetID.Sequence)) } // ParseKeyForwardRelayerAddress parses the key used to store the forward relayer address and returns the packetID From 39d4c56cd69213e2bfaa942caea1b29bd456b9bd Mon Sep 17 00:00:00 2001 From: Sean King Date: Wed, 6 Apr 2022 14:23:46 +0200 Subject: [PATCH 79/79] ics29: update with changes from main (#1221) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add banner image (#1158) Co-authored-by: Carlos Rodriguez * Add alpha, beta, and rc release definitions (#1151) ## Description The proposed definitions for each phase of our release cycle. Please feel free to adjust my wording closes: #881 --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x//spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [ ] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes * build(deps): bump google.golang.org/protobuf from 1.27.1 to 1.28.0 (#1164) Bumps [google.golang.org/protobuf](https://github.com/protocolbuffers/protobuf-go) from 1.27.1 to 1.28.0.
Release notes

Sourced from google.golang.org/protobuf's releases.

v1.28.0

Overview

The release provides a new unmarshal option for limiting the recursion depth when unmarshalling nested messages to prevent stack overflows. (UnmarshalOptions.RecursionLimit).

Notable changes

New features:

  • CL/340489: testing/protocmp: add Message.Unwrap

Documentation improvements:

  • CL/339569: reflect/protoreflect: add more docs on Value aliasing

Updated supported versions:

UnmarshalOption RecursionLimit

  • CL/385854: all: implement depth limit for unmarshalling

The new UnmarshalOptions.RecursionLimit limits the maximum recursion depth when unmarshalling messages. The limit is applied for nested messages. When messages are nested deeper than the specified limit the unmarshalling will fail. If unspecified, a default limit of 10,000 is applied.

In addition to the configurable limit for message nesting a non-configurable recursion limit for group nesting of 10,000 was introduced.

Upcoming breakage changes

The default recursion limit of 10,000 introduced in the release is subject to change. We want to align this limit with implementations for other languages in the long term. C++ and Java use a limit of 100 which is also the target for the Go implementation.

Commits
  • 32051b4 all: release v1.28.0
  • 3992ea8 all: implement depth limit for unmarshaling
  • e5db296 all: update supported versions
  • 3a9e1dc all: gofmt all
  • 26e8bcb all: remove unnecessary string([]byte) conversion in fmt.Sprintf with %s
  • 5aec41b testing/protocmp: add Message.Unwrap
  • 05be61f reflect/protoreflect: add more docs on Value aliasing
  • b03064a all: start v1.27.1-devel
  • See full diff in compare view

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=google.golang.org/protobuf&package-manager=go_modules&previous-version=1.27.1&new-version=1.28.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
* fix typos in the controller params (#1172) ## Description closes: #XXXX --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [x] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x//spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [x] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes * add versions for new releases (#1175) ## Description closes: #XXXX --- Before we can merge this PR, please make sure that all the following items have been checked off. If any of the checklist items are not applicable, please leave them but write a little note why. - [x] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work. - [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing) - [ ] Updated relevant documentation (`docs/`) or specification (`x//spec/`) - [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code). - [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md` - [x] Re-reviewed `Files changed` in the Github PR explorer - [ ] Review `Codecov Report` in the comment section below once CI passes * fix: link checker reporting broken milestone link (#1200) * update roadmap for q2 2022 and deleted history roadmap (don't think we'll need it) * requirements document for ICA (#1173) * add requirements document for interchain accounts * fix branch * added number in tittle. * apply suggestions from review Co-authored-by: Aditya * review comment Co-authored-by: Carlos Rodriguez Co-authored-by: Aditya * imp: improve Logger performance (#1160) * fix: Logger marshal errors * changelog * update Co-authored-by: Carlos Rodriguez Co-authored-by: Carlos Rodriguez Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Damian Nolan Co-authored-by: Aditya Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>