Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: integrate packet forwarding #30

Merged
merged 8 commits into from
Jun 5, 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

## [Unreleased]

### Features

- (ibc) [#30](https://github.com/KYVENetwork/chain/pull/30) Integrate [Packet Forward Middleware](https://github.com/strangelove-ventures/packet-forward-middleware).

### Improvements

- (`x/stakers`) [#46](https://github.com/KYVENetwork/chain/pull/46) Allow protocol validator commission rewards to be claimed.
Expand Down
36 changes: 30 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ import (
"github.com/KYVENetwork/chain/x/global"
globalKeeper "github.com/KYVENetwork/chain/x/global/keeper"
globalTypes "github.com/KYVENetwork/chain/x/global/types"
// PFM
pfm "github.com/strangelove-ventures/packet-forward-middleware/v6/router"
pfmKeeper "github.com/strangelove-ventures/packet-forward-middleware/v6/router/keeper"
pfmTypes "github.com/strangelove-ventures/packet-forward-middleware/v6/router/types"
// Pool
"github.com/KYVENetwork/chain/x/pool"
poolKeeper "github.com/KYVENetwork/chain/x/pool/keeper"
Expand Down Expand Up @@ -230,12 +234,15 @@ func NewKYVEApp(
bApp.SetInterfaceRegistry(interfaceRegistry)

keys := sdk.NewKVStoreKeys(
authtypes.StoreKey, authzTypes.ModuleName, banktypes.StoreKey, stakingtypes.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey, govtypes.StoreKey,
paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey,
evidencetypes.StoreKey, ibcFeeTypes.StoreKey, ibcTransferTypes.StoreKey,
icaControllerTypes.StoreKey, icaHostTypes.StoreKey, capabilitytypes.StoreKey,
groupTypes.StoreKey,
authtypes.StoreKey, authzTypes.ModuleName, banktypes.StoreKey,
capabilitytypes.StoreKey, distrtypes.StoreKey, evidencetypes.StoreKey,
feegrant.StoreKey, govtypes.StoreKey, groupTypes.StoreKey,
minttypes.StoreKey, paramstypes.StoreKey, slashingtypes.StoreKey,
stakingtypes.StoreKey, upgradetypes.StoreKey,

ibchost.StoreKey, ibcFeeTypes.StoreKey, ibcTransferTypes.StoreKey,
icaControllerTypes.StoreKey, icaHostTypes.StoreKey,
pfmTypes.StoreKey,

bundlesTypes.StoreKey,
delegationTypes.StoreKey,
Expand Down Expand Up @@ -500,6 +507,16 @@ func NewKYVEApp(
app.MsgServiceRouter(),
)

app.PFMKeeper = pfmKeeper.NewKeeper(
appCodec, keys[pfmTypes.StoreKey],
app.GetSubspace(pfmTypes.ModuleName),
app.IBCTransferKeeper,
app.IBCKeeper.ChannelKeeper,
app.DistributionKeeper,
app.BankKeeper,
app.IBCKeeper.ChannelKeeper,
)

// Create evidence Keeper for to register the IBC light client misbehaviour evidence route
evidenceKeeper := evidencekeeper.NewKeeper(
appCodec,
Expand Down Expand Up @@ -554,6 +571,13 @@ func NewKYVEApp(
var ibcTransferStack ibcPortTypes.IBCModule
ibcTransferStack = ibcTransfer.NewIBCModule(app.IBCTransferKeeper)
ibcTransferStack = ibcFee.NewIBCMiddleware(ibcTransferStack, app.IBCFeeKeeper)
ibcTransferStack = pfm.NewIBCMiddleware(
ibcTransferStack,
app.PFMKeeper,
0,
pfmKeeper.DefaultForwardTransferPacketTimeoutTimestamp,
pfmKeeper.DefaultRefundTransferPacketTimeoutTimestamp,
)

var icaControllerStack ibcPortTypes.IBCModule
icaControllerStack = icaController.NewIBCMiddleware(icaControllerStack, app.ICAControllerKeeper)
Expand Down
16 changes: 11 additions & 5 deletions app/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ import (
mintTypes "github.com/cosmos/cosmos-sdk/x/mint/types"
// Parameters
paramsKeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
// PFM
pfmKeeper "github.com/strangelove-ventures/packet-forward-middleware/v6/router/keeper"
pfmTypes "github.com/strangelove-ventures/packet-forward-middleware/v6/router/types"
// Pool
poolKeeper "github.com/KYVENetwork/chain/x/pool/keeper"
// Query
Expand Down Expand Up @@ -97,6 +100,7 @@ type Keepers struct {
IBCTransferKeeper ibcTransferKeeper.Keeper
ICAControllerKeeper icaControllerKeeper.Keeper
ICAHostKeeper icaHostKeeper.Keeper
PFMKeeper *pfmKeeper.Keeper

// KYVE
BundlesKeeper bundlesKeeper.Keeper
Expand All @@ -121,16 +125,18 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino

keeper.Subspace(authTypes.ModuleName)
keeper.Subspace(bankTypes.ModuleName)
keeper.Subspace(stakingTypes.ModuleName)
keeper.Subspace(mintTypes.ModuleName)
keeper.Subspace(crisisTypes.ModuleName)
keeper.Subspace(distributionTypes.ModuleName)
keeper.Subspace(slashingTypes.ModuleName)
keeper.Subspace(govTypes.ModuleName).WithKeyTable(govV1.ParamKeyTable())
keeper.Subspace(crisisTypes.ModuleName)
keeper.Subspace(ibcTransferTypes.ModuleName)
keeper.Subspace(mintTypes.ModuleName)
keeper.Subspace(slashingTypes.ModuleName)
keeper.Subspace(stakingTypes.ModuleName)

keeper.Subspace(ibcHost.ModuleName)
keeper.Subspace(ibcTransferTypes.ModuleName)
keeper.Subspace(icaControllerTypes.SubModuleName)
keeper.Subspace(icaHostTypes.SubModuleName)
keeper.Subspace(pfmTypes.ModuleName)

return keeper
}
5 changes: 4 additions & 1 deletion app/modules.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package app

import (
teamTypes "github.com/KYVENetwork/chain/x/team/types"
"github.com/cosmos/cosmos-sdk/types/module"

// Auth
Expand Down Expand Up @@ -54,6 +53,8 @@ import (
mintTypes "github.com/cosmos/cosmos-sdk/x/mint/types"
// Parameters
"github.com/cosmos/cosmos-sdk/x/params"
// PFM
pfm "github.com/strangelove-ventures/packet-forward-middleware/v6/router"
// Pool
"github.com/KYVENetwork/chain/x/pool"
poolTypes "github.com/KYVENetwork/chain/x/pool/types"
Expand All @@ -69,6 +70,7 @@ import (
stakingTypes "github.com/cosmos/cosmos-sdk/x/staking/types"
// Team
"github.com/KYVENetwork/chain/x/team"
teamTypes "github.com/KYVENetwork/chain/x/team/types"
// Upgrade
"github.com/cosmos/cosmos-sdk/x/upgrade"
)
Expand Down Expand Up @@ -99,6 +101,7 @@ var appModuleBasics = []module.AppModuleBasic{
ibcFee.AppModuleBasic{},
ibcTransfer.AppModuleBasic{},
ica.AppModuleBasic{},
pfm.AppModuleBasic{},

// KYVE
bundles.AppModuleBasic{},
Expand Down
10 changes: 9 additions & 1 deletion app/upgrades/v1_3/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ package v1_3
import (
"github.com/cosmos/cosmos-sdk/baseapp"
storeTypes "github.com/cosmos/cosmos-sdk/store/types"

// PFM
pfmTypes "github.com/strangelove-ventures/packet-forward-middleware/v6/router/types"
// Upgrade
upgradeTypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func CreateStoreLoader(upgradeHeight int64) baseapp.StoreLoader {
storeUpgrades := storeTypes.StoreUpgrades{}
storeUpgrades := storeTypes.StoreUpgrades{
Added: []string{
pfmTypes.StoreKey,
},
}

return upgradeTypes.UpgradeStoreLoader(upgradeHeight, &storeUpgrades)
}
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.20

require (
cosmossdk.io/errors v1.0.0-beta.7
cosmossdk.io/math v1.0.0-beta.3
cosmossdk.io/math v1.0.0-beta.4
github.com/cosmos/cosmos-proto v1.0.0-alpha8
github.com/cosmos/cosmos-sdk v0.46.12
github.com/cosmos/gogoproto v1.4.2
Expand All @@ -18,6 +18,7 @@ require (
github.com/onsi/gomega v1.26.0
github.com/spf13/cast v1.5.0
github.com/spf13/cobra v1.6.1
github.com/strangelove-ventures/packet-forward-middleware/v6 v6.0.3
github.com/stretchr/testify v1.8.2
github.com/tendermint/tendermint v0.34.27
github.com/tendermint/tm-db v0.6.7
Expand Down Expand Up @@ -131,7 +132,6 @@ require (
github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect
Expand Down Expand Up @@ -159,6 +159,7 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect
github.com/hexops/gotextdiff v1.0.3 // indirect
github.com/iancoleman/orderedmap v0.2.0 // indirect
github.com/improbable-eng/grpc-web v0.15.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/jgautheron/goconst v1.5.1 // indirect
Expand Down
9 changes: 6 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ cloud.google.com/go/storage v1.27.0/go.mod h1:x9DOL8TK/ygDUMieqwfhdpQryTeEkhGKMi
collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE=
cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w=
cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE=
cosmossdk.io/math v1.0.0-beta.3 h1:TbZxSopz2LqjJ7aXYfn7nJSb8vNaBklW6BLpcei1qwM=
cosmossdk.io/math v1.0.0-beta.3/go.mod h1:3LYasri3Zna4XpbrTNdKsWmD5fHHkaNAod/mNT9XdE4=
cosmossdk.io/math v1.0.0-beta.4 h1:JtKedVLGzA0vv84xjYmZ75RKG35Kf2WwcFu8IjRkIIw=
cosmossdk.io/math v1.0.0-beta.4/go.mod h1:An0MllWJY6PxibUpnwGk8jOm+a/qIxlKmL5Zyp9NnaM=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU=
filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
Expand Down Expand Up @@ -549,7 +549,6 @@ github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSN
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
Expand Down Expand Up @@ -678,6 +677,8 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
github.com/huin/goupnp v1.0.3-0.20220313090229-ca81a64b4204/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y=
github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o=
github.com/iancoleman/orderedmap v0.2.0 h1:sq1N/TFpYH++aViPcaKjys3bDClUEU7s5B+z6jq8pNA=
github.com/iancoleman/orderedmap v0.2.0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ=
Expand Down Expand Up @@ -1131,6 +1132,8 @@ github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRk
github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q=
github.com/stbenjam/no-sprintf-host-port v0.1.1 h1:tYugd/yrm1O0dV+ThCbaKZh195Dfm07ysF0U6JQXczc=
github.com/stbenjam/no-sprintf-host-port v0.1.1/go.mod h1:TLhvtIvONRzdmkFiio4O8LHsN9N74I+PhRquPsxpL0I=
github.com/strangelove-ventures/packet-forward-middleware/v6 v6.0.3 h1:HOBZ9m5vl5L6BP/oLtZ3xygmj1KmqgJjbWuvlsD52YA=
github.com/strangelove-ventures/packet-forward-middleware/v6 v6.0.3/go.mod h1:LB5oxowvdkiieyb6NZj4bAbvc8fE9wn1iFeTV4uXF/A=
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
Expand Down