Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BP: release/v4 <- #118] rename: router -> packetforward #119

Merged
merged 3 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions middleware/packet-forward-middleware/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ cosmovisor:

mocks: $(MOCKS_DIR)
go install go.uber.org/mock/mockgen@v0.2.0
mockgen -package=mock -destination=./test/mock/transfer_keeper.go $(GOMOD)/router/types TransferKeeper
mockgen -package=mock -destination=./test/mock/channel_keeper.go $(GOMOD)/router/types ChannelKeeper
mockgen -package=mock -destination=./test/mock/distribution_keeper.go $(GOMOD)/router/types DistributionKeeper
mockgen -package=mock -destination=./test/mock/bank_keeper.go $(GOMOD)/router/types BankKeeper
mockgen -package=mock -destination=./test/mock/channel_keeper.go $(GOMOD)/router/types ChannelKeeper
mockgen -package=mock -destination=./test/mock/transfer_keeper.go $(GOMOD)/packetforward/types TransferKeeper
mockgen -package=mock -destination=./test/mock/channel_keeper.go $(GOMOD)/packetforward/types ChannelKeeper
mockgen -package=mock -destination=./test/mock/distribution_keeper.go $(GOMOD)/packetforward/types DistributionKeeper
mockgen -package=mock -destination=./test/mock/bank_keeper.go $(GOMOD)/packetforward/types BankKeeper
mockgen -package=mock -destination=./test/mock/channel_keeper.go $(GOMOD)/packetforward/types ChannelKeeper
mockgen -package=mock -destination=./test/mock/ics4_wrapper.go github.com/cosmos/ibc-go/v4/modules/core/05-port/types ICS4Wrapper
mockgen -package=mock -destination=./test/mock/ibc_module.go github.com/cosmos/ibc-go/v4/modules/core/05-port/types IBCModule

Expand Down
2 changes: 1 addition & 1 deletion middleware/packet-forward-middleware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ The examples above show the intended usage of the `receiver` field for one or mu

## Implementation details

Flow sequence mainly encoded in [middleware](router/ibc_middleware.go) and in [keeper](router/keeper/keeper.go).
Flow sequence mainly encoded in [middleware](packetforward/ibc_middleware.go) and in [keeper](packetforward/keeper/keeper.go).

Describes `A` sending to `C` via `B` in several scenarios with operational opened channels, enabled denom composition, fees and available to refund, but no retries.

Expand Down
6 changes: 3 additions & 3 deletions middleware/packet-forward-middleware/docs/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Integration of the PFM should take approximately 20 minutes.

// Import the packet forward middleware
import (
packetforward "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router"
packetforwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/keeper"
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/router/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward"
packetforwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/keeper"
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
)

...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ package cli
import (
"fmt"

"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/router/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/packetforward/types"
"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/version"
)

// GetQueryCmd returns the query commands for router
// GetQueryCmd returns the query commands for packetforward
func GetQueryCmd() *cobra.Command {
queryCmd := &cobra.Command{
Use: "ibc-router",
Use: "packetforward",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
}
Expand All @@ -26,14 +26,14 @@ func GetQueryCmd() *cobra.Command {
return queryCmd
}

// GetCmdParams returns the command handler for ibc-router parameter querying.
// GetCmdParams returns the command handler for packetforward parameter querying.
func GetCmdParams() *cobra.Command {
cmd := &cobra.Command{
Use: "params",
Short: "Query the current ibc-router parameters",
Long: "Query the current ibc-router parameters",
Short: "Query the current packetforward parameters",
Long: "Query the current packetforward parameters",
Args: cobra.NoArgs,
Example: fmt.Sprintf("%s query ibc-router params", version.AppName),
Example: fmt.Sprintf("%s query packetforward params", version.AppName),
RunE: func(cmd *cobra.Command, _ []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
Expand All @@ -54,7 +54,7 @@ func GetCmdParams() *cobra.Command {
return cmd
}

// NewTxCmd returns the transaction commands for router
// NewTxCmd returns the transaction commands for packetforward
func NewTxCmd() *cobra.Command {
return nil
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package router
package packetforward

import (
"encoding/json"
Expand All @@ -7,8 +7,8 @@ import (
"time"

"github.com/armon/go-metrics"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/router/keeper"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/router/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/packetforward/keeper"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/packetforward/types"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package keeper

import (
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/router/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/packetforward/types"

sdk "github.com/cosmos/cosmos-sdk/types"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package keeper
import (
"context"

"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/router/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/packetforward/types"

sdk "github.com/cosmos/cosmos-sdk/types"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"time"

"github.com/armon/go-metrics"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/router/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/packetforward/types"
"github.com/tendermint/tendermint/libs/log"

"github.com/cosmos/cosmos-sdk/codec"
Expand Down Expand Up @@ -37,7 +37,7 @@ var (
// DefaultForwardTransferPacketTimeoutTimestamp is the timeout timestamp following IBC defaults
DefaultForwardTransferPacketTimeoutTimestamp = time.Duration(transfertypes.DefaultRelativePacketTimeoutTimestamp) * time.Nanosecond

// DefaultRefundTransferPacketTimeoutTimestamp is a 28-day timeout for refund packets since funds are stuck in router module otherwise.
// DefaultRefundTransferPacketTimeoutTimestamp is a 28-day timeout for refund packets since funds are stuck in packetforward module otherwise.
DefaultRefundTransferPacketTimeoutTimestamp = 28 * 24 * time.Hour
)

Expand Down Expand Up @@ -374,14 +374,14 @@ func (k *Keeper) RetryTimeout(

amount, ok := sdk.NewIntFromString(data.Amount)
if !ok {
k.Logger(ctx).Error("packetForwardMiddleware error parsing amount from string for router retry on timeout",
k.Logger(ctx).Error("packetForwardMiddleware error parsing amount from string for packetforward retry on timeout",
"original-sender-address", inFlightPacket.OriginalSenderAddress,
"refund-channel-id", inFlightPacket.RefundChannelId,
"refund-port-id", inFlightPacket.RefundPortId,
"retries-remaining", inFlightPacket.RetriesRemaining,
"amount", data.Amount,
)
return fmt.Errorf("error parsing amount from string for router retry: %s", data.Amount)
return fmt.Errorf("error parsing amount from string for packetforward retry: %s", data.Amount)
}

denom := transfertypes.ParseDenomTrace(data.Denom).IBCDenom()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package keeper

import (
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/router/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/packetforward/types"

sdk "github.com/cosmos/cosmos-sdk/types"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package router
package packetforward

import (
"context"
"encoding/json"
"fmt"
"math/rand"

"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/router/client/cli"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/router/keeper"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/router/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/packetforward/client/cli"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/packetforward/keeper"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/packetforward/types"
"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/spf13/cobra"
Expand All @@ -28,7 +28,7 @@ var (
_ module.AppModuleSimulation = AppModule{}
)

// AppModuleBasic is the router AppModuleBasic
// AppModuleBasic is the packetforward AppModuleBasic
type AppModuleBasic struct{}

// Name implements AppModuleBasic interface
Expand All @@ -43,12 +43,12 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(_ *codec.LegacyAmino) {}
func (AppModuleBasic) RegisterInterfaces(_ codectypes.InterfaceRegistry) {}

// DefaultGenesis returns default genesis state as raw bytes for the ibc
// router module.
// packetforward module.
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
return cdc.MustMarshalJSON(types.DefaultGenesisState())
}

// ValidateGenesis performs genesis state validation for the router module.
// ValidateGenesis performs genesis state validation for the packetforward module.
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error {
var gs types.GenesisState
if err := cdc.UnmarshalJSON(bz, &gs); err != nil {
Expand All @@ -61,7 +61,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingCo
// RegisterRESTRoutes implements AppModuleBasic interface
func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {}

// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the ibc-router module.
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the packetforward module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
_ = types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
}
Expand All @@ -82,7 +82,7 @@ type AppModule struct {
keeper *keeper.Keeper
}

// NewAppModule creates a new router module
// NewAppModule creates a new packetforward module
func NewAppModule(k *keeper.Keeper) AppModule {
return AppModule{
keeper: k,
Expand Down Expand Up @@ -112,7 +112,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
}

// InitGenesis performs genesis initialization for the ibc-router module. It returns
// InitGenesis performs genesis initialization for the packetforward module. It returns
// no validator updates.
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
err := am.ValidateGenesis(cdc, nil, data)
Expand All @@ -126,7 +126,7 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
return []abci.ValidatorUpdate{}
}

// ExportGenesis returns the exported genesis state as raw bytes for the ibc-router
// ExportGenesis returns the exported genesis state as raw bytes for the packetforward
// module.
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
gs := am.keeper.ExportGenesis(ctx)
Expand All @@ -146,7 +146,7 @@ func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.Valid

// AppModuleSimulation functions

// GenerateGenesisState creates a randomized GenState of the router module.
// GenerateGenesisState creates a randomized GenState of the packetforward module.
func (AppModule) GenerateGenesisState(_ *module.SimulationState) {}

// ProposalContents doesn't return any content functions for governance proposals.
Expand All @@ -159,10 +159,10 @@ func (AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange {
return nil
}

// RegisterStoreDecoder registers a decoder for router module's types
// RegisterStoreDecoder registers a decoder for packetforward module's types
func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {}

// WeightedOperations returns the all the router module operations with their respective weights.
// WeightedOperations returns the all the packetforward module operations with their respective weights.
func (am AppModule) WeightedOperations(_ module.SimulationState) []simtypes.WeightedOperation {
return nil
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package router_test
package packetforward_test

import (
"encoding/json"
"fmt"
"testing"

"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/router/keeper"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/router/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/packetforward/keeper"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/packetforward/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/test"
"github.com/iancoleman/orderedmap"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -291,7 +291,7 @@ func TestOnRecvPacket_ForwardNoFee(t *testing.T) {
Return(nil),
)

// chain B with router module receives packet and forwards. ack should be nil so that it is not written yet.
// chain B with packetforward module receives packet and forwards. ack should be nil so that it is not written yet.
ack := forwardMiddleware.OnRecvPacket(ctx, packetOrig, senderAccAddr)
require.Nil(t, ack)

Expand Down Expand Up @@ -351,7 +351,7 @@ func TestOnRecvPacket_ForwardAmountInt256(t *testing.T) {
Return(nil),
)

// chain B with router module receives packet and forwards. ack should be nil so that it is not written yet.
// chain B with packetforward module receives packet and forwards. ack should be nil so that it is not written yet.
ack := forwardMiddleware.OnRecvPacket(ctx, packetOrig, senderAccAddr)
require.Nil(t, ack)

Expand All @@ -370,7 +370,7 @@ func TestOnRecvPacket_ForwardWithFee(t *testing.T) {
forwardMiddleware := setup.ForwardMiddleware

// Set fee param to 10%
setup.Keepers.RouterKeeper.SetParams(ctx, types.NewParams(sdk.NewDecWithPrec(10, 2)))
setup.Keepers.PacketForwardKeeper.SetParams(ctx, types.NewParams(sdk.NewDecWithPrec(10, 2)))

denom := makeIBCDenom(testDestinationPort, testDestinationChannel, testDenom)
senderAccAddr := test.AccAddress(t)
Expand Down Expand Up @@ -416,7 +416,7 @@ func TestOnRecvPacket_ForwardWithFee(t *testing.T) {
Return(nil),
)

// chain B with router module receives packet and forwards. ack should be nil so that it is not written yet.
// chain B with packetforward module receives packet and forwards. ack should be nil so that it is not written yet.
ack := forwardMiddleware.OnRecvPacket(ctx, packetOrig, senderAccAddr)
require.Nil(t, ack)

Expand Down Expand Up @@ -516,11 +516,11 @@ func TestOnRecvPacket_ForwardMultihopStringNext(t *testing.T) {
Return(nil),
)

// chain B with router module receives packet and forwards. ack should be nil so that it is not written yet.
// chain B with packetforward module receives packet and forwards. ack should be nil so that it is not written yet.
ack := forwardMiddleware.OnRecvPacket(ctx, packetOrig, senderAccAddr)
require.Nil(t, ack)

// chain C with router module receives packet and forwards. ack should be nil so that it is not written yet.
// chain C with packetforward module receives packet and forwards. ack should be nil so that it is not written yet.
ack = forwardMiddleware.OnRecvPacket(ctx, packet2, senderAccAddr2)
require.Nil(t, ack)

Expand Down Expand Up @@ -626,11 +626,11 @@ func TestOnRecvPacket_ForwardMultihopJSONNext(t *testing.T) {
Return(nil),
)

// chain B with router module receives packet and forwards. ack should be nil so that it is not written yet.
// chain B with packetforward module receives packet and forwards. ack should be nil so that it is not written yet.
ack := forwardMiddleware.OnRecvPacket(ctx, packetOrig, senderAccAddr)
require.Nil(t, ack)

// chain C with router module receives packet and forwards. ack should be nil so that it is not written yet.
// chain C with packetforward module receives packet and forwards. ack should be nil so that it is not written yet.
ack = forwardMiddleware.OnRecvPacket(ctx, packet2, senderAccAddr2)
require.Nil(t, ack)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"
"testing"

"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/router/types"
"github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4/packetforward/types"
"github.com/stretchr/testify/require"
)

Expand Down
Loading
Loading