Skip to content

Commit

Permalink
Fix: pfm v4 (#232)
Browse files Browse the repository at this point in the history
* chore: Fix issue with MsgIssueResponse denom field not being populated

* fix: Update app.go to correct integrate PFM

* chore: pfm for transfer module

* chore: add v016 upgrade handler
  • Loading branch information
angelorc authored Aug 9, 2024
1 parent 456826d commit cf24787
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 73 deletions.
71 changes: 51 additions & 20 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
v013 "github.com/bitsongofficial/go-bitsong/app/upgrades/v013"
v014 "github.com/bitsongofficial/go-bitsong/app/upgrades/v014"
v015 "github.com/bitsongofficial/go-bitsong/app/upgrades/v015"
v016 "github.com/bitsongofficial/go-bitsong/app/upgrades/v016"
"strings"

v010 "github.com/bitsongofficial/go-bitsong/app/upgrades/v010"
Expand Down Expand Up @@ -432,14 +433,45 @@ func NewBitsongApp(
AddRoute(fantokentypes.RouterKey, fantoken.NewProposalHandler(app.FanTokenKeeper)).
AddRoute(merkledroptypes.RouterKey, merkledrop.NewProposalHandler(app.MerkledropKeeper))

app.PacketForwardKeeper = packetforwardkeeper.NewKeeper(
appCodec,
keys[packetforwardtypes.StoreKey],
app.GetSubspace(packetforwardtypes.ModuleName),
app.TransferKeeper,
app.IBCKeeper.ChannelKeeper,
app.DistrKeeper,
app.BankKeeper,
// The ICS4Wrapper is replaced by the IBCFeeKeeper instead of the channel so that sending can be overridden by the middleware
&app.IBCFeeKeeper,
)

// Create Transfer Keepers
app.TransferKeeper = ibctransferkeeper.NewKeeper(
appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName),
app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper,
app.AccountKeeper, app.BankKeeper, scopedTransferKeeper,
appCodec,
keys[ibctransfertypes.StoreKey],
app.GetSubspace(ibctransfertypes.ModuleName),
//app.IBCKeeper.ChannelKeeper,
app.PacketForwardKeeper,
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
app.AccountKeeper,
app.BankKeeper,
scopedTransferKeeper,
)

app.PacketForwardKeeper.SetTransferKeeper(app.TransferKeeper)

transferModule := transfer.NewAppModule(app.TransferKeeper)
transferIBCModule := transfer.NewIBCModule(app.TransferKeeper)

var transferStack porttypes.IBCModule
transferStack = transfer.NewIBCModule(app.TransferKeeper)
transferStack = packetforward.NewIBCMiddleware(
transferStack,
app.PacketForwardKeeper,
0, // retries on timeout
packetforwardkeeper.DefaultForwardTransferPacketTimeoutTimestamp, // forward timeout
packetforwardkeeper.DefaultRefundTransferPacketTimeoutTimestamp, // refund timeout
)

wasmDir := filepath.Join(homePath, "data")

Expand Down Expand Up @@ -480,7 +512,7 @@ func NewBitsongApp(
}
// Create static IBC router, add transfer route, then set and seal it
ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferIBCModule)
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferStack)
ibcRouter.AddRoute(wasm.ModuleName, wasm.NewIBCHandler(app.wasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper))
app.IBCKeeper.SetRouter(ibcRouter)

Expand All @@ -494,20 +526,6 @@ func NewBitsongApp(
govRouter,
)

app.PacketForwardKeeper = packetforwardkeeper.NewKeeper(
appCodec,
keys[packetforwardtypes.StoreKey],
app.GetSubspace(packetforwardtypes.ModuleName),
app.TransferKeeper,
app.IBCKeeper.ChannelKeeper,
app.DistrKeeper,
app.BankKeeper,
// The ICS4Wrapper is replaced by the IBCFeeKeeper instead of the channel so that sending can be overridden by the middleware
&app.IBCFeeKeeper,
)

routerModule := packetforward.NewAppModule(app.PacketForwardKeeper)

// Create evidence Keeper for to register the IBC light client misbehaviour evidence route
evidenceKeeper := evidencekeeper.NewKeeper(
appCodec, keys[evidencetypes.StoreKey], &app.StakingKeeper, app.SlashingKeeper,
Expand Down Expand Up @@ -544,7 +562,7 @@ func NewBitsongApp(
params.NewAppModule(app.ParamsKeeper),
transferModule,
wasm.NewAppModule(appCodec, &app.wasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
routerModule,
packetforward.NewAppModule(app.PacketForwardKeeper),
merkledrop.NewAppModule(appCodec, app.MerkledropKeeper),
)

Expand Down Expand Up @@ -873,6 +891,14 @@ func (app *BitsongApp) setupUpgradeStoreLoaders() {
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}

// v16 Upgrade
if upgradeInfo.Name == v016.UpgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := store.StoreUpgrades{}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}

}

func (app *BitsongApp) setupUpgradeHandlers() {
Expand Down Expand Up @@ -900,6 +926,11 @@ func (app *BitsongApp) setupUpgradeHandlers() {
v015.UpgradeName,
v015.CreateUpgradeHandler(app.mm, app.configurator),
)

app.UpgradeKeeper.SetUpgradeHandler(
v016.UpgradeName,
v016.CreateUpgradeHandler(app.mm, app.configurator),
)
}

// RegisterSwaggerAPI registers swagger route with API Server
Expand Down
5 changes: 5 additions & 0 deletions app/upgrades/v016/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package v016

const (
UpgradeName = "v016"
)
13 changes: 13 additions & 0 deletions app/upgrades/v016/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package v016

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func CreateUpgradeHandler(mm *module.Manager, configurator module.Configurator) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
return mm.RunMigrations(ctx, configurator, vm)
}
}
3 changes: 1 addition & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,6 @@ github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4
github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw=
github.com/cosmos/iavl v0.19.5 h1:rGA3hOrgNxgRM5wYcSCxgQBap7fW82WZgY78V9po/iY=
github.com/cosmos/iavl v0.19.5/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw=
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4 v4.1.1 h1:TeiMKG56Kg+lqw/+08dfusInebjVagr9v75sP2GJo6w=
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4 v4.1.1/go.mod h1:mFk2qfXAm7ndXQQuXUGm9tlC2OM9jxPQb5PRKEHNU5I=
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4 v4.1.2-0.20240228222021-455757bb5771 h1:f59vE1bhd2HvZJmDyxcGHXnk18H5BtL0GZtw0ED8gUA=
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4 v4.1.2-0.20240228222021-455757bb5771/go.mod h1:0g4hau4zO12tpvyiOcyEpcmcsXbBAN4WX+BhTO6xZVg=
github.com/cosmos/ibc-go/v4 v4.4.2 h1:PG4Yy0/bw6Hvmha3RZbc53KYzaCwuB07Ot4GLyzcBvo=
Expand Down Expand Up @@ -1041,6 +1039,7 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/mock v0.2.0 h1:TaP3xedm7JaAgScZO7tlvlKrqT0p7I6OsdGB5YNSMDU=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
Expand Down
4 changes: 3 additions & 1 deletion proto/bitsong/fantoken/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ message MsgIssue {
}

// MsgIssueResponse defines the MsgIssue response type
message MsgIssueResponse {}
message MsgIssueResponse {
string denom = 1 [ (gogoproto.moretags) = "yaml:\"denom\"" ];
}

// MsgDisableMint defines a message for disable the mint function
message MsgDisableMint {
Expand Down
4 changes: 3 additions & 1 deletion x/fantoken/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ func (m msgServer) Issue(goCtx context.Context, msg *types.MsgIssue) (*types.Msg
Denom: denom,
})

return &types.MsgIssueResponse{}, nil
return &types.MsgIssueResponse{
Denom: denom,
}, nil
}

func (m msgServer) Mint(goCtx context.Context, msg *types.MsgMint) (*types.MsgMintResponse, error) {
Expand Down
143 changes: 94 additions & 49 deletions x/fantoken/types/tx.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cf24787

Please sign in to comment.